@@ -38,10 +38,11 @@ if (true) {
38
38
`
39
39
expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
40
40
"let exports = {}; const module = { exports };
41
+ function __cjs_interop__(m) { return m.__cjs_module_runner_transform ? m.default : m; }
41
42
if (true) {
42
- module.exports = ((await import('./cjs/use-sync-external-store.production.js')).default );
43
+ module.exports = (__cjs_interop__ (await import('./cjs/use-sync-external-store.production.js')));
43
44
} else {
44
- module.exports = ((await import('./cjs/use-sync-external-store.development.js')).default );
45
+ module.exports = (__cjs_interop__ (await import('./cjs/use-sync-external-store.development.js')));
45
46
}
46
47
"
47
48
` )
@@ -57,8 +58,9 @@ if (true) {
57
58
`
58
59
expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
59
60
"let exports = {}; const module = { exports };
60
- const __cjs_to_esm_hoist_0 = (await import("react")).default;
61
- const __cjs_to_esm_hoist_1 = (await import("react-dom")).default;
61
+ function __cjs_interop__(m) { return m.__cjs_module_runner_transform ? m.default : m; }
62
+ const __cjs_to_esm_hoist_0 = __cjs_interop__(await import("react"));
63
+ const __cjs_to_esm_hoist_1 = __cjs_interop__(await import("react-dom"));
62
64
"production" !== process.env.NODE_ENV && (function() {
63
65
var React = __cjs_to_esm_hoist_0;
64
66
var ReactDOM = __cjs_to_esm_hoist_1;
@@ -82,12 +84,13 @@ function test() {
82
84
`
83
85
expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
84
86
"let exports = {}; const module = { exports };
85
- const __cjs_to_esm_hoist_0 = (await import("te" + "st")).default;
86
- const __cjs_to_esm_hoist_1 = (await import("test")).default;
87
- const __cjs_to_esm_hoist_2 = (await import("test")).default;
88
- const x1 = ((await import("te" + "st")).default);
89
- const x2 = ((await import("test")).default)().test;
90
- console.log(((await import("test")).default))
87
+ function __cjs_interop__(m) { return m.__cjs_module_runner_transform ? m.default : m; }
88
+ const __cjs_to_esm_hoist_0 = __cjs_interop__(await import("te" + "st"));
89
+ const __cjs_to_esm_hoist_1 = __cjs_interop__(await import("test"));
90
+ const __cjs_to_esm_hoist_2 = __cjs_interop__(await import("test"));
91
+ const x1 = (__cjs_interop__(await import("te" + "st")));
92
+ const x2 = (__cjs_interop__(await import("test")))().test;
93
+ console.log((__cjs_interop__(await import("test"))))
91
94
92
95
function test() {
93
96
const y1 = __cjs_to_esm_hoist_0;
@@ -130,6 +133,7 @@ function test() {
130
133
output . append ( `
131
134
;__vite_ssr_exportAll__(module.exports);
132
135
export default module.exports;
136
+ export const __cjs_module_runner_transform = true;
133
137
` )
134
138
return {
135
139
code : output . toString ( ) ,
@@ -156,6 +160,7 @@ export default module.exports;
156
160
"value": 3,
157
161
},
158
162
"depNamespace": {
163
+ "__cjs_module_runner_transform": true,
159
164
"a": "a",
160
165
"b": "b",
161
166
"default": {
@@ -164,6 +169,7 @@ export default module.exports;
164
169
},
165
170
},
166
171
"depPrimitive": "[ok]",
172
+ "dualLib": "ok",
167
173
}
168
174
` )
169
175
} )
0 commit comments