@babel/plugin-transform-runtime
Advanced tools
Comparing version 7.0.0-rc.1 to 7.0.0-rc.2
@@ -8,2 +8,22 @@ "use strict"; | ||
function _path() { | ||
const data = _interopRequireDefault(require("path")); | ||
_path = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _resolve() { | ||
const data = _interopRequireDefault(require("resolve")); | ||
_resolve = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _helperPluginUtils() { | ||
@@ -43,3 +63,18 @@ const data = require("@babel/helper-plugin-utils"); | ||
var _default = (0, _helperPluginUtils().declare)((api, options) => { | ||
function resolveAbsoluteRuntime(moduleName, dirname) { | ||
try { | ||
return _path().default.dirname(_resolve().default.sync(`${moduleName}/package.json`, { | ||
basedir: dirname | ||
})); | ||
} catch (err) { | ||
if (err.code !== "MODULE_NOT_FOUND") throw err; | ||
throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), { | ||
code: "BABEL_RUNTIME_NOT_FOUND", | ||
runtime: moduleName, | ||
dirname | ||
}); | ||
} | ||
} | ||
var _default = (0, _helperPluginUtils().declare)((api, options, dirname) => { | ||
api.assertVersion(7); | ||
@@ -51,3 +86,4 @@ const { | ||
useESModules = false, | ||
version: runtimeVersion = "7.0.0-beta.0" | ||
version: runtimeVersion = "7.0.0-beta.0", | ||
absoluteRuntime = false | ||
} = options; | ||
@@ -67,2 +103,6 @@ | ||
if (typeof absoluteRuntime !== "boolean" && typeof absoluteRuntime !== "string") { | ||
throw new Error("The 'absoluteRuntime' option must be undefined, a boolean, or a string."); | ||
} | ||
if (corejsVersion !== false && (typeof corejsVersion !== "number" || corejsVersion !== 2) && (typeof corejsVersion !== "string" || corejsVersion !== "2")) { | ||
@@ -93,3 +133,3 @@ throw new Error(`The 'corejs' option must be undefined, false, or 2, or '2', ` + `but got ${JSON.stringify(corejsVersion)}.`); | ||
if (has(options, "moduleName")) { | ||
throw new Error("The 'moduleName' option has been removed. @babel/transform-runtime " + "no longer supports arbitrary runtimes."); | ||
throw new Error("The 'moduleName' option has been removed. @babel/transform-runtime " + "no longer supports arbitrary runtimes. If you were using this to " + "set an absolute path for Babel's standard runtimes, please use the " + "'absoluteRuntime' option."); | ||
} | ||
@@ -101,2 +141,8 @@ | ||
const HEADER_HELPERS = ["interopRequireWildcard", "interopRequireDefault"]; | ||
let modulePath = moduleName; | ||
if (absoluteRuntime !== false) { | ||
modulePath = resolveAbsoluteRuntime(moduleName, _path().default.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime)); | ||
} | ||
return { | ||
@@ -112,3 +158,3 @@ pre(file) { | ||
const blockHoist = isInteropHelper && !(0, _helperModuleImports().isModule)(file.path) ? 4 : undefined; | ||
return this.addDefaultImport(`${moduleName}/${helpersDir}/${name}`, name, blockHoist); | ||
return this.addDefaultImport(`${modulePath}/${helpersDir}/${name}`, name, blockHoist); | ||
}); | ||
@@ -148,3 +194,3 @@ } | ||
if (node.name === "regeneratorRuntime" && useRuntimeRegenerator) { | ||
path.replaceWith(this.addDefaultImport(`${moduleName}/regenerator`, "regeneratorRuntime")); | ||
path.replaceWith(this.addDefaultImport(`${modulePath}/regenerator`, "regeneratorRuntime")); | ||
return; | ||
@@ -157,3 +203,3 @@ } | ||
if (scope.getBindingIdentifier(node.name)) return; | ||
path.replaceWith(this.addDefaultImport(`${moduleName}/core-js/${_definitions.default.builtins[node.name]}`, node.name)); | ||
path.replaceWith(this.addDefaultImport(`${modulePath}/core-js/${_definitions.default.builtins[node.name]}`, node.name)); | ||
}, | ||
@@ -172,3 +218,3 @@ | ||
path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${moduleName}/core-js/get-iterator`, "getIterator"), [callee.object])); | ||
path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${modulePath}/core-js/get-iterator`, "getIterator"), [callee.object])); | ||
}, | ||
@@ -180,3 +226,3 @@ | ||
if (!path.get("left").matchesPattern("Symbol.iterator")) return; | ||
path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${moduleName}/core-js/is-iterable`, "isIterable"), [path.node.right])); | ||
path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${modulePath}/core-js/is-iterable`, "isIterable"), [path.node.right])); | ||
}, | ||
@@ -208,3 +254,3 @@ | ||
path.replaceWith(this.addDefaultImport(`${moduleName}/core-js/${methods[prop.name]}`, `${obj.name}$${prop.name}`)); | ||
path.replaceWith(this.addDefaultImport(`${modulePath}/core-js/${methods[prop.name]}`, `${obj.name}$${prop.name}`)); | ||
}, | ||
@@ -221,3 +267,3 @@ | ||
if (path.scope.getBindingIdentifier(obj.name)) return; | ||
path.replaceWith(_core().types.memberExpression(this.addDefaultImport(`${moduleName}/core-js/${_definitions.default.builtins[obj.name]}`, obj.name), node.property, node.computed)); | ||
path.replaceWith(_core().types.memberExpression(this.addDefaultImport(`${modulePath}/core-js/${_definitions.default.builtins[obj.name]}`, obj.name), node.property, node.computed)); | ||
} | ||
@@ -224,0 +270,0 @@ |
{ | ||
"name": "@babel/plugin-transform-runtime", | ||
"version": "7.0.0-rc.1", | ||
"version": "7.0.0-rc.2", | ||
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals", | ||
@@ -12,4 +12,5 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime", | ||
"dependencies": { | ||
"@babel/helper-module-imports": "7.0.0-rc.1", | ||
"@babel/helper-plugin-utils": "7.0.0-rc.1" | ||
"@babel/helper-module-imports": "7.0.0-rc.2", | ||
"@babel/helper-plugin-utils": "7.0.0-rc.2", | ||
"resolve": "^1.8.1" | ||
}, | ||
@@ -20,10 +21,11 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-rc.1", | ||
"@babel/helper-plugin-test-runner": "7.0.0-rc.1", | ||
"@babel/helpers": "7.0.0-rc.1", | ||
"@babel/plugin-transform-runtime": "7.0.0-rc.1", | ||
"@babel/preset-env": "7.0.0-rc.1", | ||
"@babel/template": "7.0.0-rc.1", | ||
"@babel/core": "7.0.0-rc.2", | ||
"@babel/helper-plugin-test-runner": "7.0.0-rc.2", | ||
"@babel/helpers": "7.0.0-rc.2", | ||
"@babel/plugin-transform-runtime": "7.0.0-rc.2", | ||
"@babel/preset-env": "7.0.0-rc.2", | ||
"@babel/runtime": "7.0.0-rc.2", | ||
"@babel/template": "7.0.0-rc.2", | ||
"@babel/types": "7.0.0-beta.53" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15283
377
4
8
+ Addedresolve@^1.8.1
+ Added@babel/helper-module-imports@7.0.0-rc.2(transitive)
+ Added@babel/helper-plugin-utils@7.0.0-rc.2(transitive)
+ Added@babel/types@7.0.0-rc.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removed@babel/helper-module-imports@7.0.0-rc.1(transitive)
- Removed@babel/helper-plugin-utils@7.0.0-rc.1(transitive)
- Removed@babel/types@7.0.0-rc.1(transitive)