File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,15 @@ export default function extract(
2727) : boolean {
2828 const extractorsToExtract = options . extractors ?? DEFAULT_EXTRACTORS
2929
30- return extractorsToExtract . some ( ( ext ) => {
30+ return extractorsToExtract . some ( ( e ) => {
31+ let ext : ExtractorType = e ;
32+ if ( typeof e === "string" ) {
33+ // in case of the user using require.resolve in their extractors, we require that module
34+ ext = require ( e )
35+ if ( ( ext as any ) . default ) {
36+ ext = ( ext as any ) . default
37+ }
38+ }
3139 if ( ! ext . match ( filename ) ) return false
3240
3341 let spinner
Original file line number Diff line number Diff line change @@ -120,6 +120,18 @@ Object {
120120 plugins: Array [],
121121 presets: Array [],
122122 },
123+ extractors: Array [
124+ Array [],
125+ Array [
126+ babel,
127+ ],
128+ Array [
129+ Object {
130+ extract: [Function],
131+ match: [Function],
132+ },
133+ ],
134+ ],
123135 fallbackLocales: Object {
124136 en-gb: en,
125137 },
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export type LinguiConfig = {
4545 extractBabelOptions : Record < string , unknown >
4646 compilerBabelOptions : GeneratorOptions
4747 fallbackLocales ?: FallbackLocales
48- extractors ?: ExtractorType [ ]
48+ extractors ?: ExtractorType [ ] | string [ ]
4949 format : CatalogFormat
5050 formatOptions : CatalogFormatOptions
5151 locales : string [ ]
@@ -82,6 +82,14 @@ export const defaultConfig: LinguiConfig = {
8282 minimal : true ,
8383 }
8484 } ,
85+ extractors : multipleValidOptions (
86+ [ ] ,
87+ [ "babel" ] ,
88+ [ {
89+ match : ( fileName : string ) => false ,
90+ extract : ( filename : string , targetDir : string , options ?: any ) => { }
91+ } as ExtractorType ]
92+ ) ,
8593 extractBabelOptions : { plugins : [ ] , presets : [ ] } ,
8694 fallbackLocales : { } ,
8795 format : "po" ,
You can’t perform that action at this time.
0 commit comments