Skip to content

Commit efce3c0

Browse files
committed
chore: make the @packages/types 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 ba709b7 commit efce3c0

File tree

6 files changed

+42
-19
lines changed

6 files changed

+42
-19
lines changed

packages/types/.gitignore

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

packages/types/index.js

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

packages/types/package.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,39 @@
22
"name": "@packages/types",
33
"version": "0.0.0-development",
44
"private": true,
5-
"main": "index.js",
6-
"browser": "src/index.ts",
5+
"main": "cjs/index.js",
6+
"browser": "esm/index.js",
77
"scripts": {
8-
"build-prod": "tsc || echo 'built, with type errors'",
9-
"check-ts": "tsc --noEmit",
10-
"clean": "rimraf --glob 'src/*.js' 'src/**/*.js'",
8+
"build": "yarn build:esm && yarn build:cjs",
9+
"build-prod": "yarn build",
10+
"build:cjs": "rimraf cjs && tsc -p tsconfig.cjs.json",
11+
"build:esm": "rimraf esm && tsc -p tsconfig.esm.json",
12+
"check-ts": "tsc -p tsconfig.cjs.json --noEmit",
13+
"clean": "rimraf cjs esm",
1114
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .",
1215
"test": "vitest run"
1316
},
1417
"dependencies": {
1518
"semver": "^7.7.1"
1619
},
1720
"devDependencies": {
21+
"@packages/root": "0.0.0-development",
1822
"@types/node": "22.18.0",
1923
"axios": "^1.8.3",
2024
"better-sqlite3": "11.10.0",
2125
"devtools-protocol": "0.0.1459876",
2226
"express": "4.21.0",
27+
"rimraf": "^6.0.1",
2328
"socket.io": "4.0.1",
2429
"typescript": "~5.4.5",
2530
"vitest": "^3.2.4"
2631
},
2732
"files": [
28-
"src/*"
33+
"cjs/*",
34+
"esm/*"
2935
],
3036
"types": "src/index.ts",
37+
"module": "esm/index.js",
3138
"workspaces": {
3239
"nohoist": [
3340
"devtools-protocol"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"extends": "../ts/tsconfig.json",
32
"include": [
43
"src/*.ts",
54
"src/**/*.ts"
@@ -11,13 +10,14 @@
1110
"noUnusedLocals": false,
1211
"noUnusedParameters": false,
1312
"allowJs": true,
14-
"types": [],
1513
"noUncheckedIndexedAccess": true,
1614
"ignoreDeprecations": "5.0",
17-
/*
18-
* TODO: remove importsNotUsedAsValues after typescript 5.5 and up as it will no longer work. If we want the same behavior
19-
* as importsNotUsedAsValues, we need to use "verbatimModuleSyntax", which will require this package to be an ES Module.
20-
*/
2115
"importsNotUsedAsValues": "error",
22-
},
16+
"skipLibCheck": true,
17+
"resolveJsonModule": true,
18+
"types": [
19+
"mocha",
20+
"node"
21+
]
22+
}
2323
}

packages/types/tsconfig.cjs.json

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": "./src",
5+
"outDir": "./cjs",
6+
"target": "ES2022",
7+
"module": "CommonJS",
8+
"moduleResolution": "node"
9+
}
10+
}

packages/types/tsconfig.esm.json

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": "./src",
5+
"outDir": "./esm",
6+
"target": "ES2022",
7+
"module": "ES2022",
8+
"moduleResolution": "node"
9+
}
10+
}

0 commit comments

Comments
 (0)