Skip to content

Commit

Permalink
fix(mp): script + v-bind (#3887)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Sep 27, 2022
1 parent 21b5ed8 commit 766d08e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/uni-mp-vite/src/plugin/polyfill.ts
Expand Up @@ -7,14 +7,16 @@ import {
SFCParseResult,
SFCScriptBlock,
SFCScriptCompileOptions,
SFCTemplateCompileOptions,
} from '@vue/compiler-sfc'

export const rewriteCompileScriptOnce = once(rewriteCompileScript)
export const rewriteCompilerSfcParseOnce = once(rewriteCompilerSfcParse)

function rewriteCompileScript() {
const compiler = require(resolveBuiltIn('@vue/compiler-sfc'))
const { compileScript } = compiler
const { compileScript, compileTemplate } = compiler
// script-setup + v-bind
compiler.compileScript = (
sfc: SFCDescriptor,
options: SFCScriptCompileOptions
Expand All @@ -25,6 +27,14 @@ function rewriteCompileScript() {
}
return compileScript(sfc, options)
}
// script + v-bind
compiler.compileTemplate = (options: SFCTemplateCompileOptions) => {
if (options?.compilerOptions) {
;(options.compilerOptions as any).bindingCssVars =
options.ssrCssVars || []
}
return compileTemplate(options)
}
}

/**
Expand Down

0 comments on commit 766d08e

Please sign in to comment.