Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ packages/*/lib
packages/*/esm
packages/*/test/fixtures
packages/*/test/spawn-fixtures
packages/babel-plugin-polyfill-corejs2/data/*
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 16, 14]
node-version: [20, 22, 24]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js latest
uses: actions/setup-node@v3
with:
cache: "yarn"
- name: Downgrade Yarn and install
if: ${{ matrix.node-version < 18 }}
run: yarn set version 3 && yarn install --no-frozen-lockfile
- name: Install
if: ${{ matrix.node-version >= 18 }}
run: yarn install
- name: Build
run: yarn build
Expand All @@ -71,6 +67,9 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Delete tests that import .ts files
if: matrix.node-version == '20'
run: rm packages/babel-helper-define-polyfill-provider/test/meta-resolver.js packages/babel-plugin-polyfill-corejs3/test/check-builtin-definitions.test.js
- name: Test on Node.js ${{ matrix.node-version }}
# `maxWorkers` cannot be 1 because we are using `process.exitCode` in our tests.
run: yarn jest --ci --color --maxWorkers=2
Expand All @@ -95,7 +94,7 @@ jobs:
shell: bash
run: yarn build-es-shims-data
- name: Build
run: yarn build-corejs3-shipped-proposals && gulp build && gulp bundle
run: yarn build-corejs3-shipped-proposals && gulp build
- name: Test on Node.js latest
# `maxWorkers` cannot be 1 because we are using `process.exitCode` in our tests.
run: yarn jest --ci --color --maxWorkers=2
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ package.json
packages/*/test/fixtures/**/input.*
packages/*/test/fixtures/**/exec.*
packages/*/test/fixtures/**/output.*
packages/babel-plugin-polyfill-corejs2/data/*
packages/babel-plugin-polyfill-corejs3/src/shipped-proposals.js
62 changes: 4 additions & 58 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"use strict";

const plumber = require("gulp-plumber");
const through = require("through2");
const chalk = require("chalk");
const newer = require("gulp-newer");
const babel = require("gulp-babel");
const gulpWatch = require("gulp-watch");
const fancyLog = require("fancy-log");
const gulp = require("gulp");
const path = require("path");
const rollup = require("rollup").rollup;
Expand All @@ -17,57 +11,11 @@ const rollupJson = require("@rollup/plugin-json");
const esmBundles = [
{ name: "babel-helper-define-polyfill-provider", target: "node" },
{ name: "babel-helper-define-polyfill-provider", target: "browser" },
{ name: "babel-plugin-polyfill-corejs2" },
{ name: "babel-plugin-polyfill-corejs3" },
{ name: "babel-plugin-polyfill-es-shims" },
{ name: "babel-plugin-polyfill-regenerator" },
];

function swapSrcWithLib(srcPath) {
const parts = srcPath.split(path.sep);
parts[1] = "lib";
return parts.join(path.sep);
}

function compilationLogger() {
return through.obj(function (file, enc, callback) {
fancyLog(`Compiling '${chalk.cyan(file.relative)}'...`);
callback(null, file);
});
}

function errorsLogger() {
return plumber({
errorHandler(err) {
fancyLog(err.stack);
},
});
}

function rename(fn) {
return through.obj(function (file, enc, callback) {
file.path = fn(file);
callback(null, file);
});
}

function build() {
const base = path.join(__dirname, "packages");

return gulp
.src("./packages/*/src/**/*.{js,ts}", { base: base })
.pipe(errorsLogger())
.pipe(newer({ dest: base, map: swapSrcWithLib }))
.pipe(compilationLogger())
.pipe(babel())
.pipe(
// Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent.
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
)
.pipe(gulp.dest(base));
}

async function buildRollup() {
const base = path.join(__dirname, "packages");

Expand All @@ -90,7 +38,6 @@ async function buildRollup() {
plugins: [
rollupJson(),
rollupBabel({
envName: "esm",
babelrc: false,
babelHelpers: "bundled",
extends: "./babel.config.json",
Expand All @@ -105,21 +52,20 @@ async function buildRollup() {
});

const outputFile = target
? `${dir}/esm/index.${target}.mjs`
: `${dir}/esm/index.mjs`;
? `${dir}/lib/index.${target}.js`
: `${dir}/lib/index.js`;
await bundle.write({
file: outputFile,
format: "es",
sourcemap: true,
exports: "named",
importAttributesKey: "with",
});
})
);
}

gulp.task("build", () => build());

gulp.task("bundle", () => buildRollup());
gulp.task("build", () => buildRollup());

