[preset-env] Exclude transform-typeof-symbol with loose option. (#6831)
This commit is contained in:
parent
f3fd2ee3b2
commit
de3597983a
@ -111,12 +111,25 @@ const getPlatformSpecificDefaultFor = (targets: Targets): ?Array<string> => {
|
||||
return isAnyTarget || isWebTarget ? defaultWebIncludes : null;
|
||||
};
|
||||
|
||||
const getOptionSpecificExcludesFor = ({
|
||||
loose,
|
||||
}: {
|
||||
loose: boolean,
|
||||
}): Array<string> => {
|
||||
const defaultExcludes = [];
|
||||
if (loose) {
|
||||
defaultExcludes.push("transform-typeof-symbol");
|
||||
}
|
||||
return defaultExcludes;
|
||||
};
|
||||
|
||||
const filterItems = (
|
||||
list,
|
||||
includes,
|
||||
excludes,
|
||||
targets,
|
||||
defaultItems,
|
||||
defaultIncludes,
|
||||
defaultExcludes,
|
||||
): Set<string> => {
|
||||
const result = new Set();
|
||||
|
||||
@ -135,8 +148,12 @@ const filterItems = (
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultItems) {
|
||||
defaultItems.forEach(item => !excludes.has(item) && result.add(item));
|
||||
if (defaultIncludes) {
|
||||
defaultIncludes.forEach(item => !excludes.has(item) && result.add(item));
|
||||
}
|
||||
|
||||
if (defaultExcludes) {
|
||||
defaultExcludes.forEach(item => !includes.has(item) && result.delete(item));
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -187,6 +204,8 @@ export default function buildPreset(
|
||||
include.plugins,
|
||||
exclude.plugins,
|
||||
transformTargets,
|
||||
null,
|
||||
getOptionSpecificExcludesFor({ loose }),
|
||||
);
|
||||
|
||||
let polyfills;
|
||||
|
||||
1
experimental/babel-preset-env/test/fixtures/preset-options/loose-typeof-symbol/actual.js
vendored
Normal file
1
experimental/babel-preset-env/test/fixtures/preset-options/loose-typeof-symbol/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
typeof Symbol();
|
||||
1
experimental/babel-preset-env/test/fixtures/preset-options/loose-typeof-symbol/expected.js
vendored
Normal file
1
experimental/babel-preset-env/test/fixtures/preset-options/loose-typeof-symbol/expected.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
typeof Symbol();
|
||||
7
experimental/babel-preset-env/test/fixtures/preset-options/loose-typeof-symbol/options.json
vendored
Normal file
7
experimental/babel-preset-env/test/fixtures/preset-options/loose-typeof-symbol/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"presets": [
|
||||
["../../../../lib", {
|
||||
"loose": true
|
||||
}]
|
||||
]
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
typeof Symbol();
|
||||
@ -0,0 +1,3 @@
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
_typeof(Symbol());
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
["../../../../lib", {
|
||||
"loose": true,
|
||||
"include": ["transform-typeof-symbol"]
|
||||
}]
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user