Skip to content

Commit

Permalink
fix(extract): extract was not testing for rel or abs path created wit…
Browse files Browse the repository at this point in the history
…h babel-merge
  • Loading branch information
Dimitri Kopriwa committed Nov 22, 2018
1 parent c921ade commit 053f697
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/cli/cmds/intl_cmds/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit 053f697

Please # to comment.