gulp.task("default", gulp.series("build"));

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ If you are interested in reading about all the options supported by these plugin
<!--prettier-ignore -->
| Polyfill | Plugin | Methods |
| :------: | :----: | :-----: |
| `core-js@2` | [`babel-plugin-polyfill-corejs2`](./packages/babel-plugin-polyfill-corejs2) | `entry-global`, `usage-global` and `usage-pure` |
| `core-js@3` | [`babel-plugin-polyfill-corejs3`](./packages/babel-plugin-polyfill-corejs3) | `entry-global`, `usage-global` and `usage-pure` |
| `es-shims` | [`babel-plugin-polyfill-es-shims`](./packages/babel-plugin-polyfill-es-shims) | `usage-global` and `usage-pure` |
| `regenerator-runtime` | [`babel-plugin-polyfill-regenerator`](./packages/babel-plugin-polyfill-regenerator) | `entry-global`, `usage-global` and `usage-pure` |
Expand Down
14 changes: 2 additions & 12 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
["@babel/preset-env", { "loose": true }],
"@babel/preset-typescript"
],
"plugins": [
"./scripts/babel-plugin-remove-create-require",
"./scripts/babel-plugin-compat-core-import"
],
"plugins": ["./scripts/babel-plugin-compat-core-import"],
"targets": { "node": "current" },
"env": {
"production": {
"targets": { "node": "6.9" }
},
"esm": {
"targets": { "node": "12.20" },
"plugins": [
// Disable it
["./scripts/babel-plugin-remove-create-require", false]
]
"targets": { "node": "20.19" }
}
}
}
135 changes: 0 additions & 135 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,138 +230,3 @@ All the existig capabilities of `@babel/preset-env` and `@babel/plugin-transform
</tr>
</table>
<!-- prettier-ignore-end -->

### `core-js@2`

<!-- prettier-ignore-start -->
<table>
<thead><tr>
<th align="center">Old configuration</th>
<th align="center">New configuration</th>
</tr></thead>
<tr>
<td>

```json
{
"presets": [
["@babel/preset-env", {
"targets": { "firefox": 42 },
"useBuiltIns": "usage",
"corejs": 2
}]
]
}
```

</td>
<td>

```json
{
"targets": { "firefox": 42 },
"presets": ["@babel/preset-env"],
"plugins": [
["polyfill-corejs2", {
"method": "usage-global"
}]
]
}
```

</td>
</tr>
</table>
<!-- prettier-ignore-end -->


<!-- prettier-ignore-start -->
<table>
<thead><tr>
<th align="center">Old configuration</th>
<th align="center">New configuration</th>
</tr></thead>
<tr>
<td>

```json
{
"presets": [
["@babel/preset-env", {
"targets": { "firefox": 42 },
"useBuiltIns": "entry",
"corejs": 2
}]
]
}
```

</td>
<td>

```json
{
"targets": { "firefox": 42 },
"presets": ["@babel/preset-env"],
"plugins": [
["polyfill-corejs2", {
"method": "entry-global"
}]
]
}
```

</td>
</tr>
</table>
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->
<table>
<thead><tr>
<th align="center">Old configuration</th>
<th align="center">New configuration</th>
</tr></thead>
<tr>
<td>

```json
{
"presets": [
["@babel/preset-env", {
"targets": { "firefox": 42 }
}]
],
"plugins": [
["@babel/transform-runtime", {
"corejs": 2
}]
]
}
```

</td>
<td>

```json
{
"presets": [
["@babel/preset-env", {
"targets": { "firefox": 42 }
}]
],
"plugins": [
"@babel/transform-runtime",
["polyfill-corejs2", {
"method": "usage-pure"
}]
]
}
```

**NOTE**: The "Old" config doesn't support targets for polyfills, but you'll likely want to enable them by moving the `targets` option to the top-level.

</td>
</tr>
</table>
<!-- prettier-ignore-end -->
24 changes: 10 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"private": true,
"license": "MIT",
"scripts": {
"build": "yarn build-es-shims-data && yarn build-corejs3-shipped-proposals && gulp build && gulp bundle",
"build": "yarn build-es-shims-data && yarn build-corejs3-shipped-proposals && gulp build",
"build-corejs3-shipped-proposals": "node ./scripts/build-corejs3-shipped-proposals.mjs",
"build-es-shims-data": "node ./scripts/download-compat-table.js && node ./scripts/build-es-shims-data",
"clean": "rimraf packages/*/lib packages/*/esm",
"clean": "rimraf packages/*/lib",
"clean-all": "yarn clean && rimraf packages/*/node_modules node_modules",
"lint": "eslint packages '*.{js,ts}' --ext .js,.ts --format=codeframe",
"publish": "yarn clean && NODE_ENV=production yarn build && yarn validate && lerna publish from-git",
Expand All @@ -26,34 +26,29 @@
"@babel/preset-env": "^7.28.6",
"@babel/preset-typescript": "^7.28.5",
"@babel/runtime": "^7.28.6",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-babel": "^7.0.0",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@types/babel__traverse": "^7.28.0",
"@typescript-eslint/eslint-plugin": "^8.53.1",
"@typescript-eslint/parser": "^8.53.1",
"babel-jest": "^29.7.0",
"chalk": "^3.0.0",
"electron-to-chromium": "^1.5.278",
"eslint": "^8.57.1",
"eslint-formatter-codeframe": "^7.32.2",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.5.5",
"fancy-log": "^1.3.3",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-newer": "^1.4.0",
"gulp-plumber": "^1.2.1",
"gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1",
"jest": "^27.5.1",
"jest": "^30.2.0",
"jest-light-runner": "^0.7.11",
"lerna": "^3.22.1",
"lodash": "^4.17.23",
"prettier": "^3.8.1",
"rimraf": "^2.7.1",
"rollup": "^2.79.2",
"through2": "^2.0.5",
"rollup": "^4.59.0",
"typescript": "^5.9.3"
},
"resolutions": {
Expand All @@ -64,14 +59,15 @@
"@babel/preset-env/core-js-compat": "^3.48.0"
},
"engines": {
"node": ">= 6.9.0",
"node": "^20.19.0 || >=22.12.0",
"yarn": ">=1.0.0"
},
"workspaces": [
"packages/*",
"test/esm"
],
"jest": {
"runner": "jest-light-runner",
"testRegex": "./packages/[^/]+/test/.+\\.m?js$",
"testPathIgnorePatterns": [
"/node_modules/",
Expand Down
Loading