Skip to content

Commit fb2411f

Browse files
author
Hardik_B
committed
[UPDATED] to use esbuild
1 parent b47cf2b commit fb2411f

6 files changed

Lines changed: 280 additions & 21 deletions

File tree

build.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const esbuild = require("esbuild");
3+
4+
const sharedConfig = {
5+
bundle: true,
6+
entryPoints: ["./src/index.tsx"],
7+
// Treat all dependencies in package.json as externals to keep bundle size to a minimum
8+
logLevel: "info",
9+
minify: true,
10+
sourcemap: true,
11+
};
12+
13+
esbuild.build({
14+
...sharedConfig,
15+
format: "esm",
16+
outfile: "./dist/index.esm.js",
17+
target: ["esnext", "node14.0.0"],
18+
});
19+
20+
esbuild.build({
21+
...sharedConfig,
22+
format: "cjs",
23+
outfile: "./dist/index.cjs.js",
24+
target: ["esnext", "node14.0.0"],
25+
});

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
{
22
"name": "@dx-kit/react-conditional-match",
3-
"version": "1.1.0",
3+
"version": "2.0.0",
44
"description": "A flexible and reusable React component for conditionally rendering child elements. The component supports options for handling multiple matching children and custom fallbacks, and is lightweight and easy to use. This component can help simplify complex rendering logic in your React application and remove the need for ternary statements and if else blocks.",
5-
"main": "./dist/cjs/index.js",
6-
"module": "./dist/esm/index.js",
7-
"types": "./dist/esm/index.d.ts",
5+
"main": "./dist/index.esm.js",
6+
"module": "./dist/index.cjs.js",
7+
"types": "./dist/index.d.ts",
88
"publishConfig": {
99
"access": "public"
1010
},
1111
"scripts": {
12-
"build": "pnpm build:esm && pnpm build:cjs",
13-
"build:esm": "tsc",
14-
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
12+
"build": "pnpm clean && node build.js && tsc --emitDeclarationOnly --outDir dist",
13+
"clean": "rm -rf dist",
1514
"lint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\"",
1615
"lint-fix": "eslint --fix \"{**/*,*}.{js,ts,jsx,tsx}\"",
1716
"test": "vitest",
@@ -51,12 +50,14 @@
5150
"@testing-library/react": "^14.0.0",
5251
"@testing-library/user-event": "^14.4.3",
5352
"@types/jest": "^29.4.0",
53+
"@types/node": "^18.14.2",
5454
"@types/react": "^18.0.28",
5555
"@types/react-dom": "^18.0.11",
5656
"@types/testing-library__jest-dom": "^5.14.5",
5757
"@typescript-eslint/eslint-plugin": "^5.53.0",
5858
"@typescript-eslint/parser": "^5.53.0",
5959
"@vitejs/plugin-react": "^3.1.0",
60+
"esbuild": "^0.17.10",
6061
"eslint": "^8.34.0",
6162
"eslint-config-prettier": "^8.6.0",
6263
"eslint-plugin-prettier": "^4.2.1",

0 commit comments

Comments
 (0)