@@ -22,7 +22,7 @@ describe(transformCjsToEsm, () => {
2222exports.ok = true;
2323`
2424 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
25- "const exports = {}; const module = { exports };
25+ "let exports = {}; const module = { exports };
2626 exports.ok = true;
2727 "
2828 ` )
@@ -37,11 +37,11 @@ if (true) {
3737}
3838`
3939 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
40- "const exports = {}; const module = { exports };
40+ "let exports = {}; const module = { exports };
4141 if (true) {
42- module.exports = (await import('./cjs/use-sync-external-store.production.js'));
42+ module.exports = (( await import('./cjs/use-sync-external-store.production.js')).default );
4343 } else {
44- module.exports = (await import('./cjs/use-sync-external-store.development.js'));
44+ module.exports = (( await import('./cjs/use-sync-external-store.development.js')).default );
4545 }
4646 "
4747 ` )
@@ -56,9 +56,9 @@ if (true) {
5656})()
5757`
5858 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
59- "const exports = {}; const module = { exports };
60- const __cjs_to_esm_hoist_0 = await import("react");
61- const __cjs_to_esm_hoist_1 = await import("react-dom");
59+ "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 ;
6262 "production" !== process.env.NODE_ENV && (function() {
6363 var React = __cjs_to_esm_hoist_0;
6464 var ReactDOM = __cjs_to_esm_hoist_1;
@@ -81,13 +81,13 @@ function test() {
8181}
8282`
8383 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
84- "const exports = {}; const module = { exports };
85- const __cjs_to_esm_hoist_0 = await import("te" + "st");
86- const __cjs_to_esm_hoist_1 = await import("test");
87- const __cjs_to_esm_hoist_2 = await import("test");
88- const x1 = (await import("te" + "st"));
89- const x2 = (await import("test"))().test;
90- console.log((await import("test")))
84+ "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 ))
9191
9292 function test() {
9393 const y1 = __cjs_to_esm_hoist_0;
@@ -106,7 +106,7 @@ function test() {
106106}
107107`
108108 expect ( await testTransform ( input ) ) . toMatchInlineSnapshot ( `
109- "const exports = {}; const module = { exports };
109+ "let exports = {}; const module = { exports };
110110 {
111111 const require = () => {};
112112 require("test");
@@ -150,6 +150,11 @@ export default module.exports;
150150 "a": "a",
151151 "b": "b",
152152 },
153+ "depExports": {},
154+ "depFn": [Function],
155+ "depFnRequire": {
156+ "value": 3,
157+ },
153158 "depNamespace": {
154159 "a": "a",
155160 "b": "b",
@@ -158,6 +163,7 @@ export default module.exports;
158163 "b": "b",
159164 },
160165 },
166+ "depPrimitive": "[ok]",
161167 }
162168 ` )
163169 } )
0 commit comments