Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: failOnMissing & failOnCompileError for loaders + compiler #2198

Merged
merged 7 commits into from
Mar 21, 2025

Conversation

timofei-iatsenko
Copy link
Collaborator

@timofei-iatsenko timofei-iatsenko commented Mar 11, 2025

Description

fixes: #2193 #2192

This PR adds two new features for all places (except of Metro transformer, i later desribe way) where catalogs are compiled. Including:

  • lingui compile command
  • vite plugin
  • webpack loader

Metro tranformer doesn't have a way to pass options for now, so these flags couldn't be implemented now FYI @vonovak

failOnMissing

Will fail build if there are missing translations. Useful to ensure production builds doesn't have missing translations

For vite & webpack this option should be passed directly to theirs config.
lingui compile will perform this check when --strict flag is passed

failOnCompileError

Will fail build if there are compilation errors for messages. For example, syntax issues in the ICU expressions.

When this flag is false it will still report these errors but as warnings.

For vite & webpack this option should be passed directly to theirs config.
lingui compile will perform this check when --strict flag is passed

Other Changes

This PR might introduce some slight breaking changes for those who uses Lingui API directly.
I would prefer not to rise major version, because this should not affect users who just using lingui as usual.

  • createCompiledCatalog returns {source: string, errors: MessageCompilationError[]} instead of string
  • catalog.getTranslations returns {messages: Messages, missing: TranslationMissingEvent[]} instead of Messages

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Fixes # (issue)

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Copy link

vercel bot commented Mar 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview Mar 19, 2025 10:28am

Copy link

github-actions bot commented Mar 11, 2025

size-limit report 📦

Path Size
packages/core/dist/index.mjs 2.91 KB (0%)
packages/detect-locale/dist/index.mjs 618 B (0%)
packages/react/dist/index.mjs 1.35 KB (0%)

@timofei-iatsenko timofei-iatsenko changed the title Feature/loaders fail on errors feat: failOnMissing & failOnCompileError for loaders + compiler Mar 19, 2025
@timofei-iatsenko timofei-iatsenko changed the title feat: failOnMissing & failOnCompileError for loaders + compiler feat: failOnMissing & failOnCompileError for loaders + compiler Mar 19, 2025
Copy link
Contributor

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrii-bodnar andrii-bodnar merged commit 68c29ab into main Mar 21, 2025
13 checks passed
@andrii-bodnar andrii-bodnar deleted the feature/loaders-fail-on-errors branch March 21, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding flag to fail lingui compile if there are syntax errors
3 participants