Skip to content

Commit 3ad87dc

Browse files
committed
fix: try fix dts imports
1 parent 3cad247 commit 3ad87dc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

build.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ export default defineBuildConfig({
1414
hooks: {
1515
'build:done': async () => {
1616
for (const file of await glob('./dist/*.d.{cts,mts,ts}')) {
17-
const content = await fs.readFile(file, 'utf-8')
17+
let content = await fs.readFile(file, 'utf-8')
1818
// Override `options` type on dist dts only
19-
const newContent = content.replace(
19+
let newContent = content.replace(
2020
'class MarkdownItAsync extends MarkdownIt {',
2121
'class MarkdownItAsync extends MarkdownIt {\n // @ts-ignore\n options: MarkdownItAsyncOptions',
2222
)
23+
if (content === newContent)
24+
throw new Error(`Failed to replace for ${file}`)
25+
content = newContent
26+
newContent = content.replace(
27+
'import MarkdownIt',
28+
'import type MarkdownIt',
29+
)
2330
if (content === newContent)
2431
throw new Error(`Failed to replace for ${file}`)
2532
await fs.writeFile(file, newContent, 'utf-8')

0 commit comments

Comments
 (0)