File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 3838 "packageManager": "
[email protected] ",
3939 "dependencies": {
4040 "chalk": "^4.1.0",
41+ "hash-sum": "^2.0.0",
4142 "watchpack": "^2.4.0"
4243 },
4344 "peerDependencies": {
5758 "@intlify/vue-i18n-loader": "^3.0.0",
5859 "@types/cssesc": "^3.0.2",
5960 "@types/estree": "^0.0.45",
61+ "@types/hash-sum": "^1.0.2",
6062 "@types/jest": "^26.0.13",
6163 "@types/jsdom": "^16.2.13",
6264 "@types/mini-css-extract-plugin": "^0.9.1",
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ import type {
1111 SFCTemplateCompileOptions,
1212 SFCScriptCompileOptions,
1313} from 'vue/compiler-sfc'
14+
15+ import hashSum from 'hash-sum'
16+
1417import { selectBlock } from './select'
1518import { genHotReloadCode } from './hotReload'
1619import { genCSSModulesCode } from './cssModules'
@@ -363,6 +366,18 @@ export default function loader(
363366 .join(`\n`) + `\n`
364367 }
365368
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+
366381 // finalize
367382 if (!propsToAttach.length) {
368383 code += `\n\nconst __exports__ = script;`
You can’t perform that action at this time.
0 commit comments