Skip to content

Commit

Permalink
refactor: reuse script ast for rewriting default (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Mar 28, 2023
1 parent ca139d8 commit 9d84656
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,16 @@ async function genScriptCode(
? (['typescript'] as const)
: (['typescript', 'decorators-legacy'] as const)
: []
scriptCode = options.compiler.rewriteDefault(
script.content,
'_sfc_main',
[...defaultPlugins, ...userPlugins],
)
const as = '_sfc_main'
if (options.compiler.rewriteDefaultAST && script.scriptAst) {
options.compiler.rewriteDefaultAST(script.scriptAst, script.s, as)
} else {
scriptCode = options.compiler.rewriteDefault(
script.content,
'_sfc_main',
[...defaultPlugins, ...userPlugins],
)
}
map = script.map
} else {
if (script.src) {
Expand Down

0 comments on commit 9d84656

Please sign in to comment.