Skip to content

Commit cf1f220

Browse files
committed
chore: make the @packages/resolve-dist an independent bundle without needed ts-node to register entrypoint. Both ESM and CJS distributions are built and types are used as source to be compatible with older styles of commonjs bundling. Types are not shipped with the package.
1 parent 9baab51 commit cf1f220

File tree

8 files changed

+46
-28
lines changed

8 files changed

+46
-28
lines changed

guides/esm-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
- [x] packages/packherd-require ✅ **COMPLETED**
5555
- [ ] packages/proxy **PARTIAL** - entry point is JS
5656
- [x] packages/reporter ✅ **COMPLETED**
57-
- [ ] packages/resolve-dist **PARTIAL** - entry point is JS
57+
- [x] packages/resolve-dist **COMPLETED**
5858
- [ ] packages/rewriter **PARTIAL** - entry point is JS
5959
- [ ] packages/root
6060
- [x] packages/runner ✅ **COMPLETED**

packages/resolve-dist/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
lib/**/*.js
1+
esm/
2+
cjs/

packages/resolve-dist/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/resolve-dist/package.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,28 @@
22
"name": "@packages/resolve-dist",
33
"version": "0.0.0-development",
44
"private": true,
5-
"main": "index.js",
5+
"main": "cjs/index.js",
66
"scripts": {
7-
"build-prod": "tsc --project .",
8-
"check-ts": "tsc --noEmit && yarn -s tslint",
9-
"clean": "rimraf --glob 'lib/**/*.js'",
7+
"build": "yarn build:cjs && yarn build:esm",
8+
"build-prod": "yarn build",
9+
"build:cjs": "rimraf cjs && tsc -p tsconfig.cjs.json",
10+
"build:esm": "rimraf esm && tsc -p tsconfig.esm.json",
11+
"check-ts": "tsc -p tsconfig.cjs.json --noEmit && yarn -s tslint -p tsconfig.cjs.json",
12+
"clean": "rimraf cjs esm",
1013
"clean-deps": "rimraf node_modules",
1114
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .",
1215
"tslint": "tslint --config ../ts/tslint.json --project ."
1316
},
1417
"dependencies": {
15-
"fs-extra": "9.1.0"
16-
},
17-
"devDependencies": {
18-
"@packages/ts": "0.0.0-development"
18+
"fs-extra": "9.1.0",
19+
"rimraf": "^6.0.1",
20+
"typescript": "~5.4.5"
1921
},
2022
"files": [
21-
"lib"
23+
"cjs/*",
24+
"esm/*"
2225
],
2326
"types": "./lib/index.ts",
27+
"module": "esm/index.js",
2428
"nx": {}
2529
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"include": [
3+
"lib/**/*.ts"
4+
],
5+
"compilerOptions": {
6+
"allowJs": false,
7+
"esModuleInterop": true,
8+
"skipLibCheck": true
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"rootDir": "./lib",
5+
"outDir": "./cjs",
6+
"target": "ES2022",
7+
"module": "CommonJS",
8+
"moduleResolution": "node"
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"rootDir": "./lib",
5+
"outDir": "./esm",
6+
"target": "ES2022",
7+
"module": "ES2022",
8+
"moduleResolution": "node"
9+
}
10+
}

packages/resolve-dist/tsconfig.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)