Skip to content

Commit

Permalink
Merge pull request #18 from rollup-umd/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
kopax authored Nov 22, 2018
2 parents 16a36a3 + 053f697 commit 36a0d1d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/cli/cmds/intl_cmds/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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 36a0d1d

Please # to comment.