Skip to content

Commit

Permalink
Avoid override mistake in namespace imports (#16025)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo authored Oct 10, 2023
1 parent 3f66d23 commit 0c9032d
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 80 deletions.
4 changes: 4 additions & 0 deletions packages/babel-helpers/src/helpers-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export default Object.freeze({
"7.23.0",
"export default function _importDeferProxy(e){var t=null,constValue=function(e){return function(){return e}},proxy=function(r){return function(n,o,f){return null===t&&(t=e()),r(t,o,f)}};return new Proxy({},{defineProperty:constValue(!1),deleteProperty:constValue(!1),get:proxy(Reflect.get),getOwnPropertyDescriptor:proxy(Reflect.getOwnPropertyDescriptor),getPrototypeOf:constValue(null),isExtensible:constValue(!1),has:proxy(Reflect.has),ownKeys:proxy(Reflect.ownKeys),preventExtensions:constValue(!0),set:constValue(!1),setPrototypeOf:constValue(!1)})}",
),
interopRequireWildcard: helper(
"7.14.0",
'function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}export default function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}',
),
iterableToArrayLimit: helper(
"7.0.0-beta.0",
'export default function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(o)throw n}}return a}}',
Expand Down
47 changes: 0 additions & 47 deletions packages/babel-helpers/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,53 +372,6 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")`
}
`;

helpers.interopRequireWildcard = helper("7.14.0")`
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
export default function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
return { default: obj }
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
`;

helpers.newArrowCheck = helper("7.0.0-beta.0")`
export default function _newArrowCheck(innerThis, boundThis) {
if (innerThis !== boundThis) {
Expand Down
47 changes: 47 additions & 0 deletions packages/babel-helpers/src/helpers/interopRequireWildcard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* @minVersion 7.14.0 */

function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;

var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}

export default function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}

if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
return { default: obj };
}

var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}

var newObj = { __proto__: null };
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
exports.foo = void 0;
var foo = _interopRequireWildcard(require("./moduleWithGetter"));
exports.foo = foo;
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Object.defineProperty(exports, "baz", {
}
});
var _moduleWithGetter = _interopRequireWildcard(require("./moduleWithGetter"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
var _foo = _interopRequireDefault(require("foo"));
var Bar = _interopRequireWildcard(require("bar"));
var _baz = require("baz");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_foo.default = (42, function () {
throw new Error('"' + "Foo" + '" is read-only.');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Object.freeze(Object.prototype);
exports.constructor = 2;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as ns from "./dep.cjs";
expect(ns.constructor).toBe(2);
18 changes: 9 additions & 9 deletions packages/babel-runtime-corejs2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@
"./helpers/importDeferProxy.js"
],
"./helpers/esm/importDeferProxy": "./helpers/esm/importDeferProxy.js",
"./helpers/interopRequireWildcard": [
{
"node": "./helpers/interopRequireWildcard.js",
"import": "./helpers/esm/interopRequireWildcard.js",
"default": "./helpers/interopRequireWildcard.js"
},
"./helpers/interopRequireWildcard.js"
],
"./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js",
"./helpers/iterableToArrayLimit": [
{
"node": "./helpers/iterableToArrayLimit.js",
Expand Down Expand Up @@ -396,15 +405,6 @@
"./helpers/interopRequireDefault.js"
],
"./helpers/esm/interopRequireDefault": "./helpers/esm/interopRequireDefault.js",
"./helpers/interopRequireWildcard": [
{
"node": "./helpers/interopRequireWildcard.js",
"import": "./helpers/esm/interopRequireWildcard.js",
"default": "./helpers/interopRequireWildcard.js"
},
"./helpers/interopRequireWildcard.js"
],
"./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js",
"./helpers/newArrowCheck": [
{
"node": "./helpers/newArrowCheck.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/babel-runtime-corejs3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@
"./helpers/importDeferProxy.js"
],
"./helpers/esm/importDeferProxy": "./helpers/esm/importDeferProxy.js",
"./helpers/interopRequireWildcard": [
{
"node": "./helpers/interopRequireWildcard.js",
"import": "./helpers/esm/interopRequireWildcard.js",
"default": "./helpers/interopRequireWildcard.js"
},
"./helpers/interopRequireWildcard.js"
],
"./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js",
"./helpers/iterableToArrayLimit": [
{
"node": "./helpers/iterableToArrayLimit.js",
Expand Down Expand Up @@ -395,15 +404,6 @@
"./helpers/interopRequireDefault.js"
],
"./helpers/esm/interopRequireDefault": "./helpers/esm/interopRequireDefault.js",
"./helpers/interopRequireWildcard": [
{
"node": "./helpers/interopRequireWildcard.js",
"import": "./helpers/esm/interopRequireWildcard.js",
"default": "./helpers/interopRequireWildcard.js"
},
"./helpers/interopRequireWildcard.js"
],
"./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js",
"./helpers/newArrowCheck": [
{
"node": "./helpers/newArrowCheck.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/babel-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@
"./helpers/importDeferProxy.js"
],
"./helpers/esm/importDeferProxy": "./helpers/esm/importDeferProxy.js",
"./helpers/interopRequireWildcard": [
{
"node": "./helpers/interopRequireWildcard.js",
"import": "./helpers/esm/interopRequireWildcard.js",
"default": "./helpers/interopRequireWildcard.js"
},
"./helpers/interopRequireWildcard.js"
],
"./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js",
"./helpers/iterableToArrayLimit": [
{
"node": "./helpers/iterableToArrayLimit.js",
Expand Down Expand Up @@ -395,15 +404,6 @@
"./helpers/interopRequireDefault.js"
],
"./helpers/esm/interopRequireDefault": "./helpers/esm/interopRequireDefault.js",
"./helpers/interopRequireWildcard": [
{
"node": "./helpers/interopRequireWildcard.js",
"import": "./helpers/esm/interopRequireWildcard.js",
"default": "./helpers/interopRequireWildcard.js"
},
"./helpers/interopRequireWildcard.js"
],
"./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js",
"./helpers/newArrowCheck": [
{
"node": "./helpers/newArrowCheck.js",
Expand Down

0 comments on commit 0c9032d

Please sign in to comment.