From c921ade9d843d4cd4714219a854d0d3d8a9e7049 Mon Sep 17 00:00:00 2001 From: Dimitri Kopriwa Date: Wed, 21 Nov 2018 02:29:50 +0700 Subject: [PATCH 1/2] fix(extract): fix extract message --- src/cli/cmds/intl_cmds/extract.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/cmds/intl_cmds/extract.js b/src/cli/cmds/intl_cmds/extract.js index f038196..96015ef 100644 --- a/src/cli/cmds/intl_cmds/extract.js +++ b/src/cli/cmds/intl_cmds/extract.js @@ -114,7 +114,7 @@ exports.builder = (yargs) => yargs }) .option('babel-rc', { alias: 'r', - describe: 'Specify babelrc location (while take precedence over --babel-config if used)', + describe: 'Specify .babelrc location (will take precedence over --babel-config if used)', }); exports.handler = (argv) => { argv.path = acceptDotPath(argv.path, process.cwd()); From 053f6973d221d1adf88bfc6f34106f04cb07d451 Mon Sep 17 00:00:00 2001 From: Dimitri Kopriwa Date: Fri, 23 Nov 2018 01:43:21 +0700 Subject: [PATCH 2/2] fix(extract): extract was not testing for rel or abs path created with babel-merge --- src/cli/cmds/intl_cmds/extract.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cli/cmds/intl_cmds/extract.js b/src/cli/cmds/intl_cmds/extract.js index 96015ef..839290f 100644 --- a/src/cli/cmds/intl_cmds/extract.js +++ b/src/cli/cmds/intl_cmds/extract.js @@ -132,7 +132,15 @@ exports.handler = (argv) => { } // we use defaults presets and plugins for react if nothing is found - babelConfig.presets = babelConfig.presets || ['@babel/preset-react']; + babelConfig.presets = babelConfig.presets || [ + [ + '@babel/preset-env', + { + modules: false, + }, + ], + '@babel/preset-react', + ]; babelConfig.plugins = babelConfig.plugins || [ '@babel/plugin-transform-runtime', '@babel/plugin-transform-async-to-generator', @@ -146,16 +154,21 @@ exports.handler = (argv) => { }, ], ]; + // do not use presets that are not installed babelConfig.presets = babelConfig.presets.filter((preset) => { const name = typeof preset === 'string' ? preset : preset[0]; - return !!fs.existsSync(path.join(argv.path, 'node_modules', name)); + const absPath = fs.existsSync(name); + const relPath = fs.existsSync(path.join(argv.path, 'node_modules', name)); + return absPath || relPath; }); // do not use plugins that are not installed babelConfig.plugins = babelConfig.plugins.filter((plugin) => { const name = typeof plugin === 'string' ? plugin : plugin[0]; - return !!fs.existsSync(path.join(argv.path, 'node_modules', name)); + const absPath = fs.existsSync(name); + const relPath = fs.existsSync(path.join(argv.path, 'node_modules', name)); + return absPath || relPath; }); // we add react-intl plugins to the list