Pass rootMode from @babel/node. (#9078)
* Pass `root-mode` from `@babel/node`. * Filter `babelOptions`.
This commit is contained in:
parent
0859535b62
commit
c4d6f6dcce
@ -52,6 +52,11 @@ program.option(
|
|||||||
"The name of the 'env' to use when loading configs and plugins. " +
|
"The name of the 'env' to use when loading configs and plugins. " +
|
||||||
"Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.",
|
"Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.",
|
||||||
);
|
);
|
||||||
|
commander.option(
|
||||||
|
"--root-mode [mode]",
|
||||||
|
"The project-root resolution mode. " +
|
||||||
|
"One of 'root' (the default), 'upward', or 'upward-optional'.",
|
||||||
|
);
|
||||||
program.option("-w, --plugins [string]", "", collect);
|
program.option("-w, --plugins [string]", "", collect);
|
||||||
program.option("-b, --presets [string]", "", collect);
|
program.option("-b, --presets [string]", "", collect);
|
||||||
|
|
||||||
@ -59,7 +64,7 @@ program.version(pkg.version);
|
|||||||
program.usage("[options] [ -e script | script.js ] [arguments]");
|
program.usage("[options] [ -e script | script.js ] [arguments]");
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|
||||||
register({
|
const babelOptions = {
|
||||||
caller: {
|
caller: {
|
||||||
name: "@babel/node",
|
name: "@babel/node",
|
||||||
},
|
},
|
||||||
@ -70,12 +75,21 @@ register({
|
|||||||
presets: program.presets,
|
presets: program.presets,
|
||||||
configFile: program.configFile,
|
configFile: program.configFile,
|
||||||
envName: program.envName,
|
envName: program.envName,
|
||||||
|
rootMode: program.rootMode,
|
||||||
|
|
||||||
// Commander will default the "--no-" arguments to true, but we want to
|
// Commander will default the "--no-" arguments to true, but we want to
|
||||||
// leave them undefined so that @babel/core can handle the
|
// leave them undefined so that @babel/core can handle the
|
||||||
// default-assignment logic on its own.
|
// default-assignment logic on its own.
|
||||||
babelrc: program.babelrc === true ? undefined : program.babelrc,
|
babelrc: program.babelrc === true ? undefined : program.babelrc,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
for (const key of Object.keys(babelOptions)) {
|
||||||
|
if (babelOptions[key] === undefined) {
|
||||||
|
delete babelOptions[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(babelOptions);
|
||||||
|
|
||||||
const replPlugin = ({ types: t }) => ({
|
const replPlugin = ({ types: t }) => ({
|
||||||
visitor: {
|
visitor: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user