Skip to content

Commit 75ef80c

Browse files
committed
build!: switch from rollup to esbuild to build
BREAKING CHANGE: UMD is no longer exported. In order to reduce complexity and simplify the build process, we have switched from rollup to esbuild and only export CJS and ESM versions. This means that the UMD build is no longer exported.
1 parent 0279041 commit 75ef80c

10 files changed

+507
-257
lines changed

esbuild.mjs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as esbuild from 'esbuild';
2+
import { glob } from 'glob';
3+
4+
const files = glob.sync('src/**/*.{ts,tsx}', {
5+
ignore: ['src/examples/**', 'src/**/__tests__/**', 'src/**/*.spec.{ts,tsx}'],
6+
});
7+
8+
// Exports ESM
9+
esbuild.build({
10+
entryPoints: files,
11+
outdir: 'dist/esm',
12+
bundle: false,
13+
sourcemap: true,
14+
splitting: true,
15+
platform: 'browser',
16+
format: 'esm',
17+
target: ['esnext'],
18+
minify: true,
19+
});
20+
21+
// Exports CJS
22+
esbuild.build({
23+
entryPoints: files,
24+
outdir: 'dist/cjs',
25+
bundle: false,
26+
sourcemap: true,
27+
platform: 'browser',
28+
format: 'cjs',
29+
target: ['esnext'],
30+
minify: true,
31+
});

package.json

+14-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22
"name": "react-currency-input-field",
33
"version": "3.8.0",
44
"description": "React <input/> component for formatting currency and numbers.",
5+
"sideEffects": false,
56
"files": [
67
"dist/**/*",
78
"src/**/*"
89
],
9-
"main": "dist/index.js",
10+
"exports": {
11+
".": {
12+
"types": "./dist/index.d.ts",
13+
"import": "./dist/esm/index.js",
14+
"require": "./dist/cjs/index.js"
15+
}
16+
},
17+
"main": "dist/index.cjs.js",
1018
"module": "dist/index.esm.js",
1119
"types": "dist/index.d.ts",
1220
"homepage": "https://github.com/cchanxzy/react-currency-input-field",
1321
"scripts": {
14-
"build": "rm -rf dist && tsc && rollup -c",
22+
"build:types": "tsc",
23+
"build:js": "node esbuild.mjs",
24+
"build": "rm -rf dist && pnpm build:js && pnpm build:types",
1525
"start": "parcel src/examples/index.html --open",
1626
"test": "LANG=en_GB jest",
1727
"test-ci": "LANG=en_GB.UTF-8 cross-env NODE_ICU_DATA=node_modules/full-icu jest",
@@ -48,9 +58,6 @@
4858
"@commitlint/cli": "^18.4.3",
4959
"@commitlint/config-conventional": "^18.4.3",
5060
"@playwright/test": "^1.40.1",
51-
"@rollup/plugin-commonjs": "^19.0.0",
52-
"@rollup/plugin-node-resolve": "^13.0.0",
53-
"@rollup/plugin-typescript": "^8.2.1",
5461
"@semantic-release/changelog": "^6.0.3",
5562
"@semantic-release/git": "^10.0.1",
5663
"@testing-library/dom": "^9.3.3",
@@ -65,13 +72,15 @@
6572
"@typescript-eslint/parser": "^6.16.0",
6673
"codecov": "^3.8.3",
6774
"cross-env": "^7.0.3",
75+
"esbuild": "^0.24.0",
6876
"eslint": "^8.56.0",
6977
"eslint-config-prettier": "^9.1.0",
7078
"eslint-plugin-prettier": "^5.1.2",
7179
"eslint-plugin-react": "^7.33.2",
7280
"eslint-plugin-react-hooks": "^4.6.0",
7381
"full-icu": "^1.3.4",
7482
"gh-pages": "^5.0.0",
83+
"glob": "^11.0.0",
7584
"husky": "^8.0.3",
7685
"jest": "^29.7.0",
7786
"jest-environment-jsdom": "^29.7.0",
@@ -81,7 +90,6 @@
8190
"process": "^0.11.10",
8291
"react": "^18.2.0",
8392
"react-dom": "18.2.0",
84-
"rollup": "^2.52.7",
8593
"semantic-release": "^24.2.0",
8694
"ts-jest": "^29.1.1",
8795
"ts-node": "^10.9.2",

0 commit comments

Comments
 (0)