Skip to content

Commit dc03d30

Browse files
committed
refactor: use esm
BREAKING CHANGE: use Babel 8
1 parent 067d732 commit dc03d30

8 files changed

Lines changed: 824 additions & 992 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ npm install babel-preset-evergreen --save-dev
2929
// example: babel.config.json
3030
{
3131
"targets": "chrome >= 60",
32+
"assumptions": {
33+
"noNewArrows": false
34+
},
3235
"presets": [
3336
[
3437
"evergreen",

index.cjs renamed to index.mjs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
'use strict';
2-
3-
const { declare } = require('@babel/helper-plugin-utils');
4-
const { excludeIfMini } = require('./mini.cjs');
5-
6-
module.exports = declare((api, options = {}) => {
7-
api.assertVersion(7);
1+
import { declare } from '@babel/helper-plugin-utils';
2+
import { excludeIfMini } from './mini.mjs';
3+
import pkg from './package.json' with { type: 'json' };
84

5+
export default declare((api, options = {}) => {
6+
api.assertVersion(8);
97
const { polyfill = false } = options;
108

119
const presets = [
@@ -15,25 +13,21 @@ module.exports = declare((api, options = {}) => {
1513
modules: false,
1614
useBuiltIns: false,
1715
shippedProposals: true,
18-
spec: true,
19-
bugfixes: true,
16+
corejs: pkg.dependencies['core-js'],
2017
},
2118
],
2219
];
23-
2420
if (!polyfill) {
25-
return { presets };
21+
return {
22+
presets,
23+
};
2624
}
27-
2825
const {
2926
usage = 'global',
3027
include = [],
3128
exclude = [],
3229
mini = false,
3330
} = polyfill;
34-
35-
const pkg = require('./package.json');
36-
3731
return {
3832
presets,
3933
plugins: [

mini.cjs

Lines changed: 0 additions & 16 deletions
This file was deleted.

mini.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import modules from 'core-js-compat/modules.json' with { type: 'json' };
2+
import miniprogramCompat from 'miniprogram-compat/data/polyfill.json' with { type: 'json' };
3+
4+
const mini = [
5+
...new Set(
6+
miniprogramCompat['3.6.1'].coreJsModules.flatMap((item) => [
7+
item,
8+
item.replace('esnext.', 'es.'),
9+
item.replace('es.', 'esnext.'),
10+
]),
11+
),
12+
].toSorted();
13+
14+
export const excludeIfMini = mini.filter((item) => modules.includes(item));

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,44 @@
2727
"bugs": {
2828
"url": "https://github.com/best-shot/babel-preset-evergreen/issues"
2929
},
30-
"main": "index.cjs",
30+
"main": "index.mjs",
3131
"files": [
32-
"mini.cjs"
32+
"mini.mjs"
3333
],
34-
"type": "commonjs",
34+
"type": "module",
3535
"scripts": {
3636
"lint:eslint": "eslint . --quiet --fix --concurrency=auto",
3737
"lint:staged": "nice-move lint staged",
3838
"lint:type": "tsc -p tsconfig.json",
3939
"lint:version": "syncpack lint",
4040
"prepare": "nice-move git hooks",
4141
"prepublishOnly": "pnpm run lint:staged && pnpm run lint:type && pnpm test",
42-
"snapshot": "ava --fail-fast -u",
42+
"snapshot": "ava --fail-fast -u -w",
4343
"test": "ava --fail-fast",
4444
"version:pin": "syncpack fix-mismatches"
4545
},
4646
"dependencies": {
47-
"@babel/helper-plugin-utils": "^7.29.7",
48-
"@babel/preset-env": "^7.29.7",
49-
"babel-plugin-polyfill-corejs3": "^0.14.2",
47+
"@babel/helper-plugin-utils": "^8.0.1",
48+
"@babel/preset-env": "^8.0.2",
49+
"babel-plugin-polyfill-corejs3": "^1.0.0",
5050
"core-js": "^3.49.0",
5151
"core-js-compat": "^3.49.0",
5252
"miniprogram-compat": "^1.0.5"
5353
},
5454
"devDependencies": {
55-
"@babel/core": "^7.29.7",
55+
"@babel/core": "^8.0.1",
5656
"@bring-it/npm": "^0.9.3",
5757
"@nice-move/all-in-base": "^0.8.6",
58-
"@types/babel__core": "^7.20.5",
5958
"ava": "^8.0.1",
6059
"eslint": "^9.39.4",
6160
"garou": "^0.9.21",
6261
"prettier": "~3.8.4",
6362
"typescript": "~6.0.3"
6463
},
6564
"peerDependencies": {
66-
"@babel/core": "^7.29.0"
65+
"@babel/core": "^8.0.1"
6766
},
68-
"packageManager": "pnpm@10.28.2",
67+
"packageManager": "pnpm@10.34.4",
6968
"engines": {
7069
"node": ">=20.18.0",
7170
"pnpm": "^10.28.0"

0 commit comments

Comments
 (0)