fix(compiler-sfc): fix wrong scopeId for nested <script setup> components

This commit is contained in:
Evan You
2021-04-01 18:11:04 -04:00
parent 8c57b9131d
commit 7f7dcc9f7d
3 changed files with 53 additions and 7 deletions

View File

@@ -231,12 +231,12 @@ export function generate(
? args.map(arg => `${arg}: any`).join(',')
: args.join(', ')
if (genScopeId) {
if (isSetupInlined) {
push(`${PURE_ANNOTATION}${WITH_ID}(`)
} else {
push(`const ${functionName} = ${PURE_ANNOTATION}${WITH_ID}(`)
}
if (genScopeId && !isSetupInlined) {
// root-level _withId wrapping is no longer necessary after 3.0.8 and is
// a noop, it's only kept so that code compiled with 3.0.8+ can run with
// runtime < 3.0.8.
// TODO: consider removing in 3.1
push(`const ${functionName} = ${PURE_ANNOTATION}${WITH_ID}(`)
}
if (isSetupInlined || genScopeId) {
push(`(${signature}) => {`)
@@ -303,7 +303,7 @@ export function generate(
deindent()
push(`}`)
if (genScopeId) {
if (genScopeId && !isSetupInlined) {
push(`)`)
}
@@ -438,6 +438,7 @@ function genModulePreamble(
// we technically don't need this anymore since `withCtx` already sets the
// correct scopeId, but this is necessary for backwards compat
// TODO: consider removing in 3.1
if (genScopeId) {
push(
`const ${WITH_ID} = ${PURE_ANNOTATION}${helper(