Skip to content

Commit 195d766

Browse files
committed
fix: build with dts
1 parent e9cff2a commit 195d766

File tree

48 files changed

+225
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+225
-218
lines changed

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,8 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
114114
const { emitEsm = true, emitCjs = true, splitDevProd = false } = options;
115115

116116
const variantSpecificConfigs = [];
117-
118-
// Determine the correct types output directory based on hasBundles
119-
// hasBundles packages output to build/npm/, so types go to build/npm/types
120-
// Regular packages output to build/, so types go to build/types
121-
const typesOutDir = baseConfig.output.dir === 'build/npm' ? 'build/npm/types' : 'build/types';
122-
123117
const dtsPlugin = dts({
124118
tsconfig: path.resolve(process.cwd(), './tsconfig.types.json'),
125-
compilerOptions: {
126-
outDir: typesOutDir,
127-
},
128119
});
129120

130121
if (emitCjs) {
@@ -143,10 +134,11 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
143134
if (splitDevProd) {
144135
// Add dts plugin to the dev ESM build (only needs to run once)
145136
variantSpecificConfigs.push({
137+
plugins: [dtsPlugin],
146138
output: {
147139
format: 'esm',
148140
dir: path.join(baseConfig.output.dir, 'esm/dev'),
149-
plugins: [makePackageNodeEsm(), dtsPlugin],
141+
plugins: [makePackageNodeEsm()],
150142
},
151143
});
152144
variantSpecificConfigs.push({
@@ -158,10 +150,11 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
158150
});
159151
} else {
160152
variantSpecificConfigs.push({
153+
plugins: [dtsPlugin],
161154
output: {
162155
format: 'esm',
163156
dir: path.join(baseConfig.output.dir, 'esm'),
164-
plugins: [makePackageNodeEsm(), dtsPlugin],
157+
plugins: [makePackageNodeEsm()],
165158
},
166159
});
167160
}

nx.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@
4141
},
4242
"build:types": {
4343
"inputs": ["production", "^production"],
44-
"dependsOn": ["^build:types"],
45-
"outputs": [
46-
"{projectRoot}/build/types",
47-
"{projectRoot}/build/types-ts3.8",
48-
"{projectRoot}/build/npm/types",
49-
"{projectRoot}/build/npm/types-ts3.8"
50-
]
44+
"dependsOn": ["^build:types", "build:transpile"],
45+
"outputs": ["{projectRoot}/build/types-ts3.8", "{projectRoot}/build/npm/types-ts3.8"]
5146
},
5247
"lint": {
5348
"inputs": ["default"],

packages/astro/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
"main": "build/cjs/index.client.js",
2424
"module": "build/esm/index.server.js",
2525
"browser": "build/esm/index.client.js",
26-
"types": "build/types/index.types.d.ts",
26+
"types": "build/esm/index.types.d.ts",
2727
"exports": {
2828
".": {
29-
"types": "./build/types/index.types.d.ts",
29+
"types": "./build/esm/index.types.d.ts",
3030
"node": "./build/esm/index.server.js",
3131
"browser": "./build/esm/index.client.js",
3232
"import": "./build/esm/index.client.js",
3333
"require": "./build/cjs/index.server.js"
3434
},
3535
"./middleware": {
36-
"types": "./build/types/integration/middleware/index.types.d.ts",
36+
"types": "./build/esm/integration/middleware/index.types.d.ts",
3737
"node": "./build/esm/integration/middleware/index.js",
3838
"import": "./build/esm/integration/middleware/index.js",
3939
"require": "./build/cjs/integration/middleware/index.js"
@@ -66,7 +66,7 @@
6666
"vite": "^5.4.11"
6767
},
6868
"scripts": {
69-
"build": "run-p build:transpile build:types",
69+
"build": "run-s build:transpile build:types",
7070
"build:dev": "yarn build",
7171
"build:transpile": "rolldown -c rollup.npm.config.mjs",
7272
"build:types": "echo 'Types generated by dts plugin'",

packages/astro/rollup.npm.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sent
22

33
const variants = makeNPMConfigVariants(
44
makeBaseNPMConfig({
5-
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/integration/middleware/index.ts'],
5+
entrypoints: [
6+
'src/index.server.ts',
7+
'src/index.client.ts',
8+
'src/index.types.ts',
9+
'src/integration/middleware/index.ts',
10+
],
611
packageSpecificConfig: {
712
output: {
813
dynamicImportInCjs: true,

packages/aws-serverless/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
],
1717
"main": "build/npm/cjs/index.js",
1818
"module": "build/npm/esm/index.js",
19-
"types": "build/npm/types/index.d.ts",
19+
"types": "build/npm/esm/index.d.ts",
2020
"exports": {
2121
"./package.json": "./package.json",
2222
".": {
2323
"import": {
24-
"types": "./build/npm/types/index.d.ts",
24+
"types": "./build/npm/esm/index.d.ts",
2525
"default": "./build/npm/esm/index.js"
2626
},
2727
"require": {
28-
"types": "./build/npm/types/index.d.ts",
28+
"types": "./build/npm/esm/index.d.ts",
2929
"default": "./build/npm/cjs/index.js"
3030
}
3131
},
@@ -56,7 +56,7 @@
5656
},
5757
"typesVersions": {
5858
"<5.0": {
59-
"build/npm/types/index.d.ts": [
59+
"build/npm/esm/index.d.ts": [
6060
"build/npm/types-ts3.8/index.d.ts"
6161
]
6262
}
@@ -79,11 +79,11 @@
7979
"@vercel/nft": "^0.29.4"
8080
},
8181
"scripts": {
82-
"build": "run-p build:transpile build:types",
82+
"build": "run-s build:transpile build:types",
8383
"build:layer": "rimraf build/aws && rolldown -c rollup.lambda-extension.config.mjs && yarn ts-node scripts/buildLambdaLayer.ts",
8484
"build:dev": "run-p build:transpile build:types",
8585
"build:transpile": "rolldown -c rollup.npm.config.mjs && yarn build:layer",
86-
"build:types": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8",
86+
"build:types": "yarn downlevel-dts build/npm/esm build/npm/types-ts3.8 --to ts3.8",
8787
"build:watch": "run-p build:transpile:watch build:types:watch",
8888
"build:dev:watch": "yarn build:watch",
8989
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",

packages/browser-utils/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
],
1515
"main": "build/cjs/index.js",
1616
"module": "build/esm/index.js",
17-
"types": "build/types/index.d.ts",
17+
"types": "build/esm/index.d.ts",
1818
"exports": {
1919
"./package.json": "./package.json",
2020
".": {
2121
"import": {
22-
"types": "./build/types/index.d.ts",
22+
"types": "./build/esm/index.d.ts",
2323
"default": "./build/esm/index.js"
2424
},
2525
"require": {
26-
"types": "./build/types/index.d.ts",
26+
"types": "./build/esm/index.d.ts",
2727
"default": "./build/cjs/index.js"
2828
}
2929
}
3030
},
3131
"typesVersions": {
3232
"<5.0": {
33-
"build/types/index.d.ts": [
33+
"build/esm/index.d.ts": [
3434
"build/types-ts3.8/index.d.ts"
3535
]
3636
}
@@ -42,10 +42,10 @@
4242
"@sentry/core": "10.29.0"
4343
},
4444
"scripts": {
45-
"build": "run-p build:transpile build:types",
45+
"build": "run-s build:transpile build:types",
4646
"build:dev": "yarn build",
4747
"build:transpile": "rolldown -c rollup.npm.config.mjs",
48-
"build:types": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
48+
"build:types": "yarn downlevel-dts build/esm build/types-ts3.8 --to ts3.8",
4949
"build:watch": "run-p build:transpile:watch build:types:watch",
5050
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
5151
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",

packages/browser/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
],
1515
"main": "build/npm/cjs/prod/index.js",
1616
"module": "build/npm/esm/prod/index.js",
17-
"types": "build/npm/types/index.d.ts",
17+
"types": "build/npm/esm/dev/index.d.ts",
1818
"exports": {
1919
"./package.json": "./package.json",
2020
".": {
21-
"types": "./build/npm/types/index.d.ts",
21+
"types": "./build/npm/esm/dev/index.d.ts",
2222
"development": {
2323
"import": "./build/npm/esm/dev/index.js",
2424
"require": "./build/npm/cjs/dev/index.js"
@@ -35,7 +35,7 @@
3535
},
3636
"typesVersions": {
3737
"<5.0": {
38-
"build/npm/types/index.d.ts": [
38+
"build/npm/esm/dev/index.d.ts": [
3939
"build/npm/types-ts3.8/index.d.ts"
4040
]
4141
}
@@ -55,11 +55,11 @@
5555
"fake-indexeddb": "^6.2.4"
5656
},
5757
"scripts": {
58-
"build": "run-p build:transpile build:bundle build:types",
58+
"build": "run-s build:transpile build:types build:bundle",
5959
"build:dev": "run-p build:transpile build:types",
6060
"build:bundle": "rolldown -c rollup.bundle.config.mjs",
6161
"build:transpile": "rolldown -c rollup.npm.config.mjs",
62-
"build:types": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8",
62+
"build:types": "yarn downlevel-dts build/npm/esm/dev build/npm/types-ts3.8 --to ts3.8",
6363
"build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch",
6464
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
6565
"build:bundle:watch": "rolldown -c rollup.bundle.config.mjs --watch",

packages/bun/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
],
1515
"main": "build/cjs/index.js",
1616
"module": "build/esm/index.js",
17-
"types": "build/types/index.d.ts",
17+
"types": "build/esm/index.d.ts",
1818
"exports": {
1919
"./package.json": "./package.json",
2020
".": {
2121
"import": {
22-
"types": "./build/types/index.d.ts",
22+
"types": "./build/esm/index.d.ts",
2323
"default": "./build/esm/index.js"
2424
},
2525
"require": {
26-
"types": "./build/types/index.d.ts",
26+
"types": "./build/esm/index.d.ts",
2727
"default": "./build/cjs/index.js"
2828
}
2929
}
3030
},
3131
"typesVersions": {
3232
"<5.0": {
33-
"build/types/index.d.ts": [
33+
"build/esm/index.d.ts": [
3434
"build/types-ts3.8/index.d.ts"
3535
]
3636
}
@@ -46,10 +46,10 @@
4646
"bun-types": "^1.2.9"
4747
},
4848
"scripts": {
49-
"build": "run-p build:transpile build:types",
49+
"build": "run-s build:transpile build:types",
5050
"build:dev": "yarn build",
5151
"build:transpile": "rolldown -c rollup.npm.config.mjs",
52-
"build:types": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
52+
"build:types": "yarn downlevel-dts build/esm build/types-ts3.8 --to ts3.8",
5353
"build:watch": "run-p build:transpile:watch build:types:watch",
5454
"build:dev:watch": "yarn build:watch",
5555
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",

packages/cloudflare/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414
],
1515
"main": "build/cjs/index.js",
1616
"module": "build/esm/index.js",
17-
"types": "build/types/index.d.ts",
17+
"types": "build/esm/index.d.ts",
1818
"exports": {
1919
"./package.json": "./package.json",
2020
".": {
2121
"import": {
22-
"types": "./build/types/index.d.ts",
22+
"types": "./build/esm/index.d.ts",
2323
"default": "./build/esm/index.js"
2424
},
2525
"require": {
26-
"types": "./build/types/index.d.ts",
26+
"types": "./build/esm/index.d.ts",
2727
"default": "./build/cjs/index.js"
2828
}
2929
},
3030
"./request": {
3131
"import": {
32-
"types": "./build/types/request.d.ts",
32+
"types": "./build/esm/request.d.ts",
3333
"default": "./build/esm/request.js"
3434
},
3535
"require": {
36-
"types": "./build/types/request.d.ts",
36+
"types": "./build/esm/request.d.ts",
3737
"default": "./build/cjs/request.js"
3838
}
3939
}
4040
},
4141
"typesVersions": {
4242
"<5.0": {
43-
"build/types/index.d.ts": [
43+
"build/esm/index.d.ts": [
4444
"build/types-ts3.8/index.d.ts"
4545
]
4646
}
@@ -66,10 +66,10 @@
6666
"wrangler": "4.22.0"
6767
},
6868
"scripts": {
69-
"build": "run-p build:transpile build:types",
69+
"build": "run-s build:transpile build:types",
7070
"build:dev": "yarn build",
7171
"build:transpile": "rolldown -c rollup.npm.config.mjs",
72-
"build:types": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
72+
"build:types": "yarn downlevel-dts build/esm build/types-ts3.8 --to ts3.8",
7373
"build:watch": "run-p build:transpile:watch build:types:watch",
7474
"build:dev:watch": "yarn build:watch",
7575
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",

packages/core/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
],
1515
"main": "build/cjs/index.js",
1616
"module": "build/esm/index.js",
17-
"types": "build/types/index.d.ts",
17+
"types": "build/esm/index.d.ts",
1818
"exports": {
1919
"./package.json": "./package.json",
2020
".": {
2121
"import": {
22-
"types": "./build/types/index.d.ts",
22+
"types": "./build/esm/index.d.ts",
2323
"default": "./build/esm/index.js"
2424
},
2525
"require": {
26-
"types": "./build/types/index.d.ts",
26+
"types": "./build/esm/index.d.ts",
2727
"default": "./build/cjs/index.js"
2828
}
2929
}
3030
},
3131
"typesVersions": {
3232
"<5.0": {
33-
"build/types/index.d.ts": [
33+
"build/esm/index.d.ts": [
3434
"build/types-ts3.8/index.d.ts"
3535
]
3636
}
@@ -39,10 +39,10 @@
3939
"access": "public"
4040
},
4141
"scripts": {
42-
"build": "run-p build:transpile build:types",
42+
"build": "run-s build:transpile build:types",
4343
"build:dev": "yarn build",
4444
"build:transpile": "rolldown -c rollup.npm.config.mjs",
45-
"build:types": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
45+
"build:types": "yarn downlevel-dts build/esm build/types-ts3.8 --to ts3.8",
4646
"build:watch": "run-p build:transpile:watch build:types:watch",
4747
"build:dev:watch": "yarn build:watch",
4848
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",

0 commit comments

Comments
 (0)