[babel 8] Remove @babel/runtime@<=7.13.0 compat check (#14120)

This commit is contained in:
Nicolò Ribaudo
2022-01-08 21:06:40 +01:00
committed by GitHub
parent 910ece5e2a
commit a6d77d07b4
43 changed files with 85 additions and 70 deletions

View File

@@ -85,12 +85,14 @@ export default declare((api, options, dirname) => {
throw new Error(`The 'version' option must be a version string.`);
}
// In recent @babel/runtime versions, we can use require("helper").default
// instead of require("helper") so that it has the same interface as the
// ESM helper, and bundlers can better exchange one format for the other.
// TODO(Babel 8): Remove this check, it's always true
const DUAL_MODE_RUNTIME = "7.13.0";
const supportsCJSDefault = hasMinVersion(DUAL_MODE_RUNTIME, runtimeVersion);
if (!process.env.BABEL_8_BREAKING) {
// In recent @babel/runtime versions, we can use require("helper").default
// instead of require("helper") so that it has the same interface as the
// ESM helper, and bundlers can better exchange one format for the other.
const DUAL_MODE_RUNTIME = "7.13.0";
// eslint-disable-next-line no-var
var supportsCJSDefault = hasMinVersion(DUAL_MODE_RUNTIME, runtimeVersion);
}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
@@ -260,8 +262,13 @@ export default declare((api, options, dirname) => {
cached = t.cloneNode(cached);
} else {
cached = addDefault(file.path, source, {
importedInterop:
isHelper && supportsCJSDefault ? "compiled" : "uncompiled",
importedInterop: (
process.env.BABEL_8_BREAKING
? isHelper
: isHelper && supportsCJSDefault
)
? "compiled"
: "uncompiled",
nameHint,
blockHoist,
});