Skip to content

Commit 211793d

Browse files
committed
fix(compiler-sfc): avoid script setup marker showing up in devtools
1 parent 2e10261 commit 211793d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/compiler-sfc/src/compileScript.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -1121,15 +1121,22 @@ export function compileScript(
11211121
allBindings[key] = true
11221122
}
11231123
}
1124-
const keys = Object.keys(allBindings)
1125-
if (!__TEST__) {
1126-
// the `__isScriptSetup: true` flag is used by componentPublicInstance
1127-
// proxy to allow properties that start with $ or _
1128-
keys.push(`__isScriptSetup: true`)
1129-
}
1130-
returned = `{ ${keys.join(', ')} }`
1124+
returned = `{ ${Object.keys(allBindings).join(', ')} }`
1125+
}
1126+
1127+
if (!options.inlineTemplate && !__TEST__) {
1128+
// in non-inline mode, the `__isScriptSetup: true` flag is used by
1129+
// componentPublicInstance proxy to allow properties that start with $ or _
1130+
s.appendRight(
1131+
endOffset,
1132+
`\nconst __returned__ = ${returned}\n` +
1133+
`Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })\n` +
1134+
`return __returned__` +
1135+
`\n}\n\n`
1136+
)
1137+
} else {
1138+
s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)
11311139
}
1132-
s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)
11331140

11341141
// 11. finalize default export
11351142
let runtimeOptions = ``

0 commit comments

Comments
 (0)