Delete undefined options so we handle old core versions with new CLI versions. (#8728)
This commit is contained in:
parent
9e7c7f5683
commit
3b0f9a9f1e
@ -221,8 +221,7 @@ export default function parseArgv(args: Array<string>) {
|
|||||||
|
|
||||||
const opts = commander.opts();
|
const opts = commander.opts();
|
||||||
|
|
||||||
return {
|
const babelOptions = {
|
||||||
babelOptions: {
|
|
||||||
presets: opts.presets,
|
presets: opts.presets,
|
||||||
plugins: opts.plugins,
|
plugins: opts.plugins,
|
||||||
rootMode: opts.rootMode,
|
rootMode: opts.rootMode,
|
||||||
@ -247,10 +246,22 @@ export default function parseArgv(args: Array<string>) {
|
|||||||
// 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: opts.babelrc === true ? undefined : opts.babelrc,
|
babelrc: opts.babelrc === true ? undefined : opts.babelrc,
|
||||||
highlightCode:
|
highlightCode: opts.highlightCode === true ? undefined : opts.highlightCode,
|
||||||
opts.highlightCode === true ? undefined : opts.highlightCode,
|
|
||||||
comments: opts.comments === true ? undefined : opts.comments,
|
comments: opts.comments === true ? undefined : opts.comments,
|
||||||
},
|
};
|
||||||
|
|
||||||
|
// If the @babel/cli version is newer than the @babel/core version, and we have added
|
||||||
|
// new options for @babel/core, we'll potentially get option validation errors from
|
||||||
|
// @babel/core. To avoid that, we delete undefined options, so @babel/core will only
|
||||||
|
// give the error if users actually pass an unsupported CLI option.
|
||||||
|
for (const key of Object.keys(babelOptions)) {
|
||||||
|
if (babelOptions[key] === undefined) {
|
||||||
|
delete babelOptions[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
babelOptions,
|
||||||
cliOptions: {
|
cliOptions: {
|
||||||
filename: opts.filename,
|
filename: opts.filename,
|
||||||
filenames,
|
filenames,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user