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

refactor: remove strings support from LinguiConfig.extractors #2052

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions packages/cli/src/api/extractors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ export default async function extract(
): Promise<boolean> {
const extractorsToExtract = options.extractors ?? DEFAULT_EXTRACTORS

for (let e of extractorsToExtract) {
let ext: ExtractorType = e
if (typeof e === "string") {
// in case of the user using require.resolve in their extractors, we require that module
ext = require(e)
}
if ((ext as any).default) {
ext = (ext as any).default
}

for (let ext of extractorsToExtract) {
if (!ext.match(filename)) continue

try {
Expand Down
1 change: 0 additions & 1 deletion packages/conf/__typetests__/index.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ expectAssignable<LinguiConfig>({
expectAssignable<LinguiConfig>({
locales: ["en", "pl"],
extractors: [
"babel",
{
match: (fileName: string) => false,
extract: (
Expand Down
2 changes: 1 addition & 1 deletion packages/conf/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export type LinguiConfig = {
}
compilerBabelOptions?: any
fallbackLocales?: FallbackLocales | false
extractors?: (string | ExtractorType)[]
extractors?: ExtractorType[]
prevFormat?: CatalogFormat
localeDir?: string
format?: CatalogFormat | CatalogFormatter
Expand Down
1 change: 1 addition & 0 deletions website/docs/releases/migration-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,4 @@ You'll need to [re-compile](/docs/ref/cli.md#compile) your messages in the new f
## Deprecations and Removals

- Removed the deprecated `isTranslated` prop from the React `Trans` component.
- Removed support of the module path strings in `LinguiConfig.extractors` property. Please pass extractor object directly.
Loading