Skip to content

Commit

Permalink
refactor: remove strings support from LinguiConfig.extractors
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Oct 16, 2024
1 parent c027f0e commit 0be39d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
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
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
2 changes: 2 additions & 0 deletions website/docs/releases/migration-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,5 @@ 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.

0 comments on commit 0be39d0

Please sign in to comment.