Skip to content

Commit a73604c

Browse files
committed
fix(test): bundle the deps .d.ts file
1 parent 1c97751 commit a73604c

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

packages/test/build.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { fileURLToPath } from 'node:url';
5252

5353
import { parseSync } from 'oxc-parser';
5454
import { build } from 'rolldown';
55+
import { dts } from 'rolldown-plugin-dts';
5556

5657
import pkg from './package.json' with { type: 'json' };
5758

@@ -659,6 +660,36 @@ async function bundleLeafDeps(leafDeps: Set<string>): Promise<Map<string, string
659660
logLevel: 'warn',
660661
});
661662

663+
const dtsInput = { ...input }
664+
665+
for (const name of Object.keys(dtsInput)) {
666+
const vendorDtsPath = join(vendorDir, `vendor_${name}.d.ts`)
667+
dtsInput[name] = vendorDtsPath
668+
await writeFile(vendorDtsPath, `export * from '${name}';`, 'utf-8')
669+
}
670+
671+
await build({
672+
input: dtsInput,
673+
output: {
674+
dir: vendorDir,
675+
format: 'esm',
676+
entryFileNames: '[name].mts',
677+
},
678+
plugins: [
679+
dts({
680+
dtsInput: true,
681+
oxc: true,
682+
resolve: true,
683+
emitDtsOnly: true,
684+
tsconfig: false
685+
})
686+
]
687+
})
688+
689+
for (const p of Object.values(dtsInput)) {
690+
await rm(p)
691+
}
692+
662693
// Register all specifiers
663694
for (const dep of leafDeps) {
664695
const safeName = safeFileName(dep);

packages/test/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@
289289
"@types/chai": "^5.2.2",
290290
"@voidzero-dev/vite-plus-core": "workspace:*",
291291
"es-module-lexer": "^1.7.0",
292-
"expect-type": "^1.2.2",
293292
"obug": "^2.1.1",
294293
"picomatch": "^4.0.3",
295294
"pixelmatch": "^7.1.0",
@@ -317,10 +316,12 @@
317316
"@vitest/utils": "4.0.16",
318317
"chai": "^6.2.1",
319318
"estree-walker": "^3.0.3",
319+
"expect-type": "^1.2.2",
320320
"magic-string": "^0.30.21",
321321
"oxc-parser": "catalog:",
322322
"pathe": "^2.0.3",
323323
"rolldown": "workspace:*",
324+
"rolldown-plugin-dts": "catalog:",
324325
"tinyrainbow": "^3.0.3",
325326
"vitest-dev": "^4.0.16",
326327
"why-is-node-running": "^2.3.0"

packages/test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"experimentalDecorators": true,
1313
"customConditions": ["dev"]
1414
},
15+
"include": ["build.ts", "package.json"],
1516
"exclude": ["node_modules", "dist/**/*"]
1617
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)