Skip to content

Commit

Permalink
Update babel-polyfills packages (#14793)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jul 25, 2022
1 parent 3e3e7a8 commit 02df091
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 144 deletions.
44 changes: 23 additions & 21 deletions Gulpfile.mjs
Expand Up @@ -312,27 +312,29 @@ function buildRollup(packages, targetBrowsers) {
input,
external,
onwarn(warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") return;
if (warning.code === "UNUSED_EXTERNAL_IMPORT") {
warn(warning);
return;
}

// Rollup warns about using babel.default at
// https://github.com/babel/babel-polyfills/blob/4ac92be5b70b13e3d8a34614d8ecd900eb3f40e4/packages/babel-helper-define-polyfill-provider/src/types.js#L5
// We can safely ignore this warning, and let Rollup replace it with undefined.
if (
warning.code === "MISSING_EXPORT" &&
warning.exporter === "packages/babel-core/src/index.ts" &&
warning.missing === "default" &&
[
"@babel/helper-define-polyfill-provider",
"babel-plugin-polyfill-corejs2",
"babel-plugin-polyfill-corejs3",
"babel-plugin-polyfill-regenerator",
].some(pkg => warning.importer.includes(pkg))
) {
return;
switch (warning.code) {
case "CIRCULAR_DEPENDENCY":
case "SOURCEMAP_ERROR": // Rollup warns about the babel-polyfills source maps
return;
case "UNUSED_EXTERNAL_IMPORT":
warn(warning);
return;
case "MISSING_EXPORT":
// Rollup warns about using babel.default at
// https://github.com/babel/babel-polyfills/blob/4ac92be5b70b13e3d8a34614d8ecd900eb3f40e4/packages/babel-helper-define-polyfill-provider/src/types.js#L5
// We can safely ignore this warning, and let Rollup replace it with undefined.
if (
warning.exporter === "packages/babel-core/src/index.ts" &&
warning.missing === "default" &&
[
"@babel/helper-define-polyfill-provider",
"babel-plugin-polyfill-corejs2",
"babel-plugin-polyfill-corejs3",
"babel-plugin-polyfill-regenerator",
].some(pkg => warning.importer.includes(pkg))
) {
return;
}
}

// We use console.warn here since it prints more info than just "warn",
Expand Down
Expand Up @@ -151,6 +151,8 @@ function runCacheableScriptInTestContext(
id: filename,
exports: {},
};
moduleCache[filename] = module;

const req = (id: string) =>
runModuleInTestContext(id, filename, context, moduleCache);
const dirname = path.dirname(filename);
Expand Down Expand Up @@ -184,15 +186,12 @@ function runModuleInTestContext(
// stronger cache guarantee than the LRU's Script cache.
if (moduleCache[filename]) return moduleCache[filename].exports;

const module = runCacheableScriptInTestContext(
return runCacheableScriptInTestContext(
filename,
() => fs.readFileSync(filename, "utf8"),
context,
moduleCache,
);
moduleCache[filename] = module;

return module.exports;
).exports;
}

/**
Expand Down
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@babel/core": "workspace:^",
"@babel/helper-plugin-test-runner": "workspace:^",
"babel-plugin-polyfill-corejs3": "^0.5.2",
"babel-plugin-polyfill-corejs3": "^0.5.3",
"core-js-pure": "^3.20.2"
},
"engines": {
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-plugin-proposal-decorators/package.json
Expand Up @@ -34,7 +34,8 @@
"@babel/helper-plugin-test-runner": "workspace:^",
"@babel/traverse": "workspace:^",
"@types/charcodes": "^0.2.0",
"babel-plugin-polyfill-es-shims": "^0.6.1",
"array.prototype.concat": "^1.0.2",
"babel-plugin-polyfill-es-shims": "^0.7.0",
"charcodes": "^0.2.0",
"object.getownpropertydescriptors": "^2.1.1"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-runtime/package.json
Expand Up @@ -22,9 +22,9 @@
"dependencies": {
"@babel/helper-module-imports": "workspace:^",
"@babel/helper-plugin-utils": "workspace:^",
"babel-plugin-polyfill-corejs2": "^0.3.1",
"babel-plugin-polyfill-corejs3": "^0.5.2",
"babel-plugin-polyfill-regenerator": "^0.3.1",
"babel-plugin-polyfill-corejs2": "^0.3.2",
"babel-plugin-polyfill-corejs3": "^0.5.3",
"babel-plugin-polyfill-regenerator": "^0.4.0",
"semver": "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-preset-env/package.json
Expand Up @@ -86,9 +86,9 @@
"@babel/plugin-transform-unicode-regex": "workspace:^",
"@babel/preset-modules": "^0.1.5",
"@babel/types": "workspace:^",
"babel-plugin-polyfill-corejs2": "^0.3.1",
"babel-plugin-polyfill-corejs3": "^0.5.2",
"babel-plugin-polyfill-regenerator": "^0.3.1",
"babel-plugin-polyfill-corejs2": "^0.3.2",
"babel-plugin-polyfill-corejs3": "^0.5.3",
"babel-plugin-polyfill-regenerator": "^0.4.0",
"core-js-compat": "^3.22.1",
"semver": "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
},
Expand Down

0 comments on commit 02df091

Please sign in to comment.