Skip to content

Commit 31a9c90

Browse files
committed
wip: remove debugger, define vue flags in plugin
1 parent 50ef75e commit 31a9c90

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

packages/plugin-vue/src/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
6767

6868
handleHotUpdate,
6969

70+
config(config) {
71+
// provide default values for vue runtime esm defines
72+
config.define = {
73+
__VUE_OPTIONS_API__: true,
74+
__VUE_PROD_DEVTOOLS__: false,
75+
...config.define
76+
}
77+
},
78+
7079
configResolved(config) {
7180
options = {
7281
...options,

packages/plugin-vue/src/main.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ export async function transformMain(
9090
output.push('export default _sfc_main')
9191

9292
// HMR
93-
if (devServer) {
94-
// check if the template is the only thing that changed
95-
if (prevDescriptor && isOnlyTemplateChanged(prevDescriptor, descriptor)) {
96-
output.push(`export const _rerender_only = true`)
97-
}
93+
if (devServer && !isProduction) {
9894
output.push(`_sfc_main.__hmrId = ${JSON.stringify(descriptor.id)}`)
9995
output.push(
10096
`__VUE_HMR_RUNTIME__.createRecord(_sfc_main.__hmrId, _sfc_main)`
10197
)
98+
// check if the template is the only thing that changed
99+
if (prevDescriptor && isOnlyTemplateChanged(prevDescriptor, descriptor)) {
100+
output.push(`export const _rerender_only = true`)
101+
}
102102
output.push(
103103
`import.meta.hot.accept(({ default: updated, _rerender_only }) => {`,
104104
` if (_rerender_only) {`,

packages/plugin-vue/src/template.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function transformTemplateAsModule(
1919
const result = compile(code, descriptor, options, pluginContext)
2020

2121
let returnCode = result.code
22-
if (options.devServer) {
22+
if (options.devServer && !options.isProduction) {
2323
returnCode += `\nimport.meta.hot.accept(({ render }) => {
2424
__VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, render)
2525
})`

0 commit comments

Comments
 (0)