mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Support "env" in .babelrc files. (#8963)
This commit is contained in:
committed by
Ben Newman
parent
43ba3c9de5
commit
77ecbabf60
@@ -300,6 +300,16 @@ BCp._inferHelper = function (
|
||||
merge(babelOptions, babelrc, "presets");
|
||||
merge(babelOptions, babelrc, "plugins");
|
||||
|
||||
const babelEnv = (process.env.BABEL_ENV ||
|
||||
process.env.NODE_ENV ||
|
||||
"development");
|
||||
if (babelrc && babelrc.env && babelrc.env[babelEnv]) {
|
||||
const env = babelrc.env[babelEnv];
|
||||
walkBabelRC(env);
|
||||
merge(babelOptions, env, "presets");
|
||||
merge(babelOptions, env, "plugins");
|
||||
}
|
||||
|
||||
return !! (babelrc.presets ||
|
||||
babelrc.plugins);
|
||||
};
|
||||
|
||||
7
tools/tests/apps/modules/.babelrc
Normal file
7
tools/tests/apps/modules/.babelrc
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"env": {
|
||||
"development": {
|
||||
"plugins": ["transform-do-expressions"]
|
||||
}
|
||||
}
|
||||
}
|
||||
18
tools/tests/apps/modules/babel-env.js
Normal file
18
tools/tests/apps/modules/babel-env.js
Normal file
@@ -0,0 +1,18 @@
|
||||
function babeltest() {
|
||||
// use transform-do-expressions plugin to prove babel `env` subkey was loaded
|
||||
let x = do {
|
||||
1;
|
||||
};
|
||||
console.log(x)
|
||||
}
|
||||
|
||||
/*
|
||||
If the plugin is loaded correctly there will be no errors during the compilation of this file.
|
||||
Without this plugin you will get the error:
|
||||
|
||||
W20170803-17:58:17.054(-7)? (STDERR) var x = do {
|
||||
W20170803-17:58:17.055(-7)? (STDERR) ^^
|
||||
W20170803-17:58:17.055(-7)? (STDERR)
|
||||
W20170803-17:58:17.055(-7)? (STDERR) SyntaxError: Unexpected token do
|
||||
*/
|
||||
|
||||
@@ -19,5 +19,8 @@
|
||||
"test": "METEOR_PROFILE=100 ../../../../meteor test --full-app --driver-package dispatch:mocha-phantomjs",
|
||||
"browser": "METEOR_PROFILE=100 ../../../../meteor test --full-app --driver-package dispatch:mocha-browser",
|
||||
"test-packages": "../../../../meteor test-packages --driver-package dispatch:mocha-phantomjs packages/modules-test-package"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-transform-do-expressions": "^6.22.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user