Skip to content

Commit

Permalink
[v5] drop es5 (#2380)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Mar 2, 2024
1 parent 77162b5 commit 752b917
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,8 @@
},
"homepage": "https://github.com/pmndrs/zustand",
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/plugin-external-helpers": "^7.23.3",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/plugin-transform-typescript": "^7.23.6",
"@babel/preset-env": "^7.24.0",
"@redux-devtools/extension": "^3.3.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-typescript": "^11.1.6",
Expand Down
34 changes: 7 additions & 27 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('path')
const alias = require('@rollup/plugin-alias')
const babelPlugin = require('@rollup/plugin-babel')
const resolve = require('@rollup/plugin-node-resolve')
const replace = require('@rollup/plugin-replace')
const typescript = require('@rollup/plugin-typescript')
Expand All @@ -19,24 +18,9 @@ function external(id) {
return !id.startsWith('.') && !id.startsWith(root)
}

function getBabelOptions(targets) {
return {
babelrc: false,
ignore: ['./node_modules'],
presets: [['@babel/preset-env', { loose: true, modules: false, targets }]],
plugins: [
['@babel/plugin-transform-react-jsx', { runtime: 'automatic' }],
['@babel/plugin-transform-typescript', { isTSX: true }],
],
extensions,
comments: false,
babelHelpers: 'bundled',
}
}

function getEsbuild(env = 'development') {
function getEsbuild(format) {
return esbuild({
minify: env === 'production',
format,
target: 'es2018',
supported: { 'import-meta': true },
tsconfig: path.resolve('./tsconfig.json'),
Expand Down Expand Up @@ -83,19 +67,15 @@ function createESMConfig(input, output) {
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
getEsbuild(),
getEsbuild('esm'),
],
}
}

function createCommonJSConfig(input, output) {
return {
input,
output: {
file: `${output}.js`,
format: 'cjs',
esModule: false,
},
output: { file: output, format: 'cjs' },
external,
plugins: [
alias({ entries: entries.filter((e) => !e.find.test(input)) }),
Expand All @@ -105,7 +85,7 @@ function createCommonJSConfig(input, output) {
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
babelPlugin(getBabelOptions({ ie: 11 })),
getEsbuild('cjs'),
],
}
}
Expand All @@ -119,8 +99,8 @@ module.exports = function (args) {
}
return [
...(c === 'index' ? [createDeclarationConfig(`src/${c}.ts`, 'dist')] : []),
createCommonJSConfig(`src/${c}.ts`, `dist/${c}`),
createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`), // just for testing sed -e flag
createCommonJSConfig(`src/${c}.ts`, `dist/${c}.js`),
createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`),
]
}

Expand Down

0 comments on commit 752b917

Please sign in to comment.