@@ -69,11 +69,32 @@ switch (commandName) {
69
69
require ( 'webpack-dev-server/bin/webpack-dev-server' ) ;
70
70
break ;
71
71
case 'formatjs' : {
72
+ // The include option is used to specify which additional source folders to extract messages from.
73
+ // To extract more messages on other source folders use: --include=plugins --include=plugins2
74
+ // The intention use case is to allow extraction from the 'plugins' directory on 'frontend-app-authoring'.
75
+ // That plugins folder were kept outside the src folder to ensure they remain independent and
76
+ // can function without relying on the MFE environment's special features.
77
+ // This approach allows them to be packaged separately as NPM packages.
78
+ const additionalSrcFolders = [ ] ;
79
+ process . argv . forEach ( ( val , index ) => {
80
+ // if val starts with --include= then add the value to additionalSrcFolders
81
+ if ( val . startsWith ( '--include=' ) ) {
82
+ additionalSrcFolders . push ( val . split ( '=' ) [ 1 ] ) ;
83
+ // remove the value from process.argv
84
+ process . argv . splice ( index , 1 ) ;
85
+ }
86
+ } ) ;
87
+ const srcFolders = [ 'src' ] . concat ( additionalSrcFolders ) ;
88
+ let srcFoldersString = srcFolders . join ( ',' ) ;
89
+ if ( srcFolders . length > 1 ) {
90
+ srcFoldersString = `{${ srcFoldersString } }` ;
91
+ }
72
92
const commonArgs = [
73
93
'--format' , 'node_modules/@openedx/frontend-build/lib/formatter.js' ,
74
- '--ignore' , 'src/**/*.json' ,
94
+ '--ignore' , `${ srcFoldersString } /**/*.json` ,
95
+ '--ignore' , `${ srcFoldersString } /**/*.d.ts` ,
75
96
'--out-file' , './temp/babel-plugin-formatjs/Default.messages.json' ,
76
- '--' , 'src /**/*.js*' ,
97
+ '--' , ` ${ srcFoldersString } /**/*.{j,t}s*` ,
77
98
] ;
78
99
process . argv = process . argv . concat ( commonArgs ) ;
79
100
ensureConfigOption ( presets . formatjs ) ;
0 commit comments