From 752b917c778a0791cf7225952e71e95f758c7203 Mon Sep 17 00:00:00 2001 From: Daishi Kato Date: Sat, 2 Mar 2024 23:04:22 +0900 Subject: [PATCH] [v5] drop es5 (#2380) --- package.json | 7 ------- rollup.config.js | 34 +++++++--------------------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 9efcee3e68..c8d1129a4c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/rollup.config.js b/rollup.config.js index 215ed9d7e2..82b17c1d72 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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') @@ -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'), @@ -83,7 +67,7 @@ function createESMConfig(input, output) { delimiters: ['\\b', '\\b(?!(\\.|/))'], preventAssignment: true, }), - getEsbuild(), + getEsbuild('esm'), ], } } @@ -91,11 +75,7 @@ function createESMConfig(input, output) { 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)) }), @@ -105,7 +85,7 @@ function createCommonJSConfig(input, output) { delimiters: ['\\b', '\\b(?!(\\.|/))'], preventAssignment: true, }), - babelPlugin(getBabelOptions({ ie: 11 })), + getEsbuild('cjs'), ], } } @@ -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`), ] }