@@ -67,7 +67,7 @@ test('export function declaration', async () => {
67
67
await ssrTransformSimpleCode ( `export function foo() {}` ) ,
68
68
) . toMatchInlineSnapshot (
69
69
`
70
- "Object.defineProperty(__vite_ssr_exports__, "foo", { enumerable: true, configurable: true, get() { try { return foo } catch {} } });
70
+ "__vite_ssr_exportName__( "foo", () => { try { return foo } catch {} });
71
71
function foo() {}"
72
72
` ,
73
73
)
@@ -78,7 +78,7 @@ test('export class declaration', async () => {
78
78
await ssrTransformSimpleCode ( `export class foo {}` ) ,
79
79
) . toMatchInlineSnapshot (
80
80
`
81
- "Object.defineProperty(__vite_ssr_exports__, "foo", { enumerable: true, configurable: true, get() { try { return foo } catch {} } });
81
+ "__vite_ssr_exportName__( "foo", () => { try { return foo } catch {} });
82
82
class foo {}"
83
83
` ,
84
84
)
@@ -89,8 +89,8 @@ test('export var declaration', async () => {
89
89
await ssrTransformSimpleCode ( `export const a = 1, b = 2` ) ,
90
90
) . toMatchInlineSnapshot (
91
91
`
92
- "Object.defineProperty(__vite_ssr_exports__, "a", { enumerable: true, configurable: true, get() { try { return a } catch {} } });
93
- Object.defineProperty(__vite_ssr_exports__, "b", { enumerable: true, configurable: true, get() { try { return b } catch {} } });
92
+ "__vite_ssr_exportName__( "a", () => { try { return a } catch {} });
93
+ __vite_ssr_exportName__( "b", () => { try { return b } catch {} });
94
94
const a = 1, b = 2"
95
95
` ,
96
96
)
@@ -101,8 +101,8 @@ test('export named', async () => {
101
101
await ssrTransformSimpleCode ( `const a = 1, b = 2; export { a, b as c }` ) ,
102
102
) . toMatchInlineSnapshot (
103
103
`
104
- "Object.defineProperty(__vite_ssr_exports__, "a", { enumerable: true, configurable: true, get() { try { return a } catch {} } });
105
- Object.defineProperty(__vite_ssr_exports__, "c", { enumerable: true, configurable: true, get() { try { return b } catch {} } });
104
+ "__vite_ssr_exportName__( "a", () => { try { return a } catch {} });
105
+ __vite_ssr_exportName__( "c", () => { try { return b } catch {} });
106
106
const a = 1, b = 2; "
107
107
` ,
108
108
)
@@ -113,8 +113,8 @@ test('export named from', async () => {
113
113
await ssrTransformSimpleCode ( `export { ref, computed as c } from 'vue'` ) ,
114
114
) . toMatchInlineSnapshot (
115
115
`
116
- "Object.defineProperty(__vite_ssr_exports__, "ref", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_0__.ref } catch {} } });
117
- Object.defineProperty(__vite_ssr_exports__, "c", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_0__.computed } catch {} } });
116
+ "__vite_ssr_exportName__( "ref", () => { try { return __vite_ssr_import_0__.ref } catch {} });
117
+ __vite_ssr_exportName__( "c", () => { try { return __vite_ssr_import_0__.computed } catch {} });
118
118
const __vite_ssr_import_0__ = await __vite_ssr_import__("vue", {"importedNames":["ref","computed"]});
119
119
"
120
120
` ,
@@ -128,7 +128,7 @@ test('named exports of imported binding', async () => {
128
128
) ,
129
129
) . toMatchInlineSnapshot (
130
130
`
131
- "Object.defineProperty(__vite_ssr_exports__, "createApp", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_0__.createApp } catch {} } });
131
+ "__vite_ssr_exportName__( "createApp", () => { try { return __vite_ssr_import_0__.createApp } catch {} });
132
132
const __vite_ssr_import_0__ = await __vite_ssr_import__("vue", {"importedNames":["createApp"]});
133
133
"
134
134
` ,
@@ -155,7 +155,7 @@ test('export * as from', async () => {
155
155
await ssrTransformSimpleCode ( `export * as foo from 'vue'` ) ,
156
156
) . toMatchInlineSnapshot (
157
157
`
158
- "Object.defineProperty(__vite_ssr_exports__, "foo", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_0__ } catch {} } });
158
+ "__vite_ssr_exportName__( "foo", () => { try { return __vite_ssr_import_0__ } catch {} });
159
159
const __vite_ssr_import_0__ = await __vite_ssr_import__("vue");
160
160
"
161
161
` ,
@@ -169,7 +169,7 @@ import * as foo from 'foo'
169
169
export * as foo from 'foo'
170
170
` ) ,
171
171
) . toMatchInlineSnapshot ( `
172
- "Object.defineProperty(__vite_ssr_exports__, "foo", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_1__ } catch {} } });
172
+ "__vite_ssr_exportName__( "foo", () => { try { return __vite_ssr_import_1__ } catch {} });
173
173
const __vite_ssr_import_0__ = await __vite_ssr_import__("foo");
174
174
const __vite_ssr_import_1__ = await __vite_ssr_import__("foo");
175
175
@@ -183,7 +183,7 @@ import { foo } from 'foo'
183
183
export { foo } from 'foo'
184
184
` ) ,
185
185
) . toMatchInlineSnapshot ( `
186
- "Object.defineProperty(__vite_ssr_exports__, "foo", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_1__.foo } catch {} } });
186
+ "__vite_ssr_exportName__( "foo", () => { try { return __vite_ssr_import_1__.foo } catch {} });
187
187
const __vite_ssr_import_0__ = await __vite_ssr_import__("foo", {"importedNames":["foo"]});
188
188
const __vite_ssr_import_1__ = await __vite_ssr_import__("foo", {"importedNames":["foo"]});
189
189
@@ -197,7 +197,7 @@ import { foo } from 'foo'
197
197
export { foo as foo } from 'foo'
198
198
` ) ,
199
199
) . toMatchInlineSnapshot ( `
200
- "Object.defineProperty(__vite_ssr_exports__, "foo", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_1__.foo } catch {} } });
200
+ "__vite_ssr_exportName__( "foo", () => { try { return __vite_ssr_import_1__.foo } catch {} });
201
201
const __vite_ssr_import_0__ = await __vite_ssr_import__("foo", {"importedNames":["foo"]});
202
202
const __vite_ssr_import_1__ = await __vite_ssr_import__("foo", {"importedNames":["foo"]});
203
203
@@ -211,7 +211,7 @@ test('export * as from arbitrary module namespace identifier', async () => {
211
211
await ssrTransformSimpleCode ( `export * as "arbitrary string" from 'vue'` ) ,
212
212
) . toMatchInlineSnapshot (
213
213
`
214
- "Object.defineProperty(__vite_ssr_exports__, "arbitrary string", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_0__ } catch {} } });
214
+ "__vite_ssr_exportName__( "arbitrary string", () => { try { return __vite_ssr_import_0__ } catch {} });
215
215
const __vite_ssr_import_0__ = await __vite_ssr_import__("vue");
216
216
"
217
217
` ,
@@ -225,7 +225,7 @@ test('export as arbitrary module namespace identifier', async () => {
225
225
) ,
226
226
) . toMatchInlineSnapshot (
227
227
`
228
- "Object.defineProperty(__vite_ssr_exports__, "arbitrary string", { enumerable: true, configurable: true, get() { try { return something } catch {} } });
228
+ "__vite_ssr_exportName__( "arbitrary string", () => { try { return something } catch {} });
229
229
const something = "Something";"
230
230
` ,
231
231
)
@@ -238,7 +238,7 @@ test('export as from arbitrary module namespace identifier', async () => {
238
238
) ,
239
239
) . toMatchInlineSnapshot (
240
240
`
241
- "Object.defineProperty(__vite_ssr_exports__, "arbitrary string", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_0__["arbitrary string2"] } catch {} } });
241
+ "__vite_ssr_exportName__( "arbitrary string", () => { try { return __vite_ssr_import_0__["arbitrary string2"] } catch {} });
242
242
const __vite_ssr_import_0__ = await __vite_ssr_import__("vue", {"importedNames":["arbitrary string2"]});
243
243
"
244
244
` ,
@@ -248,7 +248,7 @@ test('export as from arbitrary module namespace identifier', async () => {
248
248
test ( 'export default' , async ( ) => {
249
249
expect ( await ssrTransformSimpleCode ( `export default {}` ) )
250
250
. toMatchInlineSnapshot ( `
251
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return __vite_ssr_export_default__ } catch {} } });
251
+ "__vite_ssr_exportName__( "default", () => { try { return __vite_ssr_export_default__ } catch {} });
252
252
const __vite_ssr_export_default__ = {}"
253
253
` )
254
254
} )
@@ -306,7 +306,7 @@ test('dynamic import', async () => {
306
306
)
307
307
expect ( result ?. code ) . toMatchInlineSnapshot (
308
308
`
309
- "Object.defineProperty(__vite_ssr_exports__, "i", { enumerable: true, configurable: true, get() { try { return i } catch {} } });
309
+ "__vite_ssr_exportName__( "i", () => { try { return i } catch {} });
310
310
const i = () => __vite_ssr_dynamic_import__('./foo')"
311
311
` ,
312
312
)
@@ -506,8 +506,8 @@ test('should declare variable for imported super class', async () => {
506
506
`export class B extends Foo {}` ,
507
507
) ,
508
508
) . toMatchInlineSnapshot ( `
509
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return A } catch {} } });
510
- Object.defineProperty(__vite_ssr_exports__, "B", { enumerable: true, configurable: true, get() { try { return B } catch {} } });
509
+ "__vite_ssr_exportName__( "default", () => { try { return A } catch {} });
510
+ __vite_ssr_exportName__( "B", () => { try { return B } catch {} });
511
511
const __vite_ssr_import_0__ = await __vite_ssr_import__("./dependency", {"importedNames":["Foo"]});
512
512
const Foo = __vite_ssr_import_0__.Foo;
513
513
class A extends Foo {};
@@ -520,14 +520,14 @@ test('should handle default export variants', async () => {
520
520
// default anonymous functions
521
521
expect ( await ssrTransformSimpleCode ( `export default function() {}\n` ) )
522
522
. toMatchInlineSnapshot ( `
523
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return __vite_ssr_export_default__ } catch {} } });
523
+ "__vite_ssr_exportName__( "default", () => { try { return __vite_ssr_export_default__ } catch {} });
524
524
const __vite_ssr_export_default__ = function() {}
525
525
"
526
526
` )
527
527
// default anonymous class
528
528
expect ( await ssrTransformSimpleCode ( `export default class {}\n` ) )
529
529
. toMatchInlineSnapshot ( `
530
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return __vite_ssr_export_default__ } catch {} } });
530
+ "__vite_ssr_exportName__( "default", () => { try { return __vite_ssr_export_default__ } catch {} });
531
531
const __vite_ssr_export_default__ = class {}
532
532
"
533
533
` )
@@ -538,7 +538,7 @@ test('should handle default export variants', async () => {
538
538
`foo.prototype = Object.prototype;` ,
539
539
) ,
540
540
) . toMatchInlineSnapshot ( `
541
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return foo } catch {} } });
541
+ "__vite_ssr_exportName__( "default", () => { try { return foo } catch {} });
542
542
function foo() {};
543
543
foo.prototype = Object.prototype;"
544
544
` )
@@ -548,8 +548,8 @@ test('should handle default export variants', async () => {
548
548
`export default class A {}\n` + `export class B extends A {}` ,
549
549
) ,
550
550
) . toMatchInlineSnapshot ( `
551
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return A } catch {} } });
552
- Object.defineProperty(__vite_ssr_exports__, "B", { enumerable: true, configurable: true, get() { try { return B } catch {} } });
551
+ "__vite_ssr_exportName__( "default", () => { try { return A } catch {} });
552
+ __vite_ssr_exportName__( "B", () => { try { return B } catch {} });
553
553
class A {};
554
554
class B extends A {}"
555
555
` )
@@ -1001,8 +1001,8 @@ export function fn1() {
1001
1001
` ,
1002
1002
) ,
1003
1003
) . toMatchInlineSnapshot ( `
1004
- "Object.defineProperty(__vite_ssr_exports__, "fn1", { enumerable: true, configurable: true, get() { try { return fn1 } catch {} } });
1005
- Object.defineProperty(__vite_ssr_exports__, "fn2", { enumerable: true, configurable: true, get() { try { return fn2 } catch {} } });
1004
+ "__vite_ssr_exportName__( "fn1", () => { try { return fn1 } catch {} });
1005
+ __vite_ssr_exportName__( "fn2", () => { try { return fn2 } catch {} });
1006
1006
1007
1007
function fn1() {
1008
1008
};function fn2() {
@@ -1024,15 +1024,15 @@ export default (function getRandom() {
1024
1024
` . trim ( )
1025
1025
1026
1026
expect ( await ssrTransformSimpleCode ( code ) ) . toMatchInlineSnapshot ( `
1027
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return __vite_ssr_export_default__ } catch {} } });
1027
+ "__vite_ssr_exportName__( "default", () => { try { return __vite_ssr_export_default__ } catch {} });
1028
1028
const __vite_ssr_export_default__ = (function getRandom() {
1029
1029
return Math.random();
1030
1030
});"
1031
1031
` )
1032
1032
1033
1033
expect ( await ssrTransformSimpleCode ( `export default (class A {});` ) )
1034
1034
. toMatchInlineSnapshot ( `
1035
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return __vite_ssr_export_default__ } catch {} } });
1035
+ "__vite_ssr_exportName__( "default", () => { try { return __vite_ssr_export_default__ } catch {} });
1036
1036
const __vite_ssr_export_default__ = (class A {});"
1037
1037
` )
1038
1038
} )
@@ -1110,7 +1110,7 @@ export class Test {
1110
1110
};` . trim ( )
1111
1111
1112
1112
expect ( await ssrTransformSimpleCode ( code ) ) . toMatchInlineSnapshot ( `
1113
- "Object.defineProperty(__vite_ssr_exports__, "Test", { enumerable: true, configurable: true, get() { try { return Test } catch {} } });
1113
+ "__vite_ssr_exportName__( "Test", () => { try { return Test } catch {} });
1114
1114
const __vite_ssr_import_0__ = await __vite_ssr_import__("foobar", {"importedNames":["foo","bar"]});
1115
1115
1116
1116
if (false) {
@@ -1309,8 +1309,8 @@ export * as bar from './bar'
1309
1309
console.log(bar)
1310
1310
` ) ,
1311
1311
) . toMatchInlineSnapshot ( `
1312
- "Object.defineProperty(__vite_ssr_exports__, "default", { enumerable: true, configurable: true, get() { try { return __vite_ssr_export_default__ } catch {} } });
1313
- Object.defineProperty(__vite_ssr_exports__, "bar", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_1__ } catch {} } });
1312
+ "__vite_ssr_exportName__( "default", () => { try { return __vite_ssr_export_default__ } catch {} });
1313
+ __vite_ssr_exportName__( "bar", () => { try { return __vite_ssr_import_1__ } catch {} });
1314
1314
const __vite_ssr_import_0__ = await __vite_ssr_import__("./foo", {"importedNames":["foo"]});
1315
1315
const __vite_ssr_import_1__ = await __vite_ssr_import__("./bar");
1316
1316
;
@@ -1585,9 +1585,9 @@ import("e")
1585
1585
export * as A from "a";
1586
1586
` )
1587
1587
expect ( result ?. code ) . toMatchInlineSnapshot ( `
1588
- "Object.defineProperty(__vite_ssr_exports__, "b", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_1__.b } catch {} } });
1589
- Object.defineProperty(__vite_ssr_exports__, "d", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_3__ } catch {} } });
1590
- Object.defineProperty(__vite_ssr_exports__, "A", { enumerable: true, configurable: true, get() { try { return __vite_ssr_import_4__ } catch {} } });
1588
+ "__vite_ssr_exportName__( "b", () => { try { return __vite_ssr_import_1__.b } catch {} });
1589
+ __vite_ssr_exportName__( "d", () => { try { return __vite_ssr_import_3__ } catch {} });
1590
+ __vite_ssr_exportName__( "A", () => { try { return __vite_ssr_import_4__ } catch {} });
1591
1591
const __vite_ssr_import_0__ = await __vite_ssr_import__("a", {"importedNames":["default"]});
1592
1592
const __vite_ssr_import_1__ = await __vite_ssr_import__("b", {"importedNames":["b"]});
1593
1593
const __vite_ssr_import_2__ = await __vite_ssr_import__("c");
0 commit comments