@@ -6,32 +6,37 @@ describe('ssr: scopeId', () => {
66 test ( 'basic' , ( ) => {
77 expect (
88 compile ( `<div><span>hello</span></div>` , {
9- scopeId
9+ scopeId,
10+ mode : 'module'
1011 } ) . code
1112 ) . 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\\")
1316
14- return function ssrRender(_ctx, _push, _parent, _attrs) {
17+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
1518 _push(\`<div\${_ssrRenderAttrs(_attrs)} data-v-xxxxxxx><span data-v-xxxxxxx>hello</span></div>\`)
16- }"
19+ }) "
1720 ` )
1821 } )
1922
2023 test ( 'inside slots (only text)' , ( ) => {
2124 // should have no branching inside slot
2225 expect (
2326 compile ( `<foo>foo</foo>` , {
24- scopeId
27+ scopeId,
28+ mode : 'module'
2529 } ) . code
2630 ) . 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\\")
2934
30- return function ssrRender(_ctx, _push, _parent, _attrs) {
35+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
3136 const _component_foo = _resolveComponent(\\"foo\\")
3237
3338 _push(_ssrRenderComponent(_component_foo, _attrs, {
34- default: _withCtx ((_, _push, _parent, _scopeId) => {
39+ default: _withId ((_, _push, _parent, _scopeId) => {
3540 if (_push) {
3641 _push(\`foo\`)
3742 } else {
@@ -42,24 +47,26 @@ describe('ssr: scopeId', () => {
4247 }),
4348 _: 1
4449 }, _parent))
45- }"
50+ }) "
4651 ` )
4752 } )
4853
4954 test ( 'inside slots (with elements)' , ( ) => {
5055 expect (
5156 compile ( `<foo><span>hello</span></foo>` , {
52- scopeId
57+ scopeId,
58+ mode : 'module'
5359 } ) . code
5460 ) . 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\\")
5764
58- return function ssrRender(_ctx, _push, _parent, _attrs) {
65+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
5966 const _component_foo = _resolveComponent(\\"foo\\")
6067
6168 _push(_ssrRenderComponent(_component_foo, _attrs, {
62- default: _withCtx ((_, _push, _parent, _scopeId) => {
69+ default: _withId ((_, _push, _parent, _scopeId) => {
6370 if (_push) {
6471 _push(\`<span data-v-xxxxxxx\${_scopeId}>hello</span>\`)
6572 } else {
@@ -70,29 +77,31 @@ describe('ssr: scopeId', () => {
7077 }),
7178 _: 1
7279 }, _parent))
73- }"
80+ }) "
7481 ` )
7582 } )
7683
7784 test ( 'nested slots' , ( ) => {
7885 expect (
7986 compile ( `<foo><span>hello</span><bar><span/></bar></foo>` , {
80- scopeId
87+ scopeId,
88+ mode : 'module'
8189 } ) . code
8290 ) . 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\\")
8594
86- return function ssrRender(_ctx, _push, _parent, _attrs) {
95+ export const ssrRender = /*#__PURE__*/_withId( function ssrRender(_ctx, _push, _parent, _attrs) {
8796 const _component_foo = _resolveComponent(\\"foo\\")
8897 const _component_bar = _resolveComponent(\\"bar\\")
8998
9099 _push(_ssrRenderComponent(_component_foo, _attrs, {
91- default: _withCtx ((_, _push, _parent, _scopeId) => {
100+ default: _withId ((_, _push, _parent, _scopeId) => {
92101 if (_push) {
93102 _push(\`<span data-v-xxxxxxx\${_scopeId}>hello</span>\`)
94103 _push(_ssrRenderComponent(_component_bar, null, {
95- default: _withCtx ((_, _push, _parent, _scopeId) => {
104+ default: _withId ((_, _push, _parent, _scopeId) => {
96105 if (_push) {
97106 _push(\`<span data-v-xxxxxxx\${_scopeId}></span>\`)
98107 } else {
@@ -107,7 +116,7 @@ describe('ssr: scopeId', () => {
107116 return [
108117 _createVNode(\\"span\\", null, \\"hello\\"),
109118 _createVNode(_component_bar, null, {
110- default: _withCtx (() => [
119+ default: _withId (() => [
111120 _createVNode(\\"span\\")
112121 ]),
113122 _: 1
@@ -117,7 +126,7 @@ describe('ssr: scopeId', () => {
117126 }),
118127 _: 1
119128 }, _parent))
120- }"
129+ }) "
121130 ` )
122131 } )
123132} )
0 commit comments