File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ export async function transformMain(
95
95
`_sfc_main.__scopeId = ${ JSON . stringify ( `data-v-${ descriptor . id } ` ) } `
96
96
)
97
97
}
98
- if ( devServer ) {
98
+ if ( devServer && ! isProduction ) {
99
99
// expose filename during serve for devtools to pickup
100
100
output . push ( `_sfc_main.__file = ${ JSON . stringify ( filename ) } ` )
101
101
}
@@ -122,6 +122,21 @@ export async function transformMain(
122
122
)
123
123
}
124
124
125
+ // SSR module registration by wrapping user setup
126
+ if ( ssr ) {
127
+ output . push (
128
+ `import { useSSRContext } from 'vue'` ,
129
+ `const _sfc_setup = _sfc_main.setup` ,
130
+ `_sfc_main.setup = (props, ctx) => {` ,
131
+ ` const ssrContext = useSSRContext()` ,
132
+ ` ;(ssrContext.modules || (ssrContext.modules = new Set())).add(${ JSON . stringify (
133
+ filename
134
+ ) } )`,
135
+ ` return _sfc_setup ? _sfc_setup(props, ctx) : undefined` ,
136
+ `}`
137
+ )
138
+ }
139
+
125
140
// if the template is inlined into the main module (indicated by the presence
126
141
// of templateMap, we need to concatenate the two source maps.
127
142
let resolvedMap = map
You can’t perform that action at this time.
0 commit comments