File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 38
38
"packageManager" :
" [email protected] " ,
39
39
"dependencies" : {
40
40
"chalk" : " ^4.1.0" ,
41
+ "hash-sum" : " ^2.0.0" ,
41
42
"watchpack" : " ^2.4.0"
42
43
},
43
44
"peerDependencies" : {
57
58
"@intlify/vue-i18n-loader" : " ^3.0.0" ,
58
59
"@types/cssesc" : " ^3.0.2" ,
59
60
"@types/estree" : " ^0.0.45" ,
61
+ "@types/hash-sum" : " ^1.0.2" ,
60
62
"@types/jest" : " ^26.0.13" ,
61
63
"@types/jsdom" : " ^16.2.13" ,
62
64
"@types/mini-css-extract-plugin" : " ^0.9.1" ,
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ import type {
11
11
SFCTemplateCompileOptions ,
12
12
SFCScriptCompileOptions ,
13
13
} from 'vue/compiler-sfc'
14
+
15
+ import hashSum from 'hash-sum'
16
+
14
17
import { selectBlock } from './select'
15
18
import { genHotReloadCode } from './hotReload'
16
19
import { genCSSModulesCode } from './cssModules'
@@ -363,6 +366,18 @@ export default function loader(
363
366
. join ( `\n` ) + `\n`
364
367
}
365
368
369
+ if ( isServer ) {
370
+ code += `\nimport { useSSRContext } from 'vue'\n`
371
+ code += `const _setup = script.setup\n`
372
+ ; ( code += `script.setup = (props, ctx) => {` ) ,
373
+ ( code += ` const ssrContext = useSSRContext()` ) ,
374
+ ( code += ` ;(ssrContext._registeredComponents || (ssrContext._registeredComponents = new Set())).add(${ JSON . stringify (
375
+ hashSum ( loaderContext . request )
376
+ ) } );`)
377
+ code += ` return _setup ? _setup(props, ctx) : undefined`
378
+ code += `}\n`
379
+ }
380
+
366
381
// finalize
367
382
if ( ! propsToAttach . length ) {
368
383
code += `\n\nconst __exports__ = script;`
You can’t perform that action at this time.
0 commit comments