Skip to content

Commit

Permalink
[v2] drop es5 (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Mar 2, 2024
1 parent 36b998b commit 9d0dc69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,8 @@
"proxy-compare": "2.6.0"
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@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
28 changes: 6 additions & 22 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 @@ -80,15 +64,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' },
output: { file: output, format: 'cjs' },
external,
plugins: [
alias({ entries: entries.filter((e) => !e.find.test(input)) }),
Expand All @@ -98,7 +82,7 @@ function createCommonJSConfig(input, output) {
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
babelPlugin(getBabelOptions({ ie: 11 })),
getEsbuild('cjs'),
],
}
}
Expand All @@ -112,7 +96,7 @@ module.exports = function (args) {
}
return [
...(c === 'index' ? [createDeclarationConfig(`src/${c}.ts`, 'dist')] : []),
createCommonJSConfig(`src/${c}.ts`, `dist/${c}`),
createCommonJSConfig(`src/${c}.ts`, `dist/${c}.js`),
createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`),
]
}
Expand Down

0 comments on commit 9d0dc69

Please sign in to comment.