Skip to content

Commit

Permalink
implement preset-modules for modern
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Feb 2, 2020
1 parent e83d0d1 commit 24c3c56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"@babel/node": "^7.7.7",
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
"@babel/plugin-proposal-throw-expressions": "^7.7.4",
"@babel/preset-modules": "^0.1.2",
"babel-jest": "^24.8.0",
"cross-env": "^6.0.3",
"directory-tree": "^2.2.3",
Expand Down
6 changes: 5 additions & 1 deletion src/lib/babel-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export default babelPlugin.custom(babelCore => {
preset.file.request.includes('@babel/preset-env'),
);

const environmentPreset = customOptions.modern
? '@babel/preset-modules'
: '@babel/preset-env';

if (envIdx !== -1) {
const preset = babelOptions.presets[envIdx];
babelOptions.presets[envIdx] = createConfigItem(
Expand Down Expand Up @@ -127,7 +131,7 @@ export default babelPlugin.custom(babelCore => {
} else {
babelOptions.presets = createConfigItems('preset', [
{
name: '@babel/preset-env',
name: environmentPreset,
targets: customOptions.modern
? ESMODULES_TARGET
: customOptions.targets,
Expand Down

0 comments on commit 24c3c56

Please sign in to comment.