Skip to content

Commit

Permalink
build!: switch from rollup to esbuild to build
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cchanxzy committed Nov 9, 2024
1 parent 0279041 commit 75ef80c
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 257 deletions.
31 changes: 31 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as esbuild from 'esbuild';
import { glob } from 'glob';

const files = glob.sync('src/**/*.{ts,tsx}', {
ignore: ['src/examples/**', 'src/**/__tests__/**', 'src/**/*.spec.{ts,tsx}'],
});

// Exports ESM
esbuild.build({
entryPoints: files,
outdir: 'dist/esm',
bundle: false,
sourcemap: true,
splitting: true,
platform: 'browser',
format: 'esm',
target: ['esnext'],
minify: true,
});

// Exports CJS
esbuild.build({
entryPoints: files,
outdir: 'dist/cjs',
bundle: false,
sourcemap: true,
platform: 'browser',
format: 'cjs',
target: ['esnext'],
minify: true,
});
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
"name": "react-currency-input-field",
"version": "3.8.0",
"description": "React <input/> component for formatting currency and numbers.",
"sideEffects": false,
"files": [
"dist/**/*",
"src/**/*"
],
"main": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"homepage": "https://github.com/cchanxzy/react-currency-input-field",
"scripts": {
"build": "rm -rf dist && tsc && rollup -c",
"build:types": "tsc",
"build:js": "node esbuild.mjs",
"build": "rm -rf dist && pnpm build:js && pnpm build:types",
"start": "parcel src/examples/index.html --open",
"test": "LANG=en_GB jest",
"test-ci": "LANG=en_GB.UTF-8 cross-env NODE_ICU_DATA=node_modules/full-icu jest",
Expand Down Expand Up @@ -48,9 +58,6 @@
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@playwright/test": "^1.40.1",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-typescript": "^8.2.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@testing-library/dom": "^9.3.3",
Expand All @@ -65,13 +72,15 @@
"@typescript-eslint/parser": "^6.16.0",
"codecov": "^3.8.3",
"cross-env": "^7.0.3",
"esbuild": "^0.24.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"full-icu": "^1.3.4",
"gh-pages": "^5.0.0",
"glob": "^11.0.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
Expand All @@ -81,7 +90,6 @@
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "18.2.0",
"rollup": "^2.52.7",
"semantic-release": "^24.2.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
Expand Down
Loading

0 comments on commit 75ef80c

Please sign in to comment.