Skip to content

Commit

Permalink
fix: try fix dts imports
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 22, 2025
1 parent 3cad247 commit 3ad87dc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ export default defineBuildConfig({
hooks: {
'build:done': async () => {
for (const file of await glob('./dist/*.d.{cts,mts,ts}')) {
const content = await fs.readFile(file, 'utf-8')
let content = await fs.readFile(file, 'utf-8')
// Override `options` type on dist dts only
const newContent = content.replace(
let newContent = content.replace(
'class MarkdownItAsync extends MarkdownIt {',
'class MarkdownItAsync extends MarkdownIt {\n // @ts-ignore\n options: MarkdownItAsyncOptions',
)
if (content === newContent)
throw new Error(`Failed to replace for ${file}`)
content = newContent
newContent = content.replace(
'import MarkdownIt',
'import type MarkdownIt',
)
if (content === newContent)
throw new Error(`Failed to replace for ${file}`)
await fs.writeFile(file, newContent, 'utf-8')
Expand Down

0 comments on commit 3ad87dc

Please sign in to comment.