Import the correct ./typeof.js helper in @babel/runtime (#14081)
This commit is contained in:
parent
2810dc6460
commit
f69f1a80d5
6
.gitignore
vendored
6
.gitignore
vendored
@ -28,27 +28,33 @@ package-lock.json
|
|||||||
/packages/babel-runtime/helpers/*.js
|
/packages/babel-runtime/helpers/*.js
|
||||||
!/packages/babel-runtime/helpers/toArray.js
|
!/packages/babel-runtime/helpers/toArray.js
|
||||||
!/packages/babel-runtime/helpers/iterableToArray.js
|
!/packages/babel-runtime/helpers/iterableToArray.js
|
||||||
|
!/packages/babel-runtime/helpers/possibleConstructorReturn.js
|
||||||
!/packages/babel-runtime/helpers/temporalRef.js
|
!/packages/babel-runtime/helpers/temporalRef.js
|
||||||
!/packages/babel-runtime/helpers/typeof.js
|
!/packages/babel-runtime/helpers/typeof.js
|
||||||
/packages/babel-runtime/helpers/esm/*.js
|
/packages/babel-runtime/helpers/esm/*.js
|
||||||
!/packages/babel-runtime/helpers/esm/toArray.js
|
!/packages/babel-runtime/helpers/esm/toArray.js
|
||||||
!/packages/babel-runtime/helpers/esm/iterableToArray.js
|
!/packages/babel-runtime/helpers/esm/iterableToArray.js
|
||||||
|
!/packages/babel-runtime/helpers/esm/possibleConstructorReturn.js
|
||||||
!/packages/babel-runtime/helpers/esm/temporalRef.js
|
!/packages/babel-runtime/helpers/esm/temporalRef.js
|
||||||
|
|
||||||
/packages/babel-runtime-corejs2/helpers/*.js
|
/packages/babel-runtime-corejs2/helpers/*.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/toArray.js
|
!/packages/babel-runtime-corejs2/helpers/toArray.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/iterableToArray.js
|
!/packages/babel-runtime-corejs2/helpers/iterableToArray.js
|
||||||
|
!/packages/babel-runtime-corejs2/helpers/possibleConstructorReturn.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/temporalRef.js
|
!/packages/babel-runtime-corejs2/helpers/temporalRef.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/typeof.js
|
!/packages/babel-runtime-corejs2/helpers/typeof.js
|
||||||
/packages/babel-runtime-corejs2/helpers/esm/*.js
|
/packages/babel-runtime-corejs2/helpers/esm/*.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js
|
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
|
!/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
|
||||||
|
!/packages/babel-runtime-corejs2/helpers/esm/possibleConstructorReturn.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
|
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
|
||||||
/packages/babel-runtime-corejs2/core-js/**/*.js
|
/packages/babel-runtime-corejs2/core-js/**/*.js
|
||||||
!/packages/babel-runtime-corejs2/core-js/map.js
|
!/packages/babel-runtime-corejs2/core-js/map.js
|
||||||
|
|
||||||
/packages/babel-runtime-corejs3/helpers/*.js
|
/packages/babel-runtime-corejs3/helpers/*.js
|
||||||
|
!/packages/babel-runtime-corejs3/helpers/possibleConstructorReturn.js
|
||||||
/packages/babel-runtime-corejs3/helpers/esm/*.js
|
/packages/babel-runtime-corejs3/helpers/esm/*.js
|
||||||
|
!/packages/babel-runtime-corejs3/helpers/esm/possibleConstructorReturn.js
|
||||||
/packages/babel-runtime-corejs3/core-js/**/*.js
|
/packages/babel-runtime-corejs3/core-js/**/*.js
|
||||||
/packages/babel-runtime-corejs3/core-js-stable/**/*.js
|
/packages/babel-runtime-corejs3/core-js-stable/**/*.js
|
||||||
|
|
||||||
|
|||||||
@ -259,15 +259,23 @@ function buildHelper(
|
|||||||
|
|
||||||
function buildRuntimeRewritePlugin(runtimeName, helperName) {
|
function buildRuntimeRewritePlugin(runtimeName, helperName) {
|
||||||
/**
|
/**
|
||||||
* rewrite helpers imports to runtime imports
|
* Rewrite helper imports to load the adequate module format version
|
||||||
* @example
|
* @example
|
||||||
* adjustImportPath(ast`"setPrototypeOf"`)
|
* adjustImportPath(ast`"setPrototypeOf"`)
|
||||||
* // returns ast`"@babel/runtime/helpers/esm/setPrototypeOf"`
|
* // returns ast`"./setPrototypeOf"`
|
||||||
* @param {*} node The string literal contains import path
|
* @example
|
||||||
|
* adjustImportPath(ast`"@babel/runtime/helpers/typeof"`)
|
||||||
|
* // returns ast`"./typeof"`
|
||||||
|
* @param {*} node The string literal that contains the import path
|
||||||
*/
|
*/
|
||||||
function adjustImportPath(node) {
|
function adjustImportPath(node) {
|
||||||
if (helpers.list.includes(node.value)) {
|
const helpersPath = path.join(runtimeName, "helpers");
|
||||||
node.value = `./${node.value}.js`;
|
const helper = node.value.startsWith(helpersPath)
|
||||||
|
? path.basename(node.value)
|
||||||
|
: node.value;
|
||||||
|
|
||||||
|
if (helpers.list.includes(helper)) {
|
||||||
|
node.value = `./${helper}.js`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
import _typeof from "./typeof.js";
|
||||||
|
import assertThisInitialized from "./assertThisInitialized.js";
|
||||||
|
export default function _possibleConstructorReturn(self, call) {
|
||||||
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||||
|
return call;
|
||||||
|
} else if (call !== void 0) {
|
||||||
|
throw new TypeError("Derived constructors may only return object or undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
return assertThisInitialized(self);
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
var _typeof = require("./typeof.js")["default"];
|
||||||
|
|
||||||
|
var assertThisInitialized = require("./assertThisInitialized.js");
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) {
|
||||||
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||||
|
return call;
|
||||||
|
} else if (call !== void 0) {
|
||||||
|
throw new TypeError("Derived constructors may only return object or undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
return assertThisInitialized(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import _typeof from "./typeof.js";
|
||||||
|
import assertThisInitialized from "./assertThisInitialized.js";
|
||||||
|
export default function _possibleConstructorReturn(self, call) {
|
||||||
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||||
|
return call;
|
||||||
|
} else if (call !== void 0) {
|
||||||
|
throw new TypeError("Derived constructors may only return object or undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
return assertThisInitialized(self);
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
var _typeof = require("./typeof.js")["default"];
|
||||||
|
|
||||||
|
var assertThisInitialized = require("./assertThisInitialized.js");
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) {
|
||||||
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||||
|
return call;
|
||||||
|
} else if (call !== void 0) {
|
||||||
|
throw new TypeError("Derived constructors may only return object or undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
return assertThisInitialized(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import _typeof from "./typeof.js";
|
||||||
|
import assertThisInitialized from "./assertThisInitialized.js";
|
||||||
|
export default function _possibleConstructorReturn(self, call) {
|
||||||
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||||
|
return call;
|
||||||
|
} else if (call !== void 0) {
|
||||||
|
throw new TypeError("Derived constructors may only return object or undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
return assertThisInitialized(self);
|
||||||
|
}
|
||||||
15
packages/babel-runtime/helpers/possibleConstructorReturn.js
Normal file
15
packages/babel-runtime/helpers/possibleConstructorReturn.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
var _typeof = require("./typeof.js")["default"];
|
||||||
|
|
||||||
|
var assertThisInitialized = require("./assertThisInitialized.js");
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) {
|
||||||
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||||||
|
return call;
|
||||||
|
} else if (call !== void 0) {
|
||||||
|
throw new TypeError("Derived constructors may only return object or undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
return assertThisInitialized(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||||
Loading…
x
Reference in New Issue
Block a user