Skip to content

Commit

Permalink
fix(compiler-sfc): avoid script setup marker showing up in devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 28, 2021
1 parent 2e10261 commit 211793d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,15 +1121,22 @@ export function compileScript(
allBindings[key] = true
}
}
const keys = Object.keys(allBindings)
if (!__TEST__) {
// the `__isScriptSetup: true` flag is used by componentPublicInstance
// proxy to allow properties that start with $ or _
keys.push(`__isScriptSetup: true`)
}
returned = `{ ${keys.join(', ')} }`
returned = `{ ${Object.keys(allBindings).join(', ')} }`
}

if (!options.inlineTemplate && !__TEST__) {
// in non-inline mode, the `__isScriptSetup: true` flag is used by
// componentPublicInstance proxy to allow properties that start with $ or _
s.appendRight(
endOffset,
`\nconst __returned__ = ${returned}\n` +
`Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })\n` +
`return __returned__` +
`\n}\n\n`
)
} else {
s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)
}
s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)

// 11. finalize default export
let runtimeOptions = ``
Expand Down

0 comments on commit 211793d

Please sign in to comment.