@@ -6,32 +6,37 @@ describe('ssr: scopeId', () => {
6
6
test ( 'basic' , ( ) => {
7
7
expect (
8
8
compile ( `<div><span>hello</span></div>` , {
9
- scopeId
9
+ scopeId,
10
+ mode : 'module'
10
11
} ) . code
11
12
) . toMatchInlineSnapshot ( `
12
- "const { ssrRenderAttrs: _ssrRenderAttrs } = require(\\"@vue/server-renderer\\")
13
+ "import { withScopeId as _withScopeId } from \\"vue\\"
14
+ import { ssrRenderAttrs as _ssrRenderAttrs } from \\"@vue/server-renderer\\"
15
+ const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\")
13
16
14
- return function ssrRender(_ctx, _push, _parent, _attrs) {
17
+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
15
18
_push(\`<div\${_ssrRenderAttrs(_attrs)} data-v-xxxxxxx><span data-v-xxxxxxx>hello</span></div>\`)
16
- }"
19
+ }) "
17
20
` )
18
21
} )
19
22
20
23
test ( 'inside slots (only text)' , ( ) => {
21
24
// should have no branching inside slot
22
25
expect (
23
26
compile ( `<foo>foo</foo>` , {
24
- scopeId
27
+ scopeId,
28
+ mode : 'module'
25
29
} ) . code
26
30
) . toMatchInlineSnapshot ( `
27
- "const { resolveComponent: _resolveComponent, withCtx: _withCtx, createTextVNode: _createTextVNode } = require(\\"vue\\")
28
- const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
31
+ "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createTextVNode as _createTextVNode, withScopeId as _withScopeId } from \\"vue\\"
32
+ import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\"
33
+ const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\")
29
34
30
- return function ssrRender(_ctx, _push, _parent, _attrs) {
35
+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
31
36
const _component_foo = _resolveComponent(\\"foo\\")
32
37
33
38
_push(_ssrRenderComponent(_component_foo, _attrs, {
34
- default: _withCtx ((_, _push, _parent, _scopeId) => {
39
+ default: _withId ((_, _push, _parent, _scopeId) => {
35
40
if (_push) {
36
41
_push(\`foo\`)
37
42
} else {
@@ -42,24 +47,26 @@ describe('ssr: scopeId', () => {
42
47
}),
43
48
_: 1
44
49
}, _parent))
45
- }"
50
+ }) "
46
51
` )
47
52
} )
48
53
49
54
test ( 'inside slots (with elements)' , ( ) => {
50
55
expect (
51
56
compile ( `<foo><span>hello</span></foo>` , {
52
- scopeId
57
+ scopeId,
58
+ mode : 'module'
53
59
} ) . code
54
60
) . toMatchInlineSnapshot ( `
55
- "const { resolveComponent: _resolveComponent, withCtx: _withCtx, createVNode: _createVNode } = require(\\"vue\\")
56
- const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
61
+ "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, withScopeId as _withScopeId } from \\"vue\\"
62
+ import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\"
63
+ const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\")
57
64
58
- return function ssrRender(_ctx, _push, _parent, _attrs) {
65
+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
59
66
const _component_foo = _resolveComponent(\\"foo\\")
60
67
61
68
_push(_ssrRenderComponent(_component_foo, _attrs, {
62
- default: _withCtx ((_, _push, _parent, _scopeId) => {
69
+ default: _withId ((_, _push, _parent, _scopeId) => {
63
70
if (_push) {
64
71
_push(\`<span data-v-xxxxxxx\${_scopeId}>hello</span>\`)
65
72
} else {
@@ -70,29 +77,31 @@ describe('ssr: scopeId', () => {
70
77
}),
71
78
_: 1
72
79
}, _parent))
73
- }"
80
+ }) "
74
81
` )
75
82
} )
76
83
77
84
test ( 'nested slots' , ( ) => {
78
85
expect (
79
86
compile ( `<foo><span>hello</span><bar><span/></bar></foo>` , {
80
- scopeId
87
+ scopeId,
88
+ mode : 'module'
81
89
} ) . code
82
90
) . toMatchInlineSnapshot ( `
83
- "const { resolveComponent: _resolveComponent, withCtx: _withCtx, createVNode: _createVNode } = require(\\"vue\\")
84
- const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
91
+ "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, withScopeId as _withScopeId } from \\"vue\\"
92
+ import { ssrRenderComponent as _ssrRenderComponent } from \\"@vue/server-renderer\\"
93
+ const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxx\\")
85
94
86
- return function ssrRender(_ctx, _push, _parent, _attrs) {
95
+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
87
96
const _component_foo = _resolveComponent(\\"foo\\")
88
97
const _component_bar = _resolveComponent(\\"bar\\")
89
98
90
99
_push(_ssrRenderComponent(_component_foo, _attrs, {
91
- default: _withCtx ((_, _push, _parent, _scopeId) => {
100
+ default: _withId ((_, _push, _parent, _scopeId) => {
92
101
if (_push) {
93
102
_push(\`<span data-v-xxxxxxx\${_scopeId}>hello</span>\`)
94
103
_push(_ssrRenderComponent(_component_bar, null, {
95
- default: _withCtx ((_, _push, _parent, _scopeId) => {
104
+ default: _withId ((_, _push, _parent, _scopeId) => {
96
105
if (_push) {
97
106
_push(\`<span data-v-xxxxxxx\${_scopeId}></span>\`)
98
107
} else {
@@ -107,7 +116,7 @@ describe('ssr: scopeId', () => {
107
116
return [
108
117
_createVNode(\\"span\\", null, \\"hello\\"),
109
118
_createVNode(_component_bar, null, {
110
- default: _withCtx (() => [
119
+ default: _withId (() => [
111
120
_createVNode(\\"span\\")
112
121
]),
113
122
_: 1
@@ -117,7 +126,7 @@ describe('ssr: scopeId', () => {
117
126
}),
118
127
_: 1
119
128
}, _parent))
120
- }"
129
+ }) "
121
130
` )
122
131
} )
123
132
} )
0 commit comments