Skip to content

Commit

Permalink
fix: vite 4.3 compatibility, close #968
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 20, 2023
1 parent ca3777c commit 6305560
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/slidev/node/plugins/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ ${title}
const imports = [
'import { inject as vueInject } from "vue"',
`import InjectedLayout from "${toAtFS(layouts[layoutName])}"`,
'import { injectionSlidevContext } from "@slidev/client/constants"',
'import { injectionSlidevContext } from "@slidev/client/constants.ts"',
`const frontmatter = ${JSON.stringify(frontmatter)}`,
'const $slidev = vueInject(injectionSlidevContext)',
]
Expand All @@ -376,7 +376,7 @@ ${title}
return code // Assume that the context is already imported and used
const imports = [
'import { inject as vueInject } from "vue"',
'import { injectionSlidevContext } from "@slidev/client/constants"',
'import { injectionSlidevContext } from "@slidev/client/constants.ts"',
'const $slidev = vueInject(injectionSlidevContext)',
]
const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/)
Expand All @@ -394,7 +394,7 @@ ${title}
component = component.slice(0, component.indexOf('</script>'))

const scriptIndex = (matchScript.index || 0) + matchScript[0].length
const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants"\n'
const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n'
code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`

let injectIndex = exportIndex + provideImport.length
Expand Down

0 comments on commit 6305560

Please sign in to comment.