Skip to content

Commit 065a158

Browse files
committed
chore(build:dts): fix building dts on Windows
1 parent 6171856 commit 065a158

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as fs from 'node:fs/promises'
2+
3+
async function patchVueRouterDts() {
4+
const content = await fs.readFile('./src/globalExtensions.ts', {
5+
encoding: 'utf-8',
6+
})
7+
const moduleAugmentationIdx = content.indexOf('/**')
8+
if (moduleAugmentationIdx === -1) {
9+
throw new Error(
10+
'Cannot find module augmentation in globalExtensions.ts, first /** comment is expected to start module augmentation'
11+
)
12+
}
13+
const targetContent = await fs.readFile('./dist/vue-router.d.ts', {
14+
encoding: 'utf-8',
15+
})
16+
await fs.writeFile(
17+
'./dist/vue-router.d.ts',
18+
`${targetContent}
19+
${content.slice(moduleAugmentationIdx)} `,
20+
{ encoding: 'utf8' }
21+
)
22+
}
23+
24+
patchVueRouterDts()

packages/router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"dev": "vitest --ui",
9292
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
9393
"build": "rimraf dist && rollup -c rollup.config.mjs",
94-
"build:dts": "api-extractor run --local --verbose && tail -n +10 src/globalExtensions.ts >> dist/vue-router.d.ts",
94+
"build:dts": "api-extractor run --local --verbose && node ./add-dts-module-augmentation.js",
9595
"build:playground": "vue-tsc --noEmit && vite build --config playground/vite.config.ts",
9696
"build:e2e": "vue-tsc --noEmit && vite build --config e2e/vite.config.mjs",
9797
"build:size": "pnpm run build && rollup -c size-checks/rollup.config.mjs",

0 commit comments

Comments
 (0)