Fix API change that e7187faea64b64d65a17c57d6578903f1fff27d6 introduced that wasn't changed in babel-register. Also use an object rather than a long ass list of arguments.
This commit is contained in:
parent
ba40f6979b
commit
bc2f84f371
@ -43,6 +43,14 @@ type PluginObject = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type MergeOptions = {
|
||||||
|
options?: Object,
|
||||||
|
extending?: Object,
|
||||||
|
alias: string,
|
||||||
|
loc?: string,
|
||||||
|
dirname?: string
|
||||||
|
};
|
||||||
|
|
||||||
export default class OptionManager {
|
export default class OptionManager {
|
||||||
constructor(log?: Logger) {
|
constructor(log?: Logger) {
|
||||||
this.resolvedConfigs = [];
|
this.resolvedConfigs = [];
|
||||||
@ -161,7 +169,11 @@ export default class OptionManager {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mergeOptions(opts, this.options, loc, null, path.dirname(loc));
|
this.mergeOptions({
|
||||||
|
options: opts,
|
||||||
|
alias: loc,
|
||||||
|
dirname: path.dirname(loc)
|
||||||
|
});
|
||||||
this.resolvedConfigs.push(loc);
|
this.resolvedConfigs.push(loc);
|
||||||
|
|
||||||
return !!opts;
|
return !!opts;
|
||||||
@ -177,7 +189,14 @@ export default class OptionManager {
|
|||||||
* - `dirname` is used to resolve plugins relative to it.
|
* - `dirname` is used to resolve plugins relative to it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mergeOptions(rawOpts?: Object, extendingOpts?: Object, alias: string = "foreign", loc?: string, dirname?: string) {
|
mergeOptions({
|
||||||
|
options: rawOpts,
|
||||||
|
extending: extendingOpts,
|
||||||
|
alias,
|
||||||
|
loc,
|
||||||
|
dirname
|
||||||
|
}: MergeOptions) {
|
||||||
|
alias = alias || "foreign";
|
||||||
if (!rawOpts) return;
|
if (!rawOpts) return;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -230,7 +249,13 @@ export default class OptionManager {
|
|||||||
// and keep them for further execution to calculate the options.
|
// and keep them for further execution to calculate the options.
|
||||||
if (opts.passPerPreset) {
|
if (opts.passPerPreset) {
|
||||||
opts.presets = this.resolvePresets(opts.presets, dirname, (preset, presetLoc) => {
|
opts.presets = this.resolvePresets(opts.presets, dirname, (preset, presetLoc) => {
|
||||||
this.mergeOptions(preset, preset, presetLoc, presetLoc, dirname);
|
this.mergeOptions({
|
||||||
|
options: preset,
|
||||||
|
extending: preset,
|
||||||
|
alias: presetLoc,
|
||||||
|
loc: presetLoc,
|
||||||
|
dirname: dirname
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, just merge presets options into the main options.
|
// Otherwise, just merge presets options into the main options.
|
||||||
@ -250,14 +275,19 @@ export default class OptionManager {
|
|||||||
// Merge them into current extending options in case of top-level
|
// Merge them into current extending options in case of top-level
|
||||||
// options. In case of presets, just re-assign options which are got
|
// options. In case of presets, just re-assign options which are got
|
||||||
// normalized during the `mergeOptions`.
|
// normalized during the `mergeOptions`.
|
||||||
if (rawOpts !== extendingOpts) {
|
if (rawOpts === extendingOpts) {
|
||||||
merge(extendingOpts, opts);
|
|
||||||
} else {
|
|
||||||
Object.assign(extendingOpts, opts);
|
Object.assign(extendingOpts, opts);
|
||||||
|
} else {
|
||||||
|
merge(extendingOpts || this.options, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge in env options
|
// merge in env options
|
||||||
this.mergeOptions(envOpts, extendingOpts, `${alias}.env.${envKey}`, null, dirname);
|
this.mergeOptions({
|
||||||
|
options: envOpts,
|
||||||
|
extending: extendingOpts,
|
||||||
|
alias: `${alias}.env.${envKey}`,
|
||||||
|
dirname: dirname
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -266,13 +296,12 @@ export default class OptionManager {
|
|||||||
*/
|
*/
|
||||||
mergePresets(presets: Array<string | Object>, dirname: string) {
|
mergePresets(presets: Array<string | Object>, dirname: string) {
|
||||||
this.resolvePresets(presets, dirname, (presetOpts, presetLoc) => {
|
this.resolvePresets(presets, dirname, (presetOpts, presetLoc) => {
|
||||||
this.mergeOptions(
|
this.mergeOptions({
|
||||||
presetOpts,
|
options: presetOpts,
|
||||||
this.options,
|
alias: presetLoc,
|
||||||
presetLoc,
|
loc: presetLoc,
|
||||||
presetLoc,
|
dirname: path.dirname(presetLoc)
|
||||||
path.dirname(presetLoc)
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +337,10 @@ export default class OptionManager {
|
|||||||
.map((line) => line.replace(/#(.*?)$/, "").trim())
|
.map((line) => line.replace(/#(.*?)$/, "").trim())
|
||||||
.filter((line) => !!line);
|
.filter((line) => !!line);
|
||||||
|
|
||||||
this.mergeOptions({ ignore: lines }, this.options, loc);
|
this.mergeOptions({
|
||||||
|
options: { ignore: lines },
|
||||||
|
loc
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
findConfigs(loc) {
|
findConfigs(loc) {
|
||||||
@ -370,7 +402,11 @@ export default class OptionManager {
|
|||||||
let filename = opts.filename;
|
let filename = opts.filename;
|
||||||
|
|
||||||
// merge in base options
|
// merge in base options
|
||||||
this.mergeOptions(opts, this.options, "base", null, filename && path.dirname(filename));
|
this.mergeOptions({
|
||||||
|
options: opts,
|
||||||
|
alias: "base",
|
||||||
|
dirname: filename && path.dirname(filename)
|
||||||
|
});
|
||||||
|
|
||||||
// resolve all .babelrc files
|
// resolve all .babelrc files
|
||||||
if (this.options.babelrc !== false) {
|
if (this.options.babelrc !== false) {
|
||||||
|
|||||||
@ -52,7 +52,11 @@ function compile(filename) {
|
|||||||
let optsManager = new OptionManager;
|
let optsManager = new OptionManager;
|
||||||
|
|
||||||
// merge in base options and resolve all the plugins and presets relative to this file
|
// merge in base options and resolve all the plugins and presets relative to this file
|
||||||
optsManager.mergeOptions(deepClone(transformOpts), "base", null, path.dirname(filename));
|
optsManager.mergeOptions({
|
||||||
|
options: deepClone(transformOpts),
|
||||||
|
alias: "base",
|
||||||
|
dirname: path.dirname(filename)
|
||||||
|
});
|
||||||
|
|
||||||
let opts = optsManager.init({ filename });
|
let opts = optsManager.init({ filename });
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user