Skip to content

Commit f5c5595

Browse files
authoredMay 22, 2023
fix: dts reg error (#381)
1 parent 79fbed3 commit f5c5595

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed
 

‎src/core/ctx.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ${dts}`.trim()}\n`
112112
originalDTS[key] = currentDTS[key]
113113
})
114114
const dtsList = Object.keys(originalDTS).sort().map(k => ` ${k}: ${originalDTS[k]}`)
115-
return currentContent.replace(dtsReg, `declare global {\n${dtsList.join('\n')}\n}`)
115+
return currentContent.replace(dtsReg, () => `declare global {\n${dtsList.join('\n')}\n}`)
116116
}
117117

118118
return currentContent
@@ -166,13 +166,13 @@ ${dts}`.trim()}\n`
166166
async function scanDirs() {
167167
if (dirs?.length) {
168168
await unimport.modifyDynamicImports(async (imports) => {
169-
const exports = await scanDirExports(dirs, {
169+
const exports_ = await scanDirExports(dirs, {
170170
filePatterns: ['*.{tsx,jsx,ts,js,mjs,cjs,mts,cts}'],
171171
}) as ImportExtended[]
172-
exports.forEach(i => i.__source = 'dir')
172+
exports_.forEach(i => i.__source = 'dir')
173173
return modifyDefaultExportsAlias([
174174
...imports.filter((i: ImportExtended) => i.__source !== 'dir'),
175-
...exports,
175+
...exports_,
176176
], options)
177177
})
178178
}

‎test/dts.increase.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ it('dts', async () => {
1414
const dtsContent = await ctx.generateDTS(dts)
1515
expect(dtsContent).toContain('AAA')
1616
expect(dtsContent).toContain('BBB')
17+
expect(dtsContent).toContain('$$')
1718
})

‎test/tmp/dts.increase.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// Generated by unplugin-auto-import
55
export {}
66
declare global {
7+
const $$: typeof import('vue/macros')['$$']
8+
const $: typeof import('vue/macros')['$']
79
const AAA: typeof import('xxx/es')['AAA']
810
const BBB: typeof import('xxx/es')['BBB']
911
}

0 commit comments

Comments
 (0)
Please sign in to comment.