Skip to content

Conversation

@timofei-iatsenko
Copy link
Collaborator

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

Description

Part of work to improve extensibility of lingui and allow it be extended by 3rd party libraries without copy/pastig code

More info is here: #2101 (comment)

This feature not particularly useful for end-users but would be valuable for integration authors

Feature description

Adds two new configuration properties for LinguiConfig, these properties allow overriding default package names for lingui macro.

  macro?: {
    corePackage?: string[]
    reactPackage?: string[]
  }

So using this feature, integration with SolidJS could be simplifed to:

defineConfig({
  macro: {
    reactPackage: ['@lingui-solid/solid/macro']
  }
})

Instead of copy/pasting the whole babel extractor and macro code.

The setting affects:

  • Macro babel plugin
  • Webpack / Vite plugin

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)

@vercel
Copy link

vercel bot commented Mar 10, 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 7:49am

@github-actions
Copy link

github-actions bot commented Mar 10, 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 marked this pull request as ready for review March 10, 2025 12:49
@timofei-iatsenko timofei-iatsenko marked this pull request as draft March 10, 2025 12:50
@timofei-iatsenko
Copy link
Collaborator Author

@andrii-bodnar anything else to get this merged?

@andrii-bodnar
Copy link
Contributor

@timofei-iatsenko looks generally good to me. The only thing that looks confusing and misleading is some of the naming.

I mean this example:

defineConfig({
  macro: {
    reactPackage: ['@lingui-solid/solid/macro']
  }
})

React package -> Solid package

A better approach might be to use more generic property names that don't tie to a specific framework. What do you think?

@timofei-iatsenko
Copy link
Collaborator Author

@andrii-bodnar might be confusing, but from other side it's a mapping and it looks logical here:

 macro: {
    corePackage: [/*legacy*/ "@lingui/macro", "@lingui/core/macro"],
    reactPackage: [/*legacy*/ "@lingui/macro", "@lingui/react/macro"],
  },

Do you have any better name in mind? jsxPackage?

@andrii-bodnar
Copy link
Contributor

Was also thinking about jsxPackage, or frameworkPackage

@timofei-iatsenko
Copy link
Collaborator Author

@andrii-bodnar fixed, also added docs to the website and copied more inline docs from website to the config types.

@timofei-iatsenko
Copy link
Collaborator Author

@andrii-bodnar i also had to remove the editorconfig-checker. It started failing i tried to fixing it but then understand that this linter doesn't have sense at all because all this checks already checked by remark and prettier. And both of them doing better job because they are context-aware, where editorconfig-checker simply checking that the line is longer then configured, ignoring the fact that the line couldn't be safely split, etc.

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.

@timofei-iatsenko thank you!

@andrii-bodnar andrii-bodnar merged commit 583dd05 into main Mar 21, 2025
10 checks passed
@andrii-bodnar andrii-bodnar deleted the feat/add-points-of-extension branch March 21, 2025 09:31
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.

3 participants