Skip to content

Commit 4a5559b

Browse files
authored
feat(formatjs): support additional src folders (#650)
1 parent 7f26332 commit 4a5559b

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

bin/fedx-scripts.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,32 @@ switch (commandName) {
6969
require('webpack-dev-server/bin/webpack-dev-server');
7070
break;
7171
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+
}
7292
const commonArgs = [
7393
'--format', 'node_modules/@openedx/frontend-build/lib/formatter.js',
74-
'--ignore', 'src/**/*.json',
94+
'--ignore', `${srcFoldersString}/**/*.json`,
95+
'--ignore', `${srcFoldersString}/**/*.d.ts`,
7596
'--out-file', './temp/babel-plugin-formatjs/Default.messages.json',
76-
'--', 'src/**/*.js*',
97+
'--', `${srcFoldersString}/**/*.{j,t}s*`,
7798
];
7899
process.argv = process.argv.concat(commonArgs);
79100
ensureConfigOption(presets.formatjs);

0 commit comments

Comments
 (0)