@@ -38,10 +38,11 @@ if (true) {
3838`
3939 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
4040 "let exports = {}; const module = { exports };
41+ function __cjs_interop__(m) { return m.__cjs_module_runner_transform ? m.default : m; }
4142 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')));
4344 } 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')));
4546 }
4647 "
4748 ` )
@@ -57,8 +58,9 @@ if (true) {
5758`
5859 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
5960 "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"));
6264 "production" !== process.env.NODE_ENV && (function() {
6365 var React = __cjs_to_esm_hoist_0;
6466 var ReactDOM = __cjs_to_esm_hoist_1;
@@ -82,12 +84,13 @@ function test() {
8284`
8385 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
8486 "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"))))
9194
9295 function test() {
9396 const y1 = __cjs_to_esm_hoist_0;
@@ -130,6 +133,7 @@ function test() {
130133 output . append ( `
131134;__vite_ssr_exportAll__(module.exports);
132135export default module.exports;
136+ export const __cjs_module_runner_transform = true;
133137` )
134138 return {
135139 code : output . toString ( ) ,
@@ -156,6 +160,7 @@ export default module.exports;
156160 "value": 3,
157161 },
158162 "depNamespace": {
163+ "__cjs_module_runner_transform": true,
159164 "a": "a",
160165 "b": "b",
161166 "default": {
@@ -164,6 +169,7 @@ export default module.exports;
164169 },
165170 },
166171 "depPrimitive": "[ok]",
172+ "dualLib": "ok",
167173 }
168174 ` )
169175 } )
0 commit comments