fix(sfc): allow variables that start with _ or $ in <script setup>

This commit is contained in:
Evan You
2021-06-23 10:13:23 -04:00
parent 63e9e2e9aa
commit 0b8b576428
4 changed files with 65 additions and 70 deletions

View File

@@ -33,27 +33,6 @@ return { x }
export const n = 1"
`;
exports[`SFC compile <script setup> <template inherit-attrs="false"> 1`] = `
"
const __default__ = {}
__default__.inheritAttrs = false
export default __default__"
`;
exports[`SFC compile <script setup> <template inherit-attrs="false"> 2`] = `
"export default {
expose: [],
inheritAttrs: false,
setup(__props) {
const a = 1
return { a }
}
}"
`;
exports[`SFC compile <script setup> defineEmit() (deprecated) 1`] = `
"export default {
expose: [],

View File

@@ -946,7 +946,9 @@ export function compileScript(
allBindings[key] = true
}
}
returned = `{ ${Object.keys(allBindings).join(', ')} }`
returned = `{ ${Object.keys(allBindings).join(', ')}${
__TEST__ ? `` : `, __isScriptSetup: true`
} }`
}
s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)