validate useBuiltIns against true,false,entry and test
This commit is contained in:
parent
bf31fff83e
commit
cb1c5eaf97
@ -1,3 +1,4 @@
|
||||
// TODO: this is the opposite of built-in-features so maybe generate one from the other?
|
||||
export const definitions = {
|
||||
builtins: {
|
||||
DataView: "es6.typed.data-view",
|
||||
|
||||
@ -66,6 +66,18 @@ export const validateModulesOption = (modulesOpt = "commonjs") => {
|
||||
return modulesOpt;
|
||||
};
|
||||
|
||||
export const validateUseBuiltInsOption = (builtInsOpt = true) => {
|
||||
invariant(
|
||||
builtInsOpt === true || builtInsOpt === false || builtInsOpt === "entry",
|
||||
`Invalid Option: The 'useBuiltIns' option must be either
|
||||
'false' to indicate no polyfill,
|
||||
'"entry"' to indicate replacing the entry polyfill, or
|
||||
'true' (default) to import only used polyfills per file`,
|
||||
);
|
||||
|
||||
return builtInsOpt;
|
||||
};
|
||||
|
||||
export default function normalizeOptions(opts) {
|
||||
checkDuplicateIncludeExcludes(opts.include, opts.exclude);
|
||||
|
||||
@ -76,6 +88,6 @@ export default function normalizeOptions(opts) {
|
||||
loose: validateLooseOption(opts.loose),
|
||||
moduleType: validateModulesOption(opts.modules),
|
||||
targets: opts.targets,
|
||||
useBuiltIns: opts.useBuiltIns === undefined ? true : opts.useBuiltIns,
|
||||
useBuiltIns: validateUseBuiltInsOption(opts.useBuiltIns),
|
||||
};
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
Array.from; // static method
|
||||
Map; // built-in
|
||||
new Promise(); // new builtin
|
||||
Symbol.match; // as member expression
|
||||
_arr[Symbol.iterator](); // Symbol.iterator
|
||||
|
||||
// no import
|
||||
Array.asdf;
|
||||
Array2.from;
|
||||
Map2;
|
||||
new Promise2();
|
||||
Symbol.asdf;
|
||||
Symbol2.match;
|
||||
_arr9[Symbol2.iterator]();
|
||||
_arr9[Symbol.iterator2]();
|
||||
|
||||
G.assign; // static method
|
||||
function H(WeakMap) { var blah = new WeakMap(); } // shadowed
|
||||
|
||||
// not covered by this plugin
|
||||
var asdf = 'copyWithin';
|
||||
i[asdf] // computed with identifier
|
||||
j[`copyWithin`] // computed with template
|
||||
var { [asdf]: _a } = k; // computed
|
||||
@ -0,0 +1,27 @@
|
||||
Array.from; // static method
|
||||
Map; // built-in
|
||||
new Promise(); // new builtin
|
||||
Symbol.match; // as member expression
|
||||
_arr[Symbol.iterator](); // Symbol.iterator
|
||||
|
||||
// no import
|
||||
Array.asdf;
|
||||
Array2.from;
|
||||
Map2;
|
||||
new Promise2();
|
||||
Symbol.asdf;
|
||||
Symbol2.match;
|
||||
_arr9[Symbol2.iterator]();
|
||||
_arr9[Symbol.iterator2]();
|
||||
|
||||
G.assign; // static method
|
||||
function H(WeakMap) {
|
||||
var blah = new WeakMap();
|
||||
} // shadowed
|
||||
|
||||
// not covered by this plugin
|
||||
var asdf = 'copyWithin';
|
||||
i[asdf]; // computed with identifier
|
||||
j['copyWithin']; // computed with template
|
||||
var _k = k,
|
||||
_a = _k[asdf]; // computed
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
["../../../../lib", {
|
||||
"useBuiltIns": false,
|
||||
"modules": false
|
||||
}]
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user