Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] drop es5 #865

Merged
merged 1 commit into from
Mar 2, 2024
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
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
Loading