Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions packages/test/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,23 @@ async function copyVitestPackages() {
totalCopied += copied;
console.log(` -> ${copied} files`);

// Copy root type definition files if they exist
// These include context.d.ts (browser providers), matchers.d.ts (expect.element),
// jest-dom.d.ts (matchers), aria-role.d.ts (ARIARole type used by context.d.ts)
// TODO: consider dynamically scanning root .d.ts files instead of hardcoding,
// since upstream @vitest/browser may add new .d.ts files in future versions.
const rootDtsFiles = ['context.d.ts', 'matchers.d.ts', 'jest-dom.d.ts', 'aria-role.d.ts'];
for (const dtsFile of rootDtsFiles) {
const rootDts = resolve(projectDir, `node_modules/${pkg}/${dtsFile}`);
// Copy root .d.ts files from @vitest/browser package directory.
// These are type definitions that live at the package root (not in dist/),
// e.g. context.d.ts, matchers.d.ts, aria-role.d.ts, utils.d.ts.
// Dynamically scan instead of hardcoding to handle future upstream additions.
if (pkg === '@vitest/browser') {
const pkgRoot = resolve(projectDir, `node_modules/${pkg}`);
try {
await stat(rootDts);
await copyFile(rootDts, join(destPkgDir, dtsFile));
console.log(` + copied ${dtsFile}`);
totalCopied++;
const pkgEntries = await readdir(pkgRoot);
for (const entry of pkgEntries) {
if (entry.endsWith('.d.ts')) {
await copyFile(join(pkgRoot, entry), join(destPkgDir, entry));
console.log(` + copied ${entry}`);
totalCopied++;
}
}
} catch {
// File doesn't exist, skip
// Package root not readable, skip
}
}
}
Expand Down
Loading