Skip to content

Commit 5a75ed1

Browse files
committed
feat(builder): generate type definition files on build time
1 parent e3adf24 commit 5a75ed1

File tree

4 files changed

+613
-1
lines changed

4 files changed

+613
-1
lines changed

internal/builder/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"devDependencies": {
1616
"@types/node": "^24",
1717
"typescript": "*",
18-
"vite": "*"
18+
"vite": "*",
19+
"vite-plugin-dts": "^4.5.4"
1920
}
2021
}

internal/builder/src/configs/vite.prod.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { resolve } from 'node:path';
22
import { existsSync } from 'node:fs';
33
import type { InlineConfig } from 'vite';
4+
import dts from 'vite-plugin-dts';
45

56
function resolveEntry(cwd: string): string {
67
const tsEntry = resolve(cwd, 'src', 'index.ts');
@@ -14,6 +15,12 @@ export function createViteProdConfig(): InlineConfig {
1415
const cwd = process.cwd();
1516

1617
return {
18+
plugins: [
19+
dts({
20+
insertTypesEntry: true,
21+
exclude: ['**/*.spec.ts', '**/*.test.ts'],
22+
}),
23+
],
1724
build: {
1825
lib: {
1926
entry: resolveEntry(cwd),
@@ -23,6 +30,9 @@ export function createViteProdConfig(): InlineConfig {
2330
outDir: resolve(cwd, 'dist'),
2431
sourcemap: true,
2532
minify: 'esbuild',
33+
rollupOptions: {
34+
external: [/\.spec\.ts$/, /\.test\.ts$/],
35+
},
2636
},
2737
};
2838
}

packages/stream/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"type": "module",
77
"main": "./dist/index.cjs",
88
"module": "./dist/index.js",
9+
"types": "./dist/index.d.ts",
910
"exports": {
1011
".": {
12+
"types": "./dist/index.d.ts",
1113
"import": "./dist/index.js",
1214
"require": "./dist/index.cjs"
1315
},
1416
"./operators": {
17+
"types": "./dist/operators.d.ts",
1518
"import": "./dist/operators.js",
1619
"require": "./dist/operators.cjs"
1720
}

0 commit comments

Comments
 (0)