Skip to content

Commit 05da6af

Browse files
feat: modernize to dual module system with separate folder structure
- Implement separate dist folders (cjs/, esm/, umd/) for clean module separation - Add UMD build support for direct web usage - Update tsconfig inheritance pattern with format-specific configs - Switch from ts-node to tsx for improved testing performance - Update package.json exports for seamless dual module importing - Remove old mixed build artifacts
1 parent 580bd55 commit 05da6af

14 files changed

+390
-138
lines changed

dist/arrayInit.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/arrayInit.mjs.map

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

dist/cjs/arrayInit.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/arrayInit.mjs renamed to dist/esm/arrayInit.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/arrayInit.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/umd/arrayInit.js

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/umd/arrayInit.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"author": "electricessence",
66
"license": "MIT",
77
"types": "dist/arrayInit.d.ts",
8-
"main": "dist/arrayInit.js",
9-
"module": "dist/arrayInit.mjs",
8+
"main": "dist/cjs/arrayInit.js",
9+
"module": "dist/esm/arrayInit.js",
10+
"umd:main": "dist/umd/arrayInit.js",
1011
"exports": {
1112
".": {
12-
"import": "./dist/arrayInit.mjs",
13-
"require": "./dist/arrayInit.js",
13+
"import": "./dist/esm/arrayInit.js",
14+
"require": "./dist/cjs/arrayInit.js",
1415
"types": "./dist/arrayInit.d.ts"
1516
}
1617
},
@@ -22,17 +23,20 @@
2223
"array initialization"
2324
],
2425
"scripts": {
25-
"build:cjs": "rimraf dist && tsc && copyfiles -u 1 src/**/*.d.ts dist",
26-
"build:esm": "rimraf temp-esm && tsc -p tsconfig.esm.json --outDir temp-esm && node -e \"require('fs').readdirSync('temp-esm').forEach(f=>{if(f.endsWith('.js')){require('fs').copyFileSync('temp-esm/'+f,'dist/'+f.replace('.js','.mjs'));} if(f.endsWith('.js.map')){require('fs').copyFileSync('temp-esm/'+f,'dist/'+f.replace('.js.map','.mjs.map'));}})\" && rimraf temp-esm",
27-
"build": "concurrently pnpm:build:cjs pnpm:build:esm",
28-
"bump": "pnpm precommit && npm version patch",
26+
"clean": "rimraf dist",
27+
"build:cjs": "tsc -p tsconfig.cjs.json",
28+
"build:esm": "tsc -p tsconfig.esm.json",
29+
"build:umd": "tsc -p tsconfig.umd.json",
30+
"build:types": "tsc -p tsconfig.types.json",
31+
"build": "pnpm i && pnpm run clean && concurrently \"pnpm:build:*\"",
32+
"bump": "pnpm run precommit && pnpm version patch",
2933
"docs": "rimraf docs && typedoc --options typedoc.json --readme none",
3034
"lint": "eslint src/**/*.ts",
31-
"precommit": "concurrently pnpm:lint pnpm:test && pnpm run build && pnpm run validate && git status -s",
32-
"prepublishOnly": "pnpm run build && pnpm run validate && pnpm test",
33-
"preversion": "concurrently pnpm:lint pnpm:test",
35+
"precommit": "pnpm i && pnpm run build && pnpm run lint && pnpm run validate && pnpm run test && git status -s",
36+
"prepublishOnly": "pnpm run build && pnpm run validate && pnpm run test",
37+
"preversion": "pnpm run lint && pnpm run test",
3438
"postversion": "git push && git push --tags && pnpm run docs && git add -A && git commit -m \"Updated docs.\" docs && git push",
35-
"test": "mocha -r ts-node/register tests/**/*.ts",
39+
"test": "tsx node_modules/mocha/bin/_mocha tests/**/*.ts",
3640
"validate": "node ./.build/validate-package.js"
3741
},
3842
"repository": {
@@ -54,7 +58,8 @@
5458
"eslint": "^9.33.0",
5559
"mocha": "^11.7.1",
5660
"rimraf": "^6.0.1",
57-
"ts-node": "^10.9.2",
61+
"tsx": "^4.20.4",
62+
"tsx": "^4.20.4",
5863
"typedoc": "^0.28.10",
5964
"typescript": "^5.9.2",
6065
"typescript-eslint": "^8.39.1"

0 commit comments

Comments
 (0)