Skip to content

Commit

Permalink
Merge branch 'master' into mkeating/alpha-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonkeating committed Oct 6, 2023
2 parents 4c76eb5 + 1ec7a93 commit 73435ef
Show file tree
Hide file tree
Showing 9 changed files with 19,360 additions and 14,988 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ documentation to learn what options are available. Example package.json::
{
"scripts": {
"build": "fedx-scripts webpack",
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
"i18n_extract": "fedx-scripts formatjs extract",
"lint": "fedx-scripts eslint --ext .jsx,.js .",
"precommit": "npm run lint",
"snapshot": "fedx-scripts jest --updateSnapshot",
Expand Down
12 changes: 12 additions & 0 deletions bin/fedx-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ switch (commandName) {
ensureConfigOption(presets.webpackDevServer);
require('webpack-dev-server/bin/webpack-dev-server');
break;
case 'formatjs': {
const commonArgs = [
'--format', 'node_modules/@edx/frontend-build/lib/formatter.js',
'--ignore', 'src/**/*.json',
'--out-file', './temp/babel-plugin-formatjs/Default.messages.json',
'--', 'src/**/*.js*',
];
process.argv = process.argv.concat(commonArgs);
ensureConfigOption(presets.formatjs);
require('@formatjs/cli/bin/formatjs');
break;
}
case 'serve':
require('../lib/scripts/serve');
break;
Expand Down
6 changes: 1 addition & 5 deletions config/babel-preserve-modules.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ module.exports = {
i18n: {
plugins: [
[
'react-intl',
{
messagesDir: './temp/babel-plugin-react-intl',
moduleSourceName: '@edx/frontend-platform/i18n',
},
'formatjs',
],
],
},
Expand Down
6 changes: 1 addition & 5 deletions config/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ module.exports = {
i18n: {
plugins: [
[
'react-intl',
{
messagesDir: './temp/babel-plugin-react-intl',
moduleSourceName: '@edx/frontend-platform/i18n',
},
'formatjs',
],
],
},
Expand Down
10 changes: 10 additions & 0 deletions lib/formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.format = (messages) => {
const results = Object.entries(messages).map(([id, message]) => (
{
id,
defaultMessage: message.defaultMessage,
description: message.description,
}
));
return results;
};
7 changes: 7 additions & 0 deletions lib/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ const babel = new ConfigPreset({
searchFilepaths,
});

const formatjs = new ConfigPreset({
defaultFilename: 'babel.config.js',
searchFilenames: ['.babelrc', '.babelrc.js', 'babel.config.js'],
searchFilepaths,
});

const babelPreserveModules = new ConfigPreset({
defaultFilename: 'babel-preserve-modules.config.js',
searchFilenames: ['.babelrc', '.babelrc.js', 'babel.config.js'],
Expand Down Expand Up @@ -52,6 +58,7 @@ const webpack = new ConfigPreset({

module.exports = {
babel,
formatjs,
babelPreserveModules,
'babel-preserve-modules': babelPreserveModules,
'babel-typescript': babelTypescript,
Expand Down
Loading

0 comments on commit 73435ef

Please sign in to comment.