From faeb2ef18e8574e7ed366d37f5f85627bc069a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 28 May 2024 11:23:05 +0900 Subject: [PATCH] fix(turbopack): Fix edge cases of tree shaking (vercel/turbo#7986) ### Description Closes PACK-2966 ### Testing Instructions I'll add some tests --------- Co-authored-by: Tobias Koppers --- .../src/aggregation/tests.rs | 1 + crates/turbopack-core/src/context.rs | 4 +- crates/turbopack-core/src/resolve/mod.rs | 11 + .../js/src/shared/runtime-utils.ts | 17 +- .../turbopack-ecmascript/benches/analyzer.rs | 3 +- .../src/analyzer/graph.rs | 19 +- .../src/analyzer/imports.rs | 89 +- .../turbopack-ecmascript/src/analyzer/mod.rs | 3 +- .../src/chunk/placeable.rs | 3 +- crates/turbopack-ecmascript/src/lib.rs | 1 + crates/turbopack-ecmascript/src/parse.rs | 13 +- .../turbopack-ecmascript/src/path_visitor.rs | 1 + .../src/references/esm/base.rs | 33 + .../src/references/esm/binding.rs | 32 +- .../src/references/esm/export.rs | 67 +- .../src/references/mod.rs | 54 +- .../side_effect_optimization/facade/module.rs | 24 +- .../locals/chunk_item.rs | 1 + .../side_effect_optimization/locals/module.rs | 7 +- .../src/tree_shake/asset.rs | 115 +- .../src/tree_shake/chunk_item.rs | 5 + .../src/tree_shake/cjs_finder.rs | 11 + .../src/tree_shake/graph.rs | 469 +++- .../src/tree_shake/merge.rs | 6 +- .../src/tree_shake/mod.rs | 351 ++- .../src/tree_shake/tests.rs | 36 +- .../src/tree_shake/util.rs | 69 +- .../tests/tree-shaker/analyzer/1/output.md | 351 +-- .../tests/tree-shaker/analyzer/2/output.md | 383 +-- .../tests/tree-shaker/analyzer/3/output.md | 321 ++- .../tree-shaker/analyzer/app-route/input.js | 31 + .../tree-shaker/analyzer/app-route/output.md | 753 ++++++ .../analyzer/combined-export/input.js | 4 + .../analyzer/combined-export/output.md | 252 ++ .../tree-shaker/analyzer/complex/output.md | 432 ++-- .../analyzer/export-named/input.js | 1 + .../analyzer/export-named/output.md | 134 + .../tree-shaker/analyzer/failed-1/input.js | 57 + .../tree-shaker/analyzer/failed-1/output.md | 501 ++++ .../tree-shaker/analyzer/failed-2/input.js | 98 + .../tree-shaker/analyzer/failed-2/output.md | 1094 ++++++++ .../tree-shaker/analyzer/failed-3/input.js | 172 ++ .../tree-shaker/analyzer/failed-3/output.md | 2202 +++++++++++++++++ .../analyzer/ipc-evaluate/input.js | 94 + .../analyzer/ipc-evaluate/output.md | 479 ++++ .../analyzer/node-globals/input.js | 2 + .../analyzer/node-globals/output.md | 92 + .../tree-shaker/analyzer/route-kind/input.js | 19 + .../tree-shaker/analyzer/route-kind/output.md | 208 ++ .../analyzer/simple-vars-1/input.js | 4 + .../analyzer/simple-vars-1/output.md | 252 ++ .../tree-shaker/analyzer/simple/output.md | 82 +- .../analyzer/template-pages/input.js | 59 + .../analyzer/template-pages/output.md | 1486 +++++++++++ .../analyzer/test-config-1/output.md | 430 ++-- .../tree-shaker/analyzer/tla-1/input.js} | 0 .../tree-shaker/analyzer/tla-1/output.md | 221 ++ .../src/compiled/stacktrace-parser/index.js | 227 +- crates/turbopack-node/js/src/ipc/index.ts | 1 + crates/turbopack-node/src/pool.rs | 5 +- .../basic}/input/index.js | 0 .../input/node_modules/package-full/a.js | 0 .../input/node_modules/package-full/b.js | 0 .../input/node_modules/package-full/c.js | 0 .../node_modules/package-full/default.js | 0 .../input/node_modules/package-full/index.js | 0 .../node_modules/package-full}/package.json | 0 .../input/node_modules/package-full/x.js | 0 .../input/node_modules/package-named/a.js | 0 .../input/node_modules/package-named/b.js | 0 .../node_modules/package-named/default.js | 0 .../input/node_modules/package-named/index.js | 0 .../package-named/not-compiled.js | 0 .../package-named/not-executed.js | 0 .../node_modules/package-named}/package.json | 0 .../input/node_modules/package-named/x.js | 0 .../input/node_modules/package-named/y.js | 0 .../input/node_modules/package-partial/a.js | 0 .../input/node_modules/package-partial/b.js | 0 .../node_modules/package-partial/dir/file.js | 0 .../node_modules/package-partial/effect.js | 0 .../node_modules/package-partial/file.side.js | 0 .../node_modules/package-partial/index.js | 0 .../package-partial/not-compiled.js | 0 .../package-partial/not-executed.js | 0 .../node_modules/package-partial/package.json | 0 .../check-side-effect.js | 0 .../package-reexport-side-effect/index.js | 0 .../package-reexport-side-effect/package.json | 0 .../side-effect.js | 0 .../side-effect2.js | 0 .../check-side-effect.js | 7 + .../package-reexport-tla-side-effect/index.js | 0 .../package.json | 0 .../side-effect.js | 0 .../side-effect2.js | 0 .../package-reexport-unused/index.js | 0 .../package-reexport-unused/package.json | 0 .../node_modules/package-reexport/index.js | 0 .../package-reexport/package.json | 0 .../check-side-effect.js | 0 .../package-require-side-effect/index.js | 0 .../package-require-side-effect/package.json | 0 .../side-effect.js | 0 .../side-effect2.js | 0 .../input/node_modules/package-star/a.js | 0 .../input/node_modules/package-star/b.js | 0 .../input/node_modules/package-star/index.js | 0 .../node_modules/package-star/not-compiled.js | 0 .../node_modules/package-star/not-executed.js | 0 .../node_modules/package-star}/package.json | 0 .../basic}/input/node_modules/tla/both.js | 0 .../basic}/input/node_modules/tla/local.js | 0 .../input/node_modules/tla}/package.json | 0 .../basic}/input/node_modules/tla/reexport.js | 0 .../input/node_modules/tla/reexported.js | 0 .../input/node_modules/tla/tla-reexported.js | 0 .../basic}/options.json | 0 .../mui-utils/input/index.js | 21 + .../generateUtilityClass/index.js | 0 .../node_modules/mui-material}/package.json | 0 .../generateUtilityClass.js | 0 .../mui-utils/generateUtilityClass/index.js | 0 .../mui-utils/node_modules/mui-utils/index.js | 0 .../node_modules/mui-utils/not-correct.js | 0 .../node_modules/mui-utils}/package.json | 0 .../mui-utils/options.json | 3 + .../namespace-object-identity/input/esm.js | 6 + .../namespace-object-identity/input/index.js | 11 + .../namespace-object-identity/options.json | 3 + .../tree-shaking/.basic/input/index.js | 1 + .../tree-shaking/.basic/options.json | 3 + .../duplicate-modules/input/cjs.js | 10 + .../duplicate-modules/input/esm.js | 9 + .../duplicate-modules/input/index.js | 10 + .../duplicate-modules/options.json | 3 + .../tree-shaking/mui-utils/input/index.js | 22 +- .../tree-shaking/mui-utils/options.json | 2 +- .../tree-shaking/no-write-access/input/esm.js | 5 + .../no-write-access/input/index.js | 12 + .../tree-shaking/no-write-access/options.json | 3 + .../tree-shaking/split-chunks/input/a.js | 3 + .../tree-shaking/split-chunks/input/b.js | 3 + .../tree-shaking/split-chunks/input/index.js | 7 + .../tree-shaking/split-chunks/input/module.js | 4 + .../tree-shaking/split-chunks/options.json | 3 + crates/turbopack-tests/tests/snapshot.rs | 6 +- .../dynamic-import/input/index.js | 7 + .../dynamic-import/input/lib.js | 35 + .../dynamic-import/options.json | 3 + ...e-shake_dynamic-import_input_lib_029950.js | 14 + ...ake_dynamic-import_input_lib_029950.js.map | 5 + ...e-shake_dynamic-import_input_lib_189889.js | 226 ++ ...ake_dynamic-import_input_lib_189889.js.map | 29 + ...shake_dynamic-import_input_index_26d958.js | 14 + ...e_dynamic-import_input_index_26d958.js.map | 7 + .../export-named/input/index.js | 4 + .../export-named/input/lib.js | 35 + .../export-named/input/module.js | 2 + .../export-named/options.json | 3 + ...-tree-shake_export-named_input_0f9f9f._.js | 122 + ...e-shake_export-named_input_0f9f9f._.js.map | 23 + .../export-namespace/input/index.js | 3 + .../export-namespace/input/lib.js | 35 + .../export-namespace/input/module.js | 2 + .../export-namespace/options.json | 3 + ...e-shake_export-namespace_input_b8c6d3._.js | 271 ++ ...ake_export-namespace_input_b8c6d3._.js.map | 37 + .../import-named-all/input/index.js | 5 + .../import-named-all/input/lib.js | 35 + .../import-named-all/options.json | 3 + ...e-shake_import-named-all_input_c16bea._.js | 101 + ...ake_import-named-all_input_c16bea._.js.map | 19 + .../import-named/input/index.js | 3 + .../import-named/input/lib.js | 35 + .../import-named/options.json | 3 + ...-tree-shake_import-named_input_3e6aa0._.js | 100 + ...e-shake_import-named_input_3e6aa0._.js.map | 19 + .../import-namespace/input/index.js | 3 + .../import-namespace/input/lib.js | 35 + .../import-namespace/options.json | 3 + ...e-shake_import-namespace_input_66459d._.js | 249 ++ ...ake_import-namespace_input_66459d._.js.map | 33 + .../import-side-effect/input/index.js | 1 + .../import-side-effect/input/lib.js | 35 + .../import-side-effect/options.json | 3 + ...shake_import-side-effect_input_86a812._.js | 70 + ...e_import-side-effect_input_86a812._.js.map | 15 + .../require-side-effect/input/index.js | 1 + .../require-side-effect/input/lib.js | 35 + .../require-side-effect/options.json | 3 + ...hake_require-side-effect_input_cc94f5._.js | 231 ++ ..._require-side-effect_input_cc94f5._.js.map | 31 + .../tree-shake-test-1/input/index.js | 35 + .../tree-shake-test-1/options.json | 3 + ...ke_tree-shake-test-1_input_index_64a65d.js | 226 ++ ...ree-shake-test-1_input_index_64a65d.js.map | 29 + ...s_snapshot_mdx_error_input_index_743c8b.js | 6 + ...apshot_mdx_error_input_index_743c8b.js.map | 5 + ...s_snapshot_mdx_error_input_index_a3c4fd.js | 9 + ...apshot_mdx_error_input_index_a3c4fd.js.map | 5 + .../output/[turbopack]_runtime.js | 18 +- .../output/[turbopack]_runtime.js.map | 10 +- ..._default_dev_runtime_input_index_40d141.js | 18 +- ...ault_dev_runtime_input_index_40d141.js.map | 8 +- crates/turbopack/src/lib.rs | 66 +- crates/turbopack/src/module_options/mod.rs | 1 + .../module_options/module_options_context.rs | 2 +- 208 files changed, 13170 insertions(+), 1271 deletions(-) create mode 100644 crates/turbopack-ecmascript/src/tree_shake/cjs_finder.rs create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/output.md create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/input.js create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/output.md rename crates/{turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js => turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/input.js} (100%) create mode 100644 crates/turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/output.md rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-full/a.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-full/b.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-full/c.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-full/default.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-full/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/mui-utils/node_modules/mui-material => side-effects-optimization/basic/input/node_modules/package-full}/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-full/x.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/a.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/b.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/default.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/not-compiled.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/not-executed.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/mui-utils/node_modules/mui-utils => side-effects-optimization/basic/input/node_modules/package-named}/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/x.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-named/y.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/a.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/b.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/dir/file.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/effect.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/file.side.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/not-compiled.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/not-executed.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-partial/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-side-effect/check-side-effect.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-side-effect/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-side-effect/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-side-effect/side-effect.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-side-effect/side-effect2.js (100%) create mode 100644 crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-tla-side-effect/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-tla-side-effect/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-tla-side-effect/side-effect.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-tla-side-effect/side-effect2.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-unused/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport-unused/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-reexport/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-require-side-effect/check-side-effect.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-require-side-effect/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-require-side-effect/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-require-side-effect/side-effect.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-require-side-effect/side-effect2.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-star/a.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-star/b.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-star/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-star/not-compiled.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/package-star/not-executed.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects/input/node_modules/package-full => side-effects-optimization/basic/input/node_modules/package-star}/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/tla/both.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/tla/local.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects/input/node_modules/package-named => side-effects-optimization/basic/input/node_modules/tla}/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/tla/reexport.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/tla/reexported.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/input/node_modules/tla/tla-reexported.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects => side-effects-optimization/basic}/options.json (100%) create mode 100644 crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/input/index.js rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking => side-effects-optimization}/mui-utils/node_modules/mui-material/generateUtilityClass/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects/input/node_modules/package-star => side-effects-optimization/mui-utils/node_modules/mui-material}/package.json (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking => side-effects-optimization}/mui-utils/node_modules/mui-utils/generateUtilityClass/generateUtilityClass.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking => side-effects-optimization}/mui-utils/node_modules/mui-utils/generateUtilityClass/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking => side-effects-optimization}/mui-utils/node_modules/mui-utils/index.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking => side-effects-optimization}/mui-utils/node_modules/mui-utils/not-correct.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{tree-shaking/side-effects/input/node_modules/tla => side-effects-optimization/mui-utils/node_modules/mui-utils}/package.json (100%) create mode 100644 crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/options.json create mode 100644 crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/esm.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/index.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/options.json create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/input/index.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/options.json create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/cjs.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/esm.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/index.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/options.json create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/esm.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/index.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/options.json create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/a.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/b.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/index.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/module.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/options.json create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js create mode 100644 crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js create mode 100644 crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js.map diff --git a/crates/turbo-tasks-memory/src/aggregation/tests.rs b/crates/turbo-tasks-memory/src/aggregation/tests.rs index 12af07a9e7453..1412c48693b93 100644 --- a/crates/turbo-tasks-memory/src/aggregation/tests.rs +++ b/crates/turbo-tasks-memory/src/aggregation/tests.rs @@ -116,6 +116,7 @@ fn check_invariants<'a>( false } }); + #[allow(clippy::never_loop)] for missing_upper in missing_uppers { let upper_value = { let upper = ctx.node(missing_upper); diff --git a/crates/turbopack-core/src/context.rs b/crates/turbopack-core/src/context.rs index e95c991b85393..8d77c677f5d76 100644 --- a/crates/turbopack-core/src/context.rs +++ b/crates/turbopack-core/src/context.rs @@ -1,6 +1,6 @@ use anyhow::{bail, Result}; use turbo_tasks::{Value, Vc}; -use turbo_tasks_fs::FileSystemPath; +use turbo_tasks_fs::{glob::Glob, FileSystemPath}; use crate::{ compile_time_info::CompileTimeInfo, @@ -76,4 +76,6 @@ pub trait AssetContext { /// Gets a new AssetContext with the transition applied. fn with_transition(self: Vc, transition: String) -> Vc>; + + fn side_effect_free_packages(self: Vc) -> Vc; } diff --git a/crates/turbopack-core/src/resolve/mod.rs b/crates/turbopack-core/src/resolve/mod.rs index 49f8584520bdf..84c324a53a3aa 100644 --- a/crates/turbopack-core/src/resolve/mod.rs +++ b/crates/turbopack-core/src/resolve/mod.rs @@ -103,6 +103,17 @@ impl ModuleResolveResult { } } + pub fn ignored() -> ModuleResolveResult { + Self::ignored_with_key(RequestKey::default()) + } + + pub fn ignored_with_key(request_key: RequestKey) -> ModuleResolveResult { + ModuleResolveResult { + primary: indexmap! { request_key => ModuleResolveResultItem::Ignore }, + affecting_sources: Vec::new(), + } + } + pub fn module(module: Vc>) -> ModuleResolveResult { Self::module_with_key(RequestKey::default(), module) } diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index 17af6c0745e81..6bf8b1ec927fe 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -74,12 +74,25 @@ function defineProp( /** * Adds the getters to the exports object. */ -function esm(exports: Exports, getters: Record any>) { +function esm( + exports: Exports, + getters: Record any) | [() => any, (v: any) => void]> +) { defineProp(exports, "__esModule", { value: true }); if (toStringTag) defineProp(exports, toStringTag, { value: "Module" }); for (const key in getters) { - defineProp(exports, key, { get: getters[key], enumerable: true }); + const item = getters[key]; + if (Array.isArray(item)) { + defineProp(exports, key, { + get: item[0], + set: item[1], + enumerable: true, + }); + } else { + defineProp(exports, key, { get: item, enumerable: true }); + } } + Object.seal(exports); } /** diff --git a/crates/turbopack-ecmascript/benches/analyzer.rs b/crates/turbopack-ecmascript/benches/analyzer.rs index d7e97abab698c..4b70575de1e98 100644 --- a/crates/turbopack-ecmascript/benches/analyzer.rs +++ b/crates/turbopack-ecmascript/benches/analyzer.rs @@ -55,7 +55,8 @@ pub fn benchmark(c: &mut Criterion) { let top_level_mark = Mark::new(); program.visit_mut_with(&mut resolver(unresolved_mark, top_level_mark, false)); - let eval_context = EvalContext::new(&program, unresolved_mark, None); + let eval_context = + EvalContext::new(&program, unresolved_mark, top_level_mark, false, None); let var_graph = create_graph(&program, &eval_context); let input = BenchInput { diff --git a/crates/turbopack-ecmascript/src/analyzer/graph.rs b/crates/turbopack-ecmascript/src/analyzer/graph.rs index dd5e634b41601..6734f06d648e6 100644 --- a/crates/turbopack-ecmascript/src/analyzer/graph.rs +++ b/crates/turbopack-ecmascript/src/analyzer/graph.rs @@ -261,6 +261,7 @@ pub fn create_graph(m: &Program, eval_context: &EvalContext) -> VarGraph { pub struct EvalContext { pub(crate) unresolved_mark: Mark, + pub(crate) top_level_mark: Mark, pub(crate) imports: ImportMap, } @@ -268,11 +269,14 @@ impl EvalContext { pub fn new( module: &Program, unresolved_mark: Mark, + top_level_mark: Mark, + skip_namespace: bool, source: Option>>, ) -> Self { Self { unresolved_mark, - imports: ImportMap::analyze(module, source), + top_level_mark, + imports: ImportMap::analyze(module, skip_namespace, source), } } @@ -1460,6 +1464,8 @@ impl VisitAstPath for Analyzer<'_> { ) { let value = self.current_value.take(); if let SimpleAssignTarget::Ident(i) = n { + n.visit_children_with_path(self, ast_path); + self.add_value( i.to_id(), value.unwrap_or_else(|| { @@ -1572,13 +1578,20 @@ impl VisitAstPath for Analyzer<'_> { ident: &'ast Ident, ast_path: &mut AstNodePath>, ) { - if !matches!( + if !(matches!( ast_path.last(), Some(AstParentNodeRef::Expr(_, ExprField::Ident)) | Some(AstParentNodeRef::Prop(_, PropField::Shorthand)) - ) { + ) || matches!( + ast_path.get(ast_path.len() - 2), + Some(AstParentNodeRef::SimpleAssignTarget( + _, + SimpleAssignTargetField::Ident, + )) + )) { return; } + if let Some((esm_reference_index, export)) = self.eval_context.imports.get_binding(&ident.to_id()) { diff --git a/crates/turbopack-ecmascript/src/analyzer/imports.rs b/crates/turbopack-ecmascript/src/analyzer/imports.rs index faa84ebbcccee..836eed10cf8a5 100644 --- a/crates/turbopack-ecmascript/src/analyzer/imports.rs +++ b/crates/turbopack-ecmascript/src/analyzer/imports.rs @@ -13,7 +13,8 @@ use swc_core::{ use turbo_tasks::Vc; use turbopack_core::{issue::IssueSource, source::Source}; -use super::{JsValue, ModuleValue}; +use super::{top_level_await::has_top_level_await, JsValue, ModuleValue}; +use crate::tree_shake::{find_turbopack_part_id_in_asserts, PartId}; #[turbo_tasks::value(serialization = "auto_for_input")] #[derive(Default, Debug, Clone, Hash, PartialOrd, Ord)] @@ -129,16 +130,22 @@ pub(crate) struct ImportMap { /// True, when the module has exports has_exports: bool, + + /// True if the module is an ESM module due to top-level await. + has_top_level_await: bool, } -#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub(crate) enum ImportedSymbol { ModuleEvaluation, Symbol(JsWord), + /// User requested the whole module Namespace, + Exports, + Part(u32), } -#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub(crate) struct ImportMapReference { pub module_path: JsWord, pub imported_symbol: ImportedSymbol, @@ -148,7 +155,10 @@ pub(crate) struct ImportMapReference { impl ImportMap { pub fn is_esm(&self) -> bool { - self.has_exports || !self.imports.is_empty() || !self.namespace_imports.is_empty() + self.has_exports + || self.has_top_level_await + || !self.imports.is_empty() + || !self.namespace_imports.is_empty() } pub fn get_import(&self, id: &Id) -> Option { @@ -192,11 +202,16 @@ impl ImportMap { } /// Analyze ES import - pub(super) fn analyze(m: &Program, source: Option>>) -> Self { + pub(super) fn analyze( + m: &Program, + skip_namespace: bool, + source: Option>>, + ) -> Self { let mut data = ImportMap::default(); m.visit_with(&mut Analyzer { data: &mut data, + skip_namespace, source, }); @@ -206,6 +221,7 @@ impl ImportMap { struct Analyzer<'a> { data: &'a mut ImportMap, + skip_namespace: bool, source: Option>>, } @@ -216,7 +232,11 @@ impl<'a> Analyzer<'a> { module_path: JsWord, imported_symbol: ImportedSymbol, annotations: ImportAnnotations, - ) -> usize { + ) -> Option { + if self.skip_namespace && matches!(imported_symbol, ImportedSymbol::Namespace) { + return None; + } + let issue_source = self .source .map(|s| IssueSource::from_swc_offsets(s, span.lo.to_usize(), span.hi.to_usize())); @@ -228,11 +248,11 @@ impl<'a> Analyzer<'a> { annotations, }; if let Some(i) = self.data.references.get_index_of(&r) { - i + Some(i) } else { let i = self.data.references.len(); self.data.references.insert(r); - i + Some(i) } } } @@ -256,13 +276,17 @@ impl Visit for Analyzer<'_> { ); for s in &import.specifiers { - let symbol = get_import_symbol_from_import(s); + let symbol = get_import_symbol_from_import(s, import.with.as_deref()); let i = self.ensure_reference( import.span, import.src.value.clone(), symbol, annotations.clone(), ); + let i = match i { + Some(v) => v, + None => continue, + }; let (local, orig_sym) = match s { ImportSpecifier::Named(ImportNamedSpecifier { @@ -293,13 +317,17 @@ impl Visit for Analyzer<'_> { ImportedSymbol::ModuleEvaluation, annotations.clone(), ); + let symbol = parse_with(export.with.as_deref()); + let i = self.ensure_reference( export.span, export.src.value.clone(), - ImportedSymbol::Namespace, + symbol.unwrap_or(ImportedSymbol::Namespace), annotations, ); - self.data.reexports.push((i, Reexport::Star)); + if let Some(i) = i { + self.data.reexports.push((i, Reexport::Star)); + } } fn visit_named_export(&mut self, export: &NamedExport) { @@ -319,10 +347,14 @@ impl Visit for Analyzer<'_> { ); for spec in export.specifiers.iter() { - let symbol = get_import_symbol_from_export(spec); + let symbol = get_import_symbol_from_export(spec, export.with.as_deref()); let i = self.ensure_reference(export.span, src.value.clone(), symbol, annotations.clone()); + let i = match i { + Some(v) => v, + None => continue, + }; match spec { ExportSpecifier::Namespace(n) => { @@ -367,6 +399,12 @@ impl Visit for Analyzer<'_> { fn visit_stmt(&mut self, _: &Stmt) { // don't visit children } + + fn visit_program(&mut self, m: &Program) { + self.data.has_top_level_await = has_top_level_await(m).is_some(); + + m.visit_children_with(self); + } } pub(crate) fn orig_name(n: &ModuleExportName) -> JsWord { @@ -376,7 +414,23 @@ pub(crate) fn orig_name(n: &ModuleExportName) -> JsWord { } } -fn get_import_symbol_from_import(specifier: &ImportSpecifier) -> ImportedSymbol { +fn parse_with(with: Option<&ObjectLit>) -> Option { + find_turbopack_part_id_in_asserts(with?).map(|v| match v { + PartId::Internal(index) => ImportedSymbol::Part(index), + PartId::ModuleEvaluation => ImportedSymbol::ModuleEvaluation, + PartId::Export(e) => ImportedSymbol::Symbol(e.into()), + PartId::Exports => ImportedSymbol::Exports, + }) +} + +fn get_import_symbol_from_import( + specifier: &ImportSpecifier, + with: Option<&ObjectLit>, +) -> ImportedSymbol { + if let Some(part) = parse_with(with) { + return part; + } + match specifier { ImportSpecifier::Named(ImportNamedSpecifier { local, imported, .. @@ -389,7 +443,14 @@ fn get_import_symbol_from_import(specifier: &ImportSpecifier) -> ImportedSymbol } } -fn get_import_symbol_from_export(specifier: &ExportSpecifier) -> ImportedSymbol { +fn get_import_symbol_from_export( + specifier: &ExportSpecifier, + with: Option<&ObjectLit>, +) -> ImportedSymbol { + if let Some(part) = parse_with(with) { + return part; + } + match specifier { ExportSpecifier::Named(ExportNamedSpecifier { orig, .. }) => { ImportedSymbol::Symbol(orig_name(orig)) diff --git a/crates/turbopack-ecmascript/src/analyzer/mod.rs b/crates/turbopack-ecmascript/src/analyzer/mod.rs index dbd26db7b8f5a..a81625e44b557 100644 --- a/crates/turbopack-ecmascript/src/analyzer/mod.rs +++ b/crates/turbopack-ecmascript/src/analyzer/mod.rs @@ -3574,7 +3574,8 @@ mod tests { let top_level_mark = Mark::new(); m.visit_mut_with(&mut resolver(unresolved_mark, top_level_mark, false)); - let eval_context = EvalContext::new(&m, unresolved_mark, None); + let eval_context = + EvalContext::new(&m, unresolved_mark, top_level_mark, false, None); let mut var_graph = create_graph(&m, &eval_context); diff --git a/crates/turbopack-ecmascript/src/chunk/placeable.rs b/crates/turbopack-ecmascript/src/chunk/placeable.rs index cac7c90695fbd..c63ebf097dc8a 100644 --- a/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -158,8 +158,7 @@ pub async fn is_marked_as_side_effect_free( return Ok(Vc::cell(true)); } - let find_package_json: turbo_tasks::ReadRef = - find_context_file(path.parent(), package_json()).await?; + let find_package_json = find_context_file(path.parent(), package_json()).await?; if let FindContextFileResult::Found(package_json, _) = *find_package_json { match *side_effects_from_package_json(package_json).await? { diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index 1c3ae077d7522..84b3e1866e8b9 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -193,6 +193,7 @@ struct MemoizedSuccessfulAnalysis { source_map: Option>, } +#[derive(Clone)] pub struct EcmascriptModuleAssetBuilder { source: Vc>, asset_context: Vc>, diff --git a/crates/turbopack-ecmascript/src/parse.rs b/crates/turbopack-ecmascript/src/parse.rs index bf66e3c80de5c..258ecd3d24796 100644 --- a/crates/turbopack-ecmascript/src/parse.rs +++ b/crates/turbopack-ecmascript/src/parse.rs @@ -46,7 +46,7 @@ use crate::{ #[allow(clippy::large_enum_variant)] pub enum ParseResult { Ok { - #[turbo_tasks(trace_ignore)] + #[turbo_tasks(debug_ignore, trace_ignore)] program: Program, #[turbo_tasks(debug_ignore, trace_ignore)] comments: Arc, @@ -278,7 +278,7 @@ async fn parse_content( let mut result = WrapFuture::new( async { let file_name = FileName::Custom(ident.to_string()); - let fm = source_map.new_source_file(file_name.clone(), string); + let fm = source_map.new_source_file(file_name.clone(), string.clone()); let comments = SwcComments::default(); @@ -405,6 +405,7 @@ async fn parse_content( } else { None }; + let messages = Some(messages.unwrap_or_else(|| vec![string.to_string()])); return Ok(ParseResult::Unparseable { messages }); } @@ -412,7 +413,13 @@ async fn parse_content( &mut swc_core::ecma::transforms::base::helpers::inject_helpers(unresolved_mark), ); - let eval_context = EvalContext::new(&parsed_program, unresolved_mark, Some(source)); + let eval_context = EvalContext::new( + &parsed_program, + unresolved_mark, + top_level_mark, + false, + Some(source), + ); Ok::(ParseResult::Ok { program: parsed_program, diff --git a/crates/turbopack-ecmascript/src/path_visitor.rs b/crates/turbopack-ecmascript/src/path_visitor.rs index f5b30a0068312..5c83fbc9036cd 100644 --- a/crates/turbopack-ecmascript/src/path_visitor.rs +++ b/crates/turbopack-ecmascript/src/path_visitor.rs @@ -143,6 +143,7 @@ macro_rules! method { impl VisitMutAstPath for ApplyVisitors<'_, '_> { // TODO: we need a macro to apply that for all methods method!(visit_mut_prop, Prop); + method!(visit_mut_simple_assign_target, SimpleAssignTarget); method!(visit_mut_expr, Expr); method!(visit_mut_member_expr, MemberExpr); method!(visit_mut_pat, Pat); diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index 2488398c46052..0c279eec9daaf 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -11,6 +11,7 @@ use turbopack_core::{ ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType, ChunkingTypeOption, ModuleId, }, + context::AssetContext, issue::{IssueSeverity, IssueSource}, module::Module, reference::ModuleReference, @@ -29,6 +30,7 @@ use crate::{ code_gen::{CodeGenerateable, CodeGeneration}, create_visitor, magic_identifier, references::util::{request_to_string, throw_module_not_found_expr}, + tree_shake::{asset::EcmascriptModulePartAsset, TURBOPACK_PART_IMPORT_SOURCE}, }; #[turbo_tasks::value] @@ -150,6 +152,37 @@ impl ModuleReference for EsmAssetReference { EcmaScriptModulesReferenceSubType::Import }; + // Skip side effect free self-references here. + if let Request::Module { module, .. } = &*self.request.await? { + if module == TURBOPACK_PART_IMPORT_SOURCE { + if let Some(part) = self.export_name { + let full_module: Vc = + Vc::try_resolve_downcast_type(self.origin) + .await? + .expect("EsmAssetReference origin should be a EcmascriptModuleAsset"); + + let side_effect_free_packages = + full_module.asset_context().side_effect_free_packages(); + + if let ModulePart::Evaluation = *part.await? { + if *full_module + .is_marked_as_side_effect_free(side_effect_free_packages) + .await? + { + return Ok(ModuleResolveResult::ignored().cell()); + } + } + + let module = + EcmascriptModulePartAsset::new(full_module, part, self.import_externals); + + return Ok(ModuleResolveResult::module(Vc::upcast(module)).cell()); + } + + bail!("export_name is required for part import") + } + } + Ok(esm_resolve( self.get_origin().resolve().await?, self.request, diff --git a/crates/turbopack-ecmascript/src/references/esm/binding.rs b/crates/turbopack-ecmascript/src/references/esm/binding.rs index 3942774ae76d4..f2f4df7d86bb5 100644 --- a/crates/turbopack-ecmascript/src/references/esm/binding.rs +++ b/crates/turbopack-ecmascript/src/references/esm/binding.rs @@ -4,7 +4,7 @@ use swc_core::{ ecma::{ ast::{ ComputedPropName, Expr, Ident, KeyValueProp, Lit, MemberExpr, MemberProp, Number, Prop, - PropName, SeqExpr, Str, + PropName, SeqExpr, SimpleAssignTarget, Str, }, visit::fields::{CalleeField, PropField}, }, @@ -127,6 +127,7 @@ impl CodeGenerateable for EsmBinding { CalleeField::Expr )) ); + visitors.push( create_visitor!(exact ast_path, visit_mut_expr(expr: &mut Expr) { if let Some(ident) = imported_module.as_deref() { @@ -140,6 +141,35 @@ impl CodeGenerateable for EsmBinding { ); break; } + Some(swc_core::ecma::visit::AstParentKind::BindingIdent( + swc_core::ecma::visit::fields::BindingIdentField::Id, + )) => { + ast_path.pop(); + + // We need to handle LHS because of code like + // (function (RouteKind1){})(RouteKind || RouteKind = {}) + if let Some(swc_core::ecma::visit::AstParentKind::SimpleAssignTarget( + swc_core::ecma::visit::fields::SimpleAssignTargetField::Ident, + )) = ast_path.last() + { + ast_path.pop(); + + visitors.push( + create_visitor!(exact ast_path, visit_mut_simple_assign_target(l: &mut SimpleAssignTarget) { + if let Some(ident) = imported_module.as_deref() { + use swc_core::common::Spanned; + *l = match make_expr(ident, this.export.as_deref(), l.span(), false) { + Expr::Ident(ident) => SimpleAssignTarget::Ident(ident.into()), + Expr::Member(member) => SimpleAssignTarget::Member(member), + _ => unreachable!(), + }; + } + }), + ); + + break; + } + } Some(_) => { ast_path.pop(); } diff --git a/crates/turbopack-ecmascript/src/references/esm/export.rs b/crates/turbopack-ecmascript/src/references/esm/export.rs index 41807de8d19ed..8338c61aa65fc 100644 --- a/crates/turbopack-ecmascript/src/references/esm/export.rs +++ b/crates/turbopack-ecmascript/src/references/esm/export.rs @@ -35,9 +35,13 @@ use crate::{ #[derive(Clone, Hash, Debug, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)] pub enum EsmExport { /// A local binding that is exported (export { a } or export const a = 1) - LocalBinding(String), + /// + /// The last bool is true if the binding is a mutable binding + LocalBinding(String, bool), /// An imported binding that is exported (export { a as b } from "...") - ImportedBinding(Vc>, String), + /// + /// The last bool is true if the binding is a mutable binding + ImportedBinding(Vc>, String, bool), /// An imported namespace that is exported (export * from "...") ImportedNamespace(Vc>), /// An error occurred while resolving the export @@ -149,7 +153,7 @@ async fn handle_declared_export( side_effect_free_packages: Vc, ) -> Result>, String)>> { match export { - EsmExport::ImportedBinding(reference, name) => { + EsmExport::ImportedBinding(reference, name, _) => { if let ReferencedAsset::Some(module) = *ReferencedAsset::from_resolve_result(reference.resolve_reference()).await? { @@ -177,7 +181,7 @@ async fn handle_declared_export( })); } } - EsmExport::LocalBinding(_) => { + EsmExport::LocalBinding(..) => { return Ok(ControlFlow::Break(FollowExportsResult { module, export_name: Some(export_name), @@ -387,7 +391,7 @@ impl EsmExports { if !exports.contains_key(export) { exports.insert( export.clone(), - EsmExport::ImportedBinding(Vc::upcast(*esm_ref), export.to_string()), + EsmExport::ImportedBinding(Vc::upcast(*esm_ref), export.to_string(), false), ); } } @@ -432,29 +436,46 @@ impl CodeGenerateable for EsmExports { EsmExport::Error => Some(quote!( "(() => { throw new Error(\"Failed binding. See build errors!\"); })" as Expr, )), - EsmExport::LocalBinding(name) => Some(quote!( - "(() => $local)" as Expr, - local = Ident::new((name as &str).into(), DUMMY_SP) - )), - EsmExport::ImportedBinding(esm_ref, name) => { + EsmExport::LocalBinding(name, mutable) => { + if *mutable { + Some(quote!( + "([() => $local, (v) => $local = v])" as Expr, + local = Ident::new((name as &str).into(), DUMMY_SP) + )) + } else { + Some(quote!( + "(() => $local)" as Expr, + local = Ident::new((name as &str).into(), DUMMY_SP) + )) + } + } + EsmExport::ImportedBinding(esm_ref, name, mutable) => { let referenced_asset = ReferencedAsset::from_resolve_result(esm_ref.resolve_reference()).await?; referenced_asset.get_ident().await?.map(|ident| { - quote!( - "(() => $expr)" as Expr, - expr: Expr = Expr::Member(MemberExpr { + let expr = Expr::Member(MemberExpr { + span: DUMMY_SP, + obj: Box::new(Expr::Ident(Ident::new(ident.into(), DUMMY_SP))), + prop: MemberProp::Computed(ComputedPropName { span: DUMMY_SP, - obj: Box::new(Expr::Ident(Ident::new(ident.into(), DUMMY_SP))), - prop: MemberProp::Computed(ComputedPropName { + expr: Box::new(Expr::Lit(Lit::Str(Str { span: DUMMY_SP, - expr: Box::new(Expr::Lit(Lit::Str(Str { - span: DUMMY_SP, - value: (name as &str).into(), - raw: None, - }))) - }) - }) - ) + value: (name as &str).into(), + raw: None, + }))), + }), + }); + if *mutable { + quote!( + "([() => $expr, (v) => $expr = v])" as Expr, + expr: Expr = expr, + ) + } else { + quote!( + "(() => $expr)" as Expr, + expr: Expr = expr, + ) + } }) } EsmExport::ImportedNamespace(esm_ref) => { diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index e651e0f7f00c9..15349f1deb058 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -132,7 +132,7 @@ use crate::{ require_context::{RequireContextAssetReference, RequireContextMap}, type_issue::SpecifiedModuleTypeIssue, }, - tree_shake::{part_of_module, split}, + tree_shake::{find_turbopack_part_id_in_asserts, part_of_module, split}, EcmascriptInputTransforms, EcmascriptModuleAsset, SpecifiedModuleType, TreeShakingMode, }; @@ -185,7 +185,8 @@ impl AnalyzeEcmascriptModuleResultBuilder { where R: Upcast>, { - self.references.insert(Vc::upcast(reference)); + let r = Vc::upcast(reference); + self.references.insert(r); self.local_references.insert(Vc::upcast(reference)); } @@ -374,9 +375,17 @@ pub(crate) async fn analyse_ecmascript_module( let module = module.ident().to_string().await?; tracing::info_span!("analyse ecmascript module", module = *module) }; - analyse_ecmascript_module_internal(module, part) + let result = analyse_ecmascript_module_internal(module, part) .instrument(span) - .await + .await; + + match result { + Ok(result) => Ok(result), + Err(err) => Err(err.context(format!( + "failed to analyse ecmascript module '{}'", + module.ident().to_string().await? + ))), + } } pub(crate) async fn analyse_ecmascript_module_internal( @@ -407,7 +416,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( let parsed = if let Some(part) = part { let parsed = parse(source, ty, transforms); - let split_data = split(path, source, parsed); + let split_data = split(source.ident(), source, parsed); part_of_module(split_data, part) } else { parse(source, ty, transforms) @@ -555,6 +564,8 @@ pub(crate) async fn analyse_ecmascript_module_internal( Some(ModulePart::evaluation()) } ImportedSymbol::Symbol(name) => Some(ModulePart::export(name.to_string())), + ImportedSymbol::Part(part_id) => Some(ModulePart::internal(*part_id)), + ImportedSymbol::Exports => Some(ModulePart::exports()), ImportedSymbol::Namespace => None, }, Some(TreeShakingMode::ReexportsOnly) => match &r.imported_symbol { @@ -563,6 +574,8 @@ pub(crate) async fn analyse_ecmascript_module_internal( Some(ModulePart::evaluation()) } ImportedSymbol::Symbol(name) => Some(ModulePart::export(name.to_string())), + ImportedSymbol::Part(part_id) => Some(ModulePart::internal(*part_id)), + ImportedSymbol::Exports => None, ImportedSymbol::Namespace => None, }, None => None, @@ -577,6 +590,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( // passing that to other turbo tasks functions later. *r = r.resolve().await?; } + for r in import_references.iter() { // `add_import_reference` will avoid adding duplicate references analysis.add_import_reference(*r); @@ -609,7 +623,11 @@ pub(crate) async fn analyse_ecmascript_module_internal( } => { visitor.esm_exports.insert( e.to_string(), - EsmExport::ImportedBinding(Vc::upcast(import_ref), i.to_string()), + EsmExport::ImportedBinding( + Vc::upcast(import_ref), + i.to_string(), + false, + ), ); } } @@ -628,11 +646,11 @@ pub(crate) async fn analyse_ecmascript_module_internal( for export in esm_exports.values() { match *export { - EsmExport::LocalBinding(_) => {} + EsmExport::LocalBinding(..) => {} EsmExport::ImportedNamespace(reference) => { analysis.add_reexport_reference(reference); } - EsmExport::ImportedBinding(reference, _) => { + EsmExport::ImportedBinding(reference, ..) => { analysis.add_reexport_reference(reference); } EsmExport::Error => {} @@ -2547,6 +2565,13 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { ast_path: &mut AstNodePath>, ) { let path = Vc::cell(as_parent_path(ast_path)); + // We create mutable exports for fake ESMs generated by module splitting + let is_fake_esm = export + .with + .as_deref() + .map(find_turbopack_part_id_in_asserts) + .is_some(); + if export.src.is_none() { for spec in export.specifiers.iter() { fn to_string(name: &ModuleExportName) -> String { @@ -2580,12 +2605,16 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { if let Some((index, export)) = imported_binding { let esm_ref = self.import_references[index]; if let Some(export) = export { - EsmExport::ImportedBinding(Vc::upcast(esm_ref), export) + EsmExport::ImportedBinding( + Vc::upcast(esm_ref), + export, + is_fake_esm, + ) } else { EsmExport::ImportedNamespace(Vc::upcast(esm_ref)) } } else { - EsmExport::LocalBinding(binding_name) + EsmExport::LocalBinding(binding_name, is_fake_esm) } }; self.esm_exports.insert(key, export); @@ -2605,7 +2634,7 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { ) { for_each_ident_in_decl(&export.decl, &mut |name| { self.esm_exports - .insert(name.clone(), EsmExport::LocalBinding(name)); + .insert(name.clone(), EsmExport::LocalBinding(name, false)); }); self.analysis .add_code_gen(EsmModuleItem::new(Vc::cell(as_parent_path(ast_path)))); @@ -2619,7 +2648,7 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { ) { self.esm_exports.insert( "default".to_string(), - EsmExport::LocalBinding(magic_identifier::mangle("default export")), + EsmExport::LocalBinding(magic_identifier::mangle("default export"), false), ); self.analysis .add_code_gen(EsmModuleItem::new(Vc::cell(as_parent_path(ast_path)))); @@ -2640,6 +2669,7 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { .as_ref() .map(|i| i.sym.to_string()) .unwrap_or_else(|| magic_identifier::mangle("default export")), + false, ), ); } diff --git a/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs b/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs index 517f3093a0086..5dd90a8e57756 100644 --- a/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs +++ b/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs @@ -41,15 +41,18 @@ impl EcmascriptModuleFacadeModule { #[turbo_tasks::function] pub async fn async_module(self: Vc) -> Result> { - let import_externals = + let (import_externals, has_top_level_await) = if let Some(async_module) = *self.await?.module.get_async_module().await? { - async_module.await?.import_externals + ( + async_module.await?.import_externals, + async_module.await?.has_top_level_await, + ) } else { - false + (false, false) }; Ok(AsyncModule { placeable: Vc::upcast(self), - has_top_level_await: false, + has_top_level_await, import_externals, } .cell()) @@ -159,7 +162,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { for (name, export) in &esm_exports.exports { let name = name.clone(); match export { - EsmExport::LocalBinding(_) => { + EsmExport::LocalBinding(_, mutable) => { exports.insert( name.clone(), EsmExport::ImportedBinding( @@ -168,16 +171,21 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { ModulePart::locals(), )), name, + *mutable, ), ); } EsmExport::ImportedNamespace(reference) => { exports.insert(name, EsmExport::ImportedNamespace(*reference)); } - EsmExport::ImportedBinding(reference, imported_name) => { + EsmExport::ImportedBinding(reference, imported_name, mutable) => { exports.insert( name, - EsmExport::ImportedBinding(*reference, imported_name.clone()), + EsmExport::ImportedBinding( + *reference, + imported_name.clone(), + *mutable, + ), ); } EsmExport::Error => { @@ -206,6 +214,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { ModulePart::exports(), )), "default".to_string(), + false, ), ); } @@ -224,6 +233,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { EsmExport::ImportedBinding( Vc::upcast(EcmascriptModulePartReference::new(self.module)), original_export.clone_value(), + false, ), ); } diff --git a/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs b/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs index 84199f6c806ec..d547bab77f80d 100644 --- a/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs @@ -60,6 +60,7 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem { exports, async_module_info, ); + Ok(EcmascriptChunkItemContent::new( content, self.chunking_context, diff --git a/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs b/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs index a733b44cb1a7e..39b98678c3f40 100644 --- a/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs +++ b/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs @@ -77,8 +77,11 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule { EsmExport::ImportedBinding(..) | EsmExport::ImportedNamespace(..) => { // not included in locals module } - EsmExport::LocalBinding(local_name) => { - exports.insert(name.clone(), EsmExport::LocalBinding(local_name.clone())); + EsmExport::LocalBinding(local_name, mutable) => { + exports.insert( + name.clone(), + EsmExport::LocalBinding(local_name.clone(), *mutable), + ); } EsmExport::Error => { exports.insert(name.clone(), EsmExport::Error); diff --git a/crates/turbopack-ecmascript/src/tree_shake/asset.rs b/crates/turbopack-ecmascript/src/tree_shake/asset.rs index 2ee105a67be7e..5c12234a16e98 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/asset.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/asset.rs @@ -1,15 +1,17 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result}; use turbo_tasks::Vc; use turbopack_core::{ asset::{Asset, AssetContent}, - chunk::{ChunkableModule, ChunkingContext}, + chunk::{ChunkableModule, ChunkingContext, EvaluatableAsset}, ident::AssetIdent, module::Module, reference::{ModuleReferences, SingleModuleReference}, resolve::ModulePart, }; -use super::{chunk_item::EcmascriptModulePartChunkItem, get_part_id, split_module, SplitResult}; +use super::{ + chunk_item::EcmascriptModulePartChunkItem, get_part_id, split_module, Key, SplitResult, +}; use crate::{ chunk::{EcmascriptChunkPlaceable, EcmascriptExports}, references::analyse_ecmascript_module, @@ -44,6 +46,18 @@ impl EcmascriptModulePartAsset { } .cell() } + + #[turbo_tasks::function] + pub async fn is_async_module(self: Vc) -> Result> { + let this = self.await?; + let result = this.full_module.failsafe_analyze(); + + if let Some(async_module) = *result.await?.async_module.await? { + Ok(async_module.is_self_async(self.references())) + } else { + Ok(Vc::cell(false)) + } + } } #[turbo_tasks::value_impl] @@ -51,28 +65,90 @@ impl Module for EcmascriptModulePartAsset { #[turbo_tasks::function] async fn ident(&self) -> Result> { let inner = self.full_module.ident(); + let result = split_module(self.full_module); - Ok(inner.with_part(self.part)) + match &*result.await? { + SplitResult::Ok { .. } => Ok(inner.with_part(self.part)), + SplitResult::Failed { .. } => Ok(inner), + } } #[turbo_tasks::function] async fn references(&self) -> Result> { let split_data = split_module(self.full_module).await?; - let deps = match &*split_data { - SplitResult::Ok { deps, .. } => deps, - _ => { - bail!("failed to split module") - } + let analyze = analyze(self.full_module, self.part).await?; + + let (deps, entrypoints) = match &*split_data { + SplitResult::Ok { + deps, entrypoints, .. + } => (deps, entrypoints), + SplitResult::Failed { .. } => return Ok(analyze.references), }; - let part_id = get_part_id(&split_data, self.part) - .await - .with_context(|| format!("part {:?} is not found in the module", self.part))?; + // Facade depends on evaluation and re-exports + if matches!(&*self.part.await?, ModulePart::Facade) { + let mut references = vec![]; + + let reference = Vc::upcast(SingleModuleReference::new( + Vc::upcast(EcmascriptModulePartAsset::new( + self.full_module, + ModulePart::evaluation(), + self.import_externals, + )), + Vc::cell("ecmascript module evaluation".to_string()), + )); + + references.push(reference); + + let reference = Vc::upcast(SingleModuleReference::new( + Vc::upcast(EcmascriptModulePartAsset::new( + self.full_module, + ModulePart::exports(), + self.import_externals, + )), + Vc::cell("ecmascript reexports".to_string()), + )); - let deps = match deps.get(&part_id) { - Some(v) => v, - None => bail!("part {:?} is not found in the module", part_id), + references.push(reference); + + references.extend(analyze.references.await?.iter().cloned()); + + return Ok(Vc::cell(references)); + } + + // ModulePart::Exports contains all reexports and a reexport of the Locals + if matches!(&*self.part.await?, ModulePart::Exports) { + let mut references = vec![]; + + for key in entrypoints.keys() { + if let Key::Export(e) = key { + let reference = Vc::upcast(SingleModuleReference::new( + Vc::upcast(EcmascriptModulePartAsset::new( + self.full_module, + ModulePart::export(e.clone()), + self.import_externals, + )), + Vc::cell(format!("ecmascript export '{e}'")), + )); + + references.push(reference); + } + } + + references.extend(analyze.references.await?.iter().cloned()); + + return Ok(Vc::cell(references)); + } + let deps = { + let part_id = get_part_id(&split_data, self.part) + .await + .with_context(|| format!("part {:?} is not found in the module", self.part))?; + + match deps.get(&part_id) { + Some(v) => &**v, + None => &[], + } }; let mut assets = deps @@ -89,8 +165,6 @@ impl Module for EcmascriptModulePartAsset { }) .collect::>>()?; - let analyze = analyze(self.full_module, self.part).await?; - assets.extend(analyze.references.await?.iter().cloned()); Ok(Vc::cell(assets)) @@ -101,9 +175,7 @@ impl Module for EcmascriptModulePartAsset { impl Asset for EcmascriptModulePartAsset { #[turbo_tasks::function] fn content(&self) -> Vc { - // This is not reachable because EcmascriptModulePartAsset implements - // ChunkableModule and ChunkableModule::as_chunk is called instead. - todo!("EcmascriptModulePartAsset::content is not implemented") + todo!() } } @@ -149,3 +221,6 @@ async fn analyze( ) -> Result> { Ok(analyse_ecmascript_module(module, Some(part))) } + +#[turbo_tasks::value_impl] +impl EvaluatableAsset for EcmascriptModulePartAsset {} diff --git a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index 9bd514b1d2f1f..61095d9c1ba6e 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -101,4 +101,9 @@ impl ChunkItem for EcmascriptModulePartChunkItem { fn module(&self) -> Vc> { Vc::upcast(self.module) } + + #[turbo_tasks::function] + fn is_self_async(&self) -> Vc { + self.module.is_async_module() + } } diff --git a/crates/turbopack-ecmascript/src/tree_shake/cjs_finder.rs b/crates/turbopack-ecmascript/src/tree_shake/cjs_finder.rs new file mode 100644 index 0000000000000..9cf44e8983818 --- /dev/null +++ b/crates/turbopack-ecmascript/src/tree_shake/cjs_finder.rs @@ -0,0 +1,11 @@ +use swc_core::ecma::ast::*; + +pub fn contains_cjs(m: &Program) -> bool { + if let Program::Module(m) = m { + if m.body.iter().any(|s| s.is_module_decl()) { + return false; + } + } + + true +} diff --git a/crates/turbopack-ecmascript/src/tree_shake/graph.rs b/crates/turbopack-ecmascript/src/tree_shake/graph.rs index 12b8b5998b9b0..1b6fd75f98850 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/graph.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/graph.rs @@ -10,23 +10,25 @@ use petgraph::{ }; use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; use swc_core::{ - common::{util::take::Take, DUMMY_SP}, + common::{util::take::Take, SyntaxContext, DUMMY_SP}, ecma::{ ast::{ - op, ClassDecl, Decl, ExportDecl, ExportNamedSpecifier, ExportSpecifier, Expr, ExprStmt, - FnDecl, Id, Ident, ImportDecl, ImportNamedSpecifier, ImportSpecifier, KeyValueProp, - Lit, Module, ModuleDecl, ModuleExportName, ModuleItem, NamedExport, ObjectLit, Prop, - PropName, PropOrSpread, Stmt, VarDecl, + op, ClassDecl, Decl, DefaultDecl, ExportDecl, ExportNamedSpecifier, ExportSpecifier, + Expr, ExprStmt, FnDecl, Id, Ident, ImportDecl, ImportNamedSpecifier, ImportSpecifier, + ImportStarAsSpecifier, KeyValueProp, Lit, Module, ModuleDecl, ModuleExportName, + ModuleItem, NamedExport, ObjectLit, Prop, PropName, PropOrSpread, Stmt, VarDecl, + VarDeclKind, VarDeclarator, }, - atoms::{js_word, JsWord}, - utils::{find_pat_ids, quote_ident}, + atoms::JsWord, + utils::{find_pat_ids, private_ident, quote_ident, IdentExt}, }, }; use super::{ util::{ids_captured_by, ids_used_by, ids_used_by_ignoring_nested}, - Key, + Key, TURBOPACK_PART_IMPORT_SOURCE, }; +use crate::magic_identifier; /// The id of an item #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -38,7 +40,8 @@ pub(crate) enum ItemId { #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub(crate) enum ItemIdGroupKind { ModuleEvaluation, - Export(Id), + /// `(local, export_name)`` + Export(Id, JsWord), } #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -104,7 +107,7 @@ pub(crate) struct ItemData { pub content: ModuleItem, - pub export: Option, + pub export: Option, } impl Default for ItemData { @@ -217,17 +220,23 @@ impl DepGraph { /// a usage side, `import` and `export` will be added. /// /// Note: ESM imports are immutable, but we do not handle it. - pub(super) fn split_module( - &self, - uri_of_module: &JsWord, - data: &FxHashMap, - ) -> SplitModuleResult { + pub(super) fn split_module(&self, data: &FxHashMap) -> SplitModuleResult { let groups = self.finalize(data); let mut exports = FxHashMap::default(); let mut part_deps = FxHashMap::<_, Vec<_>>::default(); let mut modules = vec![]; + if groups.graph_ix.is_empty() { + // If there's no dependency, all nodes are in the module evaluaiotn group. + modules.push(Module { + span: DUMMY_SP, + body: data.values().map(|v| v.content.clone()).collect(), + shebang: None, + }); + exports.insert(Key::ModuleEvaluation, 0); + } + for (ix, group) in groups.graph_ix.iter().enumerate() { let mut chunk = Module { span: DUMMY_SP, @@ -248,18 +257,27 @@ impl DepGraph { }) .collect::>(); + for id in group { + let data = data.get(id).unwrap(); + + for var in data.var_decls.iter() { + required_vars.remove(var); + } + } + for item in group { match item { - ItemId::Group(ItemIdGroupKind::Export(id)) => { + ItemId::Group(ItemIdGroupKind::Export(id, _)) => { required_vars.insert(id); if let Some(export) = &data[item].export { - exports.insert(Key::Export(export.0.to_string()), ix as u32); + exports.insert(Key::Export(export.to_string()), ix as u32); } } ItemId::Group(ItemIdGroupKind::ModuleEvaluation) => { exports.insert(Key::ModuleEvaluation, ix as u32); } + _ => {} } } @@ -270,10 +288,10 @@ impl DepGraph { { let mut specifiers = vec![]; - let deps = groups.graph_ix.get_index(dep as usize).unwrap(); + let dep_items = groups.graph_ix.get_index(dep as usize).unwrap(); - for dep in deps { - let data = data.get(dep).unwrap(); + for dep_item in dep_items { + let data = data.get(dep_item).unwrap(); for var in data.var_decls.iter().chain(data.write_vars.iter()) { if required_vars.remove(var) { @@ -294,9 +312,11 @@ impl DepGraph { .push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { span: DUMMY_SP, specifiers, - src: Box::new(uri_of_module.clone().into()), + src: Box::new(TURBOPACK_PART_IMPORT_SOURCE.into()), type_only: false, - with: Some(Box::new(create_turbopack_chunk_id_assert(dep))), + with: Some(Box::new(create_turbopack_part_id_assert(PartId::Internal( + dep, + )))), phase: Default::default(), }))); } @@ -310,7 +330,10 @@ impl DepGraph { // Emit `export { foo }` for var in data.write_vars.iter() { - if required_vars.remove(var) { + if required_vars.remove(var) + || data.read_vars.contains(var) + || data.var_decls.contains(var) + { let assertion_prop = PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { key: quote_ident!("__turbopack_var__").into(), @@ -330,7 +353,11 @@ impl DepGraph { is_type_only: false, }, )], - src: None, + src: if cfg!(test) { + Some(Box::new("__TURBOPACK_VAR__".into())) + } else { + None + }, type_only: false, with: Some(Box::new(ObjectLit { span: DUMMY_SP, @@ -478,7 +505,8 @@ impl DepGraph { // We need to sort, because we start from the group item and add others start // from them. But the final module should be in the order of the original code. for group in groups.iter_mut() { - group.sort() + group.sort(); + group.dedup(); } let mut new_graph = InternedGraph::default(); @@ -521,7 +549,12 @@ impl DepGraph { } /// Fills information per module items - pub(super) fn init(&mut self, module: &Module) -> (Vec, FxHashMap) { + pub(super) fn init( + &mut self, + module: &Module, + unresolved_ctxt: SyntaxContext, + top_level_ctxt: SyntaxContext, + ) -> (Vec, FxHashMap) { let mut exports = vec![]; let mut items = FxHashMap::default(); let mut ids = vec![]; @@ -532,49 +565,242 @@ impl DepGraph { match item { ModuleDecl::ExportDecl(item) => match &item.decl { Decl::Fn(FnDecl { ident, .. }) | Decl::Class(ClassDecl { ident, .. }) => { - exports.push(ident.to_id()); + exports.push((ident.to_id(), None)); } Decl::Var(v) => { for decl in &v.decls { let ids: Vec = find_pat_ids(&decl.name); for id in ids { - exports.push(id); + exports.push((id, None)); } } } _ => {} }, - ModuleDecl::ExportNamed(NamedExport { - src, specifiers, .. - }) if src.is_none() => { - // We are not interested in re-exports. - for s in specifiers { - match s { - ExportSpecifier::Named(s) => { + ModuleDecl::ExportNamed(item) => { + if let Some(src) = &item.src { + // One item for the import for re-export + let id = ItemId::Item { + index, + kind: ItemIdItemKind::ImportOfModule, + }; + ids.push(id.clone()); + items.insert( + id, + ItemData { + is_hoisted: true, + side_effects: true, + content: ModuleItem::ModuleDecl(ModuleDecl::Import( + ImportDecl { + specifiers: Default::default(), + src: src.clone(), + ..ImportDecl::dummy() + }, + )), + ..Default::default() + }, + ); + } + + for (si, s) in item.specifiers.iter().enumerate() { + let (orig, mut local, exported) = match s { + ExportSpecifier::Named(s) => ( + Some(s.orig.clone()), match s.exported.as_ref().unwrap_or(&s.orig) { - ModuleExportName::Ident(i) => { - exports.push(i.to_id()); - } - ModuleExportName::Str(..) => {} - } - } - ExportSpecifier::Default(..) => { - exports.push((js_word!("default"), Default::default())); - } - ExportSpecifier::Namespace(s) => match &s.name { - ModuleExportName::Ident(i) => { - exports.push(i.to_id()); + ModuleExportName::Ident(i) => i.clone(), + ModuleExportName::Str(..) => quote_ident!("_tmp"), + }, + Some(s.exported.clone().unwrap_or_else(|| s.orig.clone())), + ), + ExportSpecifier::Default(s) => ( + Some(ModuleExportName::Ident(Ident::new( + "default".into(), + DUMMY_SP, + ))), + quote_ident!("default"), + Some(ModuleExportName::Ident(s.exported.clone())), + ), + ExportSpecifier::Namespace(s) => ( + None, + match &s.name { + ModuleExportName::Ident(i) => i.clone(), + ModuleExportName::Str(..) => quote_ident!("_tmp"), + }, + Some(s.name.clone()), + ), + }; + + if item.src.is_some() { + local.sym = + magic_identifier::mangle(&format!("reexport {}", local.sym)) + .into(); + local = local.private(); + } + + exports.push((local.to_id(), exported.clone())); + + if let Some(src) = &item.src { + let id = ItemId::Item { + index, + kind: ItemIdItemKind::ImportBinding(si as _), + }; + ids.push(id.clone()); + + let import = match s { + ExportSpecifier::Namespace(..) => { + ImportSpecifier::Namespace(ImportStarAsSpecifier { + span: DUMMY_SP, + local: local.clone(), + }) } - ModuleExportName::Str(..) => {} - }, + _ => ImportSpecifier::Named(ImportNamedSpecifier { + span: DUMMY_SP, + local: local.clone(), + imported: orig, + is_type_only: false, + }), + }; + items.insert( + id, + ItemData { + is_hoisted: true, + var_decls: [local.to_id()].into_iter().collect(), + pure: true, + content: ModuleItem::ModuleDecl(ModuleDecl::Import( + ImportDecl { + span: DUMMY_SP, + specifiers: vec![import], + src: src.clone(), + type_only: false, + with: None, + phase: Default::default(), + }, + )), + ..Default::default() + }, + ); } } } - ModuleDecl::ExportDefaultDecl(_) | ModuleDecl::ExportDefaultExpr(_) => { - exports.push((js_word!("default"), Default::default())); + + ModuleDecl::ExportDefaultDecl(export) => { + let id = match &export.decl { + DefaultDecl::Class(c) => c.ident.clone(), + DefaultDecl::Fn(f) => f.ident.clone(), + DefaultDecl::TsInterfaceDecl(_) => unreachable!(), + }; + + let default_var = id.unwrap_or_else(|| { + private_ident!(magic_identifier::mangle("default export")) + }); + + { + let used_ids = ids_used_by_ignoring_nested( + &export.decl, + [unresolved_ctxt, top_level_ctxt], + ); + let captured_ids = + ids_captured_by(&export.decl, [unresolved_ctxt, top_level_ctxt]); + let data = ItemData { + read_vars: used_ids.read, + eventual_read_vars: captured_ids.read, + write_vars: used_ids.write, + eventual_write_vars: captured_ids.write, + var_decls: [default_var.to_id()].into_iter().collect(), + side_effects: true, + content: ModuleItem::ModuleDecl(item.clone()), + ..Default::default() + }; + + let id = ItemId::Item { + index, + kind: ItemIdItemKind::Normal, + }; + ids.push(id.clone()); + items.insert(id, data); + } + + exports.push(( + default_var.to_id(), + Some(ModuleExportName::Ident(quote_ident!("default"))), + )); + } + ModuleDecl::ExportDefaultExpr(export) => { + let default_var = + private_ident!(magic_identifier::mangle("default export")); + + { + // For + // let __TURBOPACK_default_export__ = expr; + + let mut used_ids = ids_used_by_ignoring_nested( + &export.expr, + [unresolved_ctxt, top_level_ctxt], + ); + let captured_ids = + ids_captured_by(&export.expr, [unresolved_ctxt, top_level_ctxt]); + + used_ids.write.insert(default_var.to_id()); + + let data = ItemData { + read_vars: used_ids.read, + eventual_read_vars: captured_ids.read, + write_vars: used_ids.write, + eventual_write_vars: captured_ids.write, + var_decls: [default_var.to_id()].into_iter().collect(), + side_effects: true, + content: ModuleItem::Stmt(Stmt::Decl(Decl::Var(Box::new( + VarDecl { + span: DUMMY_SP, + kind: VarDeclKind::Const, + declare: false, + decls: vec![VarDeclarator { + span: DUMMY_SP, + name: default_var.clone().into(), + init: Some(export.expr.clone()), + definite: false, + }], + }, + )))), + ..Default::default() + }; + + let id = ItemId::Item { + index, + kind: ItemIdItemKind::Normal, + }; + ids.push(id.clone()); + items.insert(id, data); + } + + { + // For export default __TURBOPACK__default__export__ + + exports.push(( + default_var.to_id(), + Some(ModuleExportName::Ident(quote_ident!("default"))), + )); + } } - ModuleDecl::ExportAll(_) => { - // noop as this is a reexport. + + ModuleDecl::ExportAll(item) => { + // One item for the import for re-export + let id = ItemId::Item { + index, + kind: ItemIdItemKind::ImportOfModule, + }; + ids.push(id.clone()); + items.insert( + id, + ItemData { + is_hoisted: true, + side_effects: true, + content: ModuleItem::ModuleDecl(ModuleDecl::ExportAll( + item.clone(), + )), + ..Default::default() + }, + ); } _ => {} } @@ -632,6 +858,7 @@ impl DepGraph { ); } } + ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { decl: Decl::Fn(f), .. @@ -643,24 +870,55 @@ impl DepGraph { }; ids.push(id.clone()); - let vars = ids_used_by(&f.function); + let vars = ids_used_by(&f.function, [unresolved_ctxt, top_level_ctxt]); + let var_decls = { + let mut v = IndexSet::with_capacity_and_hasher(1, Default::default()); + v.insert(f.ident.to_id()); + v + }; items.insert( id, ItemData { is_hoisted: true, eventual_read_vars: vars.read, eventual_write_vars: vars.write, - var_decls: { - let mut v = - IndexSet::with_capacity_and_hasher(1, Default::default()); - v.insert(f.ident.to_id()); - v - }, + write_vars: var_decls.clone(), + var_decls, content: ModuleItem::Stmt(Stmt::Decl(Decl::Fn(f.clone()))), ..Default::default() }, ); } + ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { + decl: Decl::Class(c), + .. + })) + | ModuleItem::Stmt(Stmt::Decl(Decl::Class(c))) => { + let id = ItemId::Item { + index, + kind: ItemIdItemKind::Normal, + }; + ids.push(id.clone()); + + let vars = ids_used_by(&c.class, [unresolved_ctxt, top_level_ctxt]); + let var_decls = { + let mut v = IndexSet::with_capacity_and_hasher(1, Default::default()); + v.insert(c.ident.to_id()); + v + }; + items.insert( + id, + ItemData { + is_hoisted: true, + eventual_read_vars: vars.read, + eventual_write_vars: vars.write, + write_vars: var_decls.clone(), + var_decls, + content: ModuleItem::Stmt(Stmt::Decl(Decl::Class(c.clone()))), + ..Default::default() + }, + ); + } ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { decl: Decl::Var(v), .. @@ -674,8 +932,12 @@ impl DepGraph { ids.push(id.clone()); let decl_ids: Vec = find_pat_ids(&decl.name); - let vars = ids_used_by_ignoring_nested(&decl.init); - let eventual_vars = ids_captured_by(&decl.init); + let vars = ids_used_by_ignoring_nested( + &decl.init, + [unresolved_ctxt, top_level_ctxt], + ); + let eventual_vars = + ids_captured_by(&decl.init, [unresolved_ctxt, top_level_ctxt]); let var_decl = Box::new(VarDecl { decls: vec![decl.clone()], @@ -701,21 +963,34 @@ impl DepGraph { expr: box Expr::Assign(assign), .. })) => { - let mut used_ids = ids_used_by_ignoring_nested(item); - let captured_ids = ids_captured_by(item); + let mut used_ids = + ids_used_by_ignoring_nested(item, [unresolved_ctxt, top_level_ctxt]); + let captured_ids = ids_captured_by(item, [unresolved_ctxt, top_level_ctxt]); if assign.op != op!("=") { - let extra_ids = ids_used_by_ignoring_nested(&assign.left); + used_ids.read.extend(used_ids.write.iter().cloned()); + + let extra_ids = ids_used_by_ignoring_nested( + &assign.left, + [unresolved_ctxt, top_level_ctxt], + ); used_ids.read.extend(extra_ids.read); used_ids.write.extend(extra_ids.write); } + let side_effects = used_ids + .read + .iter() + .chain(used_ids.write.iter()) + .any(|id| id.1 == unresolved_ctxt); + let data = ItemData { read_vars: used_ids.read, eventual_read_vars: captured_ids.read, write_vars: used_ids.write, eventual_write_vars: captured_ids.write, content: item.clone(), + side_effects, ..Default::default() }; @@ -726,11 +1001,19 @@ impl DepGraph { ids.push(id.clone()); items.insert(id, data); } + + ModuleItem::ModuleDecl( + ModuleDecl::ExportDefaultDecl(..) + | ModuleDecl::ExportDefaultExpr(..) + | ModuleDecl::ExportNamed(NamedExport { src: Some(..), .. }), + ) => {} + _ => { // Default to normal - let used_ids = ids_used_by_ignoring_nested(item); - let captured_ids = ids_captured_by(item); + let used_ids = + ids_used_by_ignoring_nested(item, [unresolved_ctxt, top_level_ctxt]); + let captured_ids = ids_captured_by(item, [unresolved_ctxt, top_level_ctxt]); let data = ItemData { read_vars: used_ids.read, eventual_read_vars: captured_ids.read, @@ -767,8 +1050,12 @@ impl DepGraph { ); } - for export in exports { - let id = ItemId::Group(ItemIdGroupKind::Export(export.clone())); + for (local, export_name) in exports { + let name = match &export_name { + Some(ModuleExportName::Ident(v)) => v.to_id(), + _ => local.clone(), + }; + let id = ItemId::Group(ItemIdGroupKind::Export(local.clone(), name.0.clone())); ids.push(id.clone()); items.insert( id.clone(), @@ -777,15 +1064,15 @@ impl DepGraph { span: DUMMY_SP, specifiers: vec![ExportSpecifier::Named(ExportNamedSpecifier { span: DUMMY_SP, - orig: ModuleExportName::Ident(export.clone().into()), - exported: None, + orig: ModuleExportName::Ident(local.clone().into()), + exported: export_name, is_type_only: false, })], src: None, type_only: false, with: None, })), - export: Some(export.clone()), + export: Some(name.0), ..Default::default() }, ); @@ -798,10 +1085,11 @@ impl DepGraph { where T: IntoIterator, { - let mut from_ix = None; + // This value cannot be lazily initialized because we need to ensure that + // ModuleEvaluation exists even if there's no side effect. + let from = self.g.node(from); for to in to { - let from = *from_ix.get_or_insert_with(|| self.g.node(from)); let to = self.g.node(to); self.g.idx_graph.add_edge(from, to, Dependency::Strong); @@ -834,24 +1122,47 @@ impl DepGraph { } } -const ASSERT_CHUNK_KEY: &str = "__turbopack_chunk__"; +const ASSERT_CHUNK_KEY: &str = "__turbopack_part__"; + +#[derive(Debug, Clone)] +pub(crate) enum PartId { + ModuleEvaluation, + Exports, + Export(String), + Internal(u32), +} -fn create_turbopack_chunk_id_assert(dep: u32) -> ObjectLit { +pub(crate) fn create_turbopack_part_id_assert(dep: PartId) -> ObjectLit { + // We can't use quote! as `with` is not standard yet ObjectLit { span: DUMMY_SP, props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { key: PropName::Ident(Ident::new(ASSERT_CHUNK_KEY.into(), DUMMY_SP)), - value: (dep as f64).into(), + value: match dep { + PartId::ModuleEvaluation => "module evaluation".into(), + PartId::Exports => "exports".into(), + PartId::Export(e) => format!("export {e}").into(), + PartId::Internal(dep) => (dep as f64).into(), + }, })))], } } -pub(crate) fn find_turbopack_chunk_id_in_asserts(asserts: &ObjectLit) -> Option { +pub(crate) fn find_turbopack_part_id_in_asserts(asserts: &ObjectLit) -> Option { asserts.props.iter().find_map(|prop| match prop { PropOrSpread::Prop(box Prop::KeyValue(KeyValueProp { key: PropName::Ident(key), value: box Expr::Lit(Lit::Num(chunk_id)), - })) if &*key.sym == ASSERT_CHUNK_KEY => Some(chunk_id.value as u32), + })) if &*key.sym == ASSERT_CHUNK_KEY => Some(PartId::Internal(chunk_id.value as u32)), + + PropOrSpread::Prop(box Prop::KeyValue(KeyValueProp { + key: PropName::Ident(key), + value: box Expr::Lit(Lit::Str(s)), + })) if &*key.sym == ASSERT_CHUNK_KEY => match &*s.value { + "module evaluation" => Some(PartId::ModuleEvaluation), + "exports" => Some(PartId::Exports), + _ => None, + }, _ => None, }) } diff --git a/crates/turbopack-ecmascript/src/tree_shake/merge.rs b/crates/turbopack-ecmascript/src/tree_shake/merge.rs index 984dbf95f56b1..282b1bb3fab3e 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/merge.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/merge.rs @@ -5,7 +5,7 @@ use swc_core::ecma::{ atoms::JsWord, }; -use super::graph::find_turbopack_chunk_id_in_asserts; +use super::{graph::find_turbopack_part_id_in_asserts, PartId}; /// A loader used to merge module items after splitting. pub trait Load { @@ -51,9 +51,9 @@ where let part_id = import .with .as_deref() - .and_then(find_turbopack_chunk_id_in_asserts); + .and_then(find_turbopack_part_id_in_asserts); - if let Some(part_id) = part_id { + if let Some(PartId::Internal(part_id)) = part_id { if self.done.insert((import.src.value.clone(), part_id)) { if let Some(dep) = self.loader.load(&import.src.value, part_id)? { let mut dep = self.merge_recursively(dep)?; diff --git a/crates/turbopack-ecmascript/src/tree_shake/mod.rs b/crates/turbopack-ecmascript/src/tree_shake/mod.rs index 1ec0c85417cf8..49c8c18cf0815 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/mod.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/mod.rs @@ -1,25 +1,35 @@ +use std::borrow::Cow; + use anyhow::{bail, Result}; use indexmap::IndexSet; use rustc_hash::FxHashMap; -use swc_core::ecma::ast::{Id, Module, Program}; -use turbo_tasks::Vc; -use turbo_tasks_fs::FileSystemPath; -use turbopack_core::{ - resolve::{origin::ResolveOrigin, ModulePart}, - source::Source, +use swc_core::{ + common::{util::take::Take, SyntaxContext, DUMMY_SP, GLOBALS}, + ecma::ast::{ + ExportNamedSpecifier, Id, Ident, ImportDecl, Module, ModuleDecl, ModuleExportName, + ModuleItem, NamedExport, Program, + }, }; +use turbo_tasks::{ValueToString, Vc}; +use turbopack_core::{ident::AssetIdent, resolve::ModulePart, source::Source}; +pub(crate) use self::graph::{ + create_turbopack_part_id_assert, find_turbopack_part_id_in_asserts, PartId, +}; use self::graph::{DepGraph, ItemData, ItemId, ItemIdGroupKind, Mode, SplitModuleResult}; use crate::{analyzer::graph::EvalContext, parse::ParseResult, EcmascriptModuleAsset}; pub mod asset; pub mod chunk_item; +mod cjs_finder; mod graph; pub mod merge; #[cfg(test)] mod tests; mod util; +pub(crate) const TURBOPACK_PART_IMPORT_SOURCE: &str = "__TURBOPACK_PART__"; + pub struct Analyzer<'a> { g: &'a mut DepGraph, item_ids: &'a Vec, @@ -30,7 +40,7 @@ pub struct Analyzer<'a> { vars: FxHashMap, } -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] struct VarState { /// The module items that might trigger side effects on that variable. /// We also store if this is a `const` write, so no further change will @@ -40,10 +50,22 @@ struct VarState { last_reads: Vec, } +fn get_var<'a>(map: &'a FxHashMap, id: &Id) -> Cow<'a, VarState> { + let v = map.get(id); + match v { + Some(v) => Cow::Borrowed(v), + None => Cow::Owned(Default::default()), + } +} + impl Analyzer<'_> { - pub(super) fn analyze(module: &Module) -> (DepGraph, FxHashMap) { + pub(super) fn analyze( + module: &Module, + unresolved_ctxt: SyntaxContext, + top_level_ctxt: SyntaxContext, + ) -> (DepGraph, FxHashMap) { let mut g = DepGraph::default(); - let (item_ids, mut items) = g.init(module); + let (item_ids, mut items) = g.init(module, unresolved_ctxt, top_level_ctxt); let mut analyzer = Analyzer { g: &mut g, @@ -53,7 +75,7 @@ impl Analyzer<'_> { vars: Default::default(), }; - let eventual_ids = analyzer.hoist_vars_and_bindings(module); + let eventual_ids = analyzer.hoist_vars_and_bindings(); analyzer.evaluate_immediate(module, &eventual_ids); @@ -68,7 +90,7 @@ impl Analyzer<'_> { /// /// /// Returns all (EVENTUAL_READ/WRITE_VARS) in the module. - fn hoist_vars_and_bindings(&mut self, _module: &Module) -> IndexSet { + fn hoist_vars_and_bindings(&mut self) -> IndexSet { let mut eventual_ids = IndexSet::default(); for item_id in self.item_ids.iter() { @@ -114,9 +136,9 @@ impl Analyzer<'_> { // var. // (the writes need to be executed before this read) - if let Some(state) = self.vars.get(id) { - self.g.add_strong_deps(item_id, state.last_writes.iter()); - } + let state = get_var(&self.vars, id); + + self.g.add_strong_deps(item_id, state.last_writes.iter()); } // For each var in WRITE_VARS: @@ -127,9 +149,8 @@ impl Analyzer<'_> { // (the reads need to be executed before this write, when // it’s needed) - if let Some(state) = self.vars.get(id) { - self.g.add_weak_deps(item_id, state.last_reads.iter()); - } + let state = get_var(&self.vars, id); + self.g.add_weak_deps(item_id, state.last_reads.iter()); } if item.side_effects { @@ -141,10 +162,10 @@ impl Analyzer<'_> { // Create weak dependencies to all LAST_WRITES and // LAST_READS. for id in eventual_ids.iter() { - if let Some(state) = self.vars.get(id) { - self.g.add_weak_deps(item_id, state.last_writes.iter()); - self.g.add_weak_deps(item_id, state.last_reads.iter()); - } + let state = get_var(&self.vars, id); + + self.g.add_weak_deps(item_id, state.last_writes.iter()); + self.g.add_weak_deps(item_id, state.last_reads.iter()); } } @@ -195,9 +216,8 @@ impl Analyzer<'_> { // Create a strong dependency to all module items listed in // LAST_WRITES for that var. - if let Some(state) = self.vars.get(id) { - self.g.add_strong_deps(item_id, state.last_writes.iter()); - } + let state = get_var(&self.vars, id); + self.g.add_strong_deps(item_id, state.last_writes.iter()); } // For each var in EVENTUAL_WRITE_VARS: @@ -205,9 +225,9 @@ impl Analyzer<'_> { // Create a weak dependency to all module items listed in // LAST_READS for that var. - if let Some(state) = self.vars.get(id) { - self.g.add_weak_deps(item_id, state.last_reads.iter()); - } + let state = get_var(&self.vars, id); + + self.g.add_weak_deps(item_id, state.last_reads.iter()); } // (no state update happens, since this is only triggered by @@ -227,12 +247,12 @@ impl Analyzer<'_> { self.g .add_strong_deps(item_id, self.last_side_effects.iter()); } - ItemIdGroupKind::Export(id) => { + ItemIdGroupKind::Export(local, _) => { // Create a strong dependency to LAST_WRITES for this var - if let Some(state) = self.vars.get(id) { - self.g.add_strong_deps(item_id, state.last_writes.iter()); - } + let state = get_var(&self.vars, local); + + self.g.add_strong_deps(item_id, state.last_writes.iter()); } } } @@ -272,7 +292,18 @@ async fn get_part_id(result: &SplitResult, part: Vc) -> Result let part_id = match entrypoints.get(&key) { Some(id) => *id, None => { - bail!("could not find part id for module part {:?}", key) + // We need to handle `*` reexports specially. + if let ModulePart::Export(..) = &*part { + if let Some(&part_id) = entrypoints.get(&Key::ModuleEvaluation) { + return Ok(part_id); + } + } + + bail!( + "could not find part id for module part {:?} in {:?}", + key, + entrypoints + ) } }; @@ -282,18 +313,21 @@ async fn get_part_id(result: &SplitResult, part: Vc) -> Result #[turbo_tasks::value(shared, serialization = "none", eq = "manual")] pub(crate) enum SplitResult { Ok { + asset_ident: Vc, + /// `u32` is a index to `modules`. - #[turbo_tasks(debug_ignore, trace_ignore)] + #[turbo_tasks(trace_ignore)] entrypoints: FxHashMap, #[turbo_tasks(debug_ignore, trace_ignore)] modules: Vec>, - #[turbo_tasks(debug_ignore, trace_ignore)] + #[turbo_tasks(trace_ignore)] deps: FxHashMap>, }, - Unparseable, - NotFound, + Failed { + parse_result: Vc, + }, } impl PartialEq for SplitResult { @@ -306,29 +340,47 @@ impl PartialEq for SplitResult { } #[turbo_tasks::function] -pub(super) fn split_module(asset: Vc) -> Vc { - split(asset.origin_path(), asset.source(), asset.parse()) +pub(super) async fn split_module(asset: Vc) -> Result> { + Ok(split(asset.source().ident(), asset.source(), asset.parse())) } #[turbo_tasks::function] pub(super) async fn split( - path: Vc, + ident: Vc, source: Vc>, parsed: Vc, ) -> Result> { - let filename = path.await?.file_name().to_string(); let parse_result = parsed.await?; match &*parse_result { ParseResult::Ok { - program: Program::Module(module), + program, comments, eval_context, source_map, globals, .. } => { - let (mut dep_graph, items) = Analyzer::analyze(module); + // If the script file is a common js file, we cannot split the module + if cjs_finder::contains_cjs(program) { + return Ok(SplitResult::Failed { + parse_result: parsed, + } + .cell()); + } + + let module = match program { + Program::Module(module) => module, + Program::Script(..) => unreachable!("CJS is already handled"), + }; + + let (mut dep_graph, items) = GLOBALS.set(globals, || { + Analyzer::analyze( + module, + SyntaxContext::empty().apply_mark(eval_context.unresolved_mark), + SyntaxContext::empty().apply_mark(eval_context.top_level_mark), + ) + }); dep_graph.handle_weak(Mode::Production); @@ -336,14 +388,35 @@ pub(super) async fn split( entrypoints, part_deps, modules, - } = dep_graph.split_module(&format!("./{filename}").into(), &items); + } = dep_graph.split_module(&items); + + assert_ne!(modules.len(), 0, "modules.len() == 0;\nModule: {module:?}",); + assert_eq!( + entrypoints.get(&Key::ModuleEvaluation), + Some(&0), + "ModuleEvaluation is not the first module" + ); + + for &v in entrypoints.values() { + assert!( + v < modules.len() as u32, + "Invalid entrypoint '{}' while there are only '{}' modules", + v, + modules.len() + ); + } let modules = modules .into_iter() .map(|module| { let program = Program::Module(module); - let eval_context = - EvalContext::new(&program, eval_context.unresolved_mark, Some(source)); + let eval_context = EvalContext::new( + &program, + eval_context.unresolved_mark, + eval_context.top_level_mark, + false, + Some(source), + ); ParseResult::cell(ParseResult::Ok { program, @@ -356,14 +429,18 @@ pub(super) async fn split( .collect(); Ok(SplitResult::Ok { + asset_ident: ident, entrypoints, deps: part_deps, modules, } .cell()) } - ParseResult::NotFound => Ok(SplitResult::NotFound.cell()), - _ => Ok(SplitResult::Unparseable.cell()), + + _ => Ok(SplitResult::Failed { + parse_result: parsed, + } + .cell()), } } @@ -375,12 +452,186 @@ pub(super) async fn part_of_module( let split_data = split_data.await?; match &*split_data { - SplitResult::Ok { modules, .. } => { + SplitResult::Ok { + asset_ident, + modules, + entrypoints, + deps, + .. + } => { + debug_assert_ne!(modules.len(), 0, "modules.len() == 0"); + + if matches!(&*part.await?, ModulePart::Facade) { + if let ParseResult::Ok { + comments, + eval_context, + globals, + source_map, + .. + } = &*modules[0].await? + { + let mut module = Module::dummy(); + + let mut export_names = entrypoints + .keys() + .filter_map(|key| { + if let Key::Export(v) = key { + Some(v.clone()) + } else { + None + } + }) + .collect::>(); + export_names.sort(); + + module + .body + .push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + span: DUMMY_SP, + specifiers: vec![], + src: Box::new(TURBOPACK_PART_IMPORT_SOURCE.into()), + type_only: false, + with: Some(Box::new(create_turbopack_part_id_assert( + PartId::ModuleEvaluation, + ))), + phase: Default::default(), + }))); + + let specifiers = export_names + .into_iter() + .map(|export_name| { + swc_core::ecma::ast::ExportSpecifier::Named(ExportNamedSpecifier { + span: DUMMY_SP, + orig: ModuleExportName::Ident(Ident::new( + export_name.into(), + DUMMY_SP, + )), + exported: None, + is_type_only: false, + }) + }) + .collect::>(); + + module + .body + .push(ModuleItem::ModuleDecl(ModuleDecl::ExportNamed( + NamedExport { + span: DUMMY_SP, + specifiers, + src: Some(Box::new(TURBOPACK_PART_IMPORT_SOURCE.into())), + type_only: false, + with: Some(Box::new(create_turbopack_part_id_assert( + PartId::Exports, + ))), + }, + ))); + + let program = Program::Module(module); + let eval_context = EvalContext::new( + &program, + eval_context.unresolved_mark, + eval_context.top_level_mark, + true, + None, + ); + return Ok(ParseResult::Ok { + program, + comments: comments.clone(), + eval_context, + globals: globals.clone(), + source_map: source_map.clone(), + } + .cell()); + } else { + unreachable!() + } + } + + if matches!(&*part.await?, ModulePart::Exports) { + if let ParseResult::Ok { + comments, + eval_context, + globals, + source_map, + .. + } = &*modules[0].await? + { + let mut export_names = entrypoints + .keys() + .filter_map(|key| { + if let Key::Export(v) = key { + Some(v.clone()) + } else { + None + } + }) + .collect::>(); + export_names.sort(); + + let mut module = Module::dummy(); + + for export_name in export_names { + // We can't use quote! as `with` is not standard yet + let chunk_prop = + create_turbopack_part_id_assert(PartId::Export(export_name.clone())); + + let specifier = + swc_core::ecma::ast::ExportSpecifier::Named(ExportNamedSpecifier { + span: DUMMY_SP, + orig: ModuleExportName::Ident(Ident::new( + export_name.into(), + DUMMY_SP, + )), + exported: None, + is_type_only: false, + }); + module + .body + .push(ModuleItem::ModuleDecl(ModuleDecl::ExportNamed( + NamedExport { + span: DUMMY_SP, + specifiers: vec![specifier], + src: Some(Box::new(TURBOPACK_PART_IMPORT_SOURCE.into())), + type_only: false, + with: Some(Box::new(chunk_prop)), + }, + ))); + } + + let program = Program::Module(module); + let eval_context = EvalContext::new( + &program, + eval_context.unresolved_mark, + eval_context.top_level_mark, + true, + None, + ); + return Ok(ParseResult::Ok { + program, + comments: comments.clone(), + eval_context, + globals: globals.clone(), + source_map: source_map.clone(), + } + .cell()); + } else { + unreachable!() + } + } + let part_id = get_part_id(&split_data, part).await?; + if part_id as usize >= modules.len() { + bail!( + "part_id is out of range: {part_id} >= {}; asset = {}; entrypoints = \ + {entrypoints:?}: part_deps = {deps:?}", + asset_ident.to_string().await?, + modules.len(), + ); + } + Ok(modules[part_id as usize]) } - SplitResult::Unparseable => Ok(ParseResult::Unparseable { messages: None }.cell()), - SplitResult::NotFound => Ok(ParseResult::NotFound.cell()), + SplitResult::Failed { parse_result } => Ok(*parse_result), } } diff --git a/crates/turbopack-ecmascript/src/tree_shake/tests.rs b/crates/turbopack-ecmascript/src/tree_shake/tests.rs index 443016552df60..1f7d0d345b8e4 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/tests.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/tests.rs @@ -10,16 +10,15 @@ use indexmap::IndexSet; use rustc_hash::FxHasher; use serde::Deserialize; use swc_core::{ - common::{util::take::Take, SourceMap}, + common::{util::take::Take, Mark, SourceMap, SyntaxContext}, ecma::{ ast::{EsVersion, Id, Module}, atoms::JsWord, codegen::text_writer::JsWriter, parser::parse_file_as_module, + visit::VisitMutWith, }, - testing::{ - fixture, NormalizedOutput, {self}, - }, + testing::{self, fixture, NormalizedOutput}, }; use super::{ @@ -53,7 +52,7 @@ fn run(input: PathBuf) { testing::run_test(false, |cm, _handler| { let fm = cm.load_file(&input).unwrap(); - let module = parse_file_as_module( + let mut module = parse_file_as_module( &fm, Default::default(), EsVersion::latest(), @@ -62,8 +61,19 @@ fn run(input: PathBuf) { ) .unwrap(); + let unresolved_mark = Mark::new(); + let top_level_mark = Mark::new(); + let unresolved_ctxt = SyntaxContext::empty().apply_mark(unresolved_mark); + let top_level_ctxt = SyntaxContext::empty().apply_mark(top_level_mark); + + module.visit_mut_with(&mut swc_core::ecma::transforms::base::resolver( + unresolved_mark, + top_level_mark, + false, + )); + let mut g = DepGraph::default(); - let (item_ids, mut items) = g.init(&module); + let (item_ids, mut items) = g.init(&module, unresolved_ctxt, top_level_ctxt); let mut s = String::new(); @@ -133,7 +143,7 @@ fn run(input: PathBuf) { vars: Default::default(), }; - let eventual_ids = analyzer.hoist_vars_and_bindings(&module); + let eventual_ids = analyzer.hoist_vars_and_bindings(); writeln!(s, "# Phase 1").unwrap(); writeln!(s, "```mermaid\n{}```", render_graph(&item_ids, analyzer.g)).unwrap(); @@ -180,7 +190,9 @@ fn run(input: PathBuf) { modules, entrypoints, .. - } = g.split_module(&uri_of_module, analyzer.items); + } = g.split_module(analyzer.items); + + writeln!(s, "# Entrypoints\n\n```\n{:#?}\n```\n\n", entrypoints).unwrap(); if !skip_parts { writeln!(s, "# Modules ({})", if is_debug { "dev" } else { "prod" }).unwrap(); @@ -199,7 +211,7 @@ fn run(input: PathBuf) { for e in &entries { let key = match e { ItemIdGroupKind::ModuleEvaluation => Key::ModuleEvaluation, - ItemIdGroupKind::Export(e) => Key::Export(e.0.to_string()), + ItemIdGroupKind::Export(_, name) => Key::Export(name.to_string()), }; let index = entrypoints[&key]; @@ -230,7 +242,7 @@ fn run(input: PathBuf) { &exports.join(","), exports .into_iter() - .map(|e| ItemIdGroupKind::Export((e.into(), Default::default()))) + .map(|e| ItemIdGroupKind::Export(((*e).into(), Default::default()), e.into())) .collect(), true, ); @@ -324,7 +336,7 @@ where mermaid, " N{}[\"{}\"];", i, - render(item).replace('"', "\\\"").replace([';', '\n'], "") + render(item).replace([';', '\n'], "").replace('"', """) ) .unwrap(); } @@ -349,7 +361,7 @@ where fn render_item_id(id: &ItemId) -> Option { match id { ItemId::Group(ItemIdGroupKind::ModuleEvaluation) => Some("ModuleEvaluation".into()), - ItemId::Group(ItemIdGroupKind::Export(id)) => Some(format!("export {}", id.0)), + ItemId::Group(ItemIdGroupKind::Export(_, name)) => Some(format!("export {name}")), _ => None, } } diff --git a/crates/turbopack-ecmascript/src/tree_shake/util.rs b/crates/turbopack-ecmascript/src/tree_shake/util.rs index d23e6053c0d29..15d4e92f493a6 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/util.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/util.rs @@ -2,12 +2,15 @@ use std::hash::BuildHasherDefault; use indexmap::IndexSet; use rustc_hash::FxHasher; -use swc_core::ecma::{ - ast::{ - AssignTarget, BlockStmtOrExpr, Constructor, Expr, Function, Id, Ident, MemberProp, Pat, - PropName, +use swc_core::{ + common::SyntaxContext, + ecma::{ + ast::{ + AssignTarget, BlockStmtOrExpr, Constructor, ExportNamedSpecifier, ExportSpecifier, + Expr, Function, Id, Ident, MemberProp, NamedExport, Pat, PropName, + }, + visit::{noop_visit_type, visit_obj_and_computed, Visit, VisitWith}, }, - visit::{noop_visit_type, visit_obj_and_computed, Visit, VisitWith}, }; #[derive(Debug, Default, Clone, Copy)] @@ -20,6 +23,7 @@ enum Mode { /// A visitor which collects variables which are read or written. #[derive(Default)] pub(crate) struct IdentUsageCollector { + only: [SyntaxContext; 2], vars: Vars, ignore_nested: bool, mode: Mode, @@ -57,6 +61,16 @@ impl Visit for IdentUsageCollector { n.visit_children_with(self); } + fn visit_export_named_specifier(&mut self, n: &ExportNamedSpecifier) { + n.orig.visit_with(self); + } + + fn visit_export_specifier(&mut self, n: &ExportSpecifier) { + self.with_mode(Mode::Read, |this| { + n.visit_children_with(this); + }) + } + fn visit_expr(&mut self, e: &Expr) { self.with_mode(Mode::Read, |this| { e.visit_children_with(this); @@ -72,6 +86,12 @@ impl Visit for IdentUsageCollector { } fn visit_ident(&mut self, n: &Ident) { + // We allow SyntaxContext::empty() because Some built-in files do not go into + // resolver() + if !self.only.contains(&n.span.ctxt) && n.span.ctxt != SyntaxContext::empty() { + return; + } + match self.mode { Mode::Read => { self.vars.read.insert(n.to_id()); @@ -88,6 +108,14 @@ impl Visit for IdentUsageCollector { } } + fn visit_named_export(&mut self, n: &NamedExport) { + if n.src.is_some() { + return; + } + + n.visit_children_with(self); + } + fn visit_pat(&mut self, p: &Pat) { self.with_mode(Mode::Write, |this| { p.visit_children_with(this); @@ -109,6 +137,7 @@ impl Visit for IdentUsageCollector { /// evaluation time. #[derive(Default)] pub(crate) struct CapturedIdCollector { + only: [SyntaxContext; 2], vars: Vars, is_nested: bool, mode: Mode, @@ -149,6 +178,12 @@ impl Visit for CapturedIdCollector { }) } + fn visit_export_specifier(&mut self, n: &ExportSpecifier) { + self.with_mode(Mode::Read, |this| { + n.visit_children_with(this); + }) + } + fn visit_expr(&mut self, e: &Expr) { self.with_mode(Mode::Read, |this| { e.visit_children_with(this); @@ -166,6 +201,12 @@ impl Visit for CapturedIdCollector { return; } + // We allow SyntaxContext::empty() because Some built-in files do not go into + // resolver() + if !self.only.contains(&n.span.ctxt) && n.span.ctxt != SyntaxContext::empty() { + return; + } + match self.mode { Mode::Read => { self.vars.read.insert(n.to_id()); @@ -203,11 +244,15 @@ pub(crate) struct Vars { } /// Returns `(read, write)` -pub(crate) fn ids_captured_by(n: &N) -> Vars +/// +/// Note: This functions accept `SyntaxContext` to filter out variables which +/// are not interesting. We only need to analyze top-level variables. +pub(crate) fn ids_captured_by(n: &N, only: [SyntaxContext; 2]) -> Vars where N: VisitWith, { let mut v = CapturedIdCollector { + only, is_nested: false, ..Default::default() }; @@ -216,11 +261,15 @@ where } /// Returns `(read, write)` -pub(crate) fn ids_used_by(n: &N) -> Vars +/// +/// Note: This functions accept `SyntaxContext` to filter out variables which +/// are not interesting. We only need to analyze top-level variables. +pub(crate) fn ids_used_by(n: &N, only: [SyntaxContext; 2]) -> Vars where N: VisitWith, { let mut v = IdentUsageCollector { + only, ignore_nested: false, ..Default::default() }; @@ -229,11 +278,15 @@ where } /// Returns `(read, write)` -pub(crate) fn ids_used_by_ignoring_nested(n: &N) -> Vars +/// +/// Note: This functions accept `SyntaxContext` to filter out variables which +/// are not interesting. We only need to analyze top-level variables. +pub(crate) fn ids_used_by_ignoring_nested(n: &N, only: [SyntaxContext; 2]) -> Vars where N: VisitWith, { let mut v = IdentUsageCollector { + only, ignore_nested: true, ..Default::default() }; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/1/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/1/output.md index 8fb5d8e982dac..0b92f964586ee 100644 --- a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/1/output.md +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/1/output.md @@ -60,7 +60,7 @@ foobar += bar; ``` -- Reads: `bar` +- Reads: `bar`, `foobar` - Write: `foobar` ## Item 7: Stmt 5, `VarDeclarator(0)` @@ -81,6 +81,7 @@ foobar += "foo"; ``` +- Reads: `foobar` - Write: `foobar` ## Item 9: Stmt 7, `Normal` @@ -100,6 +101,7 @@ foobarCopy += "Unused"; ``` +- Reads: `foobarCopy` - Write: `foobarCopy` ## Item 11: Stmt 9, `Normal` @@ -114,6 +116,7 @@ function internal() { - Hoisted - Declares: `internal` - Reads (eventual): `upper`, `foobar` +- Write: `internal` ## Item 12: Stmt 10, `Normal` @@ -127,6 +130,7 @@ export function external1() { - Hoisted - Declares: `external1` - Reads (eventual): `internal`, `foobar` +- Write: `external1` ## Item 13: Stmt 11, `Normal` @@ -139,6 +143,7 @@ export function external2() { - Hoisted - Declares: `external2` +- Write: `external2` - Write (eventual): `foobar` # Phase 1 @@ -196,19 +201,19 @@ graph TD Item18["export external2"]; Item4 --> Item3; Item6 --> Item5; + Item6 --> Item3; Item6 -.-> Item4; - Item7 --> Item3; Item7 --> Item6; + Item8 --> Item6; Item8 -.-> Item4; Item8 -.-> Item7; Item9 --> Item7; Item9 --> Item1; Item9 -.-> Item2; - Item9 -.-> Item3; - Item9 -.-> Item6; Item9 -.-> Item8; Item9 -.-> Item4; Item9 -.-> Item11; + Item10 --> Item7; Item10 -.-> Item9; ``` # Phase 3 @@ -239,30 +244,27 @@ graph TD Item18["export external2"]; Item4 --> Item3; Item6 --> Item5; + Item6 --> Item3; Item6 -.-> Item4; - Item7 --> Item3; Item7 --> Item6; + Item8 --> Item6; Item8 -.-> Item4; Item8 -.-> Item7; Item9 --> Item7; Item9 --> Item1; Item9 -.-> Item2; - Item9 -.-> Item3; - Item9 -.-> Item6; Item9 -.-> Item8; Item9 -.-> Item4; Item9 -.-> Item11; + Item10 --> Item7; Item10 -.-> Item9; Item11 --> Item2; - Item11 --> Item3; - Item11 --> Item6; Item11 --> Item8; Item12 --> Item11; - Item12 --> Item3; - Item12 --> Item6; Item12 --> Item8; Item13 -.-> Item4; Item13 -.-> Item7; + Item13 -.-> Item8; ``` # Phase 4 ```mermaid @@ -292,34 +294,29 @@ graph TD Item18["export external2"]; Item4 --> Item3; Item6 --> Item5; + Item6 --> Item3; Item6 -.-> Item4; - Item7 --> Item3; Item7 --> Item6; + Item8 --> Item6; Item8 -.-> Item4; Item8 -.-> Item7; Item9 --> Item7; Item9 --> Item1; Item9 -.-> Item2; - Item9 -.-> Item3; - Item9 -.-> Item6; Item9 -.-> Item8; Item9 -.-> Item4; Item9 -.-> Item11; + Item10 --> Item7; Item10 -.-> Item9; Item11 --> Item2; - Item11 --> Item3; - Item11 --> Item6; Item11 --> Item8; Item12 --> Item11; - Item12 --> Item3; - Item12 --> Item6; Item12 --> Item8; Item13 -.-> Item4; Item13 -.-> Item7; + Item13 -.-> Item8; Item14 --> Item1; Item14 --> Item9; - Item15 --> Item3; - Item15 --> Item6; Item15 --> Item8; Item16 --> Item4; Item17 --> Item12; @@ -329,10 +326,10 @@ graph TD ```mermaid graph TD N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule), ItemId(0, ImportBinding(0)), ItemId(7, Normal)]"]; - N1["Items: [ItemId(Export((\"foobar\", #0)))]"]; - N2["Items: [ItemId(Export((\"foo\", #0)))]"]; - N3["Items: [ItemId(Export((\"external1\", #0))), ItemId(10, Normal)]"]; - N4["Items: [ItemId(Export((\"external2\", #0))), ItemId(11, Normal)]"]; + N1["Items: [ItemId(Export(("foobar", #2), "foobar"))]"]; + N2["Items: [ItemId(Export(("foo", #2), "foo"))]"]; + N3["Items: [ItemId(Export(("external1", #2), "external1")), ItemId(10, Normal)]"]; + N4["Items: [ItemId(Export(("external2", #2), "external2")), ItemId(11, Normal)]"]; N5["Items: [ItemId(1, VarDeclarator(0))]"]; N6["Items: [ItemId(2, VarDeclarator(0))]"]; N7["Items: [ItemId(3, VarDeclarator(0))]"]; @@ -342,51 +339,60 @@ graph TD N11["Items: [ItemId(0, ImportBinding(0)), ItemId(9, Normal)]"]; N0 --> N9; N0 --> N11; - N0 --> N5; - N0 --> N8; N0 --> N10; N0 --> N6; - N1 --> N5; - N1 --> N8; N1 --> N10; N2 --> N6; N3 --> N11; - N3 --> N5; - N3 --> N8; N3 --> N10; N4 --> N6; N4 --> N9; + N4 --> N10; N6 --> N5; N8 --> N7; + N8 --> N5; N8 --> N6; - N9 --> N5; N9 --> N8; + N10 --> N8; N10 --> N6; N10 --> N9; - N11 --> N5; - N11 --> N8; N11 --> N10; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 3, + Export( + "foo", + ): 2, + Export( + "foobar", + ): 1, + Export( + "external2", + ): 4, +} +``` + + # Modules (dev) ## Part 0 ```js -import { foobarCopy } from "entry.js" assert { - __turbopack_chunk__: 9 -}; -import "entry.js" assert { - __turbopack_chunk__: 11 +import { foobarCopy } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; -import "entry.js" assert { - __turbopack_chunk__: 5 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; -import "entry.js" assert { - __turbopack_chunk__: 10 -}; -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; "module evaluation"; import "module"; @@ -396,208 +402,223 @@ console.log(foobarCopy); ``` ## Part 1 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { foobar }; ``` ## Part 2 ```js -import { foo } from "entry.js" assert { - __turbopack_chunk__: 6 +import { foo } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; export { foo }; ``` ## Part 3 ```js -import { internal } from "entry.js" assert { - __turbopack_chunk__: 11 -}; -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { internal } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { external1 }; function external1() { return internal() + foobar; } +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 ```js -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; -import "entry.js" assert { - __turbopack_chunk__: 9 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let foobar = "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; const foo = foobar; -export { foo }; +export { foo } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js const bar = "bar"; -export { bar }; +export { bar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js -import { bar } from "entry.js" assert { - __turbopack_chunk__: 7 +import { bar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; -import "entry.js" assert { - __turbopack_chunk__: 6 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; foobar += bar; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 9 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; let foobarCopy = foobar; -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 10 ```js -import "entry.js" assert { - __turbopack_chunk__: 6 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; -import "entry.js" assert { - __turbopack_chunk__: 9 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; foobar += "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 11 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; import { upper } from "module"; function internal() { return upper(foobar); } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js +import { foobarCopy } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; import "module"; import { upper } from "module"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -const foo = foobar; -export { foo }; -foobar += bar; -export { foobar }; -let foobarCopy = foobar; -export { foobarCopy }; -import { upper } from "module"; -foobar += "foo"; -export { foobar }; -function internal() { - return upper(foobar); -} "module evaluation"; console.log(foobarCopy); ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 3, + Export( + "foo", + ): 2, + Export( + "foobar", + ): 1, + Export( + "external2", + ): 4, +} +``` + + # Modules (prod) ## Part 0 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; "module evaluation"; import "module"; let foobarCopy = foobar; console.log(foobarCopy); -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 1 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { foobar }; ``` ## Part 2 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; export { foo }; const foo = foobar; -export { foo }; +export { foo } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 3 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { external1 }; import { upper } from "module"; @@ -607,6 +628,12 @@ function internal() { function external1() { return internal() + foobar; } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 @@ -615,47 +642,63 @@ export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let foobar = "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js const bar = "bar"; -export { bar }; +export { bar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js -import { bar } from "entry.js" assert { - __turbopack_chunk__: 6 +import { bar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; foobar += bar; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; foobar += "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; import "module"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -foobar += bar; -export { foobar }; "module evaluation"; let foobarCopy = foobar; console.log(foobarCopy); -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/2/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/2/output.md index 5a4cbff34d420..ef2fc1ea5d109 100644 --- a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/2/output.md +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/2/output.md @@ -14,6 +14,7 @@ export function external1() { - Hoisted - Declares: `external1` - Reads (eventual): `internal`, `foobar` +- Write: `external1` ## Item 2: Stmt 1, `ImportOfModule` @@ -73,7 +74,7 @@ foobar += bar; ``` -- Reads: `bar` +- Reads: `bar`, `foobar` - Write: `foobar` ## Item 8: Stmt 6, `VarDeclarator(0)` @@ -94,6 +95,7 @@ foobar += "foo"; ``` +- Reads: `foobar` - Write: `foobar` ## Item 10: Stmt 8, `Normal` @@ -113,6 +115,7 @@ foobarCopy += "Unused"; ``` +- Reads: `foobarCopy` - Write: `foobarCopy` ## Item 12: Stmt 10, `Normal` @@ -127,6 +130,7 @@ function internal() { - Hoisted - Declares: `internal` - Reads (eventual): `upper`, `foobar` +- Write: `internal` ## Item 13: Stmt 11, `Normal` @@ -139,6 +143,7 @@ export function external2() { - Hoisted - Declares: `external2` +- Write: `external2` - Write (eventual): `foobar` ## Item 14: Stmt 12, `ImportOfModule` @@ -155,7 +160,7 @@ import "other"; ```mermaid graph TD Item3; - Item2; + Item1; Item4; Item5; Item6; @@ -167,7 +172,7 @@ graph TD Item12; Item13; Item14; - Item1; + Item2; Item15; Item15["ModuleEvaluation"]; Item16; @@ -178,13 +183,13 @@ graph TD Item18["export foo"]; Item19; Item19["export external2"]; - Item1 --> Item2; + Item2 --> Item1; ``` # Phase 2 ```mermaid graph TD Item3; - Item2; + Item1; Item4; Item5; Item6; @@ -196,7 +201,7 @@ graph TD Item12; Item13; Item14; - Item1; + Item2; Item15; Item15["ModuleEvaluation"]; Item16; @@ -207,30 +212,30 @@ graph TD Item18["export foo"]; Item19; Item19["export external2"]; - Item1 --> Item2; + Item2 --> Item1; Item6 --> Item5; Item8 --> Item7; + Item8 --> Item5; Item8 -.-> Item6; - Item9 --> Item5; Item9 --> Item8; + Item10 --> Item8; Item10 -.-> Item6; Item10 -.-> Item9; Item11 --> Item9; - Item11 --> Item2; Item11 --> Item1; + Item11 --> Item2; Item11 -.-> Item13; - Item11 -.-> Item5; - Item11 -.-> Item8; Item11 -.-> Item10; Item11 -.-> Item6; Item11 -.-> Item4; + Item12 --> Item9; Item12 -.-> Item11; ``` # Phase 3 ```mermaid graph TD Item3; - Item2; + Item1; Item4; Item5; Item6; @@ -242,7 +247,7 @@ graph TD Item12; Item13; Item14; - Item1; + Item2; Item15; Item15["ModuleEvaluation"]; Item16; @@ -253,40 +258,37 @@ graph TD Item18["export foo"]; Item19; Item19["export external2"]; - Item1 --> Item2; + Item2 --> Item1; Item6 --> Item5; Item8 --> Item7; + Item8 --> Item5; Item8 -.-> Item6; - Item9 --> Item5; Item9 --> Item8; + Item10 --> Item8; Item10 -.-> Item6; Item10 -.-> Item9; Item11 --> Item9; - Item11 --> Item2; Item11 --> Item1; + Item11 --> Item2; Item11 -.-> Item13; - Item11 -.-> Item5; - Item11 -.-> Item8; Item11 -.-> Item10; Item11 -.-> Item6; Item11 -.-> Item4; + Item12 --> Item9; Item12 -.-> Item11; Item3 --> Item13; - Item3 --> Item5; - Item3 --> Item8; Item3 --> Item10; Item13 --> Item4; - Item13 --> Item5; - Item13 --> Item8; Item13 --> Item10; Item14 -.-> Item6; Item14 -.-> Item9; + Item14 -.-> Item10; ``` # Phase 4 ```mermaid graph TD Item3; - Item2; + Item1; Item4; Item5; Item6; @@ -298,7 +300,7 @@ graph TD Item12; Item13; Item14; - Item1; + Item2; Item15; Item15["ModuleEvaluation"]; Item16; @@ -309,40 +311,35 @@ graph TD Item18["export foo"]; Item19; Item19["export external2"]; - Item1 --> Item2; + Item2 --> Item1; Item6 --> Item5; Item8 --> Item7; + Item8 --> Item5; Item8 -.-> Item6; - Item9 --> Item5; Item9 --> Item8; + Item10 --> Item8; Item10 -.-> Item6; Item10 -.-> Item9; Item11 --> Item9; - Item11 --> Item2; Item11 --> Item1; + Item11 --> Item2; Item11 -.-> Item13; - Item11 -.-> Item5; - Item11 -.-> Item8; Item11 -.-> Item10; Item11 -.-> Item6; Item11 -.-> Item4; + Item12 --> Item9; Item12 -.-> Item11; Item3 --> Item13; - Item3 --> Item5; - Item3 --> Item8; Item3 --> Item10; Item13 --> Item4; - Item13 --> Item5; - Item13 --> Item8; Item13 --> Item10; Item14 -.-> Item6; Item14 -.-> Item9; - Item15 --> Item2; + Item14 -.-> Item10; Item15 --> Item1; + Item15 --> Item2; Item15 --> Item11; Item16 --> Item3; - Item17 --> Item5; - Item17 --> Item8; Item17 --> Item10; Item18 --> Item6; Item19 --> Item14; @@ -351,10 +348,10 @@ graph TD ```mermaid graph TD N0["Items: [ItemId(ModuleEvaluation), ItemId(1, ImportOfModule), ItemId(1, ImportBinding(0)), ItemId(8, Normal), ItemId(12, ImportOfModule)]"]; - N1["Items: [ItemId(Export((\"external1\", #0))), ItemId(0, Normal)]"]; - N2["Items: [ItemId(Export((\"foobar\", #0)))]"]; - N3["Items: [ItemId(Export((\"foo\", #0)))]"]; - N4["Items: [ItemId(Export((\"external2\", #0))), ItemId(11, Normal)]"]; + N1["Items: [ItemId(Export(("external1", #2), "external1")), ItemId(0, Normal)]"]; + N2["Items: [ItemId(Export(("foobar", #2), "foobar"))]"]; + N3["Items: [ItemId(Export(("foo", #2), "foo"))]"]; + N4["Items: [ItemId(Export(("external2", #2), "external2")), ItemId(11, Normal)]"]; N5["Items: [ItemId(2, VarDeclarator(0))]"]; N6["Items: [ItemId(3, VarDeclarator(0))]"]; N7["Items: [ItemId(4, VarDeclarator(0))]"]; @@ -364,51 +361,60 @@ graph TD N11["Items: [ItemId(1, ImportBinding(0)), ItemId(10, Normal)]"]; N0 --> N9; N0 --> N11; - N0 --> N5; - N0 --> N8; N0 --> N10; N0 --> N6; N1 --> N11; - N1 --> N5; - N1 --> N8; N1 --> N10; - N2 --> N5; - N2 --> N8; N2 --> N10; N3 --> N6; N4 --> N6; N4 --> N9; + N4 --> N10; N6 --> N5; N8 --> N7; + N8 --> N5; N8 --> N6; - N9 --> N5; N9 --> N8; + N10 --> N8; N10 --> N6; N10 --> N9; - N11 --> N5; - N11 --> N8; N11 --> N10; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 1, + Export( + "foo", + ): 3, + Export( + "foobar", + ): 2, + Export( + "external2", + ): 4, +} +``` + + # Modules (dev) ## Part 0 ```js -import { foobarCopy } from "entry.js" assert { - __turbopack_chunk__: 9 -}; -import "entry.js" assert { - __turbopack_chunk__: 11 -}; -import "entry.js" assert { - __turbopack_chunk__: 5 +import { foobarCopy } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import "entry.js" assert { - __turbopack_chunk__: 10 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; "module evaluation"; import "module"; @@ -419,186 +425,205 @@ import "other"; ``` ## Part 1 ```js -import { internal } from "entry.js" assert { - __turbopack_chunk__: 11 +import { internal } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { external1 }; function external1() { return internal() + foobar; } +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 2 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { foobar }; ``` ## Part 3 ```js -import { foo } from "entry.js" assert { - __turbopack_chunk__: 6 +import { foo } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; export { foo }; ``` ## Part 4 ```js -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; -import "entry.js" assert { - __turbopack_chunk__: 9 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let foobar = "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; const foo = foobar; -export { foo }; +export { foo } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js const bar = "bar"; -export { bar }; +export { bar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js -import { bar } from "entry.js" assert { - __turbopack_chunk__: 7 +import { bar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; foobar += bar; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 9 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; let foobarCopy = foobar; -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 10 ```js -import "entry.js" assert { - __turbopack_chunk__: 6 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; -import "entry.js" assert { - __turbopack_chunk__: 9 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; foobar += "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 11 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; import { upper } from "module"; function internal() { return upper(foobar); } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js +import { foobarCopy } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; import "module"; import { upper } from "module"; import "other"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -const foo = foobar; -export { foo }; -foobar += bar; -export { foobar }; -let foobarCopy = foobar; -export { foobarCopy }; -import { upper } from "module"; -foobar += "foo"; -export { foobar }; -function internal() { - return upper(foobar); -} "module evaluation"; console.log(foobarCopy); ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 1, + Export( + "foo", + ): 3, + Export( + "foobar", + ): 2, + Export( + "external2", + ): 4, +} +``` + + # Modules (prod) ## Part 0 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; "module evaluation"; import "module"; let foobarCopy = foobar; console.log(foobarCopy); import "other"; -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 1 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { external1 }; function external1() { @@ -608,30 +633,32 @@ import { upper } from "module"; function internal() { return upper(foobar); } +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 2 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { foobar }; ``` ## Part 3 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; export { foo }; const foo = foobar; -export { foo }; +export { foo } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 @@ -640,48 +667,64 @@ export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let foobar = "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js const bar = "bar"; -export { bar }; +export { bar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js -import { bar } from "entry.js" assert { - __turbopack_chunk__: 6 +import { bar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; foobar += bar; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; foobar += "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; import "module"; import "other"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -foobar += bar; -export { foobar }; "module evaluation"; let foobarCopy = foobar; console.log(foobarCopy); -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/3/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/3/output.md index 421ad8b01333e..b167ee982dd46 100644 --- a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/3/output.md +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/3/output.md @@ -11,6 +11,7 @@ function d1() {} - Hoisted - Declares: `d1` +- Write: `d1` ## Item 2: Stmt 1, `Normal` @@ -21,6 +22,7 @@ function d2() {} - Hoisted - Declares: `d2` +- Write: `d2` ## Item 3: Stmt 2, `Normal` @@ -31,6 +33,7 @@ function d3() {} - Hoisted - Declares: `d3` +- Write: `d3` ## Item 4: Stmt 3, `Normal` @@ -44,6 +47,7 @@ export function c1_1() { - Hoisted - Declares: `c1_1` - Reads (eventual): `c1_2` +- Write: `c1_1` ## Item 5: Stmt 4, `Normal` @@ -57,6 +61,7 @@ function c1_2() { - Hoisted - Declares: `c1_2` - Reads (eventual): `c1_3`, `d1` +- Write: `c1_2` ## Item 6: Stmt 5, `Normal` @@ -70,6 +75,7 @@ export function c1_3() { - Hoisted - Declares: `c1_3` - Reads (eventual): `c1_1`, `d2` +- Write: `c1_3` ## Item 7: Stmt 6, `Normal` @@ -83,6 +89,7 @@ function c2_1() { - Hoisted - Declares: `c2_1` - Reads (eventual): `c2_2`, `d3` +- Write: `c2_1` ## Item 8: Stmt 7, `Normal` @@ -96,6 +103,7 @@ export function c2_2() { - Hoisted - Declares: `c2_2` - Reads (eventual): `c2_3` +- Write: `c2_2` ## Item 9: Stmt 8, `Normal` @@ -109,6 +117,7 @@ function c2_3() { - Hoisted - Declares: `c2_3` - Reads (eventual): `c2_1` +- Write: `c2_3` ## Item 10: Stmt 9, `Normal` @@ -306,9 +315,9 @@ graph TD ```mermaid graph TD N0["Items: [ItemId(ModuleEvaluation), ItemId(9, Normal), ItemId(10, Normal)]"]; - N1["Items: [ItemId(Export((\"c1_1\", #0)))]"]; - N2["Items: [ItemId(Export((\"c1_3\", #0)))]"]; - N3["Items: [ItemId(Export((\"c2_2\", #0)))]"]; + N1["Items: [ItemId(Export(("c1_1", #2), "c1_1"))]"]; + N2["Items: [ItemId(Export(("c1_3", #2), "c1_3"))]"]; + N3["Items: [ItemId(Export(("c2_2", #2), "c2_2"))]"]; N4["Items: [ItemId(3, Normal), ItemId(4, Normal), ItemId(5, Normal)]"]; N5["Items: [ItemId(6, Normal), ItemId(7, Normal), ItemId(8, Normal)]"]; N6["Items: [ItemId(0, Normal)]"]; @@ -326,23 +335,41 @@ graph TD N4 --> N7; N5 --> N8; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "c1_1", + ): 1, + Export( + "c1_3", + ): 2, + Export( + "c2_2", + ): 3, +} +``` + + # Modules (dev) ## Part 0 ```js -import { c1_3 } from "entry.js" assert { - __turbopack_chunk__: 4 +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 }; -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; -import "entry.js" assert { - __turbopack_chunk__: 7 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; -import { c2_2 } from "entry.js" assert { - __turbopack_chunk__: 5 +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; "module evaluation"; c1_3(); @@ -351,35 +378,35 @@ c2_2(); ``` ## Part 1 ```js -import { c1_1 } from "entry.js" assert { - __turbopack_chunk__: 4 +import { c1_1 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 }; export { c1_1 }; ``` ## Part 2 ```js -import { c1_3 } from "entry.js" assert { - __turbopack_chunk__: 4 +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 }; export { c1_3 }; ``` ## Part 3 ```js -import { c2_2 } from "entry.js" assert { - __turbopack_chunk__: 5 +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; export { c2_2 }; ``` ## Part 4 ```js -import { d1 } from "entry.js" assert { - __turbopack_chunk__: 6 +import { d1 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; -import { d2 } from "entry.js" assert { - __turbopack_chunk__: 7 +import { d2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; function c1_1() { return c1_2(); @@ -390,12 +417,21 @@ function c1_2() { function c1_3() { return c1_1(d2); } +export { c1_1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c1_2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c1_3 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js -import { d3 } from "entry.js" assert { - __turbopack_chunk__: 8 +import { d3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; function c2_1() { return c2_2(d3); @@ -406,59 +442,89 @@ function c2_2() { function c2_3() { return c2_1(); } +export { c2_1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c2_2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c2_3 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js function d1() {} +export { d1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js function d2() {} +export { d2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js function d3() {} +export { d3 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js -function d1() {} -function d2() {} -function c1_1() { - return c1_2(); -} -function c1_2() { - return c1_3(d1); -} -function c1_3() { - return c1_1(d2); -} -function d3() {} -function c2_1() { - return c2_2(d3); -} -function c2_2() { - return c2_3(); -} -function c2_3() { - return c2_1(); -} +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; "module evaluation"; c1_3(); c2_2(); ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "c1_1", + ): 1, + Export( + "c1_3", + ): 2, + Export( + "c2_2", + ): 3, +} +``` + + # Modules (prod) ## Part 0 ```js -import { c1_3 } from "entry.js" assert { - __turbopack_chunk__: 4 +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 }; -import { c2_2 } from "entry.js" assert { - __turbopack_chunk__: 5 +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; "module evaluation"; c1_3(); @@ -467,35 +533,35 @@ c2_2(); ``` ## Part 1 ```js -import { c1_1 } from "entry.js" assert { - __turbopack_chunk__: 4 +import { c1_1 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 }; export { c1_1 }; ``` ## Part 2 ```js -import { c1_3 } from "entry.js" assert { - __turbopack_chunk__: 4 +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 }; export { c1_3 }; ``` ## Part 3 ```js -import { c2_2 } from "entry.js" assert { - __turbopack_chunk__: 5 +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; export { c2_2 }; ``` ## Part 4 ```js -import { d1 } from "entry.js" assert { - __turbopack_chunk__: 6 +import { d1 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; -import { d2 } from "entry.js" assert { - __turbopack_chunk__: 7 +import { d2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; function c1_1() { return c1_2(); @@ -506,12 +572,21 @@ function c1_2() { function c1_3() { return c1_1(d2); } +export { c1_1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c1_2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c1_3 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js -import { d3 } from "entry.js" assert { - __turbopack_chunk__: 8 +import { d3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; function c2_1() { return c2_2(d3); @@ -522,91 +597,107 @@ function c2_2() { function c2_3() { return c2_1(); } +export { c2_1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c2_2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { c2_3 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js function d1() {} +export { d1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js function d2() {} +export { d2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js function d3() {} +export { d3 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js -function d1() {} -function d2() {} -function c1_1() { - return c1_2(); -} -function c1_2() { - return c1_3(d1); -} -function c1_3() { - return c1_1(d2); -} -function d3() {} -function c2_1() { - return c2_2(d3); -} -function c2_2() { - return c2_3(); -} -function c2_3() { - return c2_1(); -} +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; "module evaluation"; c1_3(); c2_2(); ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "c1_1", + ): 1, + Export( + "c1_3", + ): 2, + Export( + "c2_2", + ): 3, +} +``` + + ## Merged (c1_3) ```js -function d1() {} -function d2() {} -function c1_1() { - return c1_2(); -} -function c1_2() { - return c1_3(d1); -} -function c1_3() { - return c1_1(d2); -} +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; export { c1_3 }; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "c1_1", + ): 1, + Export( + "c1_3", + ): 2, + Export( + "c2_2", + ): 3, +} +``` + + ## Merged (c1_3,c2_2) ```js -function d1() {} -function d2() {} -function c1_1() { - return c1_2(); -} -function c1_2() { - return c1_3(d1); -} -function c1_3() { - return c1_1(d2); -} +import { c1_3 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import { c2_2 } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; export { c1_3 }; -function d3() {} -function c2_1() { - return c2_2(d3); -} -function c2_2() { - return c2_3(); -} -function c2_3() { - return c2_1(); -} export { c2_2 }; ``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/input.js new file mode 100644 index 0000000000000..a32837722b8ad --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/input.js @@ -0,0 +1,31 @@ +import { AppRouteRouteModule } from '../../server/future/route-modules/app-route/module.compiled'; +import { RouteKind } from '../../server/future/route-kind'; +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; +import * as userland from 'VAR_USERLAND'; +// We inject the nextConfigOutput here so that we can use them in the route +// module. +// INJECT:nextConfigOutput +const routeModule = new AppRouteRouteModule({ + definition: { + kind: RouteKind.APP_ROUTE, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + filename: 'VAR_DEFINITION_FILENAME', + bundlePath: 'VAR_DEFINITION_BUNDLE_PATH' + }, + resolvedPagePath: 'VAR_RESOLVED_PAGE_PATH', + nextConfigOutput, + userland +}); +// Pull out the exports that we need to expose from the module. This should +// be eliminated when we've moved the other routes to the new format. These +// are used to hook into the route. +const { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } = routeModule; +const originalPathname = 'VAR_ORIGINAL_PATHNAME'; +function patchFetch() { + return _patchFetch({ + serverHooks, + staticGenerationAsyncStorage + }); +} +export { routeModule, requestAsyncStorage, staticGenerationAsyncStorage, serverHooks, originalPathname, patchFetch, }; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/output.md new file mode 100644 index 0000000000000..5674fe185a9e5 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/app-route/output.md @@ -0,0 +1,753 @@ +# Items + +Count: 20 + +## Item 1: Stmt 0, `ImportOfModule` + +```js +import { AppRouteRouteModule } from '../../server/future/route-modules/app-route/module.compiled'; + +``` + +- Hoisted +- Side effects + +## Item 2: Stmt 0, `ImportBinding(0)` + +```js +import { AppRouteRouteModule } from '../../server/future/route-modules/app-route/module.compiled'; + +``` + +- Hoisted +- Declares: `AppRouteRouteModule` + +## Item 3: Stmt 1, `ImportOfModule` + +```js +import { RouteKind } from '../../server/future/route-kind'; + +``` + +- Hoisted +- Side effects + +## Item 4: Stmt 1, `ImportBinding(0)` + +```js +import { RouteKind } from '../../server/future/route-kind'; + +``` + +- Hoisted +- Declares: `RouteKind` + +## Item 5: Stmt 2, `ImportOfModule` + +```js +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; + +``` + +- Hoisted +- Side effects + +## Item 6: Stmt 2, `ImportBinding(0)` + +```js +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; + +``` + +- Hoisted +- Declares: `_patchFetch` + +## Item 7: Stmt 3, `ImportOfModule` + +```js +import * as userland from 'VAR_USERLAND'; + +``` + +- Hoisted +- Side effects + +## Item 8: Stmt 3, `ImportBinding(0)` + +```js +import * as userland from 'VAR_USERLAND'; + +``` + +- Hoisted +- Declares: `userland` + +## Item 9: Stmt 4, `VarDeclarator(0)` + +```js +const routeModule = new AppRouteRouteModule({ + definition: { + kind: RouteKind.APP_ROUTE, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + filename: 'VAR_DEFINITION_FILENAME', + bundlePath: 'VAR_DEFINITION_BUNDLE_PATH' + }, + resolvedPagePath: 'VAR_RESOLVED_PAGE_PATH', + nextConfigOutput, + userland +}); + +``` + +- Declares: `routeModule` +- Reads: `AppRouteRouteModule`, `RouteKind`, `nextConfigOutput`, `userland` +- Write: `routeModule` + +## Item 10: Stmt 5, `VarDeclarator(0)` + +```js +const { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } = routeModule; + +``` + +- Declares: `requestAsyncStorage`, `staticGenerationAsyncStorage`, `serverHooks` +- Reads: `routeModule` +- Write: `requestAsyncStorage`, `staticGenerationAsyncStorage`, `serverHooks` + +## Item 11: Stmt 6, `VarDeclarator(0)` + +```js +const originalPathname = 'VAR_ORIGINAL_PATHNAME'; + +``` + +- Declares: `originalPathname` +- Write: `originalPathname` + +## Item 12: Stmt 7, `Normal` + +```js +function patchFetch() { + return _patchFetch({ + serverHooks, + staticGenerationAsyncStorage + }); +} + +``` + +- Hoisted +- Declares: `patchFetch` +- Reads (eventual): `_patchFetch`, `serverHooks`, `staticGenerationAsyncStorage` +- Write: `patchFetch` + +## Item 13: Stmt 8, `Normal` + +```js +export { routeModule, requestAsyncStorage, staticGenerationAsyncStorage, serverHooks, originalPathname, patchFetch }; + +``` + +- Side effects +- Reads: `routeModule`, `requestAsyncStorage`, `staticGenerationAsyncStorage`, `serverHooks`, `originalPathname`, `patchFetch` + +# Phase 1 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item14["ModuleEvaluation"]; + Item15; + Item15["export routeModule"]; + Item16; + Item16["export requestAsyncStorage"]; + Item17; + Item17["export staticGenerationAsyncStorage"]; + Item18; + Item18["export serverHooks"]; + Item19; + Item19["export originalPathname"]; + Item20; + Item20["export patchFetch"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item14["ModuleEvaluation"]; + Item15; + Item15["export routeModule"]; + Item16; + Item16["export requestAsyncStorage"]; + Item17; + Item17["export staticGenerationAsyncStorage"]; + Item18; + Item18["export serverHooks"]; + Item19; + Item19["export originalPathname"]; + Item20; + Item20["export patchFetch"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item9 --> Item5; + Item9 --> Item6; + Item9 --> Item8; + Item10 --> Item9; + Item13 --> Item9; + Item13 --> Item10; + Item13 --> Item11; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item4; + Item13 -.-> Item7; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item14["ModuleEvaluation"]; + Item15; + Item15["export routeModule"]; + Item16; + Item16["export requestAsyncStorage"]; + Item17; + Item17["export staticGenerationAsyncStorage"]; + Item18; + Item18["export serverHooks"]; + Item19; + Item19["export originalPathname"]; + Item20; + Item20["export patchFetch"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item9 --> Item5; + Item9 --> Item6; + Item9 --> Item8; + Item10 --> Item9; + Item13 --> Item9; + Item13 --> Item10; + Item13 --> Item11; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item4; + Item13 -.-> Item7; + Item12 --> Item7; + Item12 --> Item10; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item14["ModuleEvaluation"]; + Item15; + Item15["export routeModule"]; + Item16; + Item16["export requestAsyncStorage"]; + Item17; + Item17["export staticGenerationAsyncStorage"]; + Item18; + Item18["export serverHooks"]; + Item19; + Item19["export originalPathname"]; + Item20; + Item20["export patchFetch"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item9 --> Item5; + Item9 --> Item6; + Item9 --> Item8; + Item10 --> Item9; + Item13 --> Item9; + Item13 --> Item10; + Item13 --> Item11; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item4; + Item13 -.-> Item7; + Item12 --> Item7; + Item12 --> Item10; + Item14 --> Item1; + Item14 --> Item2; + Item14 --> Item3; + Item14 --> Item4; + Item14 --> Item13; + Item15 --> Item9; + Item16 --> Item10; + Item17 --> Item10; + Item18 --> Item10; + Item19 --> Item11; + Item20 --> Item12; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule), ItemId(1, ImportOfModule), ItemId(2, ImportOfModule), ItemId(2, ImportBinding(0)), ItemId(3, ImportOfModule), ItemId(8, Normal)]"]; + N1["Items: [ItemId(Export(("routeModule", #2), "routeModule"))]"]; + N2["Items: [ItemId(Export(("requestAsyncStorage", #2), "requestAsyncStorage"))]"]; + N3["Items: [ItemId(Export(("staticGenerationAsyncStorage", #2), "staticGenerationAsyncStorage"))]"]; + N4["Items: [ItemId(Export(("serverHooks", #2), "serverHooks"))]"]; + N5["Items: [ItemId(Export(("originalPathname", #2), "originalPathname"))]"]; + N6["Items: [ItemId(Export(("patchFetch", #2), "patchFetch"))]"]; + N7["Items: [ItemId(0, ImportBinding(0)), ItemId(1, ImportBinding(0)), ItemId(3, ImportBinding(0)), ItemId(4, VarDeclarator(0))]"]; + N8["Items: [ItemId(5, VarDeclarator(0))]"]; + N9["Items: [ItemId(6, VarDeclarator(0))]"]; + N10["Items: [ItemId(2, ImportBinding(0)), ItemId(7, Normal)]"]; + N0 --> N7; + N0 --> N8; + N0 --> N9; + N0 --> N10; + N1 --> N7; + N2 --> N8; + N3 --> N8; + N4 --> N8; + N5 --> N9; + N6 --> N10; + N8 --> N7; + N10 --> N8; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "serverHooks", + ): 4, + Export( + "requestAsyncStorage", + ): 2, + Export( + "staticGenerationAsyncStorage", + ): 3, + Export( + "patchFetch", + ): 6, + Export( + "routeModule", + ): 1, + Export( + "originalPathname", + ): 5, +} +``` + + +# Modules (dev) +## Part 0 +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import { originalPathname } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import { patchFetch } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +"module evaluation"; +import '../../server/future/route-modules/app-route/module.compiled'; +import '../../server/future/route-kind'; +import '../../server/lib/patch-fetch'; +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; +import 'VAR_USERLAND'; +export { routeModule, requestAsyncStorage, staticGenerationAsyncStorage, serverHooks, originalPathname, patchFetch }; + +``` +## Part 1 +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +export { routeModule as routeModule }; + +``` +## Part 2 +```js +import { requestAsyncStorage } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +export { requestAsyncStorage as requestAsyncStorage }; + +``` +## Part 3 +```js +import { staticGenerationAsyncStorage } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +export { staticGenerationAsyncStorage as staticGenerationAsyncStorage }; + +``` +## Part 4 +```js +import { serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +export { serverHooks as serverHooks }; + +``` +## Part 5 +```js +import { originalPathname } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +export { originalPathname as originalPathname }; + +``` +## Part 6 +```js +import { patchFetch } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { patchFetch as patchFetch }; + +``` +## Part 7 +```js +import { AppRouteRouteModule } from '../../server/future/route-modules/app-route/module.compiled'; +import { RouteKind } from '../../server/future/route-kind'; +import * as userland from 'VAR_USERLAND'; +const routeModule = new AppRouteRouteModule({ + definition: { + kind: RouteKind.APP_ROUTE, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + filename: 'VAR_DEFINITION_FILENAME', + bundlePath: 'VAR_DEFINITION_BUNDLE_PATH' + }, + resolvedPagePath: 'VAR_RESOLVED_PAGE_PATH', + nextConfigOutput, + userland +}); +export { routeModule } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 8 +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +const { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } = routeModule; +export { requestAsyncStorage } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { staticGenerationAsyncStorage } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { serverHooks } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 9 +```js +const originalPathname = 'VAR_ORIGINAL_PATHNAME'; +export { originalPathname } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 10 +```js +import { staticGenerationAsyncStorage, serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; +function patchFetch() { + return _patchFetch({ + serverHooks, + staticGenerationAsyncStorage + }); +} +export { patchFetch } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import { originalPathname } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import { patchFetch } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import '../../server/future/route-modules/app-route/module.compiled'; +import '../../server/future/route-kind'; +import '../../server/lib/patch-fetch'; +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; +import 'VAR_USERLAND'; +"module evaluation"; +export { routeModule, requestAsyncStorage, staticGenerationAsyncStorage, serverHooks, originalPathname, patchFetch }; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "serverHooks", + ): 4, + Export( + "requestAsyncStorage", + ): 2, + Export( + "staticGenerationAsyncStorage", + ): 3, + Export( + "patchFetch", + ): 6, + Export( + "routeModule", + ): 1, + Export( + "originalPathname", + ): 5, +} +``` + + +# Modules (prod) +## Part 0 +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import { originalPathname } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import { patchFetch } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +"module evaluation"; +import '../../server/future/route-modules/app-route/module.compiled'; +import '../../server/future/route-kind'; +import '../../server/lib/patch-fetch'; +import 'VAR_USERLAND'; +export { routeModule, requestAsyncStorage, staticGenerationAsyncStorage, serverHooks, originalPathname, patchFetch }; + +``` +## Part 1 +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +export { routeModule as routeModule }; + +``` +## Part 2 +```js +import { requestAsyncStorage } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +export { requestAsyncStorage as requestAsyncStorage }; + +``` +## Part 3 +```js +import { staticGenerationAsyncStorage } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +export { staticGenerationAsyncStorage as staticGenerationAsyncStorage }; + +``` +## Part 4 +```js +import { serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +export { serverHooks as serverHooks }; + +``` +## Part 5 +```js +import { originalPathname } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +export { originalPathname as originalPathname }; + +``` +## Part 6 +```js +import { patchFetch } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { patchFetch as patchFetch }; + +``` +## Part 7 +```js +import { AppRouteRouteModule } from '../../server/future/route-modules/app-route/module.compiled'; +import { RouteKind } from '../../server/future/route-kind'; +import * as userland from 'VAR_USERLAND'; +const routeModule = new AppRouteRouteModule({ + definition: { + kind: RouteKind.APP_ROUTE, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + filename: 'VAR_DEFINITION_FILENAME', + bundlePath: 'VAR_DEFINITION_BUNDLE_PATH' + }, + resolvedPagePath: 'VAR_RESOLVED_PAGE_PATH', + nextConfigOutput, + userland +}); +export { routeModule } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 8 +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +const { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } = routeModule; +export { requestAsyncStorage } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { staticGenerationAsyncStorage } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { serverHooks } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 9 +```js +const originalPathname = 'VAR_ORIGINAL_PATHNAME'; +export { originalPathname } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 10 +```js +import { staticGenerationAsyncStorage, serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import { patchFetch as _patchFetch } from '../../server/lib/patch-fetch'; +function patchFetch() { + return _patchFetch({ + serverHooks, + staticGenerationAsyncStorage + }); +} +export { patchFetch } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { routeModule } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import { requestAsyncStorage, staticGenerationAsyncStorage, serverHooks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import { originalPathname } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import { patchFetch } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import '../../server/future/route-modules/app-route/module.compiled'; +import '../../server/future/route-kind'; +import '../../server/lib/patch-fetch'; +import 'VAR_USERLAND'; +"module evaluation"; +export { routeModule, requestAsyncStorage, staticGenerationAsyncStorage, serverHooks, originalPathname, patchFetch }; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/input.js new file mode 100644 index 0000000000000..4b7aee241e63f --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/input.js @@ -0,0 +1,4 @@ +const a = "a"; +const b = "b"; + +export { a, b }; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/output.md new file mode 100644 index 0000000000000..ff7725d97d2d8 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/combined-export/output.md @@ -0,0 +1,252 @@ +# Items + +Count: 6 + +## Item 1: Stmt 0, `VarDeclarator(0)` + +```js +const a = "a"; + +``` + +- Declares: `a` +- Write: `a` + +## Item 2: Stmt 1, `VarDeclarator(0)` + +```js +const b = "b"; + +``` + +- Declares: `b` +- Write: `b` + +## Item 3: Stmt 2, `Normal` + +```js +export { a, b }; + +``` + +- Side effects +- Reads: `a`, `b` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; + Item3 --> Item1; + Item3 --> Item2; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; + Item3 --> Item1; + Item3 --> Item2; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item3; + Item5 --> Item1; + Item6 --> Item2; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(2, Normal)]"]; + N1["Items: [ItemId(Export(("a", #2), "a"))]"]; + N2["Items: [ItemId(Export(("b", #2), "b"))]"]; + N3["Items: [ItemId(0, VarDeclarator(0))]"]; + N4["Items: [ItemId(1, VarDeclarator(0))]"]; + N0 --> N3; + N0 --> N4; + N1 --> N3; + N2 --> N4; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "b", + ): 2, + Export( + "a", + ): 1, +} +``` + + +# Modules (dev) +## Part 0 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` +## Part 1 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { a as a }; + +``` +## Part 2 +```js +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +export { b as b }; + +``` +## Part 3 +```js +const a = "a"; +export { a } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +const b = "b"; +export { b } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "b", + ): 2, + Export( + "a", + ): 1, +} +``` + + +# Modules (prod) +## Part 0 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` +## Part 1 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { a as a }; + +``` +## Part 2 +```js +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +export { b as b }; + +``` +## Part 3 +```js +const a = "a"; +export { a } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +const b = "b"; +export { b } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/complex/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/complex/output.md index 73be124f96ae3..80e4cdf3c3c32 100644 --- a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/complex/output.md +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/complex/output.md @@ -19,6 +19,7 @@ dog += "!"; ``` +- Reads: `dog` - Write: `dog` ## Item 3: Stmt 2, `Normal` @@ -43,6 +44,7 @@ function getDog() { - Hoisted - Declares: `getDog` - Reads (eventual): `dog` +- Write: `getDog` ## Item 5: Stmt 4, `Normal` @@ -51,6 +53,7 @@ dog += "!"; ``` +- Reads: `dog` - Write: `dog` ## Item 6: Stmt 5, `Normal` @@ -74,8 +77,8 @@ function setDog(newDog) { - Hoisted - Declares: `setDog` -- Reads (eventual): `newDog` -- Write (eventual): `newDog`, `dog` +- Write: `setDog` +- Write (eventual): `dog` ## Item 8: Stmt 7, `Normal` @@ -84,6 +87,7 @@ dog += "!"; ``` +- Reads: `dog` - Write: `dog` ## Item 9: Stmt 8, `Normal` @@ -144,6 +148,7 @@ export function getChimera() { - Hoisted - Declares: `getChimera` - Reads (eventual): `cat`, `dog` +- Write: `getChimera` # Phase 1 ```mermaid @@ -198,23 +203,17 @@ graph TD Item17["export initialCat"]; Item18; Item18["export getChimera"]; - Item3 --> Item1; + Item2 --> Item1; Item3 --> Item2; + Item5 --> Item2; Item5 -.-> Item3; - Item6 --> Item1; - Item6 --> Item2; Item6 --> Item5; Item6 --> Item3; + Item8 --> Item5; Item8 -.-> Item6; - Item9 --> Item1; - Item9 --> Item2; - Item9 --> Item5; Item9 --> Item8; Item9 --> Item3; Item9 --> Item6; - Item10 --> Item1; - Item10 --> Item2; - Item10 --> Item5; Item10 --> Item8; Item10 --> Item4; Item10 --> Item7; @@ -246,37 +245,25 @@ graph TD Item17["export initialCat"]; Item18; Item18["export getChimera"]; - Item3 --> Item1; + Item2 --> Item1; Item3 --> Item2; + Item5 --> Item2; Item5 -.-> Item3; - Item6 --> Item1; - Item6 --> Item2; Item6 --> Item5; Item6 --> Item3; + Item8 --> Item5; Item8 -.-> Item6; - Item9 --> Item1; - Item9 --> Item2; - Item9 --> Item5; Item9 --> Item8; Item9 --> Item3; Item9 --> Item6; - Item10 --> Item1; - Item10 --> Item2; - Item10 --> Item5; Item10 --> Item8; Item10 --> Item4; Item10 --> Item7; Item12 --> Item11; - Item4 --> Item1; - Item4 --> Item2; - Item4 --> Item5; Item4 --> Item8; Item7 -.-> Item9; Item7 -.-> Item10; Item13 --> Item11; - Item13 --> Item1; - Item13 --> Item2; - Item13 --> Item5; Item13 --> Item8; ``` # Phase 4 @@ -305,37 +292,25 @@ graph TD Item17["export initialCat"]; Item18; Item18["export getChimera"]; - Item3 --> Item1; + Item2 --> Item1; Item3 --> Item2; + Item5 --> Item2; Item5 -.-> Item3; - Item6 --> Item1; - Item6 --> Item2; Item6 --> Item5; Item6 --> Item3; + Item8 --> Item5; Item8 -.-> Item6; - Item9 --> Item1; - Item9 --> Item2; - Item9 --> Item5; Item9 --> Item8; Item9 --> Item3; Item9 --> Item6; - Item10 --> Item1; - Item10 --> Item2; - Item10 --> Item5; Item10 --> Item8; Item10 --> Item4; Item10 --> Item7; Item12 --> Item11; - Item4 --> Item1; - Item4 --> Item2; - Item4 --> Item5; Item4 --> Item8; Item7 -.-> Item9; Item7 -.-> Item10; Item13 --> Item11; - Item13 --> Item1; - Item13 --> Item2; - Item13 --> Item5; Item13 --> Item8; Item14 --> Item3; Item14 --> Item6; @@ -349,10 +324,10 @@ graph TD ```mermaid graph TD N0["Items: [ItemId(ModuleEvaluation)]"]; - N1["Items: [ItemId(Export((\"dogRef\", #0)))]"]; - N2["Items: [ItemId(Export((\"cat\", #0)))]"]; - N3["Items: [ItemId(Export((\"initialCat\", #0))), ItemId(11, VarDeclarator(0))]"]; - N4["Items: [ItemId(Export((\"getChimera\", #0))), ItemId(12, Normal)]"]; + N1["Items: [ItemId(Export(("dogRef", #2), "dogRef"))]"]; + N2["Items: [ItemId(Export(("cat", #2), "cat"))]"]; + N3["Items: [ItemId(Export(("initialCat", #2), "initialCat")), ItemId(11, VarDeclarator(0))]"]; + N4["Items: [ItemId(Export(("getChimera", #2), "getChimera")), ItemId(12, Normal)]"]; N5["Items: [ItemId(6, Normal), ItemId(9, VarDeclarator(0))]"]; N6["Items: [ItemId(0, VarDeclarator(0))]"]; N7["Items: [ItemId(1, Normal)]"]; @@ -370,118 +345,114 @@ graph TD N2 --> N14; N3 --> N14; N4 --> N14; - N4 --> N6; - N4 --> N7; - N4 --> N10; N4 --> N12; N5 --> N13; - N5 --> N6; - N5 --> N7; - N5 --> N10; N5 --> N12; N5 --> N9; - N8 --> N6; + N7 --> N6; N8 --> N7; - N9 --> N6; - N9 --> N7; - N9 --> N10; N9 --> N12; + N10 --> N7; N10 --> N8; - N11 --> N6; - N11 --> N7; N11 --> N10; N11 --> N8; + N12 --> N10; N12 --> N11; - N13 --> N6; - N13 --> N7; - N13 --> N10; N13 --> N12; N13 --> N8; N13 --> N11; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "getChimera", + ): 4, + Export( + "initialCat", + ): 3, + Export( + "cat", + ): 2, + Export( + "dogRef", + ): 1, +} +``` + + # Modules (dev) ## Part 0 ```js -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; -import "entry.js" assert { - __turbopack_chunk__: 11 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import "entry.js" assert { - __turbopack_chunk__: 13 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 }; "module evaluation"; ``` ## Part 1 ```js -import { dogRef } from "entry.js" assert { - __turbopack_chunk__: 5 +import { dogRef } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; export { dogRef }; ``` ## Part 2 ```js -import { cat } from "entry.js" assert { - __turbopack_chunk__: 14 +import { cat } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 }; export { cat }; ``` ## Part 3 ```js -import { cat } from "entry.js" assert { - __turbopack_chunk__: 14 +import { cat } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 }; export { initialCat }; const initialCat = cat; -export { initialCat }; +export { initialCat } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 ```js -import { cat } from "entry.js" assert { - __turbopack_chunk__: 14 +import { cat } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 }; -import { dog } from "entry.js" assert { - __turbopack_chunk__: 6 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 -}; -import "entry.js" assert { - __turbopack_chunk__: 12 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 12 }; export { getChimera }; function getChimera() { return cat + dog; } +export { getChimera } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js -import "entry.js" assert { - __turbopack_chunk__: 13 -}; -import { dog } from "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 }; -import "entry.js" assert { - __turbopack_chunk__: 7 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 12 }; -import "entry.js" assert { - __turbopack_chunk__: 10 -}; -import "entry.js" assert { - __turbopack_chunk__: 12 -}; -import { getDog } from "entry.js" assert { - __turbopack_chunk__: 9 +import { getDog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; function setDog(newDog) { dog = newDog; @@ -491,105 +462,103 @@ const dogRef = { get: getDog, set: setDog }; -export { dogRef }; +export { setDog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { dogRef } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js let dog = "dog"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; dog += "!"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 6 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; console.log(dog); ``` ## Part 9 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 6 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 -}; -import "entry.js" assert { - __turbopack_chunk__: 12 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 12 }; function getDog() { return dog; } +export { getDog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 10 ```js -import "entry.js" assert { - __turbopack_chunk__: 8 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; dog += "!"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 11 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 6 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; console.log(dog); ``` ## Part 12 ```js -import "entry.js" assert { - __turbopack_chunk__: 11 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; dog += "!"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 13 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 6 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 12 }; -import "entry.js" assert { - __turbopack_chunk__: 10 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; -import "entry.js" assert { - __turbopack_chunk__: 12 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 11 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; console.log(dog); @@ -597,39 +566,57 @@ console.log(dog); ## Part 14 ```js let cat = "cat"; -export { cat }; +export { cat } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js -let dog = "dog"; -export { dog }; -dog += "!"; -export { dog }; -console.log(dog); -dog += "!"; -export { dog }; -console.log(dog); -dog += "!"; -export { dog }; -console.log(dog); +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; "module evaluation"; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "getChimera", + ): 4, + Export( + "initialCat", + ): 3, + Export( + "cat", + ): 2, + Export( + "dogRef", + ): 1, +} +``` + + # Modules (prod) ## Part 0 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 5 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; "module evaluation"; console.log(dog); @@ -639,17 +626,8 @@ console.log(dog); ``` ## Part 1 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 6 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { dogRef }; function getDog() { @@ -663,90 +641,114 @@ const dogRef = { get: getDog, set: setDog }; -export { dogRef }; +export { getDog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { setDog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { dogRef } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 2 ```js -import { cat } from "entry.js" assert { - __turbopack_chunk__: 9 +import { cat } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; export { cat }; ``` ## Part 3 ```js -import { cat } from "entry.js" assert { - __turbopack_chunk__: 9 +import { cat } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; export { initialCat }; const initialCat = cat; -export { initialCat }; +export { initialCat } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 ```js -import { cat } from "entry.js" assert { - __turbopack_chunk__: 9 +import { cat } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; -import { dog } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 6 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { getChimera }; function getChimera() { return cat + dog; } +export { getChimera } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let dog = "dog"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; dog += "!"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; dog += "!"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; dog += "!"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 9 ```js let cat = "cat"; -export { cat }; +export { cat } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js -let dog = "dog"; -export { dog }; -dog += "!"; -export { dog }; -dog += "!"; -export { dog }; -dog += "!"; -export { dog }; +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; "module evaluation"; console.log(dog); console.log(dog); diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/input.js new file mode 100644 index 0000000000000..7ae3e218f9eb8 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/input.js @@ -0,0 +1 @@ +export { cat as fakeCat } from "./lib"; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/output.md new file mode 100644 index 0000000000000..7ef7fc01d4a80 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/export-named/output.md @@ -0,0 +1,134 @@ +# Items + +Count: 4 + +## Item 1: Stmt 0, `ImportOfModule` + +```js +export { cat as fakeCat } from "./lib"; + +``` + +- Hoisted +- Side effects + +## Item 2: Stmt 0, `ImportBinding(0)` + +```js +export { cat as fakeCat } from "./lib"; + +``` + +- Hoisted +- Declares: `__TURBOPACK__reexport__fakeCat__` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export fakeCat"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export fakeCat"]; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export fakeCat"]; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export fakeCat"]; + Item3 --> Item1; + Item4 --> Item2; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule)]"]; + N1["Items: [ItemId(Export(("__TURBOPACK__reexport__fakeCat__", #3), "fakeCat")), ItemId(0, ImportBinding(0))]"]; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "fakeCat", + ): 1, +} +``` + + +# Modules (dev) +## Part 0 +```js +"module evaluation"; +import "./lib"; + +``` +## Part 1 +```js +export { __TURBOPACK__reexport__fakeCat__ as fakeCat }; +import { cat as __TURBOPACK__reexport__fakeCat__ } from "./lib"; + +``` +## Merged (module eval) +```js +import "./lib"; +"module evaluation"; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "fakeCat", + ): 1, +} +``` + + +# Modules (prod) +## Part 0 +```js +"module evaluation"; +import "./lib"; + +``` +## Part 1 +```js +export { __TURBOPACK__reexport__fakeCat__ as fakeCat }; +import { cat as __TURBOPACK__reexport__fakeCat__ } from "./lib"; + +``` +## Merged (module eval) +```js +import "./lib"; +"module evaluation"; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/input.js new file mode 100644 index 0000000000000..f2974f26f1c70 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/input.js @@ -0,0 +1,57 @@ +let source; +const eventCallbacks = []; +function getSocketProtocol(assetPrefix) { + let protocol = location.protocol; + try { + protocol = new URL(assetPrefix).protocol; + } catch (_) {} + return protocol === "http:" ? "ws" : "wss"; +} +export function addMessageListener(cb) { + eventCallbacks.push(cb); +} +export function sendMessage(data) { + if (!source || source.readyState !== source.OPEN) return; + return source.send(data); +} +export function connectHMR(options) { + const { timeout = 5 * 1000 } = options; + function init() { + if (source) source.close(); + console.log("[HMR] connecting..."); + function handleOnline() { + const connected = { + type: "turbopack-connected" + }; + eventCallbacks.forEach((cb)=>{ + cb(connected); + }); + if (options.log) console.log("[HMR] connected"); + } + function handleMessage(event) { + const message = { + type: "turbopack-message", + data: JSON.parse(event.data) + }; + eventCallbacks.forEach((cb)=>{ + cb(message); + }); + } + function handleDisconnect() { + source.close(); + setTimeout(init, timeout); + } + const { hostname, port } = location; + const protocol = getSocketProtocol(options.assetPrefix || ""); + const assetPrefix = options.assetPrefix.replace(/^\/+/, ""); + let url = `${protocol}://${hostname}:${port}${assetPrefix ? `/${assetPrefix}` : ""}`; + if (assetPrefix.startsWith("http")) { + url = `${protocol}://${assetPrefix.split("://")[1]}`; + } + source = new window.WebSocket(`${url}${options.path}`); + source.onopen = handleOnline; + source.onerror = handleDisconnect; + source.onmessage = handleMessage; + } + init(); +} diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/output.md new file mode 100644 index 0000000000000..f6fe3c1915364 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-1/output.md @@ -0,0 +1,501 @@ +# Items + +Count: 10 + +## Item 1: Stmt 0, `VarDeclarator(0)` + +```js +let source; + +``` + +- Declares: `source` +- Write: `source` + +## Item 2: Stmt 1, `VarDeclarator(0)` + +```js +const eventCallbacks = []; + +``` + +- Declares: `eventCallbacks` +- Write: `eventCallbacks` + +## Item 3: Stmt 2, `Normal` + +```js +function getSocketProtocol(assetPrefix) { + let protocol = location.protocol; + try { + protocol = new URL(assetPrefix).protocol; + } catch (_) {} + return protocol === "http:" ? "ws" : "wss"; +} + +``` + +- Hoisted +- Declares: `getSocketProtocol` +- Reads (eventual): `location`, `URL` +- Write: `getSocketProtocol` + +## Item 4: Stmt 3, `Normal` + +```js +export function addMessageListener(cb) { + eventCallbacks.push(cb); +} + +``` + +- Hoisted +- Declares: `addMessageListener` +- Reads (eventual): `eventCallbacks` +- Write: `addMessageListener` + +## Item 5: Stmt 4, `Normal` + +```js +export function sendMessage(data) { + if (!source || source.readyState !== source.OPEN) return; + return source.send(data); +} + +``` + +- Hoisted +- Declares: `sendMessage` +- Reads (eventual): `source` +- Write: `sendMessage` + +## Item 6: Stmt 5, `Normal` + +```js +export function connectHMR(options) { + const { timeout = 5 * 1000 } = options; + function init() { + if (source) source.close(); + console.log("[HMR] connecting..."); + function handleOnline() { + const connected = { + type: "turbopack-connected" + }; + eventCallbacks.forEach((cb)=>{ + cb(connected); + }); + if (options.log) console.log("[HMR] connected"); + } + function handleMessage(event) { + const message = { + type: "turbopack-message", + data: JSON.parse(event.data) + }; + eventCallbacks.forEach((cb)=>{ + cb(message); + }); + } + function handleDisconnect() { + source.close(); + setTimeout(init, timeout); + } + const { hostname, port } = location; + const protocol = getSocketProtocol(options.assetPrefix || ""); + const assetPrefix = options.assetPrefix.replace(/^\/+/, ""); + let url = `${protocol}://${hostname}:${port}${assetPrefix ? `/${assetPrefix}` : ""}`; + if (assetPrefix.startsWith("http")) { + url = `${protocol}://${assetPrefix.split("://")[1]}`; + } + source = new window.WebSocket(`${url}${options.path}`); + source.onopen = handleOnline; + source.onerror = handleDisconnect; + source.onmessage = handleMessage; + } + init(); +} + +``` + +- Hoisted +- Declares: `connectHMR` +- Reads (eventual): `source`, `console`, `eventCallbacks`, `JSON`, `setTimeout`, `location`, `getSocketProtocol`, `window` +- Write: `connectHMR` +- Write (eventual): `source` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item7; + Item7["ModuleEvaluation"]; + Item8; + Item8["export addMessageListener"]; + Item9; + Item9["export sendMessage"]; + Item10; + Item10["export connectHMR"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item7; + Item7["ModuleEvaluation"]; + Item8; + Item8["export addMessageListener"]; + Item9; + Item9["export sendMessage"]; + Item10; + Item10["export connectHMR"]; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item7; + Item7["ModuleEvaluation"]; + Item8; + Item8["export addMessageListener"]; + Item9; + Item9["export sendMessage"]; + Item10; + Item10["export connectHMR"]; + Item4 --> Item2; + Item5 --> Item1; + Item6 --> Item1; + Item6 --> Item2; + Item6 --> Item3; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item7; + Item7["ModuleEvaluation"]; + Item8; + Item8["export addMessageListener"]; + Item9; + Item9["export sendMessage"]; + Item10; + Item10["export connectHMR"]; + Item4 --> Item2; + Item5 --> Item1; + Item6 --> Item1; + Item6 --> Item2; + Item6 --> Item3; + Item8 --> Item4; + Item9 --> Item5; + Item10 --> Item6; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation)]"]; + N1["Items: [ItemId(Export(("addMessageListener", #2), "addMessageListener")), ItemId(3, Normal)]"]; + N2["Items: [ItemId(Export(("sendMessage", #2), "sendMessage")), ItemId(4, Normal)]"]; + N3["Items: [ItemId(Export(("connectHMR", #2), "connectHMR")), ItemId(2, Normal), ItemId(5, Normal)]"]; + N4["Items: [ItemId(0, VarDeclarator(0))]"]; + N5["Items: [ItemId(1, VarDeclarator(0))]"]; + N1 --> N5; + N2 --> N4; + N3 --> N4; + N3 --> N5; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "connectHMR", + ): 3, + Export( + "addMessageListener", + ): 1, + Export( + "sendMessage", + ): 2, +} +``` + + +# Modules (dev) +## Part 0 +```js +"module evaluation"; + +``` +## Part 1 +```js +import { eventCallbacks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +export { addMessageListener }; +function addMessageListener(cb) { + eventCallbacks.push(cb); +} +export { addMessageListener } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 2 +```js +import { source } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +export { sendMessage }; +function sendMessage(data) { + if (!source || source.readyState !== source.OPEN) return; + return source.send(data); +} +export { sendMessage } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import { source } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import { eventCallbacks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +export { connectHMR }; +function getSocketProtocol(assetPrefix) { + let protocol = location.protocol; + try { + protocol = new URL(assetPrefix).protocol; + } catch (_) {} + return protocol === "http:" ? "ws" : "wss"; +} +function connectHMR(options) { + const { timeout = 5 * 1000 } = options; + function init() { + if (source) source.close(); + console.log("[HMR] connecting..."); + function handleOnline() { + const connected = { + type: "turbopack-connected" + }; + eventCallbacks.forEach((cb)=>{ + cb(connected); + }); + if (options.log) console.log("[HMR] connected"); + } + function handleMessage(event) { + const message = { + type: "turbopack-message", + data: JSON.parse(event.data) + }; + eventCallbacks.forEach((cb)=>{ + cb(message); + }); + } + function handleDisconnect() { + source.close(); + setTimeout(init, timeout); + } + const { hostname, port } = location; + const protocol = getSocketProtocol(options.assetPrefix || ""); + const assetPrefix = options.assetPrefix.replace(/^\/+/, ""); + let url = `${protocol}://${hostname}:${port}${assetPrefix ? `/${assetPrefix}` : ""}`; + if (assetPrefix.startsWith("http")) { + url = `${protocol}://${assetPrefix.split("://")[1]}`; + } + source = new window.WebSocket(`${url}${options.path}`); + source.onopen = handleOnline; + source.onerror = handleDisconnect; + source.onmessage = handleMessage; + } + init(); +} +export { getSocketProtocol } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { connectHMR } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +let source; +export { source } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +const eventCallbacks = []; +export { eventCallbacks } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +"module evaluation"; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "connectHMR", + ): 3, + Export( + "addMessageListener", + ): 1, + Export( + "sendMessage", + ): 2, +} +``` + + +# Modules (prod) +## Part 0 +```js +"module evaluation"; + +``` +## Part 1 +```js +import { eventCallbacks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +export { addMessageListener }; +function addMessageListener(cb) { + eventCallbacks.push(cb); +} +export { addMessageListener } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 2 +```js +import { source } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +export { sendMessage }; +function sendMessage(data) { + if (!source || source.readyState !== source.OPEN) return; + return source.send(data); +} +export { sendMessage } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import { source } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import { eventCallbacks } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +export { connectHMR }; +function getSocketProtocol(assetPrefix) { + let protocol = location.protocol; + try { + protocol = new URL(assetPrefix).protocol; + } catch (_) {} + return protocol === "http:" ? "ws" : "wss"; +} +function connectHMR(options) { + const { timeout = 5 * 1000 } = options; + function init() { + if (source) source.close(); + console.log("[HMR] connecting..."); + function handleOnline() { + const connected = { + type: "turbopack-connected" + }; + eventCallbacks.forEach((cb)=>{ + cb(connected); + }); + if (options.log) console.log("[HMR] connected"); + } + function handleMessage(event) { + const message = { + type: "turbopack-message", + data: JSON.parse(event.data) + }; + eventCallbacks.forEach((cb)=>{ + cb(message); + }); + } + function handleDisconnect() { + source.close(); + setTimeout(init, timeout); + } + const { hostname, port } = location; + const protocol = getSocketProtocol(options.assetPrefix || ""); + const assetPrefix = options.assetPrefix.replace(/^\/+/, ""); + let url = `${protocol}://${hostname}:${port}${assetPrefix ? `/${assetPrefix}` : ""}`; + if (assetPrefix.startsWith("http")) { + url = `${protocol}://${assetPrefix.split("://")[1]}`; + } + source = new window.WebSocket(`${url}${options.path}`); + source.onopen = handleOnline; + source.onerror = handleDisconnect; + source.onmessage = handleMessage; + } + init(); +} +export { getSocketProtocol } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { connectHMR } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +let source; +export { source } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +const eventCallbacks = []; +export { eventCallbacks } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +"module evaluation"; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/input.js new file mode 100644 index 0000000000000..d0e0a6793cecb --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/input.js @@ -0,0 +1,98 @@ +import React from 'react'; +import { DynamicServerError } from '../../client/components/hooks-server-context'; +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; +import { getPathname } from '../../lib/url'; +const hasPostpone = typeof React.unstable_postpone === 'function'; +export function createPrerenderState(isDebugSkeleton) { + return { + isDebugSkeleton, + dynamicAccesses: [] + }; +} +export function markCurrentScopeAsDynamic(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + return; + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} +export function trackDynamicDataAccessed(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + throw new Error(`Route ${pathname} used "${expression}" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`); + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} +export function Postpone({ reason, prerenderState, pathname }) { + postponeWithTracking(prerenderState, reason, pathname); +} +export function trackDynamicFetch(store, expression) { + if (!store.prerenderState || store.isUnstableCacheCallback) return; + postponeWithTracking(store.prerenderState, expression, store.urlPathname); +} +function postponeWithTracking(prerenderState, expression, pathname) { + assertPostpone(); + const reason = `Route ${pathname} needs to bail out of prerendering at this point because it used ${expression}. ` + `React throws this special object to indicate where. It should not be caught by ` + `your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`; + prerenderState.dynamicAccesses.push({ + stack: prerenderState.isDebugSkeleton ? new Error().stack : undefined, + expression + }); + React.unstable_postpone(reason); +} +export function usedDynamicAPIs(prerenderState) { + return prerenderState.dynamicAccesses.length > 0; +} +export function formatDynamicAPIAccesses(prerenderState) { + return prerenderState.dynamicAccesses.filter((access)=>typeof access.stack === 'string' && access.stack.length > 0).map(({ expression, stack })=>{ + stack = stack.split('\n').slice(4).filter((line)=>{ + if (line.includes('node_modules/next/')) { + return false; + } + if (line.includes(' ()')) { + return false; + } + if (line.includes(' (node:')) { + return false; + } + return true; + }).join('\n'); + return `Dynamic API Usage Debug - ${expression}:\n${stack}`; + }); +} +function assertPostpone() { + if (!hasPostpone) { + throw new Error(`Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js`); + } +} +export function createPostponedAbortSignal(reason) { + assertPostpone(); + const controller = new AbortController(); + try { + React.unstable_postpone(reason); + } catch (x) { + controller.abort(x); + } + return controller.signal; +} diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/output.md new file mode 100644 index 0000000000000..7ab4874e5634d --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-2/output.md @@ -0,0 +1,1094 @@ +# Items + +Count: 28 + +## Item 1: Stmt 0, `ImportOfModule` + +```js +import React from 'react'; + +``` + +- Hoisted +- Side effects + +## Item 2: Stmt 0, `ImportBinding(0)` + +```js +import React from 'react'; + +``` + +- Hoisted +- Declares: `React` + +## Item 3: Stmt 1, `ImportOfModule` + +```js +import { DynamicServerError } from '../../client/components/hooks-server-context'; + +``` + +- Hoisted +- Side effects + +## Item 4: Stmt 1, `ImportBinding(0)` + +```js +import { DynamicServerError } from '../../client/components/hooks-server-context'; + +``` + +- Hoisted +- Declares: `DynamicServerError` + +## Item 5: Stmt 2, `ImportOfModule` + +```js +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; + +``` + +- Hoisted +- Side effects + +## Item 6: Stmt 2, `ImportBinding(0)` + +```js +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; + +``` + +- Hoisted +- Declares: `StaticGenBailoutError` + +## Item 7: Stmt 3, `ImportOfModule` + +```js +import { getPathname } from '../../lib/url'; + +``` + +- Hoisted +- Side effects + +## Item 8: Stmt 3, `ImportBinding(0)` + +```js +import { getPathname } from '../../lib/url'; + +``` + +- Hoisted +- Declares: `getPathname` + +## Item 9: Stmt 4, `VarDeclarator(0)` + +```js +const hasPostpone = typeof React.unstable_postpone === 'function'; + +``` + +- Declares: `hasPostpone` +- Reads: `React` +- Write: `hasPostpone` + +## Item 10: Stmt 5, `Normal` + +```js +export function createPrerenderState(isDebugSkeleton) { + return { + isDebugSkeleton, + dynamicAccesses: [] + }; +} + +``` + +- Hoisted +- Declares: `createPrerenderState` +- Write: `createPrerenderState` + +## Item 11: Stmt 6, `Normal` + +```js +export function markCurrentScopeAsDynamic(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + return; + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} + +``` + +- Hoisted +- Declares: `markCurrentScopeAsDynamic` +- Reads (eventual): `getPathname`, `StaticGenBailoutError`, `postponeWithTracking`, `DynamicServerError` +- Write: `markCurrentScopeAsDynamic` + +## Item 12: Stmt 7, `Normal` + +```js +export function trackDynamicDataAccessed(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + throw new Error(`Route ${pathname} used "${expression}" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`); + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} + +``` + +- Hoisted +- Declares: `trackDynamicDataAccessed` +- Reads (eventual): `getPathname`, `Error`, `StaticGenBailoutError`, `postponeWithTracking`, `DynamicServerError` +- Write: `trackDynamicDataAccessed` + +## Item 13: Stmt 8, `Normal` + +```js +export function Postpone({ reason, prerenderState, pathname }) { + postponeWithTracking(prerenderState, reason, pathname); +} + +``` + +- Hoisted +- Declares: `Postpone` +- Reads (eventual): `postponeWithTracking` +- Write: `Postpone` + +## Item 14: Stmt 9, `Normal` + +```js +export function trackDynamicFetch(store, expression) { + if (!store.prerenderState || store.isUnstableCacheCallback) return; + postponeWithTracking(store.prerenderState, expression, store.urlPathname); +} + +``` + +- Hoisted +- Declares: `trackDynamicFetch` +- Reads (eventual): `postponeWithTracking` +- Write: `trackDynamicFetch` + +## Item 15: Stmt 10, `Normal` + +```js +function postponeWithTracking(prerenderState, expression, pathname) { + assertPostpone(); + const reason = `Route ${pathname} needs to bail out of prerendering at this point because it used ${expression}. ` + `React throws this special object to indicate where. It should not be caught by ` + `your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`; + prerenderState.dynamicAccesses.push({ + stack: prerenderState.isDebugSkeleton ? new Error().stack : undefined, + expression + }); + React.unstable_postpone(reason); +} + +``` + +- Hoisted +- Declares: `postponeWithTracking` +- Reads (eventual): `assertPostpone`, `Error`, `undefined`, `React` +- Write: `postponeWithTracking` + +## Item 16: Stmt 11, `Normal` + +```js +export function usedDynamicAPIs(prerenderState) { + return prerenderState.dynamicAccesses.length > 0; +} + +``` + +- Hoisted +- Declares: `usedDynamicAPIs` +- Write: `usedDynamicAPIs` + +## Item 17: Stmt 12, `Normal` + +```js +export function formatDynamicAPIAccesses(prerenderState) { + return prerenderState.dynamicAccesses.filter((access)=>typeof access.stack === 'string' && access.stack.length > 0).map(({ expression, stack })=>{ + stack = stack.split('\n').slice(4).filter((line)=>{ + if (line.includes('node_modules/next/')) { + return false; + } + if (line.includes(' ()')) { + return false; + } + if (line.includes(' (node:')) { + return false; + } + return true; + }).join('\n'); + return `Dynamic API Usage Debug - ${expression}:\n${stack}`; + }); +} + +``` + +- Hoisted +- Declares: `formatDynamicAPIAccesses` +- Write: `formatDynamicAPIAccesses` + +## Item 18: Stmt 13, `Normal` + +```js +function assertPostpone() { + if (!hasPostpone) { + throw new Error(`Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js`); + } +} + +``` + +- Hoisted +- Declares: `assertPostpone` +- Reads (eventual): `hasPostpone`, `Error` +- Write: `assertPostpone` + +## Item 19: Stmt 14, `Normal` + +```js +export function createPostponedAbortSignal(reason) { + assertPostpone(); + const controller = new AbortController(); + try { + React.unstable_postpone(reason); + } catch (x) { + controller.abort(x); + } + return controller.signal; +} + +``` + +- Hoisted +- Declares: `createPostponedAbortSignal` +- Reads (eventual): `assertPostpone`, `AbortController`, `React` +- Write: `createPostponedAbortSignal` + +# Phase 1 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item20["ModuleEvaluation"]; + Item21; + Item21["export createPrerenderState"]; + Item22; + Item22["export markCurrentScopeAsDynamic"]; + Item23; + Item23["export trackDynamicDataAccessed"]; + Item24; + Item24["export Postpone"]; + Item25; + Item25["export trackDynamicFetch"]; + Item26; + Item26["export usedDynamicAPIs"]; + Item27; + Item27["export formatDynamicAPIAccesses"]; + Item28; + Item28["export createPostponedAbortSignal"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item20["ModuleEvaluation"]; + Item21; + Item21["export createPrerenderState"]; + Item22; + Item22["export markCurrentScopeAsDynamic"]; + Item23; + Item23["export trackDynamicDataAccessed"]; + Item24; + Item24["export Postpone"]; + Item25; + Item25["export trackDynamicFetch"]; + Item26; + Item26["export usedDynamicAPIs"]; + Item27; + Item27["export formatDynamicAPIAccesses"]; + Item28; + Item28["export createPostponedAbortSignal"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item9 --> Item5; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item20["ModuleEvaluation"]; + Item21; + Item21["export createPrerenderState"]; + Item22; + Item22["export markCurrentScopeAsDynamic"]; + Item23; + Item23["export trackDynamicDataAccessed"]; + Item24; + Item24["export Postpone"]; + Item25; + Item25["export trackDynamicFetch"]; + Item26; + Item26["export usedDynamicAPIs"]; + Item27; + Item27["export formatDynamicAPIAccesses"]; + Item28; + Item28["export createPostponedAbortSignal"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item9 --> Item5; + Item11 --> Item8; + Item11 --> Item7; + Item11 --> Item15; + Item11 --> Item6; + Item12 --> Item8; + Item12 --> Item7; + Item12 --> Item15; + Item12 --> Item6; + Item13 --> Item15; + Item14 --> Item15; + Item15 --> Item18; + Item15 --> Item5; + Item18 --> Item9; + Item19 --> Item18; + Item19 --> Item5; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item5; + Item2; + Item6; + Item3; + Item7; + Item4; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item20["ModuleEvaluation"]; + Item21; + Item21["export createPrerenderState"]; + Item22; + Item22["export markCurrentScopeAsDynamic"]; + Item23; + Item23["export trackDynamicDataAccessed"]; + Item24; + Item24["export Postpone"]; + Item25; + Item25["export trackDynamicFetch"]; + Item26; + Item26["export usedDynamicAPIs"]; + Item27; + Item27["export formatDynamicAPIAccesses"]; + Item28; + Item28["export createPostponedAbortSignal"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item9 --> Item5; + Item11 --> Item8; + Item11 --> Item7; + Item11 --> Item15; + Item11 --> Item6; + Item12 --> Item8; + Item12 --> Item7; + Item12 --> Item15; + Item12 --> Item6; + Item13 --> Item15; + Item14 --> Item15; + Item15 --> Item18; + Item15 --> Item5; + Item18 --> Item9; + Item19 --> Item18; + Item19 --> Item5; + Item20 --> Item1; + Item20 --> Item2; + Item20 --> Item3; + Item20 --> Item4; + Item21 --> Item10; + Item22 --> Item11; + Item23 --> Item12; + Item24 --> Item13; + Item25 --> Item14; + Item26 --> Item16; + Item27 --> Item17; + Item28 --> Item19; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule), ItemId(1, ImportOfModule), ItemId(2, ImportOfModule), ItemId(3, ImportOfModule)]"]; + N1["Items: [ItemId(Export(("createPrerenderState", #2), "createPrerenderState")), ItemId(5, Normal)]"]; + N2["Items: [ItemId(Export(("markCurrentScopeAsDynamic", #2), "markCurrentScopeAsDynamic")), ItemId(1, ImportBinding(0)), ItemId(2, ImportBinding(0)), ItemId(3, ImportBinding(0)), ItemId(6, Normal)]"]; + N3["Items: [ItemId(Export(("trackDynamicDataAccessed", #2), "trackDynamicDataAccessed")), ItemId(1, ImportBinding(0)), ItemId(2, ImportBinding(0)), ItemId(3, ImportBinding(0)), ItemId(7, Normal)]"]; + N4["Items: [ItemId(Export(("Postpone", #2), "Postpone")), ItemId(8, Normal)]"]; + N5["Items: [ItemId(Export(("trackDynamicFetch", #2), "trackDynamicFetch")), ItemId(9, Normal)]"]; + N6["Items: [ItemId(Export(("usedDynamicAPIs", #2), "usedDynamicAPIs")), ItemId(11, Normal)]"]; + N7["Items: [ItemId(Export(("formatDynamicAPIAccesses", #2), "formatDynamicAPIAccesses")), ItemId(12, Normal)]"]; + N8["Items: [ItemId(Export(("createPostponedAbortSignal", #2), "createPostponedAbortSignal")), ItemId(0, ImportBinding(0)), ItemId(14, Normal)]"]; + N9["Items: [ItemId(0, ImportBinding(0)), ItemId(4, VarDeclarator(0))]"]; + N10["Items: [ItemId(0, ImportBinding(0)), ItemId(10, Normal)]"]; + N11["Items: [ItemId(13, Normal)]"]; + N2 --> N3; + N2 --> N10; + N3 --> N10; + N4 --> N10; + N5 --> N10; + N8 --> N11; + N8 --> N10; + N9 --> N10; + N10 --> N11; + N11 --> N9; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "createPrerenderState", + ): 1, + Export( + "markCurrentScopeAsDynamic", + ): 2, + Export( + "usedDynamicAPIs", + ): 6, + Export( + "trackDynamicDataAccessed", + ): 3, + Export( + "Postpone", + ): 4, + Export( + "trackDynamicFetch", + ): 5, + Export( + "createPostponedAbortSignal", + ): 8, + Export( + "formatDynamicAPIAccesses", + ): 7, +} +``` + + +# Modules (dev) +## Part 0 +```js +"module evaluation"; +import 'react'; +import '../../client/components/hooks-server-context'; +import '../../client/components/static-generation-bailout'; +import '../../lib/url'; + +``` +## Part 1 +```js +export { createPrerenderState }; +function createPrerenderState(isDebugSkeleton) { + return { + isDebugSkeleton, + dynamicAccesses: [] + }; +} +export { createPrerenderState } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 2 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { markCurrentScopeAsDynamic }; +import { DynamicServerError } from '../../client/components/hooks-server-context'; +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; +import { getPathname } from '../../lib/url'; +function markCurrentScopeAsDynamic(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + return; + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} +export { markCurrentScopeAsDynamic } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { trackDynamicDataAccessed }; +import { DynamicServerError } from '../../client/components/hooks-server-context'; +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; +import { getPathname } from '../../lib/url'; +function trackDynamicDataAccessed(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + throw new Error(`Route ${pathname} used "${expression}" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`); + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} +export { trackDynamicDataAccessed } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { Postpone }; +function Postpone({ reason, prerenderState, pathname }) { + postponeWithTracking(prerenderState, reason, pathname); +} +export { Postpone } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { trackDynamicFetch }; +function trackDynamicFetch(store, expression) { + if (!store.prerenderState || store.isUnstableCacheCallback) return; + postponeWithTracking(store.prerenderState, expression, store.urlPathname); +} +export { trackDynamicFetch } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 6 +```js +export { usedDynamicAPIs }; +function usedDynamicAPIs(prerenderState) { + return prerenderState.dynamicAccesses.length > 0; +} +export { usedDynamicAPIs } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 7 +```js +export { formatDynamicAPIAccesses }; +function formatDynamicAPIAccesses(prerenderState) { + return prerenderState.dynamicAccesses.filter((access)=>typeof access.stack === 'string' && access.stack.length > 0).map(({ expression, stack })=>{ + stack = stack.split('\n').slice(4).filter((line)=>{ + if (line.includes('node_modules/next/')) { + return false; + } + if (line.includes(' ()')) { + return false; + } + if (line.includes(' (node:')) { + return false; + } + return true; + }).join('\n'); + return `Dynamic API Usage Debug - ${expression}:\n${stack}`; + }); +} +export { formatDynamicAPIAccesses } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 8 +```js +import { assertPostpone } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { createPostponedAbortSignal }; +import React from 'react'; +function createPostponedAbortSignal(reason) { + assertPostpone(); + const controller = new AbortController(); + try { + React.unstable_postpone(reason); + } catch (x) { + controller.abort(x); + } + return controller.signal; +} +export { createPostponedAbortSignal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 9 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import React from 'react'; +const hasPostpone = typeof React.unstable_postpone === 'function'; +export { hasPostpone } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 10 +```js +import { assertPostpone } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import React from 'react'; +function postponeWithTracking(prerenderState, expression, pathname) { + assertPostpone(); + const reason = `Route ${pathname} needs to bail out of prerendering at this point because it used ${expression}. ` + `React throws this special object to indicate where. It should not be caught by ` + `your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`; + prerenderState.dynamicAccesses.push({ + stack: prerenderState.isDebugSkeleton ? new Error().stack : undefined, + expression + }); + React.unstable_postpone(reason); +} +export { postponeWithTracking } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 11 +```js +import { hasPostpone } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +function assertPostpone() { + if (!hasPostpone) { + throw new Error(`Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js`); + } +} +export { assertPostpone } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import 'react'; +import '../../client/components/hooks-server-context'; +import '../../client/components/static-generation-bailout'; +import '../../lib/url'; +"module evaluation"; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "createPrerenderState", + ): 1, + Export( + "markCurrentScopeAsDynamic", + ): 2, + Export( + "usedDynamicAPIs", + ): 6, + Export( + "trackDynamicDataAccessed", + ): 3, + Export( + "Postpone", + ): 4, + Export( + "trackDynamicFetch", + ): 5, + Export( + "createPostponedAbortSignal", + ): 8, + Export( + "formatDynamicAPIAccesses", + ): 7, +} +``` + + +# Modules (prod) +## Part 0 +```js +"module evaluation"; +import 'react'; +import '../../client/components/hooks-server-context'; +import '../../client/components/static-generation-bailout'; +import '../../lib/url'; + +``` +## Part 1 +```js +export { createPrerenderState }; +function createPrerenderState(isDebugSkeleton) { + return { + isDebugSkeleton, + dynamicAccesses: [] + }; +} +export { createPrerenderState } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 2 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { markCurrentScopeAsDynamic }; +import { DynamicServerError } from '../../client/components/hooks-server-context'; +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; +import { getPathname } from '../../lib/url'; +function markCurrentScopeAsDynamic(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + return; + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} +export { markCurrentScopeAsDynamic } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { trackDynamicDataAccessed }; +import { DynamicServerError } from '../../client/components/hooks-server-context'; +import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'; +import { getPathname } from '../../lib/url'; +function trackDynamicDataAccessed(store, expression) { + const pathname = getPathname(store.urlPathname); + if (store.isUnstableCacheCallback) { + throw new Error(`Route ${pathname} used "${expression}" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`); + } else if (store.dynamicShouldError) { + throw new StaticGenBailoutError(`Route ${pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`); + } else if (store.prerenderState) { + postponeWithTracking(store.prerenderState, expression, pathname); + } else { + store.revalidate = 0; + if (store.isStaticGeneration) { + const err = new DynamicServerError(`Route ${pathname} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`); + store.dynamicUsageDescription = expression; + store.dynamicUsageStack = err.stack; + throw err; + } + } +} +export { trackDynamicDataAccessed } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { Postpone }; +function Postpone({ reason, prerenderState, pathname }) { + postponeWithTracking(prerenderState, reason, pathname); +} +export { Postpone } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +import { postponeWithTracking } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { trackDynamicFetch }; +function trackDynamicFetch(store, expression) { + if (!store.prerenderState || store.isUnstableCacheCallback) return; + postponeWithTracking(store.prerenderState, expression, store.urlPathname); +} +export { trackDynamicFetch } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 6 +```js +export { usedDynamicAPIs }; +function usedDynamicAPIs(prerenderState) { + return prerenderState.dynamicAccesses.length > 0; +} +export { usedDynamicAPIs } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 7 +```js +export { formatDynamicAPIAccesses }; +function formatDynamicAPIAccesses(prerenderState) { + return prerenderState.dynamicAccesses.filter((access)=>typeof access.stack === 'string' && access.stack.length > 0).map(({ expression, stack })=>{ + stack = stack.split('\n').slice(4).filter((line)=>{ + if (line.includes('node_modules/next/')) { + return false; + } + if (line.includes(' ()')) { + return false; + } + if (line.includes(' (node:')) { + return false; + } + return true; + }).join('\n'); + return `Dynamic API Usage Debug - ${expression}:\n${stack}`; + }); +} +export { formatDynamicAPIAccesses } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 8 +```js +import { assertPostpone } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +export { createPostponedAbortSignal }; +import React from 'react'; +function createPostponedAbortSignal(reason) { + assertPostpone(); + const controller = new AbortController(); + try { + React.unstable_postpone(reason); + } catch (x) { + controller.abort(x); + } + return controller.signal; +} +export { createPostponedAbortSignal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 9 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import React from 'react'; +const hasPostpone = typeof React.unstable_postpone === 'function'; +export { hasPostpone } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 10 +```js +import { assertPostpone } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import React from 'react'; +function postponeWithTracking(prerenderState, expression, pathname) { + assertPostpone(); + const reason = `Route ${pathname} needs to bail out of prerendering at this point because it used ${expression}. ` + `React throws this special object to indicate where. It should not be caught by ` + `your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`; + prerenderState.dynamicAccesses.push({ + stack: prerenderState.isDebugSkeleton ? new Error().stack : undefined, + expression + }); + React.unstable_postpone(reason); +} +export { postponeWithTracking } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 11 +```js +import { hasPostpone } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +function assertPostpone() { + if (!hasPostpone) { + throw new Error(`Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js`); + } +} +export { assertPostpone } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import 'react'; +import '../../client/components/hooks-server-context'; +import '../../client/components/static-generation-bailout'; +import '../../lib/url'; +"module evaluation"; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/input.js new file mode 100644 index 0000000000000..441b34ae57bca --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/input.js @@ -0,0 +1,172 @@ +import { createConnection } from "node:net"; +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; +import { getProperError } from "./error"; +export function structuredError(e) { + e = getProperError(e); + return { + name: e.name, + message: e.message, + stack: typeof e.stack === "string" ? parseStackTrace(e.stack) : [] + }; +} +function createIpc(port) { + const socket = createConnection(port, "127.0.0.1"); + const packetQueue = []; + const recvPromiseResolveQueue = []; + function pushPacket(packet) { + const recvPromiseResolve = recvPromiseResolveQueue.shift(); + if (recvPromiseResolve != null) { + recvPromiseResolve(JSON.parse(packet.toString("utf8"))); + } else { + packetQueue.push(packet); + } + } + let state = { + type: "waiting" + }; + let buffer = Buffer.alloc(0); + socket.once("connect", ()=>{ + socket.on("data", (chunk)=>{ + buffer = Buffer.concat([ + buffer, + chunk + ]); + loop: while(true){ + switch(state.type){ + case "waiting": + { + if (buffer.length >= 4) { + const length = buffer.readUInt32BE(0); + buffer = buffer.subarray(4); + state = { + type: "packet", + length + }; + } else { + break loop; + } + break; + } + case "packet": + { + if (buffer.length >= state.length) { + const packet = buffer.subarray(0, state.length); + buffer = buffer.subarray(state.length); + state = { + type: "waiting" + }; + pushPacket(packet); + } else { + break loop; + } + break; + } + } + } + }); + }); + socket.once("close", ()=>{ + process.exit(0); + }); + function send(message) { + const packet = Buffer.from(JSON.stringify(message), "utf8"); + const length = Buffer.alloc(4); + length.writeUInt32BE(packet.length); + socket.write(length); + return new Promise((resolve, reject)=>{ + socket.write(packet, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + function sendReady() { + const length = Buffer.from([ + 0, + 0, + 0, + 0 + ]); + return new Promise((resolve, reject)=>{ + socket.write(length, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + return { + async recv () { + const packet = packetQueue.shift(); + if (packet != null) { + return JSON.parse(packet.toString("utf8")); + } + const result = await new Promise((resolve)=>{ + recvPromiseResolveQueue.push((result)=>{ + resolve(result); + }); + }); + return result; + }, + send (message) { + return send(message); + }, + sendReady, + async sendError (error) { + try { + await send({ + type: "error", + ...structuredError(error) + }); + } catch (err) { + console.error("failed to send error back to rust:", err); + process.exit(1); + } + process.exit(0); + } + }; +} +const PORT = process.argv[2]; +export const IPC = createIpc(parseInt(PORT, 10)); +process.on("uncaughtException", (err)=>{ + IPC.sendError(err); +}); +const improveConsole = (name, stream, addStack)=>{ + const original = console[name]; + const stdio = process[stream]; + console[name] = (...args)=>{ + stdio.write(`TURBOPACK_OUTPUT_B\n`); + original(...args); + if (addStack) { + const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n"; + stdio.write("TURBOPACK_OUTPUT_S\n"); + stdio.write(stack); + } + stdio.write("TURBOPACK_OUTPUT_E\n"); + }; +}; +improveConsole("error", "stderr", true); +improveConsole("warn", "stderr", true); +improveConsole("count", "stdout", true); +improveConsole("trace", "stderr", false); +improveConsole("log", "stdout", true); +improveConsole("group", "stdout", true); +improveConsole("groupCollapsed", "stdout", true); +improveConsole("table", "stdout", true); +improveConsole("debug", "stdout", true); +improveConsole("info", "stdout", true); +improveConsole("dir", "stdout", true); +improveConsole("dirxml", "stdout", true); +improveConsole("timeEnd", "stdout", true); +improveConsole("timeLog", "stdout", true); +improveConsole("timeStamp", "stdout", true); +improveConsole("assert", "stderr", true); diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/output.md new file mode 100644 index 0000000000000..dd4ee200bda38 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/failed-3/output.md @@ -0,0 +1,2202 @@ +# Items + +Count: 31 + +## Item 1: Stmt 0, `ImportOfModule` + +```js +import { createConnection } from "node:net"; + +``` + +- Hoisted +- Side effects + +## Item 2: Stmt 0, `ImportBinding(0)` + +```js +import { createConnection } from "node:net"; + +``` + +- Hoisted +- Declares: `createConnection` + +## Item 3: Stmt 1, `ImportOfModule` + +```js +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; + +``` + +- Hoisted +- Side effects + +## Item 4: Stmt 1, `ImportBinding(0)` + +```js +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; + +``` + +- Hoisted +- Declares: `parseStackTrace` + +## Item 5: Stmt 2, `ImportOfModule` + +```js +import { getProperError } from "./error"; + +``` + +- Hoisted +- Side effects + +## Item 6: Stmt 2, `ImportBinding(0)` + +```js +import { getProperError } from "./error"; + +``` + +- Hoisted +- Declares: `getProperError` + +## Item 7: Stmt 3, `Normal` + +```js +export function structuredError(e) { + e = getProperError(e); + return { + name: e.name, + message: e.message, + stack: typeof e.stack === "string" ? parseStackTrace(e.stack) : [] + }; +} + +``` + +- Hoisted +- Declares: `structuredError` +- Reads (eventual): `getProperError`, `parseStackTrace` +- Write: `structuredError` + +## Item 8: Stmt 4, `Normal` + +```js +function createIpc(port) { + const socket = createConnection(port, "127.0.0.1"); + const packetQueue = []; + const recvPromiseResolveQueue = []; + function pushPacket(packet) { + const recvPromiseResolve = recvPromiseResolveQueue.shift(); + if (recvPromiseResolve != null) { + recvPromiseResolve(JSON.parse(packet.toString("utf8"))); + } else { + packetQueue.push(packet); + } + } + let state = { + type: "waiting" + }; + let buffer = Buffer.alloc(0); + socket.once("connect", ()=>{ + socket.on("data", (chunk)=>{ + buffer = Buffer.concat([ + buffer, + chunk + ]); + loop: while(true){ + switch(state.type){ + case "waiting": + { + if (buffer.length >= 4) { + const length = buffer.readUInt32BE(0); + buffer = buffer.subarray(4); + state = { + type: "packet", + length + }; + } else { + break loop; + } + break; + } + case "packet": + { + if (buffer.length >= state.length) { + const packet = buffer.subarray(0, state.length); + buffer = buffer.subarray(state.length); + state = { + type: "waiting" + }; + pushPacket(packet); + } else { + break loop; + } + break; + } + } + } + }); + }); + socket.once("close", ()=>{ + process.exit(0); + }); + function send(message) { + const packet = Buffer.from(JSON.stringify(message), "utf8"); + const length = Buffer.alloc(4); + length.writeUInt32BE(packet.length); + socket.write(length); + return new Promise((resolve, reject)=>{ + socket.write(packet, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + function sendReady() { + const length = Buffer.from([ + 0, + 0, + 0, + 0 + ]); + return new Promise((resolve, reject)=>{ + socket.write(length, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + return { + async recv () { + const packet = packetQueue.shift(); + if (packet != null) { + return JSON.parse(packet.toString("utf8")); + } + const result = await new Promise((resolve)=>{ + recvPromiseResolveQueue.push((result)=>{ + resolve(result); + }); + }); + return result; + }, + send (message) { + return send(message); + }, + sendReady, + async sendError (error) { + try { + await send({ + type: "error", + ...structuredError(error) + }); + } catch (err) { + console.error("failed to send error back to rust:", err); + process.exit(1); + } + process.exit(0); + } + }; +} + +``` + +- Hoisted +- Declares: `createIpc` +- Reads (eventual): `createConnection`, `JSON`, `Buffer`, `loop`, `process`, `Promise`, `structuredError`, `console` +- Write: `createIpc` + +## Item 9: Stmt 5, `VarDeclarator(0)` + +```js +const PORT = process.argv[2]; + +``` + +- Declares: `PORT` +- Reads: `process` +- Write: `PORT` + +## Item 10: Stmt 6, `VarDeclarator(0)` + +```js +export const IPC = createIpc(parseInt(PORT, 10)); + +``` + +- Declares: `IPC` +- Reads: `createIpc`, `parseInt`, `PORT` +- Write: `IPC` + +## Item 11: Stmt 7, `Normal` + +```js +process.on("uncaughtException", (err)=>{ + IPC.sendError(err); +}); + +``` + +- Side effects +- Reads: `process` +- Reads (eventual): `IPC` + +## Item 12: Stmt 8, `VarDeclarator(0)` + +```js +const improveConsole = (name, stream, addStack)=>{ + const original = console[name]; + const stdio = process[stream]; + console[name] = (...args)=>{ + stdio.write(`TURBOPACK_OUTPUT_B\n`); + original(...args); + if (addStack) { + const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n"; + stdio.write("TURBOPACK_OUTPUT_S\n"); + stdio.write(stack); + } + stdio.write("TURBOPACK_OUTPUT_E\n"); + }; +}; + +``` + +- Declares: `improveConsole` +- Reads (eventual): `console`, `process`, `Error` +- Write: `improveConsole` + +## Item 13: Stmt 9, `Normal` + +```js +improveConsole("error", "stderr", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 14: Stmt 10, `Normal` + +```js +improveConsole("warn", "stderr", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 15: Stmt 11, `Normal` + +```js +improveConsole("count", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 16: Stmt 12, `Normal` + +```js +improveConsole("trace", "stderr", false); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 17: Stmt 13, `Normal` + +```js +improveConsole("log", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 18: Stmt 14, `Normal` + +```js +improveConsole("group", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 19: Stmt 15, `Normal` + +```js +improveConsole("groupCollapsed", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 20: Stmt 16, `Normal` + +```js +improveConsole("table", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 21: Stmt 17, `Normal` + +```js +improveConsole("debug", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 22: Stmt 18, `Normal` + +```js +improveConsole("info", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 23: Stmt 19, `Normal` + +```js +improveConsole("dir", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 24: Stmt 20, `Normal` + +```js +improveConsole("dirxml", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 25: Stmt 21, `Normal` + +```js +improveConsole("timeEnd", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 26: Stmt 22, `Normal` + +```js +improveConsole("timeLog", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 27: Stmt 23, `Normal` + +```js +improveConsole("timeStamp", "stdout", true); + +``` + +- Side effects +- Reads: `improveConsole` + +## Item 28: Stmt 24, `Normal` + +```js +improveConsole("assert", "stderr", true); + +``` + +- Side effects +- Reads: `improveConsole` + +# Phase 1 +```mermaid +graph TD + Item1; + Item4; + Item2; + Item5; + Item3; + Item6; + Item7; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item26; + Item27; + Item28; + Item29; + Item29["ModuleEvaluation"]; + Item30; + Item30["export structuredError"]; + Item31; + Item31["export IPC"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item4; + Item2; + Item5; + Item3; + Item6; + Item7; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item26; + Item27; + Item28; + Item29; + Item29["ModuleEvaluation"]; + Item30; + Item30["export structuredError"]; + Item31; + Item31["export IPC"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item10 --> Item8; + Item10 --> Item9; + Item11 --> Item1; + Item11 --> Item2; + Item11 --> Item3; + Item11 -.-> Item6; + Item11 -.-> Item5; + Item11 -.-> Item4; + Item11 -.-> Item9; + Item11 -.-> Item7; + Item11 -.-> Item10; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item11; + Item13 -.-> Item6; + Item13 -.-> Item5; + Item13 -.-> Item4; + Item13 -.-> Item9; + Item13 -.-> Item7; + Item13 -.-> Item10; + Item14 --> Item12; + Item14 --> Item1; + Item14 --> Item2; + Item14 --> Item3; + Item14 --> Item11; + Item14 --> Item13; + Item14 -.-> Item6; + Item14 -.-> Item5; + Item14 -.-> Item4; + Item14 -.-> Item9; + Item14 -.-> Item7; + Item14 -.-> Item10; + Item15 --> Item12; + Item15 --> Item1; + Item15 --> Item2; + Item15 --> Item3; + Item15 --> Item11; + Item15 --> Item13; + Item15 --> Item14; + Item15 -.-> Item6; + Item15 -.-> Item5; + Item15 -.-> Item4; + Item15 -.-> Item9; + Item15 -.-> Item7; + Item15 -.-> Item10; + Item16 --> Item12; + Item16 --> Item1; + Item16 --> Item2; + Item16 --> Item3; + Item16 --> Item11; + Item16 --> Item13; + Item16 --> Item14; + Item16 --> Item15; + Item16 -.-> Item6; + Item16 -.-> Item5; + Item16 -.-> Item4; + Item16 -.-> Item9; + Item16 -.-> Item7; + Item16 -.-> Item10; + Item17 --> Item12; + Item17 --> Item1; + Item17 --> Item2; + Item17 --> Item3; + Item17 --> Item11; + Item17 --> Item13; + Item17 --> Item14; + Item17 --> Item15; + Item17 --> Item16; + Item17 -.-> Item6; + Item17 -.-> Item5; + Item17 -.-> Item4; + Item17 -.-> Item9; + Item17 -.-> Item7; + Item17 -.-> Item10; + Item18 --> Item12; + Item18 --> Item1; + Item18 --> Item2; + Item18 --> Item3; + Item18 --> Item11; + Item18 --> Item13; + Item18 --> Item14; + Item18 --> Item15; + Item18 --> Item16; + Item18 --> Item17; + Item18 -.-> Item6; + Item18 -.-> Item5; + Item18 -.-> Item4; + Item18 -.-> Item9; + Item18 -.-> Item7; + Item18 -.-> Item10; + Item19 --> Item12; + Item19 --> Item1; + Item19 --> Item2; + Item19 --> Item3; + Item19 --> Item11; + Item19 --> Item13; + Item19 --> Item14; + Item19 --> Item15; + Item19 --> Item16; + Item19 --> Item17; + Item19 --> Item18; + Item19 -.-> Item6; + Item19 -.-> Item5; + Item19 -.-> Item4; + Item19 -.-> Item9; + Item19 -.-> Item7; + Item19 -.-> Item10; + Item20 --> Item12; + Item20 --> Item1; + Item20 --> Item2; + Item20 --> Item3; + Item20 --> Item11; + Item20 --> Item13; + Item20 --> Item14; + Item20 --> Item15; + Item20 --> Item16; + Item20 --> Item17; + Item20 --> Item18; + Item20 --> Item19; + Item20 -.-> Item6; + Item20 -.-> Item5; + Item20 -.-> Item4; + Item20 -.-> Item9; + Item20 -.-> Item7; + Item20 -.-> Item10; + Item21 --> Item12; + Item21 --> Item1; + Item21 --> Item2; + Item21 --> Item3; + Item21 --> Item11; + Item21 --> Item13; + Item21 --> Item14; + Item21 --> Item15; + Item21 --> Item16; + Item21 --> Item17; + Item21 --> Item18; + Item21 --> Item19; + Item21 --> Item20; + Item21 -.-> Item6; + Item21 -.-> Item5; + Item21 -.-> Item4; + Item21 -.-> Item9; + Item21 -.-> Item7; + Item21 -.-> Item10; + Item22 --> Item12; + Item22 --> Item1; + Item22 --> Item2; + Item22 --> Item3; + Item22 --> Item11; + Item22 --> Item13; + Item22 --> Item14; + Item22 --> Item15; + Item22 --> Item16; + Item22 --> Item17; + Item22 --> Item18; + Item22 --> Item19; + Item22 --> Item20; + Item22 --> Item21; + Item22 -.-> Item6; + Item22 -.-> Item5; + Item22 -.-> Item4; + Item22 -.-> Item9; + Item22 -.-> Item7; + Item22 -.-> Item10; + Item23 --> Item12; + Item23 --> Item1; + Item23 --> Item2; + Item23 --> Item3; + Item23 --> Item11; + Item23 --> Item13; + Item23 --> Item14; + Item23 --> Item15; + Item23 --> Item16; + Item23 --> Item17; + Item23 --> Item18; + Item23 --> Item19; + Item23 --> Item20; + Item23 --> Item21; + Item23 --> Item22; + Item23 -.-> Item6; + Item23 -.-> Item5; + Item23 -.-> Item4; + Item23 -.-> Item9; + Item23 -.-> Item7; + Item23 -.-> Item10; + Item24 --> Item12; + Item24 --> Item1; + Item24 --> Item2; + Item24 --> Item3; + Item24 --> Item11; + Item24 --> Item13; + Item24 --> Item14; + Item24 --> Item15; + Item24 --> Item16; + Item24 --> Item17; + Item24 --> Item18; + Item24 --> Item19; + Item24 --> Item20; + Item24 --> Item21; + Item24 --> Item22; + Item24 --> Item23; + Item24 -.-> Item6; + Item24 -.-> Item5; + Item24 -.-> Item4; + Item24 -.-> Item9; + Item24 -.-> Item7; + Item24 -.-> Item10; + Item25 --> Item12; + Item25 --> Item1; + Item25 --> Item2; + Item25 --> Item3; + Item25 --> Item11; + Item25 --> Item13; + Item25 --> Item14; + Item25 --> Item15; + Item25 --> Item16; + Item25 --> Item17; + Item25 --> Item18; + Item25 --> Item19; + Item25 --> Item20; + Item25 --> Item21; + Item25 --> Item22; + Item25 --> Item23; + Item25 --> Item24; + Item25 -.-> Item6; + Item25 -.-> Item5; + Item25 -.-> Item4; + Item25 -.-> Item9; + Item25 -.-> Item7; + Item25 -.-> Item10; + Item26 --> Item12; + Item26 --> Item1; + Item26 --> Item2; + Item26 --> Item3; + Item26 --> Item11; + Item26 --> Item13; + Item26 --> Item14; + Item26 --> Item15; + Item26 --> Item16; + Item26 --> Item17; + Item26 --> Item18; + Item26 --> Item19; + Item26 --> Item20; + Item26 --> Item21; + Item26 --> Item22; + Item26 --> Item23; + Item26 --> Item24; + Item26 --> Item25; + Item26 -.-> Item6; + Item26 -.-> Item5; + Item26 -.-> Item4; + Item26 -.-> Item9; + Item26 -.-> Item7; + Item26 -.-> Item10; + Item27 --> Item12; + Item27 --> Item1; + Item27 --> Item2; + Item27 --> Item3; + Item27 --> Item11; + Item27 --> Item13; + Item27 --> Item14; + Item27 --> Item15; + Item27 --> Item16; + Item27 --> Item17; + Item27 --> Item18; + Item27 --> Item19; + Item27 --> Item20; + Item27 --> Item21; + Item27 --> Item22; + Item27 --> Item23; + Item27 --> Item24; + Item27 --> Item25; + Item27 --> Item26; + Item27 -.-> Item6; + Item27 -.-> Item5; + Item27 -.-> Item4; + Item27 -.-> Item9; + Item27 -.-> Item7; + Item27 -.-> Item10; + Item28 --> Item12; + Item28 --> Item1; + Item28 --> Item2; + Item28 --> Item3; + Item28 --> Item11; + Item28 --> Item13; + Item28 --> Item14; + Item28 --> Item15; + Item28 --> Item16; + Item28 --> Item17; + Item28 --> Item18; + Item28 --> Item19; + Item28 --> Item20; + Item28 --> Item21; + Item28 --> Item22; + Item28 --> Item23; + Item28 --> Item24; + Item28 --> Item25; + Item28 --> Item26; + Item28 --> Item27; + Item28 -.-> Item6; + Item28 -.-> Item5; + Item28 -.-> Item4; + Item28 -.-> Item9; + Item28 -.-> Item7; + Item28 -.-> Item10; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item4; + Item2; + Item5; + Item3; + Item6; + Item7; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item26; + Item27; + Item28; + Item29; + Item29["ModuleEvaluation"]; + Item30; + Item30["export structuredError"]; + Item31; + Item31["export IPC"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item10 --> Item8; + Item10 --> Item9; + Item11 --> Item1; + Item11 --> Item2; + Item11 --> Item3; + Item11 -.-> Item6; + Item11 -.-> Item5; + Item11 -.-> Item4; + Item11 -.-> Item9; + Item11 -.-> Item7; + Item11 --> Item10; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item11; + Item13 -.-> Item6; + Item13 -.-> Item5; + Item13 -.-> Item4; + Item13 -.-> Item9; + Item13 -.-> Item7; + Item13 -.-> Item10; + Item14 --> Item12; + Item14 --> Item1; + Item14 --> Item2; + Item14 --> Item3; + Item14 --> Item11; + Item14 --> Item13; + Item14 -.-> Item6; + Item14 -.-> Item5; + Item14 -.-> Item4; + Item14 -.-> Item9; + Item14 -.-> Item7; + Item14 -.-> Item10; + Item15 --> Item12; + Item15 --> Item1; + Item15 --> Item2; + Item15 --> Item3; + Item15 --> Item11; + Item15 --> Item13; + Item15 --> Item14; + Item15 -.-> Item6; + Item15 -.-> Item5; + Item15 -.-> Item4; + Item15 -.-> Item9; + Item15 -.-> Item7; + Item15 -.-> Item10; + Item16 --> Item12; + Item16 --> Item1; + Item16 --> Item2; + Item16 --> Item3; + Item16 --> Item11; + Item16 --> Item13; + Item16 --> Item14; + Item16 --> Item15; + Item16 -.-> Item6; + Item16 -.-> Item5; + Item16 -.-> Item4; + Item16 -.-> Item9; + Item16 -.-> Item7; + Item16 -.-> Item10; + Item17 --> Item12; + Item17 --> Item1; + Item17 --> Item2; + Item17 --> Item3; + Item17 --> Item11; + Item17 --> Item13; + Item17 --> Item14; + Item17 --> Item15; + Item17 --> Item16; + Item17 -.-> Item6; + Item17 -.-> Item5; + Item17 -.-> Item4; + Item17 -.-> Item9; + Item17 -.-> Item7; + Item17 -.-> Item10; + Item18 --> Item12; + Item18 --> Item1; + Item18 --> Item2; + Item18 --> Item3; + Item18 --> Item11; + Item18 --> Item13; + Item18 --> Item14; + Item18 --> Item15; + Item18 --> Item16; + Item18 --> Item17; + Item18 -.-> Item6; + Item18 -.-> Item5; + Item18 -.-> Item4; + Item18 -.-> Item9; + Item18 -.-> Item7; + Item18 -.-> Item10; + Item19 --> Item12; + Item19 --> Item1; + Item19 --> Item2; + Item19 --> Item3; + Item19 --> Item11; + Item19 --> Item13; + Item19 --> Item14; + Item19 --> Item15; + Item19 --> Item16; + Item19 --> Item17; + Item19 --> Item18; + Item19 -.-> Item6; + Item19 -.-> Item5; + Item19 -.-> Item4; + Item19 -.-> Item9; + Item19 -.-> Item7; + Item19 -.-> Item10; + Item20 --> Item12; + Item20 --> Item1; + Item20 --> Item2; + Item20 --> Item3; + Item20 --> Item11; + Item20 --> Item13; + Item20 --> Item14; + Item20 --> Item15; + Item20 --> Item16; + Item20 --> Item17; + Item20 --> Item18; + Item20 --> Item19; + Item20 -.-> Item6; + Item20 -.-> Item5; + Item20 -.-> Item4; + Item20 -.-> Item9; + Item20 -.-> Item7; + Item20 -.-> Item10; + Item21 --> Item12; + Item21 --> Item1; + Item21 --> Item2; + Item21 --> Item3; + Item21 --> Item11; + Item21 --> Item13; + Item21 --> Item14; + Item21 --> Item15; + Item21 --> Item16; + Item21 --> Item17; + Item21 --> Item18; + Item21 --> Item19; + Item21 --> Item20; + Item21 -.-> Item6; + Item21 -.-> Item5; + Item21 -.-> Item4; + Item21 -.-> Item9; + Item21 -.-> Item7; + Item21 -.-> Item10; + Item22 --> Item12; + Item22 --> Item1; + Item22 --> Item2; + Item22 --> Item3; + Item22 --> Item11; + Item22 --> Item13; + Item22 --> Item14; + Item22 --> Item15; + Item22 --> Item16; + Item22 --> Item17; + Item22 --> Item18; + Item22 --> Item19; + Item22 --> Item20; + Item22 --> Item21; + Item22 -.-> Item6; + Item22 -.-> Item5; + Item22 -.-> Item4; + Item22 -.-> Item9; + Item22 -.-> Item7; + Item22 -.-> Item10; + Item23 --> Item12; + Item23 --> Item1; + Item23 --> Item2; + Item23 --> Item3; + Item23 --> Item11; + Item23 --> Item13; + Item23 --> Item14; + Item23 --> Item15; + Item23 --> Item16; + Item23 --> Item17; + Item23 --> Item18; + Item23 --> Item19; + Item23 --> Item20; + Item23 --> Item21; + Item23 --> Item22; + Item23 -.-> Item6; + Item23 -.-> Item5; + Item23 -.-> Item4; + Item23 -.-> Item9; + Item23 -.-> Item7; + Item23 -.-> Item10; + Item24 --> Item12; + Item24 --> Item1; + Item24 --> Item2; + Item24 --> Item3; + Item24 --> Item11; + Item24 --> Item13; + Item24 --> Item14; + Item24 --> Item15; + Item24 --> Item16; + Item24 --> Item17; + Item24 --> Item18; + Item24 --> Item19; + Item24 --> Item20; + Item24 --> Item21; + Item24 --> Item22; + Item24 --> Item23; + Item24 -.-> Item6; + Item24 -.-> Item5; + Item24 -.-> Item4; + Item24 -.-> Item9; + Item24 -.-> Item7; + Item24 -.-> Item10; + Item25 --> Item12; + Item25 --> Item1; + Item25 --> Item2; + Item25 --> Item3; + Item25 --> Item11; + Item25 --> Item13; + Item25 --> Item14; + Item25 --> Item15; + Item25 --> Item16; + Item25 --> Item17; + Item25 --> Item18; + Item25 --> Item19; + Item25 --> Item20; + Item25 --> Item21; + Item25 --> Item22; + Item25 --> Item23; + Item25 --> Item24; + Item25 -.-> Item6; + Item25 -.-> Item5; + Item25 -.-> Item4; + Item25 -.-> Item9; + Item25 -.-> Item7; + Item25 -.-> Item10; + Item26 --> Item12; + Item26 --> Item1; + Item26 --> Item2; + Item26 --> Item3; + Item26 --> Item11; + Item26 --> Item13; + Item26 --> Item14; + Item26 --> Item15; + Item26 --> Item16; + Item26 --> Item17; + Item26 --> Item18; + Item26 --> Item19; + Item26 --> Item20; + Item26 --> Item21; + Item26 --> Item22; + Item26 --> Item23; + Item26 --> Item24; + Item26 --> Item25; + Item26 -.-> Item6; + Item26 -.-> Item5; + Item26 -.-> Item4; + Item26 -.-> Item9; + Item26 -.-> Item7; + Item26 -.-> Item10; + Item27 --> Item12; + Item27 --> Item1; + Item27 --> Item2; + Item27 --> Item3; + Item27 --> Item11; + Item27 --> Item13; + Item27 --> Item14; + Item27 --> Item15; + Item27 --> Item16; + Item27 --> Item17; + Item27 --> Item18; + Item27 --> Item19; + Item27 --> Item20; + Item27 --> Item21; + Item27 --> Item22; + Item27 --> Item23; + Item27 --> Item24; + Item27 --> Item25; + Item27 --> Item26; + Item27 -.-> Item6; + Item27 -.-> Item5; + Item27 -.-> Item4; + Item27 -.-> Item9; + Item27 -.-> Item7; + Item27 -.-> Item10; + Item28 --> Item12; + Item28 --> Item1; + Item28 --> Item2; + Item28 --> Item3; + Item28 --> Item11; + Item28 --> Item13; + Item28 --> Item14; + Item28 --> Item15; + Item28 --> Item16; + Item28 --> Item17; + Item28 --> Item18; + Item28 --> Item19; + Item28 --> Item20; + Item28 --> Item21; + Item28 --> Item22; + Item28 --> Item23; + Item28 --> Item24; + Item28 --> Item25; + Item28 --> Item26; + Item28 --> Item27; + Item28 -.-> Item6; + Item28 -.-> Item5; + Item28 -.-> Item4; + Item28 -.-> Item9; + Item28 -.-> Item7; + Item28 -.-> Item10; + Item7 --> Item6; + Item7 --> Item5; + Item8 --> Item4; + Item8 --> Item7; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item4; + Item2; + Item5; + Item3; + Item6; + Item7; + Item8; + Item9; + Item10; + Item11; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item26; + Item27; + Item28; + Item29; + Item29["ModuleEvaluation"]; + Item30; + Item30["export structuredError"]; + Item31; + Item31["export IPC"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item10 --> Item8; + Item10 --> Item9; + Item11 --> Item1; + Item11 --> Item2; + Item11 --> Item3; + Item11 -.-> Item6; + Item11 -.-> Item5; + Item11 -.-> Item4; + Item11 -.-> Item9; + Item11 -.-> Item7; + Item11 --> Item10; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item11; + Item13 -.-> Item6; + Item13 -.-> Item5; + Item13 -.-> Item4; + Item13 -.-> Item9; + Item13 -.-> Item7; + Item13 -.-> Item10; + Item14 --> Item12; + Item14 --> Item1; + Item14 --> Item2; + Item14 --> Item3; + Item14 --> Item11; + Item14 --> Item13; + Item14 -.-> Item6; + Item14 -.-> Item5; + Item14 -.-> Item4; + Item14 -.-> Item9; + Item14 -.-> Item7; + Item14 -.-> Item10; + Item15 --> Item12; + Item15 --> Item1; + Item15 --> Item2; + Item15 --> Item3; + Item15 --> Item11; + Item15 --> Item13; + Item15 --> Item14; + Item15 -.-> Item6; + Item15 -.-> Item5; + Item15 -.-> Item4; + Item15 -.-> Item9; + Item15 -.-> Item7; + Item15 -.-> Item10; + Item16 --> Item12; + Item16 --> Item1; + Item16 --> Item2; + Item16 --> Item3; + Item16 --> Item11; + Item16 --> Item13; + Item16 --> Item14; + Item16 --> Item15; + Item16 -.-> Item6; + Item16 -.-> Item5; + Item16 -.-> Item4; + Item16 -.-> Item9; + Item16 -.-> Item7; + Item16 -.-> Item10; + Item17 --> Item12; + Item17 --> Item1; + Item17 --> Item2; + Item17 --> Item3; + Item17 --> Item11; + Item17 --> Item13; + Item17 --> Item14; + Item17 --> Item15; + Item17 --> Item16; + Item17 -.-> Item6; + Item17 -.-> Item5; + Item17 -.-> Item4; + Item17 -.-> Item9; + Item17 -.-> Item7; + Item17 -.-> Item10; + Item18 --> Item12; + Item18 --> Item1; + Item18 --> Item2; + Item18 --> Item3; + Item18 --> Item11; + Item18 --> Item13; + Item18 --> Item14; + Item18 --> Item15; + Item18 --> Item16; + Item18 --> Item17; + Item18 -.-> Item6; + Item18 -.-> Item5; + Item18 -.-> Item4; + Item18 -.-> Item9; + Item18 -.-> Item7; + Item18 -.-> Item10; + Item19 --> Item12; + Item19 --> Item1; + Item19 --> Item2; + Item19 --> Item3; + Item19 --> Item11; + Item19 --> Item13; + Item19 --> Item14; + Item19 --> Item15; + Item19 --> Item16; + Item19 --> Item17; + Item19 --> Item18; + Item19 -.-> Item6; + Item19 -.-> Item5; + Item19 -.-> Item4; + Item19 -.-> Item9; + Item19 -.-> Item7; + Item19 -.-> Item10; + Item20 --> Item12; + Item20 --> Item1; + Item20 --> Item2; + Item20 --> Item3; + Item20 --> Item11; + Item20 --> Item13; + Item20 --> Item14; + Item20 --> Item15; + Item20 --> Item16; + Item20 --> Item17; + Item20 --> Item18; + Item20 --> Item19; + Item20 -.-> Item6; + Item20 -.-> Item5; + Item20 -.-> Item4; + Item20 -.-> Item9; + Item20 -.-> Item7; + Item20 -.-> Item10; + Item21 --> Item12; + Item21 --> Item1; + Item21 --> Item2; + Item21 --> Item3; + Item21 --> Item11; + Item21 --> Item13; + Item21 --> Item14; + Item21 --> Item15; + Item21 --> Item16; + Item21 --> Item17; + Item21 --> Item18; + Item21 --> Item19; + Item21 --> Item20; + Item21 -.-> Item6; + Item21 -.-> Item5; + Item21 -.-> Item4; + Item21 -.-> Item9; + Item21 -.-> Item7; + Item21 -.-> Item10; + Item22 --> Item12; + Item22 --> Item1; + Item22 --> Item2; + Item22 --> Item3; + Item22 --> Item11; + Item22 --> Item13; + Item22 --> Item14; + Item22 --> Item15; + Item22 --> Item16; + Item22 --> Item17; + Item22 --> Item18; + Item22 --> Item19; + Item22 --> Item20; + Item22 --> Item21; + Item22 -.-> Item6; + Item22 -.-> Item5; + Item22 -.-> Item4; + Item22 -.-> Item9; + Item22 -.-> Item7; + Item22 -.-> Item10; + Item23 --> Item12; + Item23 --> Item1; + Item23 --> Item2; + Item23 --> Item3; + Item23 --> Item11; + Item23 --> Item13; + Item23 --> Item14; + Item23 --> Item15; + Item23 --> Item16; + Item23 --> Item17; + Item23 --> Item18; + Item23 --> Item19; + Item23 --> Item20; + Item23 --> Item21; + Item23 --> Item22; + Item23 -.-> Item6; + Item23 -.-> Item5; + Item23 -.-> Item4; + Item23 -.-> Item9; + Item23 -.-> Item7; + Item23 -.-> Item10; + Item24 --> Item12; + Item24 --> Item1; + Item24 --> Item2; + Item24 --> Item3; + Item24 --> Item11; + Item24 --> Item13; + Item24 --> Item14; + Item24 --> Item15; + Item24 --> Item16; + Item24 --> Item17; + Item24 --> Item18; + Item24 --> Item19; + Item24 --> Item20; + Item24 --> Item21; + Item24 --> Item22; + Item24 --> Item23; + Item24 -.-> Item6; + Item24 -.-> Item5; + Item24 -.-> Item4; + Item24 -.-> Item9; + Item24 -.-> Item7; + Item24 -.-> Item10; + Item25 --> Item12; + Item25 --> Item1; + Item25 --> Item2; + Item25 --> Item3; + Item25 --> Item11; + Item25 --> Item13; + Item25 --> Item14; + Item25 --> Item15; + Item25 --> Item16; + Item25 --> Item17; + Item25 --> Item18; + Item25 --> Item19; + Item25 --> Item20; + Item25 --> Item21; + Item25 --> Item22; + Item25 --> Item23; + Item25 --> Item24; + Item25 -.-> Item6; + Item25 -.-> Item5; + Item25 -.-> Item4; + Item25 -.-> Item9; + Item25 -.-> Item7; + Item25 -.-> Item10; + Item26 --> Item12; + Item26 --> Item1; + Item26 --> Item2; + Item26 --> Item3; + Item26 --> Item11; + Item26 --> Item13; + Item26 --> Item14; + Item26 --> Item15; + Item26 --> Item16; + Item26 --> Item17; + Item26 --> Item18; + Item26 --> Item19; + Item26 --> Item20; + Item26 --> Item21; + Item26 --> Item22; + Item26 --> Item23; + Item26 --> Item24; + Item26 --> Item25; + Item26 -.-> Item6; + Item26 -.-> Item5; + Item26 -.-> Item4; + Item26 -.-> Item9; + Item26 -.-> Item7; + Item26 -.-> Item10; + Item27 --> Item12; + Item27 --> Item1; + Item27 --> Item2; + Item27 --> Item3; + Item27 --> Item11; + Item27 --> Item13; + Item27 --> Item14; + Item27 --> Item15; + Item27 --> Item16; + Item27 --> Item17; + Item27 --> Item18; + Item27 --> Item19; + Item27 --> Item20; + Item27 --> Item21; + Item27 --> Item22; + Item27 --> Item23; + Item27 --> Item24; + Item27 --> Item25; + Item27 --> Item26; + Item27 -.-> Item6; + Item27 -.-> Item5; + Item27 -.-> Item4; + Item27 -.-> Item9; + Item27 -.-> Item7; + Item27 -.-> Item10; + Item28 --> Item12; + Item28 --> Item1; + Item28 --> Item2; + Item28 --> Item3; + Item28 --> Item11; + Item28 --> Item13; + Item28 --> Item14; + Item28 --> Item15; + Item28 --> Item16; + Item28 --> Item17; + Item28 --> Item18; + Item28 --> Item19; + Item28 --> Item20; + Item28 --> Item21; + Item28 --> Item22; + Item28 --> Item23; + Item28 --> Item24; + Item28 --> Item25; + Item28 --> Item26; + Item28 --> Item27; + Item28 -.-> Item6; + Item28 -.-> Item5; + Item28 -.-> Item4; + Item28 -.-> Item9; + Item28 -.-> Item7; + Item28 -.-> Item10; + Item7 --> Item6; + Item7 --> Item5; + Item8 --> Item4; + Item8 --> Item7; + Item29 --> Item1; + Item29 --> Item2; + Item29 --> Item3; + Item29 --> Item11; + Item29 --> Item13; + Item29 --> Item14; + Item29 --> Item15; + Item29 --> Item16; + Item29 --> Item17; + Item29 --> Item18; + Item29 --> Item19; + Item29 --> Item20; + Item29 --> Item21; + Item29 --> Item22; + Item29 --> Item23; + Item29 --> Item24; + Item29 --> Item25; + Item29 --> Item26; + Item29 --> Item27; + Item29 --> Item28; + Item30 --> Item7; + Item31 --> Item10; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule), ItemId(0, ImportBinding(0)), ItemId(1, ImportOfModule), ItemId(1, ImportBinding(0)), ItemId(2, ImportOfModule), ItemId(2, ImportBinding(0)), ItemId(7, Normal), ItemId(8, VarDeclarator(0)), ItemId(9, Normal), ItemId(10, Normal), ItemId(11, Normal), ItemId(12, Normal), ItemId(13, Normal), ItemId(14, Normal), ItemId(15, Normal), ItemId(16, Normal), ItemId(17, Normal), ItemId(18, Normal), ItemId(19, Normal), ItemId(20, Normal), ItemId(21, Normal), ItemId(22, Normal), ItemId(23, Normal), ItemId(24, Normal)]"]; + N1["Items: [ItemId(Export(("structuredError", #2), "structuredError"))]"]; + N2["Items: [ItemId(Export(("IPC", #2), "IPC"))]"]; + N3["Items: [ItemId(1, ImportBinding(0)), ItemId(2, ImportBinding(0)), ItemId(3, Normal)]"]; + N4["Items: [ItemId(0, ImportBinding(0)), ItemId(4, Normal)]"]; + N5["Items: [ItemId(5, VarDeclarator(0))]"]; + N6["Items: [ItemId(6, VarDeclarator(0))]"]; + N0 --> N3; + N0 --> N4; + N0 --> N5; + N0 --> N6; + N1 --> N3; + N2 --> N6; + N4 --> N3; + N6 --> N4; + N6 --> N5; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "structuredError", + ): 1, + Export( + "IPC", + ): 2, +} +``` + + +# Modules (dev) +## Part 0 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +import { IPC } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +"module evaluation"; +import "node:net"; +import { createConnection } from "node:net"; +import "../compiled/stacktrace-parser"; +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; +import "./error"; +import { getProperError } from "./error"; +process.on("uncaughtException", (err)=>{ + IPC.sendError(err); +}); +const improveConsole = (name, stream, addStack)=>{ + const original = console[name]; + const stdio = process[stream]; + console[name] = (...args)=>{ + stdio.write(`TURBOPACK_OUTPUT_B\n`); + original(...args); + if (addStack) { + const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n"; + stdio.write("TURBOPACK_OUTPUT_S\n"); + stdio.write(stack); + } + stdio.write("TURBOPACK_OUTPUT_E\n"); + }; +}; +improveConsole("error", "stderr", true); +improveConsole("warn", "stderr", true); +improveConsole("count", "stdout", true); +improveConsole("trace", "stderr", false); +improveConsole("log", "stdout", true); +improveConsole("group", "stdout", true); +improveConsole("groupCollapsed", "stdout", true); +improveConsole("table", "stdout", true); +improveConsole("debug", "stdout", true); +improveConsole("info", "stdout", true); +improveConsole("dir", "stdout", true); +improveConsole("dirxml", "stdout", true); +improveConsole("timeEnd", "stdout", true); +improveConsole("timeLog", "stdout", true); +improveConsole("timeStamp", "stdout", true); +improveConsole("assert", "stderr", true); +export { improveConsole } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 1 +```js +import { structuredError } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { structuredError }; + +``` +## Part 2 +```js +import { IPC } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +export { IPC }; + +``` +## Part 3 +```js +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; +import { getProperError } from "./error"; +function structuredError(e) { + e = getProperError(e); + return { + name: e.name, + message: e.message, + stack: typeof e.stack === "string" ? parseStackTrace(e.stack) : [] + }; +} +export { structuredError } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +import { structuredError } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { createConnection } from "node:net"; +function createIpc(port) { + const socket = createConnection(port, "127.0.0.1"); + const packetQueue = []; + const recvPromiseResolveQueue = []; + function pushPacket(packet) { + const recvPromiseResolve = recvPromiseResolveQueue.shift(); + if (recvPromiseResolve != null) { + recvPromiseResolve(JSON.parse(packet.toString("utf8"))); + } else { + packetQueue.push(packet); + } + } + let state = { + type: "waiting" + }; + let buffer = Buffer.alloc(0); + socket.once("connect", ()=>{ + socket.on("data", (chunk)=>{ + buffer = Buffer.concat([ + buffer, + chunk + ]); + loop: while(true){ + switch(state.type){ + case "waiting": + { + if (buffer.length >= 4) { + const length = buffer.readUInt32BE(0); + buffer = buffer.subarray(4); + state = { + type: "packet", + length + }; + } else { + break loop; + } + break; + } + case "packet": + { + if (buffer.length >= state.length) { + const packet = buffer.subarray(0, state.length); + buffer = buffer.subarray(state.length); + state = { + type: "waiting" + }; + pushPacket(packet); + } else { + break loop; + } + break; + } + } + } + }); + }); + socket.once("close", ()=>{ + process.exit(0); + }); + function send(message) { + const packet = Buffer.from(JSON.stringify(message), "utf8"); + const length = Buffer.alloc(4); + length.writeUInt32BE(packet.length); + socket.write(length); + return new Promise((resolve, reject)=>{ + socket.write(packet, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + function sendReady() { + const length = Buffer.from([ + 0, + 0, + 0, + 0 + ]); + return new Promise((resolve, reject)=>{ + socket.write(length, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + return { + async recv () { + const packet = packetQueue.shift(); + if (packet != null) { + return JSON.parse(packet.toString("utf8")); + } + const result = await new Promise((resolve)=>{ + recvPromiseResolveQueue.push((result)=>{ + resolve(result); + }); + }); + return result; + }, + send (message) { + return send(message); + }, + sendReady, + async sendError (error) { + try { + await send({ + type: "error", + ...structuredError(error) + }); + } catch (err) { + console.error("failed to send error back to rust:", err); + process.exit(1); + } + process.exit(0); + } + }; +} +export { createIpc } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +const PORT = process.argv[2]; +export { PORT } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 6 +```js +import { createIpc } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import { PORT } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +const IPC = createIpc(parseInt(PORT, 10)); +export { IPC } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +import { IPC } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "node:net"; +import { createConnection } from "node:net"; +import "../compiled/stacktrace-parser"; +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; +import "./error"; +import { getProperError } from "./error"; +"module evaluation"; +process.on("uncaughtException", (err)=>{ + IPC.sendError(err); +}); +const improveConsole = (name, stream, addStack)=>{ + const original = console[name]; + const stdio = process[stream]; + console[name] = (...args)=>{ + stdio.write(`TURBOPACK_OUTPUT_B\n`); + original(...args); + if (addStack) { + const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n"; + stdio.write("TURBOPACK_OUTPUT_S\n"); + stdio.write(stack); + } + stdio.write("TURBOPACK_OUTPUT_E\n"); + }; +}; +improveConsole("error", "stderr", true); +improveConsole("warn", "stderr", true); +improveConsole("count", "stdout", true); +improveConsole("trace", "stderr", false); +improveConsole("log", "stdout", true); +improveConsole("group", "stdout", true); +improveConsole("groupCollapsed", "stdout", true); +improveConsole("table", "stdout", true); +improveConsole("debug", "stdout", true); +improveConsole("info", "stdout", true); +improveConsole("dir", "stdout", true); +improveConsole("dirxml", "stdout", true); +improveConsole("timeEnd", "stdout", true); +improveConsole("timeLog", "stdout", true); +improveConsole("timeStamp", "stdout", true); +improveConsole("assert", "stderr", true); +export { improveConsole } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "structuredError", + ): 1, + Export( + "IPC", + ): 2, +} +``` + + +# Modules (prod) +## Part 0 +```js +import { IPC } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +"module evaluation"; +import "node:net"; +import "../compiled/stacktrace-parser"; +import "./error"; +process.on("uncaughtException", (err)=>{ + IPC.sendError(err); +}); +const improveConsole = (name, stream, addStack)=>{ + const original = console[name]; + const stdio = process[stream]; + console[name] = (...args)=>{ + stdio.write(`TURBOPACK_OUTPUT_B\n`); + original(...args); + if (addStack) { + const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n"; + stdio.write("TURBOPACK_OUTPUT_S\n"); + stdio.write(stack); + } + stdio.write("TURBOPACK_OUTPUT_E\n"); + }; +}; +improveConsole("error", "stderr", true); +improveConsole("warn", "stderr", true); +improveConsole("count", "stdout", true); +improveConsole("trace", "stderr", false); +improveConsole("log", "stdout", true); +improveConsole("group", "stdout", true); +improveConsole("groupCollapsed", "stdout", true); +improveConsole("table", "stdout", true); +improveConsole("debug", "stdout", true); +improveConsole("info", "stdout", true); +improveConsole("dir", "stdout", true); +improveConsole("dirxml", "stdout", true); +improveConsole("timeEnd", "stdout", true); +improveConsole("timeLog", "stdout", true); +improveConsole("timeStamp", "stdout", true); +improveConsole("assert", "stderr", true); +export { improveConsole } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 1 +```js +import { structuredError } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { structuredError }; + +``` +## Part 2 +```js +import { IPC } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +export { IPC }; + +``` +## Part 3 +```js +import { parse as parseStackTrace } from "../compiled/stacktrace-parser"; +import { getProperError } from "./error"; +function structuredError(e) { + e = getProperError(e); + return { + name: e.name, + message: e.message, + stack: typeof e.stack === "string" ? parseStackTrace(e.stack) : [] + }; +} +export { structuredError } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +import { structuredError } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { createConnection } from "node:net"; +function createIpc(port) { + const socket = createConnection(port, "127.0.0.1"); + const packetQueue = []; + const recvPromiseResolveQueue = []; + function pushPacket(packet) { + const recvPromiseResolve = recvPromiseResolveQueue.shift(); + if (recvPromiseResolve != null) { + recvPromiseResolve(JSON.parse(packet.toString("utf8"))); + } else { + packetQueue.push(packet); + } + } + let state = { + type: "waiting" + }; + let buffer = Buffer.alloc(0); + socket.once("connect", ()=>{ + socket.on("data", (chunk)=>{ + buffer = Buffer.concat([ + buffer, + chunk + ]); + loop: while(true){ + switch(state.type){ + case "waiting": + { + if (buffer.length >= 4) { + const length = buffer.readUInt32BE(0); + buffer = buffer.subarray(4); + state = { + type: "packet", + length + }; + } else { + break loop; + } + break; + } + case "packet": + { + if (buffer.length >= state.length) { + const packet = buffer.subarray(0, state.length); + buffer = buffer.subarray(state.length); + state = { + type: "waiting" + }; + pushPacket(packet); + } else { + break loop; + } + break; + } + } + } + }); + }); + socket.once("close", ()=>{ + process.exit(0); + }); + function send(message) { + const packet = Buffer.from(JSON.stringify(message), "utf8"); + const length = Buffer.alloc(4); + length.writeUInt32BE(packet.length); + socket.write(length); + return new Promise((resolve, reject)=>{ + socket.write(packet, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + function sendReady() { + const length = Buffer.from([ + 0, + 0, + 0, + 0 + ]); + return new Promise((resolve, reject)=>{ + socket.write(length, (err)=>{ + process.stderr.write(`TURBOPACK_OUTPUT_D\n`); + process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { + reject(err); + } else { + resolve(); + } + }); + }); + } + return { + async recv () { + const packet = packetQueue.shift(); + if (packet != null) { + return JSON.parse(packet.toString("utf8")); + } + const result = await new Promise((resolve)=>{ + recvPromiseResolveQueue.push((result)=>{ + resolve(result); + }); + }); + return result; + }, + send (message) { + return send(message); + }, + sendReady, + async sendError (error) { + try { + await send({ + type: "error", + ...structuredError(error) + }); + } catch (err) { + console.error("failed to send error back to rust:", err); + process.exit(1); + } + process.exit(0); + } + }; +} +export { createIpc } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +const PORT = process.argv[2]; +export { PORT } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 6 +```js +import { createIpc } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +import { PORT } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +const IPC = createIpc(parseInt(PORT, 10)); +export { IPC } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { IPC } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "node:net"; +import "../compiled/stacktrace-parser"; +import "./error"; +"module evaluation"; +process.on("uncaughtException", (err)=>{ + IPC.sendError(err); +}); +const improveConsole = (name, stream, addStack)=>{ + const original = console[name]; + const stdio = process[stream]; + console[name] = (...args)=>{ + stdio.write(`TURBOPACK_OUTPUT_B\n`); + original(...args); + if (addStack) { + const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n"; + stdio.write("TURBOPACK_OUTPUT_S\n"); + stdio.write(stack); + } + stdio.write("TURBOPACK_OUTPUT_E\n"); + }; +}; +improveConsole("error", "stderr", true); +improveConsole("warn", "stderr", true); +improveConsole("count", "stdout", true); +improveConsole("trace", "stderr", false); +improveConsole("log", "stdout", true); +improveConsole("group", "stdout", true); +improveConsole("groupCollapsed", "stdout", true); +improveConsole("table", "stdout", true); +improveConsole("debug", "stdout", true); +improveConsole("info", "stdout", true); +improveConsole("dir", "stdout", true); +improveConsole("dirxml", "stdout", true); +improveConsole("timeEnd", "stdout", true); +improveConsole("timeLog", "stdout", true); +improveConsole("timeStamp", "stdout", true); +improveConsole("assert", "stderr", true); +export { improveConsole } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/input.js new file mode 100644 index 0000000000000..3a98dcf8f5bdd --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/input.js @@ -0,0 +1,94 @@ +import { IPC } from "./index"; +const ipc = IPC; +const queue = []; +export const run = async (moduleFactory)=>{ + let nextId = 1; + const requests = new Map(); + const internalIpc = { + sendInfo: (message)=>ipc.send({ + type: "info", + data: message + }), + sendRequest: (message)=>{ + const id = nextId++; + let resolve, reject; + const promise = new Promise((res, rej)=>{ + resolve = res; + reject = rej; + }); + requests.set(id, { + resolve, + reject + }); + return ipc.send({ + type: "request", + id, + data: message + }).then(()=>promise); + }, + sendError: (error)=>{ + return ipc.sendError(error); + } + }; + let getValue; + try { + const module = await moduleFactory(); + if (typeof module.init === "function") { + await module.init(); + } + getValue = module.default; + await ipc.sendReady(); + } catch (err) { + await ipc.sendReady(); + await ipc.sendError(err); + } + let isRunning = false; + const run = async ()=>{ + while(queue.length > 0){ + const args = queue.shift(); + try { + const value = await getValue(internalIpc, ...args); + await ipc.send({ + type: "end", + data: value === undefined ? undefined : JSON.stringify(value, null, 2), + duration: 0 + }); + } catch (e) { + await ipc.sendError(e); + } + } + isRunning = false; + }; + while(true){ + const msg = await ipc.recv(); + switch(msg.type){ + case "evaluate": + { + queue.push(msg.args); + if (!isRunning) { + isRunning = true; + run(); + } + break; + } + case "result": + { + const request = requests.get(msg.id); + if (request) { + requests.delete(msg.id); + if (msg.error) { + request.reject(new Error(msg.error)); + } else { + request.resolve(msg.data); + } + } + break; + } + default: + { + console.error("unexpected message type", msg.type); + process.exit(1); + } + } + } +}; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/output.md new file mode 100644 index 0000000000000..02e87dfd14ace --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/ipc-evaluate/output.md @@ -0,0 +1,479 @@ +# Items + +Count: 7 + +## Item 1: Stmt 0, `ImportOfModule` + +```js +import { IPC } from "./index"; + +``` + +- Hoisted +- Side effects + +## Item 2: Stmt 0, `ImportBinding(0)` + +```js +import { IPC } from "./index"; + +``` + +- Hoisted +- Declares: `IPC` + +## Item 3: Stmt 1, `VarDeclarator(0)` + +```js +const ipc = IPC; + +``` + +- Declares: `ipc` +- Reads: `IPC` +- Write: `ipc` + +## Item 4: Stmt 2, `VarDeclarator(0)` + +```js +const queue = []; + +``` + +- Declares: `queue` +- Write: `queue` + +## Item 5: Stmt 3, `VarDeclarator(0)` + +```js +export const run = async (moduleFactory)=>{ + let nextId = 1; + const requests = new Map(); + const internalIpc = { + sendInfo: (message)=>ipc.send({ + type: "info", + data: message + }), + sendRequest: (message)=>{ + const id = nextId++; + let resolve, reject; + const promise = new Promise((res, rej)=>{ + resolve = res; + reject = rej; + }); + requests.set(id, { + resolve, + reject + }); + return ipc.send({ + type: "request", + id, + data: message + }).then(()=>promise); + }, + sendError: (error)=>{ + return ipc.sendError(error); + } + }; + let getValue; + try { + const module = await moduleFactory(); + if (typeof module.init === "function") { + await module.init(); + } + getValue = module.default; + await ipc.sendReady(); + } catch (err) { + await ipc.sendReady(); + await ipc.sendError(err); + } + let isRunning = false; + const run = async ()=>{ + while(queue.length > 0){ + const args = queue.shift(); + try { + const value = await getValue(internalIpc, ...args); + await ipc.send({ + type: "end", + data: value === undefined ? undefined : JSON.stringify(value, null, 2), + duration: 0 + }); + } catch (e) { + await ipc.sendError(e); + } + } + isRunning = false; + }; + while(true){ + const msg = await ipc.recv(); + switch(msg.type){ + case "evaluate": + { + queue.push(msg.args); + if (!isRunning) { + isRunning = true; + run(); + } + break; + } + case "result": + { + const request = requests.get(msg.id); + if (request) { + requests.delete(msg.id); + if (msg.error) { + request.reject(new Error(msg.error)); + } else { + request.resolve(msg.data); + } + } + break; + } + default: + { + console.error("unexpected message type", msg.type); + process.exit(1); + } + } + } +}; + +``` + +- Declares: `run` +- Reads (eventual): `Map`, `ipc`, `Promise`, `queue`, `undefined`, `JSON`, `Error`, `console`, `process` +- Write: `run` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item6["ModuleEvaluation"]; + Item7; + Item7["export run"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item6["ModuleEvaluation"]; + Item7; + Item7["export run"]; + Item3 --> Item2; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item6["ModuleEvaluation"]; + Item7; + Item7["export run"]; + Item3 --> Item2; + Item5 --> Item3; + Item5 --> Item4; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item5; + Item6; + Item6["ModuleEvaluation"]; + Item7; + Item7["export run"]; + Item3 --> Item2; + Item5 --> Item3; + Item5 --> Item4; + Item6 --> Item1; + Item7 --> Item5; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule)]"]; + N1["Items: [ItemId(Export(("run", #2), "run")), ItemId(0, ImportBinding(0)), ItemId(1, VarDeclarator(0)), ItemId(2, VarDeclarator(0)), ItemId(3, VarDeclarator(0))]"]; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "run", + ): 1, +} +``` + + +# Modules (dev) +## Part 0 +```js +"module evaluation"; +import "./index"; + +``` +## Part 1 +```js +export { run }; +import { IPC } from "./index"; +const ipc = IPC; +const queue = []; +const run = async (moduleFactory)=>{ + let nextId = 1; + const requests = new Map(); + const internalIpc = { + sendInfo: (message)=>ipc.send({ + type: "info", + data: message + }), + sendRequest: (message)=>{ + const id = nextId++; + let resolve, reject; + const promise = new Promise((res, rej)=>{ + resolve = res; + reject = rej; + }); + requests.set(id, { + resolve, + reject + }); + return ipc.send({ + type: "request", + id, + data: message + }).then(()=>promise); + }, + sendError: (error)=>{ + return ipc.sendError(error); + } + }; + let getValue; + try { + const module = await moduleFactory(); + if (typeof module.init === "function") { + await module.init(); + } + getValue = module.default; + await ipc.sendReady(); + } catch (err) { + await ipc.sendReady(); + await ipc.sendError(err); + } + let isRunning = false; + const run = async ()=>{ + while(queue.length > 0){ + const args = queue.shift(); + try { + const value = await getValue(internalIpc, ...args); + await ipc.send({ + type: "end", + data: value === undefined ? undefined : JSON.stringify(value, null, 2), + duration: 0 + }); + } catch (e) { + await ipc.sendError(e); + } + } + isRunning = false; + }; + while(true){ + const msg = await ipc.recv(); + switch(msg.type){ + case "evaluate": + { + queue.push(msg.args); + if (!isRunning) { + isRunning = true; + run(); + } + break; + } + case "result": + { + const request = requests.get(msg.id); + if (request) { + requests.delete(msg.id); + if (msg.error) { + request.reject(new Error(msg.error)); + } else { + request.resolve(msg.data); + } + } + break; + } + default: + { + console.error("unexpected message type", msg.type); + process.exit(1); + } + } + } +}; +export { ipc } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { queue } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { run } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "./index"; +"module evaluation"; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "run", + ): 1, +} +``` + + +# Modules (prod) +## Part 0 +```js +"module evaluation"; +import "./index"; + +``` +## Part 1 +```js +export { run }; +import { IPC } from "./index"; +const ipc = IPC; +const queue = []; +const run = async (moduleFactory)=>{ + let nextId = 1; + const requests = new Map(); + const internalIpc = { + sendInfo: (message)=>ipc.send({ + type: "info", + data: message + }), + sendRequest: (message)=>{ + const id = nextId++; + let resolve, reject; + const promise = new Promise((res, rej)=>{ + resolve = res; + reject = rej; + }); + requests.set(id, { + resolve, + reject + }); + return ipc.send({ + type: "request", + id, + data: message + }).then(()=>promise); + }, + sendError: (error)=>{ + return ipc.sendError(error); + } + }; + let getValue; + try { + const module = await moduleFactory(); + if (typeof module.init === "function") { + await module.init(); + } + getValue = module.default; + await ipc.sendReady(); + } catch (err) { + await ipc.sendReady(); + await ipc.sendError(err); + } + let isRunning = false; + const run = async ()=>{ + while(queue.length > 0){ + const args = queue.shift(); + try { + const value = await getValue(internalIpc, ...args); + await ipc.send({ + type: "end", + data: value === undefined ? undefined : JSON.stringify(value, null, 2), + duration: 0 + }); + } catch (e) { + await ipc.sendError(e); + } + } + isRunning = false; + }; + while(true){ + const msg = await ipc.recv(); + switch(msg.type){ + case "evaluate": + { + queue.push(msg.args); + if (!isRunning) { + isRunning = true; + run(); + } + break; + } + case "result": + { + const request = requests.get(msg.id); + if (request) { + requests.delete(msg.id); + if (msg.error) { + request.reject(new Error(msg.error)); + } else { + request.resolve(msg.data); + } + } + break; + } + default: + { + console.error("unexpected message type", msg.type); + process.exit(1); + } + } + } +}; +export { ipc } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { queue } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { run } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "./index"; +"module evaluation"; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/input.js new file mode 100644 index 0000000000000..257842725280c --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/input.js @@ -0,0 +1,2 @@ +// @ts-ignore +process.turbopack = {}; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/output.md new file mode 100644 index 0000000000000..ab622fe1df812 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/node-globals/output.md @@ -0,0 +1,92 @@ +# Items + +Count: 2 + +## Item 1: Stmt 0, `Normal` + +```js +process.turbopack = {}; + +``` + +- Side effects +- Reads: `process` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item2["ModuleEvaluation"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item2["ModuleEvaluation"]; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item2["ModuleEvaluation"]; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item2["ModuleEvaluation"]; + Item2 --> Item1; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, Normal)]"]; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, +} +``` + + +# Modules (dev) +## Part 0 +```js +"module evaluation"; +process.turbopack = {}; + +``` +## Merged (module eval) +```js +"module evaluation"; +process.turbopack = {}; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, +} +``` + + +# Modules (prod) +## Part 0 +```js +"module evaluation"; +process.turbopack = {}; + +``` +## Merged (module eval) +```js +"module evaluation"; +process.turbopack = {}; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/input.js new file mode 100644 index 0000000000000..0f94568637374 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/input.js @@ -0,0 +1,19 @@ +export var RouteKind; +(function(RouteKind) { + /** + * `PAGES` represents all the React pages that are under `pages/`. + */ RouteKind["PAGES"] = "PAGES"; + /** + * `PAGES_API` represents all the API routes under `pages/api/`. + */ RouteKind["PAGES_API"] = "PAGES_API"; + /** + * `APP_PAGE` represents all the React pages that are under `app/` with the + * filename of `page.{j,t}s{,x}`. + */ RouteKind["APP_PAGE"] = "APP_PAGE"; + /** + * `APP_ROUTE` represents all the API routes and metadata routes that are under `app/` with the + * filename of `route.{j,t}s{,x}`. + */ RouteKind["APP_ROUTE"] = "APP_ROUTE"; +})(RouteKind || (RouteKind = {})); + +//# sourceMappingURL=route-kind.js.map diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/output.md new file mode 100644 index 0000000000000..6b87f8e428ad7 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/route-kind/output.md @@ -0,0 +1,208 @@ +# Items + +Count: 4 + +## Item 1: Stmt 0, `VarDeclarator(0)` + +```js +export var RouteKind; + +``` + +- Declares: `RouteKind` +- Write: `RouteKind` + +## Item 2: Stmt 1, `Normal` + +```js +(function(RouteKind) { + RouteKind["PAGES"] = "PAGES"; + RouteKind["PAGES_API"] = "PAGES_API"; + RouteKind["APP_PAGE"] = "APP_PAGE"; + RouteKind["APP_ROUTE"] = "APP_ROUTE"; +})(RouteKind || (RouteKind = {})); + +``` + +- Side effects +- Reads: `RouteKind` +- Write: `RouteKind` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export RouteKind"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export RouteKind"]; + Item2 --> Item1; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export RouteKind"]; + Item2 --> Item1; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item3["ModuleEvaluation"]; + Item4; + Item4["export RouteKind"]; + Item2 --> Item1; + Item3 --> Item2; + Item4 --> Item2; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation)]"]; + N1["Items: [ItemId(Export(("RouteKind", #2), "RouteKind"))]"]; + N2["Items: [ItemId(0, VarDeclarator(0))]"]; + N3["Items: [ItemId(1, Normal)]"]; + N0 --> N3; + N1 --> N3; + N3 --> N2; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "RouteKind", + ): 1, +} +``` + + +# Modules (dev) +## Part 0 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +"module evaluation"; + +``` +## Part 1 +```js +import { RouteKind } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { RouteKind }; + +``` +## Part 2 +```js +var RouteKind; +export { RouteKind } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import { RouteKind } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 2 +}; +(function(RouteKind) { + RouteKind["PAGES"] = "PAGES"; + RouteKind["PAGES_API"] = "PAGES_API"; + RouteKind["APP_PAGE"] = "APP_PAGE"; + RouteKind["APP_ROUTE"] = "APP_ROUTE"; +})(RouteKind || (RouteKind = {})); +export { RouteKind } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +"module evaluation"; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "RouteKind", + ): 1, +} +``` + + +# Modules (prod) +## Part 0 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +"module evaluation"; + +``` +## Part 1 +```js +import { RouteKind } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { RouteKind }; + +``` +## Part 2 +```js +var RouteKind; +export { RouteKind } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import { RouteKind } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 2 +}; +(function(RouteKind) { + RouteKind["PAGES"] = "PAGES"; + RouteKind["PAGES_API"] = "PAGES_API"; + RouteKind["APP_PAGE"] = "APP_PAGE"; + RouteKind["APP_ROUTE"] = "APP_ROUTE"; +})(RouteKind || (RouteKind = {})); +export { RouteKind } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +"module evaluation"; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/input.js new file mode 100644 index 0000000000000..4b7aee241e63f --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/input.js @@ -0,0 +1,4 @@ +const a = "a"; +const b = "b"; + +export { a, b }; diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/output.md new file mode 100644 index 0000000000000..ff7725d97d2d8 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple-vars-1/output.md @@ -0,0 +1,252 @@ +# Items + +Count: 6 + +## Item 1: Stmt 0, `VarDeclarator(0)` + +```js +const a = "a"; + +``` + +- Declares: `a` +- Write: `a` + +## Item 2: Stmt 1, `VarDeclarator(0)` + +```js +const b = "b"; + +``` + +- Declares: `b` +- Write: `b` + +## Item 3: Stmt 2, `Normal` + +```js +export { a, b }; + +``` + +- Side effects +- Reads: `a`, `b` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; + Item3 --> Item1; + Item3 --> Item2; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; + Item3 --> Item1; + Item3 --> Item2; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export a"]; + Item6; + Item6["export b"]; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item3; + Item5 --> Item1; + Item6 --> Item2; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(2, Normal)]"]; + N1["Items: [ItemId(Export(("a", #2), "a"))]"]; + N2["Items: [ItemId(Export(("b", #2), "b"))]"]; + N3["Items: [ItemId(0, VarDeclarator(0))]"]; + N4["Items: [ItemId(1, VarDeclarator(0))]"]; + N0 --> N3; + N0 --> N4; + N1 --> N3; + N2 --> N4; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "b", + ): 2, + Export( + "a", + ): 1, +} +``` + + +# Modules (dev) +## Part 0 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` +## Part 1 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { a as a }; + +``` +## Part 2 +```js +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +export { b as b }; + +``` +## Part 3 +```js +const a = "a"; +export { a } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +const b = "b"; +export { b } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "b", + ): 2, + Export( + "a", + ): 1, +} +``` + + +# Modules (prod) +## Part 0 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` +## Part 1 +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { a as a }; + +``` +## Part 2 +```js +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +export { b as b }; + +``` +## Part 3 +```js +const a = "a"; +export { a } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +const b = "b"; +export { b } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import { a } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +import { b } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 4 +}; +"module evaluation"; +export { a, b }; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple/output.md index e577593ac37f2..57a1684f7f9b7 100644 --- a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple/output.md +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/simple/output.md @@ -115,12 +115,27 @@ graph TD ```mermaid graph TD N0["Items: [ItemId(ModuleEvaluation)]"]; - N1["Items: [ItemId(Export((\"DOG\", #0))), ItemId(2, VarDeclarator(0))]"]; - N2["Items: [ItemId(Export((\"CHIMERA\", #0))), ItemId(1, VarDeclarator(0)), ItemId(3, VarDeclarator(0))]"]; + N1["Items: [ItemId(Export(("DOG", #2), "DOG")), ItemId(2, VarDeclarator(0))]"]; + N2["Items: [ItemId(Export(("CHIMERA", #2), "CHIMERA")), ItemId(1, VarDeclarator(0)), ItemId(3, VarDeclarator(0))]"]; N3["Items: [ItemId(0, VarDeclarator(0))]"]; N1 --> N3; N2 --> N3; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "DOG", + ): 1, + Export( + "CHIMERA", + ): 2, +} +``` + + # Modules (dev) ## Part 0 ```js @@ -129,30 +144,38 @@ graph TD ``` ## Part 1 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 3 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 }; export { DOG }; const DOG = dog; -export { DOG }; +export { DOG } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 2 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 3 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 }; export { CHIMERA }; const cat = "cat"; const CHIMERA = cat + dog; -export { cat }; -export { CHIMERA }; +export { cat } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { CHIMERA } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 3 ```js const dog = "dog"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) @@ -160,6 +183,21 @@ export { dog }; "module evaluation"; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "DOG", + ): 1, + Export( + "CHIMERA", + ): 2, +} +``` + + # Modules (prod) ## Part 0 ```js @@ -168,30 +206,38 @@ export { dog }; ``` ## Part 1 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 3 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 }; export { DOG }; const DOG = dog; -export { DOG }; +export { DOG } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 2 ```js -import { dog } from "entry.js" assert { - __turbopack_chunk__: 3 +import { dog } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 }; export { CHIMERA }; const cat = "cat"; const CHIMERA = cat + dog; -export { cat }; -export { CHIMERA }; +export { cat } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { CHIMERA } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 3 ```js const dog = "dog"; -export { dog }; +export { dog } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/input.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/input.js new file mode 100644 index 0000000000000..87093f682e655 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/input.js @@ -0,0 +1,59 @@ +import { PagesRouteModule } from '../../server/future/route-modules/pages/module.compiled' +import { RouteKind } from '../../server/future/route-kind' +import { hoist } from './helpers' + +// Import the app and document modules. +import Document from 'VAR_MODULE_DOCUMENT' +import App from 'VAR_MODULE_APP' + +// Import the userland code. +import * as userland from 'VAR_USERLAND' + +// Re-export the component (should be the default export). +export default hoist(userland, 'default') + +// Re-export methods. +export const getStaticProps = hoist(userland, 'getStaticProps') +export const getStaticPaths = hoist(userland, 'getStaticPaths') +export const getServerSideProps = hoist(userland, 'getServerSideProps') +export const config = hoist(userland, 'config') +export const reportWebVitals = hoist(userland, 'reportWebVitals') + +// Re-export legacy methods. +export const unstable_getStaticProps = hoist( + userland, + 'unstable_getStaticProps' +) +export const unstable_getStaticPaths = hoist( + userland, + 'unstable_getStaticPaths' +) +export const unstable_getStaticParams = hoist( + userland, + 'unstable_getStaticParams' +) +export const unstable_getServerProps = hoist( + userland, + 'unstable_getServerProps' +) +export const unstable_getServerSideProps = hoist( + userland, + 'unstable_getServerSideProps' +) + +// Create and export the route module that will be consumed. +export const routeModule = new PagesRouteModule({ + definition: { + kind: RouteKind.PAGES, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + // The following aren't used in production. + bundlePath: '', + filename: '', + }, + components: { + App, + Document, + }, + userland, +}) diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/output.md new file mode 100644 index 0000000000000..dccd4d458a3a4 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/template-pages/output.md @@ -0,0 +1,1486 @@ +# Items + +Count: 37 + +## Item 1: Stmt 0, `ImportOfModule` + +```js +import { PagesRouteModule } from '../../server/future/route-modules/pages/module.compiled'; + +``` + +- Hoisted +- Side effects + +## Item 2: Stmt 0, `ImportBinding(0)` + +```js +import { PagesRouteModule } from '../../server/future/route-modules/pages/module.compiled'; + +``` + +- Hoisted +- Declares: `PagesRouteModule` + +## Item 3: Stmt 1, `ImportOfModule` + +```js +import { RouteKind } from '../../server/future/route-kind'; + +``` + +- Hoisted +- Side effects + +## Item 4: Stmt 1, `ImportBinding(0)` + +```js +import { RouteKind } from '../../server/future/route-kind'; + +``` + +- Hoisted +- Declares: `RouteKind` + +## Item 5: Stmt 2, `ImportOfModule` + +```js +import { hoist } from './helpers'; + +``` + +- Hoisted +- Side effects + +## Item 6: Stmt 2, `ImportBinding(0)` + +```js +import { hoist } from './helpers'; + +``` + +- Hoisted +- Declares: `hoist` + +## Item 7: Stmt 3, `ImportOfModule` + +```js +import Document from 'VAR_MODULE_DOCUMENT'; + +``` + +- Hoisted +- Side effects + +## Item 8: Stmt 3, `ImportBinding(0)` + +```js +import Document from 'VAR_MODULE_DOCUMENT'; + +``` + +- Hoisted +- Declares: `Document` + +## Item 9: Stmt 4, `ImportOfModule` + +```js +import App from 'VAR_MODULE_APP'; + +``` + +- Hoisted +- Side effects + +## Item 10: Stmt 4, `ImportBinding(0)` + +```js +import App from 'VAR_MODULE_APP'; + +``` + +- Hoisted +- Declares: `App` + +## Item 11: Stmt 5, `ImportOfModule` + +```js +import * as userland from 'VAR_USERLAND'; + +``` + +- Hoisted +- Side effects + +## Item 12: Stmt 5, `ImportBinding(0)` + +```js +import * as userland from 'VAR_USERLAND'; + +``` + +- Hoisted +- Declares: `userland` + +## Item 13: Stmt 6, `Normal` + +```js +export default hoist(userland, 'default'); + +``` + +- Side effects +- Declares: `__TURBOPACK__default__export__` +- Reads: `hoist`, `userland` +- Write: `__TURBOPACK__default__export__` + +## Item 14: Stmt 7, `VarDeclarator(0)` + +```js +export const getStaticProps = hoist(userland, 'getStaticProps'); + +``` + +- Declares: `getStaticProps` +- Reads: `hoist`, `userland` +- Write: `getStaticProps` + +## Item 15: Stmt 8, `VarDeclarator(0)` + +```js +export const getStaticPaths = hoist(userland, 'getStaticPaths'); + +``` + +- Declares: `getStaticPaths` +- Reads: `hoist`, `userland` +- Write: `getStaticPaths` + +## Item 16: Stmt 9, `VarDeclarator(0)` + +```js +export const getServerSideProps = hoist(userland, 'getServerSideProps'); + +``` + +- Declares: `getServerSideProps` +- Reads: `hoist`, `userland` +- Write: `getServerSideProps` + +## Item 17: Stmt 10, `VarDeclarator(0)` + +```js +export const config = hoist(userland, 'config'); + +``` + +- Declares: `config` +- Reads: `hoist`, `userland` +- Write: `config` + +## Item 18: Stmt 11, `VarDeclarator(0)` + +```js +export const reportWebVitals = hoist(userland, 'reportWebVitals'); + +``` + +- Declares: `reportWebVitals` +- Reads: `hoist`, `userland` +- Write: `reportWebVitals` + +## Item 19: Stmt 12, `VarDeclarator(0)` + +```js +export const unstable_getStaticProps = hoist(userland, 'unstable_getStaticProps'); + +``` + +- Declares: `unstable_getStaticProps` +- Reads: `hoist`, `userland` +- Write: `unstable_getStaticProps` + +## Item 20: Stmt 13, `VarDeclarator(0)` + +```js +export const unstable_getStaticPaths = hoist(userland, 'unstable_getStaticPaths'); + +``` + +- Declares: `unstable_getStaticPaths` +- Reads: `hoist`, `userland` +- Write: `unstable_getStaticPaths` + +## Item 21: Stmt 14, `VarDeclarator(0)` + +```js +export const unstable_getStaticParams = hoist(userland, 'unstable_getStaticParams'); + +``` + +- Declares: `unstable_getStaticParams` +- Reads: `hoist`, `userland` +- Write: `unstable_getStaticParams` + +## Item 22: Stmt 15, `VarDeclarator(0)` + +```js +export const unstable_getServerProps = hoist(userland, 'unstable_getServerProps'); + +``` + +- Declares: `unstable_getServerProps` +- Reads: `hoist`, `userland` +- Write: `unstable_getServerProps` + +## Item 23: Stmt 16, `VarDeclarator(0)` + +```js +export const unstable_getServerSideProps = hoist(userland, 'unstable_getServerSideProps'); + +``` + +- Declares: `unstable_getServerSideProps` +- Reads: `hoist`, `userland` +- Write: `unstable_getServerSideProps` + +## Item 24: Stmt 17, `VarDeclarator(0)` + +```js +export const routeModule = new PagesRouteModule({ + definition: { + kind: RouteKind.PAGES, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + bundlePath: '', + filename: '' + }, + components: { + App, + Document + }, + userland +}); + +``` + +- Declares: `routeModule` +- Reads: `PagesRouteModule`, `RouteKind`, `App`, `Document`, `userland` +- Write: `routeModule` + +# Phase 1 +```mermaid +graph TD + Item1; + Item7; + Item2; + Item8; + Item3; + Item9; + Item4; + Item10; + Item5; + Item11; + Item6; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item25["ModuleEvaluation"]; + Item26; + Item26["export default"]; + Item27; + Item27["export getStaticProps"]; + Item28; + Item28["export getStaticPaths"]; + Item29; + Item29["export getServerSideProps"]; + Item30; + Item30["export config"]; + Item31; + Item31["export reportWebVitals"]; + Item32; + Item32["export unstable_getStaticProps"]; + Item33; + Item33["export unstable_getStaticPaths"]; + Item34; + Item34["export unstable_getStaticParams"]; + Item35; + Item35["export unstable_getServerProps"]; + Item36; + Item36["export unstable_getServerSideProps"]; + Item37; + Item37["export routeModule"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item5 --> Item1; + Item5 --> Item2; + Item5 --> Item3; + Item5 --> Item4; + Item6 --> Item1; + Item6 --> Item2; + Item6 --> Item3; + Item6 --> Item4; + Item6 --> Item5; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item7; + Item2; + Item8; + Item3; + Item9; + Item4; + Item10; + Item5; + Item11; + Item6; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item25["ModuleEvaluation"]; + Item26; + Item26["export default"]; + Item27; + Item27["export getStaticProps"]; + Item28; + Item28["export getStaticPaths"]; + Item29; + Item29["export getServerSideProps"]; + Item30; + Item30["export config"]; + Item31; + Item31["export reportWebVitals"]; + Item32; + Item32["export unstable_getStaticProps"]; + Item33; + Item33["export unstable_getStaticPaths"]; + Item34; + Item34["export unstable_getStaticParams"]; + Item35; + Item35["export unstable_getServerProps"]; + Item36; + Item36["export unstable_getServerSideProps"]; + Item37; + Item37["export routeModule"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item5 --> Item1; + Item5 --> Item2; + Item5 --> Item3; + Item5 --> Item4; + Item6 --> Item1; + Item6 --> Item2; + Item6 --> Item3; + Item6 --> Item4; + Item6 --> Item5; + Item13 --> Item9; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item4; + Item13 --> Item5; + Item13 --> Item6; + Item14 --> Item9; + Item14 --> Item12; + Item15 --> Item9; + Item15 --> Item12; + Item16 --> Item9; + Item16 --> Item12; + Item17 --> Item9; + Item17 --> Item12; + Item18 --> Item9; + Item18 --> Item12; + Item19 --> Item9; + Item19 --> Item12; + Item20 --> Item9; + Item20 --> Item12; + Item21 --> Item9; + Item21 --> Item12; + Item22 --> Item9; + Item22 --> Item12; + Item23 --> Item9; + Item23 --> Item12; + Item24 --> Item7; + Item24 --> Item8; + Item24 --> Item11; + Item24 --> Item10; + Item24 --> Item12; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item7; + Item2; + Item8; + Item3; + Item9; + Item4; + Item10; + Item5; + Item11; + Item6; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item25["ModuleEvaluation"]; + Item26; + Item26["export default"]; + Item27; + Item27["export getStaticProps"]; + Item28; + Item28["export getStaticPaths"]; + Item29; + Item29["export getServerSideProps"]; + Item30; + Item30["export config"]; + Item31; + Item31["export reportWebVitals"]; + Item32; + Item32["export unstable_getStaticProps"]; + Item33; + Item33["export unstable_getStaticPaths"]; + Item34; + Item34["export unstable_getStaticParams"]; + Item35; + Item35["export unstable_getServerProps"]; + Item36; + Item36["export unstable_getServerSideProps"]; + Item37; + Item37["export routeModule"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item5 --> Item1; + Item5 --> Item2; + Item5 --> Item3; + Item5 --> Item4; + Item6 --> Item1; + Item6 --> Item2; + Item6 --> Item3; + Item6 --> Item4; + Item6 --> Item5; + Item13 --> Item9; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item4; + Item13 --> Item5; + Item13 --> Item6; + Item14 --> Item9; + Item14 --> Item12; + Item15 --> Item9; + Item15 --> Item12; + Item16 --> Item9; + Item16 --> Item12; + Item17 --> Item9; + Item17 --> Item12; + Item18 --> Item9; + Item18 --> Item12; + Item19 --> Item9; + Item19 --> Item12; + Item20 --> Item9; + Item20 --> Item12; + Item21 --> Item9; + Item21 --> Item12; + Item22 --> Item9; + Item22 --> Item12; + Item23 --> Item9; + Item23 --> Item12; + Item24 --> Item7; + Item24 --> Item8; + Item24 --> Item11; + Item24 --> Item10; + Item24 --> Item12; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item7; + Item2; + Item8; + Item3; + Item9; + Item4; + Item10; + Item5; + Item11; + Item6; + Item12; + Item13; + Item14; + Item15; + Item16; + Item17; + Item18; + Item19; + Item20; + Item21; + Item22; + Item23; + Item24; + Item25; + Item25["ModuleEvaluation"]; + Item26; + Item26["export default"]; + Item27; + Item27["export getStaticProps"]; + Item28; + Item28["export getStaticPaths"]; + Item29; + Item29["export getServerSideProps"]; + Item30; + Item30["export config"]; + Item31; + Item31["export reportWebVitals"]; + Item32; + Item32["export unstable_getStaticProps"]; + Item33; + Item33["export unstable_getStaticPaths"]; + Item34; + Item34["export unstable_getStaticParams"]; + Item35; + Item35["export unstable_getServerProps"]; + Item36; + Item36["export unstable_getServerSideProps"]; + Item37; + Item37["export routeModule"]; + Item2 --> Item1; + Item3 --> Item1; + Item3 --> Item2; + Item4 --> Item1; + Item4 --> Item2; + Item4 --> Item3; + Item5 --> Item1; + Item5 --> Item2; + Item5 --> Item3; + Item5 --> Item4; + Item6 --> Item1; + Item6 --> Item2; + Item6 --> Item3; + Item6 --> Item4; + Item6 --> Item5; + Item13 --> Item9; + Item13 --> Item12; + Item13 --> Item1; + Item13 --> Item2; + Item13 --> Item3; + Item13 --> Item4; + Item13 --> Item5; + Item13 --> Item6; + Item14 --> Item9; + Item14 --> Item12; + Item15 --> Item9; + Item15 --> Item12; + Item16 --> Item9; + Item16 --> Item12; + Item17 --> Item9; + Item17 --> Item12; + Item18 --> Item9; + Item18 --> Item12; + Item19 --> Item9; + Item19 --> Item12; + Item20 --> Item9; + Item20 --> Item12; + Item21 --> Item9; + Item21 --> Item12; + Item22 --> Item9; + Item22 --> Item12; + Item23 --> Item9; + Item23 --> Item12; + Item24 --> Item7; + Item24 --> Item8; + Item24 --> Item11; + Item24 --> Item10; + Item24 --> Item12; + Item25 --> Item1; + Item25 --> Item2; + Item25 --> Item3; + Item25 --> Item4; + Item25 --> Item5; + Item25 --> Item6; + Item25 --> Item13; + Item26 --> Item13; + Item27 --> Item14; + Item28 --> Item15; + Item29 --> Item16; + Item30 --> Item17; + Item31 --> Item18; + Item32 --> Item19; + Item33 --> Item20; + Item34 --> Item21; + Item35 --> Item22; + Item36 --> Item23; + Item37 --> Item24; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation)]"]; + N1["Items: [ItemId(Export(("__TURBOPACK__default__export__", #3), "default"))]"]; + N2["Items: [ItemId(Export(("getStaticProps", #2), "getStaticProps")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(7, VarDeclarator(0))]"]; + N3["Items: [ItemId(Export(("getStaticPaths", #2), "getStaticPaths")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(8, VarDeclarator(0))]"]; + N4["Items: [ItemId(Export(("getServerSideProps", #2), "getServerSideProps")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(9, VarDeclarator(0))]"]; + N5["Items: [ItemId(Export(("config", #2), "config")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(10, VarDeclarator(0))]"]; + N6["Items: [ItemId(Export(("reportWebVitals", #2), "reportWebVitals")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(11, VarDeclarator(0))]"]; + N7["Items: [ItemId(Export(("unstable_getStaticProps", #2), "unstable_getStaticProps")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(12, VarDeclarator(0))]"]; + N8["Items: [ItemId(Export(("unstable_getStaticPaths", #2), "unstable_getStaticPaths")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(13, VarDeclarator(0))]"]; + N9["Items: [ItemId(Export(("unstable_getStaticParams", #2), "unstable_getStaticParams")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(14, VarDeclarator(0))]"]; + N10["Items: [ItemId(Export(("unstable_getServerProps", #2), "unstable_getServerProps")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(15, VarDeclarator(0))]"]; + N11["Items: [ItemId(Export(("unstable_getServerSideProps", #2), "unstable_getServerSideProps")), ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(16, VarDeclarator(0))]"]; + N12["Items: [ItemId(Export(("routeModule", #2), "routeModule")), ItemId(0, ImportBinding(0)), ItemId(1, ImportBinding(0)), ItemId(3, ImportBinding(0)), ItemId(4, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(17, VarDeclarator(0))]"]; + N13["Items: [ItemId(0, ImportOfModule)]"]; + N14["Items: [ItemId(1, ImportOfModule)]"]; + N15["Items: [ItemId(2, ImportOfModule)]"]; + N16["Items: [ItemId(3, ImportOfModule)]"]; + N17["Items: [ItemId(4, ImportOfModule)]"]; + N18["Items: [ItemId(5, ImportOfModule)]"]; + N19["Items: [ItemId(2, ImportBinding(0)), ItemId(5, ImportBinding(0)), ItemId(6, Normal)]"]; + N0 --> N13; + N0 --> N14; + N0 --> N15; + N0 --> N16; + N0 --> N17; + N0 --> N18; + N0 --> N19; + N1 --> N19; + N2 --> N19; + N3 --> N19; + N4 --> N19; + N5 --> N19; + N6 --> N19; + N7 --> N19; + N8 --> N19; + N9 --> N19; + N10 --> N19; + N11 --> N19; + N12 --> N19; + N14 --> N13; + N15 --> N13; + N15 --> N14; + N16 --> N13; + N16 --> N14; + N16 --> N15; + N17 --> N13; + N17 --> N14; + N17 --> N15; + N17 --> N16; + N18 --> N13; + N18 --> N14; + N18 --> N15; + N18 --> N16; + N18 --> N17; + N19 --> N13; + N19 --> N14; + N19 --> N15; + N19 --> N16; + N19 --> N17; + N19 --> N18; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "unstable_getStaticPaths", + ): 8, + Export( + "unstable_getServerSideProps", + ): 11, + Export( + "reportWebVitals", + ): 6, + Export( + "unstable_getServerProps", + ): 10, + Export( + "routeModule", + ): 12, + Export( + "getStaticProps", + ): 2, + Export( + "config", + ): 5, + Export( + "unstable_getStaticParams", + ): 9, + Export( + "unstable_getStaticProps", + ): 7, + Export( + "default", + ): 1, + Export( + "getStaticPaths", + ): 3, + Export( + "getServerSideProps", + ): 4, +} +``` + + +# Modules (dev) +## Part 0 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 18 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +"module evaluation"; + +``` +## Part 1 +```js +import { __TURBOPACK__default__export__ } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { __TURBOPACK__default__export__ as default }; + +``` +## Part 2 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { getStaticProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const getStaticProps = hoist(userland, 'getStaticProps'); +export { getStaticProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { getStaticPaths }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const getStaticPaths = hoist(userland, 'getStaticPaths'); +export { getStaticPaths } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { getServerSideProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const getServerSideProps = hoist(userland, 'getServerSideProps'); +export { getServerSideProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { config }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const config = hoist(userland, 'config'); +export { config } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 6 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { reportWebVitals }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const reportWebVitals = hoist(userland, 'reportWebVitals'); +export { reportWebVitals } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 7 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getStaticProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getStaticProps = hoist(userland, 'unstable_getStaticProps'); +export { unstable_getStaticProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 8 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getStaticPaths }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getStaticPaths = hoist(userland, 'unstable_getStaticPaths'); +export { unstable_getStaticPaths } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 9 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getStaticParams }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getStaticParams = hoist(userland, 'unstable_getStaticParams'); +export { unstable_getStaticParams } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 10 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getServerProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getServerProps = hoist(userland, 'unstable_getServerProps'); +export { unstable_getServerProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 11 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getServerSideProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getServerSideProps = hoist(userland, 'unstable_getServerSideProps'); +export { unstable_getServerSideProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 12 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { routeModule }; +import { PagesRouteModule } from '../../server/future/route-modules/pages/module.compiled'; +import { RouteKind } from '../../server/future/route-kind'; +import Document from 'VAR_MODULE_DOCUMENT'; +import App from 'VAR_MODULE_APP'; +import * as userland from 'VAR_USERLAND'; +const routeModule = new PagesRouteModule({ + definition: { + kind: RouteKind.PAGES, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + bundlePath: '', + filename: '' + }, + components: { + App, + Document + }, + userland +}); +export { routeModule } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 13 +```js +import '../../server/future/route-modules/pages/module.compiled'; + +``` +## Part 14 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import '../../server/future/route-kind'; + +``` +## Part 15 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import './helpers'; + +``` +## Part 16 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import 'VAR_MODULE_DOCUMENT'; + +``` +## Part 17 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import 'VAR_MODULE_APP'; + +``` +## Part 18 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import 'VAR_USERLAND'; + +``` +## Part 19 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 18 +}; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const __TURBOPACK__default__export__ = hoist(userland, 'default'); +export { __TURBOPACK__default__export__ } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 18 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +"module evaluation"; + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "unstable_getStaticPaths", + ): 8, + Export( + "unstable_getServerSideProps", + ): 11, + Export( + "reportWebVitals", + ): 6, + Export( + "unstable_getServerProps", + ): 10, + Export( + "routeModule", + ): 12, + Export( + "getStaticProps", + ): 2, + Export( + "config", + ): 5, + Export( + "unstable_getStaticParams", + ): 9, + Export( + "unstable_getStaticProps", + ): 7, + Export( + "default", + ): 1, + Export( + "getStaticPaths", + ): 3, + Export( + "getServerSideProps", + ): 4, +} +``` + + +# Modules (prod) +## Part 0 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 18 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +"module evaluation"; + +``` +## Part 1 +```js +import { __TURBOPACK__default__export__ } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { __TURBOPACK__default__export__ as default }; + +``` +## Part 2 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { getStaticProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const getStaticProps = hoist(userland, 'getStaticProps'); +export { getStaticProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { getStaticPaths }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const getStaticPaths = hoist(userland, 'getStaticPaths'); +export { getStaticPaths } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 4 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { getServerSideProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const getServerSideProps = hoist(userland, 'getServerSideProps'); +export { getServerSideProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 5 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { config }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const config = hoist(userland, 'config'); +export { config } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 6 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { reportWebVitals }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const reportWebVitals = hoist(userland, 'reportWebVitals'); +export { reportWebVitals } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 7 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getStaticProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getStaticProps = hoist(userland, 'unstable_getStaticProps'); +export { unstable_getStaticProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 8 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getStaticPaths }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getStaticPaths = hoist(userland, 'unstable_getStaticPaths'); +export { unstable_getStaticPaths } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 9 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getStaticParams }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getStaticParams = hoist(userland, 'unstable_getStaticParams'); +export { unstable_getStaticParams } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 10 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getServerProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getServerProps = hoist(userland, 'unstable_getServerProps'); +export { unstable_getServerProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 11 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { unstable_getServerSideProps }; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const unstable_getServerSideProps = hoist(userland, 'unstable_getServerSideProps'); +export { unstable_getServerSideProps } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 12 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +export { routeModule }; +import { PagesRouteModule } from '../../server/future/route-modules/pages/module.compiled'; +import { RouteKind } from '../../server/future/route-kind'; +import Document from 'VAR_MODULE_DOCUMENT'; +import App from 'VAR_MODULE_APP'; +import * as userland from 'VAR_USERLAND'; +const routeModule = new PagesRouteModule({ + definition: { + kind: RouteKind.PAGES, + page: 'VAR_DEFINITION_PAGE', + pathname: 'VAR_DEFINITION_PATHNAME', + bundlePath: '', + filename: '' + }, + components: { + App, + Document + }, + userland +}); +export { routeModule } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 13 +```js +import '../../server/future/route-modules/pages/module.compiled'; + +``` +## Part 14 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import '../../server/future/route-kind'; + +``` +## Part 15 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import './helpers'; + +``` +## Part 16 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import 'VAR_MODULE_DOCUMENT'; + +``` +## Part 17 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import 'VAR_MODULE_APP'; + +``` +## Part 18 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import 'VAR_USERLAND'; + +``` +## Part 19 +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 18 +}; +import { hoist } from './helpers'; +import * as userland from 'VAR_USERLAND'; +const __TURBOPACK__default__export__ = hoist(userland, 'default'); +export { __TURBOPACK__default__export__ } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 13 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 14 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 15 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 16 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 17 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 18 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 19 +}; +"module evaluation"; + +``` diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/test-config-1/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/test-config-1/output.md index 34a8233c25d47..a20d68147f5cf 100644 --- a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/test-config-1/output.md +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/test-config-1/output.md @@ -60,7 +60,7 @@ foobar += bar; ``` -- Reads: `bar` +- Reads: `bar`, `foobar` - Write: `foobar` ## Item 7: Stmt 5, `VarDeclarator(0)` @@ -81,6 +81,7 @@ foobar += "foo"; ``` +- Reads: `foobar` - Write: `foobar` ## Item 9: Stmt 7, `Normal` @@ -100,6 +101,7 @@ foobarCopy += "Unused"; ``` +- Reads: `foobarCopy` - Write: `foobarCopy` ## Item 11: Stmt 9, `Normal` @@ -114,6 +116,7 @@ function internal() { - Hoisted - Declares: `internal` - Reads (eventual): `upper`, `foobar` +- Write: `internal` ## Item 12: Stmt 10, `Normal` @@ -127,6 +130,7 @@ export function external1() { - Hoisted - Declares: `external1` - Reads (eventual): `internal`, `foobar` +- Write: `external1` ## Item 13: Stmt 11, `Normal` @@ -139,6 +143,7 @@ export function external2() { - Hoisted - Declares: `external2` +- Write: `external2` - Write (eventual): `foobar` # Phase 1 @@ -196,19 +201,19 @@ graph TD Item18["export external2"]; Item4 --> Item3; Item6 --> Item5; + Item6 --> Item3; Item6 -.-> Item4; - Item7 --> Item3; Item7 --> Item6; + Item8 --> Item6; Item8 -.-> Item4; Item8 -.-> Item7; Item9 --> Item7; Item9 --> Item1; Item9 -.-> Item2; - Item9 -.-> Item3; - Item9 -.-> Item6; Item9 -.-> Item8; Item9 -.-> Item4; Item9 -.-> Item11; + Item10 --> Item7; Item10 -.-> Item9; ``` # Phase 3 @@ -239,30 +244,27 @@ graph TD Item18["export external2"]; Item4 --> Item3; Item6 --> Item5; + Item6 --> Item3; Item6 -.-> Item4; - Item7 --> Item3; Item7 --> Item6; + Item8 --> Item6; Item8 -.-> Item4; Item8 -.-> Item7; Item9 --> Item7; Item9 --> Item1; Item9 -.-> Item2; - Item9 -.-> Item3; - Item9 -.-> Item6; Item9 -.-> Item8; Item9 -.-> Item4; Item9 -.-> Item11; + Item10 --> Item7; Item10 -.-> Item9; Item11 --> Item2; - Item11 --> Item3; - Item11 --> Item6; Item11 --> Item8; Item12 --> Item11; - Item12 --> Item3; - Item12 --> Item6; Item12 --> Item8; Item13 -.-> Item4; Item13 -.-> Item7; + Item13 -.-> Item8; ``` # Phase 4 ```mermaid @@ -292,34 +294,29 @@ graph TD Item18["export external2"]; Item4 --> Item3; Item6 --> Item5; + Item6 --> Item3; Item6 -.-> Item4; - Item7 --> Item3; Item7 --> Item6; + Item8 --> Item6; Item8 -.-> Item4; Item8 -.-> Item7; Item9 --> Item7; Item9 --> Item1; Item9 -.-> Item2; - Item9 -.-> Item3; - Item9 -.-> Item6; Item9 -.-> Item8; Item9 -.-> Item4; Item9 -.-> Item11; + Item10 --> Item7; Item10 -.-> Item9; Item11 --> Item2; - Item11 --> Item3; - Item11 --> Item6; Item11 --> Item8; Item12 --> Item11; - Item12 --> Item3; - Item12 --> Item6; Item12 --> Item8; Item13 -.-> Item4; Item13 -.-> Item7; + Item13 -.-> Item8; Item14 --> Item1; Item14 --> Item9; - Item15 --> Item3; - Item15 --> Item6; Item15 --> Item8; Item16 --> Item4; Item17 --> Item12; @@ -329,10 +326,10 @@ graph TD ```mermaid graph TD N0["Items: [ItemId(ModuleEvaluation), ItemId(0, ImportOfModule), ItemId(0, ImportBinding(0)), ItemId(7, Normal)]"]; - N1["Items: [ItemId(Export((\"foobar\", #0)))]"]; - N2["Items: [ItemId(Export((\"foo\", #0)))]"]; - N3["Items: [ItemId(Export((\"external1\", #0))), ItemId(10, Normal)]"]; - N4["Items: [ItemId(Export((\"external2\", #0))), ItemId(11, Normal)]"]; + N1["Items: [ItemId(Export(("foobar", #2), "foobar"))]"]; + N2["Items: [ItemId(Export(("foo", #2), "foo"))]"]; + N3["Items: [ItemId(Export(("external1", #2), "external1")), ItemId(10, Normal)]"]; + N4["Items: [ItemId(Export(("external2", #2), "external2")), ItemId(11, Normal)]"]; N5["Items: [ItemId(1, VarDeclarator(0))]"]; N6["Items: [ItemId(2, VarDeclarator(0))]"]; N7["Items: [ItemId(3, VarDeclarator(0))]"]; @@ -342,51 +339,60 @@ graph TD N11["Items: [ItemId(0, ImportBinding(0)), ItemId(9, Normal)]"]; N0 --> N9; N0 --> N11; - N0 --> N5; - N0 --> N8; N0 --> N10; N0 --> N6; - N1 --> N5; - N1 --> N8; N1 --> N10; N2 --> N6; N3 --> N11; - N3 --> N5; - N3 --> N8; N3 --> N10; N4 --> N6; N4 --> N9; + N4 --> N10; N6 --> N5; N8 --> N7; + N8 --> N5; N8 --> N6; - N9 --> N5; N9 --> N8; + N10 --> N8; N10 --> N6; N10 --> N9; - N11 --> N5; - N11 --> N8; N11 --> N10; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 3, + Export( + "foo", + ): 2, + Export( + "foobar", + ): 1, + Export( + "external2", + ): 4, +} +``` + + # Modules (dev) ## Part 0 ```js -import { foobarCopy } from "entry.js" assert { - __turbopack_chunk__: 9 -}; -import "entry.js" assert { - __turbopack_chunk__: 11 +import { foobarCopy } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; -import "entry.js" assert { - __turbopack_chunk__: 5 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import "entry.js" assert { - __turbopack_chunk__: 8 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; -import "entry.js" assert { - __turbopack_chunk__: 10 -}; -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; "module evaluation"; import "module"; @@ -396,208 +402,223 @@ console.log(foobarCopy); ``` ## Part 1 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { foobar }; ``` ## Part 2 ```js -import { foo } from "entry.js" assert { - __turbopack_chunk__: 6 +import { foo } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; export { foo }; ``` ## Part 3 ```js -import { internal } from "entry.js" assert { - __turbopack_chunk__: 11 -}; -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { internal } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 }; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { external1 }; function external1() { return internal() + foobar; } +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 ```js -import "entry.js" assert { - __turbopack_chunk__: 6 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; -import "entry.js" assert { - __turbopack_chunk__: 9 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let foobar = "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; const foo = foobar; -export { foo }; +export { foo } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js const bar = "bar"; -export { bar }; +export { bar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js -import { bar } from "entry.js" assert { - __turbopack_chunk__: 7 +import { bar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; -import "entry.js" assert { - __turbopack_chunk__: 6 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 }; foobar += bar; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 9 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; let foobarCopy = foobar; -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 10 ```js -import "entry.js" assert { - __turbopack_chunk__: 6 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; -import "entry.js" assert { - __turbopack_chunk__: 9 +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 }; foobar += "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 11 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 -}; -import "entry.js" assert { - __turbopack_chunk__: 10 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 }; import { upper } from "module"; function internal() { return upper(foobar); } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js +import { foobarCopy } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 9 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 11 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 10 +}; +import "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; import "module"; import { upper } from "module"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -const foo = foobar; -export { foo }; -foobar += bar; -export { foobar }; -let foobarCopy = foobar; -export { foobarCopy }; -import { upper } from "module"; -foobar += "foo"; -export { foobar }; -function internal() { - return upper(foobar); -} "module evaluation"; console.log(foobarCopy); ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 3, + Export( + "foo", + ): 2, + Export( + "foobar", + ): 1, + Export( + "external2", + ): 4, +} +``` + + # Modules (prod) ## Part 0 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 }; "module evaluation"; import "module"; let foobarCopy = foobar; console.log(foobarCopy); -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 1 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { foobar }; ``` ## Part 2 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; export { foo }; const foo = foobar; -export { foo }; +export { foo } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 3 ```js -import { foobar } from "entry.js" assert { - __turbopack_chunk__: 5 -}; -import "entry.js" assert { - __turbopack_chunk__: 7 -}; -import "entry.js" assert { - __turbopack_chunk__: 8 +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 }; export { external1 }; import { upper } from "module"; @@ -607,6 +628,12 @@ function internal() { function external1() { return internal() + foobar; } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 4 @@ -615,61 +642,93 @@ export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 5 ```js let foobar = "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 6 ```js const bar = "bar"; -export { bar }; +export { bar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 7 ```js -import { bar } from "entry.js" assert { - __turbopack_chunk__: 6 +import { bar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 6 +}; +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 5 }; foobar += bar; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Part 8 ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; foobar += "foo"; -export { foobar }; +export { foobar } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` ## Merged (module eval) ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 7 +}; import "module"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -foobar += bar; -export { foobar }; "module evaluation"; let foobarCopy = foobar; console.log(foobarCopy); -export { foobarCopy }; +export { foobarCopy } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +# Entrypoints ``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 3, + Export( + "foo", + ): 2, + Export( + "foobar", + ): 1, + Export( + "external2", + ): 4, +} +``` + + ## Merged (external1) ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; import { upper } from "module"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -foobar += bar; -export { foobar }; -foobar += "foo"; -export { foobar }; export { external1 }; function internal() { return upper(foobar); @@ -677,19 +736,41 @@ function internal() { function external1() { return internal() + foobar; } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "external1", + ): 3, + Export( + "foo", + ): 2, + Export( + "foobar", + ): 1, + Export( + "external2", + ): 4, +} +``` + + ## Merged (external1,external2) ```js +import { foobar } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 8 +}; import { upper } from "module"; -let foobar = "foo"; -export { foobar }; -const bar = "bar"; -export { bar }; -foobar += bar; -export { foobar }; -foobar += "foo"; -export { foobar }; export { external1 }; function internal() { return upper(foobar); @@ -697,9 +778,18 @@ function internal() { function external1() { return internal() + foobar; } +export { internal } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; +export { external1 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; export { external2 }; function external2() { foobar += "."; } +export { external2 } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; ``` diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/input.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js rename to crates/turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/input.js diff --git a/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/output.md b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/output.md new file mode 100644 index 0000000000000..1f296f1665993 --- /dev/null +++ b/crates/turbopack-ecmascript/tests/tree-shaker/analyzer/tla-1/output.md @@ -0,0 +1,221 @@ +# Items + +Count: 6 + +## Item 1: Stmt 0, `Normal` + +```js +await Promise.resolve(); + +``` + +- Side effects +- Reads: `Promise` + +## Item 2: Stmt 1, `VarDeclarator(0)` + +```js +export const effects = []; + +``` + +- Declares: `effects` +- Write: `effects` + +## Item 3: Stmt 2, `Normal` + +```js +export function effect(name) { + effects.push(name); +} + +``` + +- Hoisted +- Declares: `effect` +- Reads (eventual): `effects` +- Write: `effect` + +# Phase 1 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export effects"]; + Item6; + Item6["export effect"]; +``` +# Phase 2 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export effects"]; + Item6; + Item6["export effect"]; +``` +# Phase 3 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export effects"]; + Item6; + Item6["export effect"]; + Item3 --> Item2; +``` +# Phase 4 +```mermaid +graph TD + Item1; + Item2; + Item3; + Item4; + Item4["ModuleEvaluation"]; + Item5; + Item5["export effects"]; + Item6; + Item6["export effect"]; + Item3 --> Item2; + Item4 --> Item1; + Item5 --> Item2; + Item6 --> Item3; +``` +# Final +```mermaid +graph TD + N0["Items: [ItemId(ModuleEvaluation), ItemId(0, Normal)]"]; + N1["Items: [ItemId(Export(("effects", #2), "effects"))]"]; + N2["Items: [ItemId(Export(("effect", #2), "effect")), ItemId(2, Normal)]"]; + N3["Items: [ItemId(1, VarDeclarator(0))]"]; + N1 --> N3; + N2 --> N3; +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "effects", + ): 1, + Export( + "effect", + ): 2, +} +``` + + +# Modules (dev) +## Part 0 +```js +"module evaluation"; +await Promise.resolve(); + +``` +## Part 1 +```js +import { effects } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { effects }; + +``` +## Part 2 +```js +import { effects } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { effect }; +function effect(name) { + effects.push(name); +} +export { effect } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +const effects = []; +export { effects } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +"module evaluation"; +await Promise.resolve(); + +``` +# Entrypoints + +``` +{ + ModuleEvaluation: 0, + Export( + "effects", + ): 1, + Export( + "effect", + ): 2, +} +``` + + +# Modules (prod) +## Part 0 +```js +"module evaluation"; +await Promise.resolve(); + +``` +## Part 1 +```js +import { effects } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { effects }; + +``` +## Part 2 +```js +import { effects } from "__TURBOPACK_PART__" assert { + __turbopack_part__: 3 +}; +export { effect }; +function effect(name) { + effects.push(name); +} +export { effect } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Part 3 +```js +const effects = []; +export { effects } from "__TURBOPACK_VAR__" assert { + __turbopack_var__: true +}; + +``` +## Merged (module eval) +```js +"module evaluation"; +await Promise.resolve(); + +``` diff --git a/crates/turbopack-node/js/src/compiled/stacktrace-parser/index.js b/crates/turbopack-node/js/src/compiled/stacktrace-parser/index.js index 8a4faf75014b3..e6546a064f7a0 100644 --- a/crates/turbopack-node/js/src/compiled/stacktrace-parser/index.js +++ b/crates/turbopack-node/js/src/compiled/stacktrace-parser/index.js @@ -1,119 +1,110 @@ -(() => { - "use strict"; - if (typeof __nccwpck_require__ !== "undefined") - __nccwpck_require__.ab = __dirname + "/"; - var e = {}; - (() => { - var r = e; - Object.defineProperty(r, "__esModule", { value: true }); - var n = ""; - function parse(e) { - var r = e.split("\n"); - return r.reduce(function (e, r) { - var n = - parseChrome(r) || - parseWinjs(r) || - parseGecko(r) || - parseNode(r) || - parseJSC(r); - if (n) { - e.push(n); - } - return e; - }, []); +if (typeof __nccwpck_require__ !== "undefined") + __nccwpck_require__.ab = __dirname + "/"; + +var n = ""; +export function parse(e) { + var r = e.split("\n"); + return r.reduce(function (e, r) { + var n = + parseChrome(r) || + parseWinjs(r) || + parseGecko(r) || + parseNode(r) || + parseJSC(r); + if (n) { + e.push(n); } - var a = - /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack||\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i; - var l = /\((\S*)(?::(\d+))(?::(\d+))\)/; - function parseChrome(e) { - var r = a.exec(e); - if (!r) { - return null; - } - var u = r[2] && r[2].indexOf("native") === 0; - var t = r[2] && r[2].indexOf("eval") === 0; - var i = l.exec(r[2]); - if (t && i != null) { - r[2] = i[1]; - r[3] = i[2]; - r[4] = i[3]; - } - return { - file: !u ? r[2] : null, - methodName: r[1] || n, - arguments: u ? [r[2]] : [], - lineNumber: r[3] ? +r[3] : null, - column: r[4] ? +r[4] : null, - }; - } - var u = - /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; - function parseWinjs(e) { - var r = u.exec(e); - if (!r) { - return null; - } - return { - file: r[2], - methodName: r[1] || n, - arguments: [], - lineNumber: +r[3], - column: r[4] ? +r[4] : null, - }; - } - var t = - /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; - var i = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i; - function parseGecko(e) { - var r = t.exec(e); - if (!r) { - return null; - } - var a = r[3] && r[3].indexOf(" > eval") > -1; - var l = i.exec(r[3]); - if (a && l != null) { - r[3] = l[1]; - r[4] = l[2]; - r[5] = null; - } - return { - file: r[3], - methodName: r[1] || n, - arguments: r[2] ? r[2].split(",") : [], - lineNumber: r[4] ? +r[4] : null, - column: r[5] ? +r[5] : null, - }; - } - var s = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i; - function parseJSC(e) { - var r = s.exec(e); - if (!r) { - return null; - } - return { - file: r[3], - methodName: r[1] || n, - arguments: [], - lineNumber: +r[4], - column: r[5] ? +r[5] : null, - }; - } - var o = - /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i; - function parseNode(e) { - var r = o.exec(e); - if (!r) { - return null; - } - return { - file: r[2], - methodName: r[1] || n, - arguments: [], - lineNumber: +r[3], - column: r[4] ? +r[4] : null, - }; - } - r.parse = parse; - })(); - module.exports = e; -})(); + return e; + }, []); +} +var a = + /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack||\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i; +var l = /\((\S*)(?::(\d+))(?::(\d+))\)/; +function parseChrome(e) { + var r = a.exec(e); + if (!r) { + return null; + } + var u = r[2] && r[2].indexOf("native") === 0; + var t = r[2] && r[2].indexOf("eval") === 0; + var i = l.exec(r[2]); + if (t && i != null) { + r[2] = i[1]; + r[3] = i[2]; + r[4] = i[3]; + } + return { + file: !u ? r[2] : null, + methodName: r[1] || n, + arguments: u ? [r[2]] : [], + lineNumber: r[3] ? +r[3] : null, + column: r[4] ? +r[4] : null, + }; +} +var u = + /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; +function parseWinjs(e) { + var r = u.exec(e); + if (!r) { + return null; + } + return { + file: r[2], + methodName: r[1] || n, + arguments: [], + lineNumber: +r[3], + column: r[4] ? +r[4] : null, + }; +} +var t = + /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; +var i = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i; +function parseGecko(e) { + var r = t.exec(e); + if (!r) { + return null; + } + var a = r[3] && r[3].indexOf(" > eval") > -1; + var l = i.exec(r[3]); + if (a && l != null) { + r[3] = l[1]; + r[4] = l[2]; + r[5] = null; + } + return { + file: r[3], + methodName: r[1] || n, + arguments: r[2] ? r[2].split(",") : [], + lineNumber: r[4] ? +r[4] : null, + column: r[5] ? +r[5] : null, + }; +} +var s = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i; +function parseJSC(e) { + var r = s.exec(e); + if (!r) { + return null; + } + return { + file: r[3], + methodName: r[1] || n, + arguments: [], + lineNumber: +r[4], + column: r[5] ? +r[5] : null, + }; +} +var o = + /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i; +function parseNode(e) { + var r = o.exec(e); + if (!r) { + return null; + } + return { + file: r[2], + methodName: r[1] || n, + arguments: [], + lineNumber: +r[3], + column: r[4] ? +r[4] : null, + }; +} diff --git a/crates/turbopack-node/js/src/ipc/index.ts b/crates/turbopack-node/js/src/ipc/index.ts index a29da6a437dd6..fa8d37f0c8a74 100644 --- a/crates/turbopack-node/js/src/ipc/index.ts +++ b/crates/turbopack-node/js/src/ipc/index.ts @@ -116,6 +116,7 @@ function createIpc( socket.write(length, (err) => { process.stderr.write(`TURBOPACK_OUTPUT_D\n`); process.stdout.write(`TURBOPACK_OUTPUT_D\n`); + if (err != null) { reject(err); } else { diff --git a/crates/turbopack-node/src/pool.rs b/crates/turbopack-node/src/pool.rs index 2c3ee1eb769f7..2dd964a1aa9c0 100644 --- a/crates/turbopack-node/src/pool.rs +++ b/crates/turbopack-node/src/pool.rs @@ -440,7 +440,10 @@ impl NodeJsPoolProcess { let ready_signal = process.recv().await?; if !ready_signal.is_empty() { - bail!("Node.js process didn't send the expected ready signal"); + bail!( + "Node.js process didn't send the expected ready signal\nOutput:\n{}", + String::from_utf8_lossy(&ready_signal) + ); } drop(guard); diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/a.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/a.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/a.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/a.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/b.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/b.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/b.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/b.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/c.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/c.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/c.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/c.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/default.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/default.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/default.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/default.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-material/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-material/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/x.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/x.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/x.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-full/x.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/a.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/a.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/a.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/a.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/b.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/b.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/b.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/b.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/default.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/default.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/default.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/default.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/not-compiled.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/not-compiled.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/not-compiled.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/not-compiled.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/not-executed.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/not-executed.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/not-executed.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/not-executed.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/x.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/x.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/x.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/x.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/y.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/y.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/y.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-named/y.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/a.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/a.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/a.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/a.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/b.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/b.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/b.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/b.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/dir/file.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/dir/file.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/dir/file.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/dir/file.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/effect.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/effect.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/effect.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/file.side.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/file.side.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/file.side.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/file.side.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/not-compiled.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/not-compiled.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/not-compiled.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/not-compiled.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/not-executed.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/not-executed.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/not-executed.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/not-executed.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-partial/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-partial/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/check-side-effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/check-side-effect.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/check-side-effect.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/check-side-effect.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/side-effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/side-effect.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/side-effect.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/side-effect.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/side-effect2.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/side-effect2.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-side-effect/side-effect2.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-side-effect/side-effect2.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js new file mode 100644 index 0000000000000..de355e58250b1 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/check-side-effect.js @@ -0,0 +1,7 @@ +await Promise.resolve(); + +export const effects = []; + +export function effect(name) { + effects.push(name); +} diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/side-effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/side-effect.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/side-effect.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/side-effect.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/side-effect2.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/side-effect2.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-tla-side-effect/side-effect2.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-tla-side-effect/side-effect2.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-unused/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-unused/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-unused/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-unused/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-unused/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-unused/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport-unused/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport-unused/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-reexport/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-reexport/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/check-side-effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/check-side-effect.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/check-side-effect.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/check-side-effect.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/side-effect.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/side-effect.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/side-effect.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/side-effect.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/side-effect2.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/side-effect2.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-require-side-effect/side-effect2.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-require-side-effect/side-effect2.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/a.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/a.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/a.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/a.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/b.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/b.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/b.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/b.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/not-compiled.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/not-compiled.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/not-compiled.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/not-compiled.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/not-executed.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/not-executed.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/not-executed.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/not-executed.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-full/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/package-star/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/both.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/both.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/both.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/both.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/local.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/local.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/local.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/local.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-named/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/reexport.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/reexport.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/reexport.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/reexport.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/reexported.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/reexported.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/reexported.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/reexported.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/tla-reexported.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/tla-reexported.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/tla-reexported.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/input/node_modules/tla/tla-reexported.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/options.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/options.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/options.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/basic/options.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/input/index.js new file mode 100644 index 0000000000000..30838b215a56e --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/input/index.js @@ -0,0 +1,21 @@ +import * as NS1 from "mui-material/generateUtilityClass"; +import * as NS2 from "mui-utils"; +import * as NS3 from "mui-utils/generateUtilityClass"; + +it("should import renamed exports correctly", () => { + const ns = Object(NS1); + expect(typeof ns.default).toBe("function"); + expect(ns.default()).toBe("ok"); +}); + +it("should import renamed exports correctly", () => { + const ns = Object(NS2); + expect(typeof ns.unstable_generateUtilityClass).toBe("function"); + expect(ns.unstable_generateUtilityClass()).toBe("ok"); +}); + +it("should import renamed exports correctly", () => { + const ns = Object(NS3); + expect(typeof ns.default).toBe("function"); + expect(ns.default()).toBe("ok"); +}); diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-material/generateUtilityClass/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-material/generateUtilityClass/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-material/generateUtilityClass/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-material/generateUtilityClass/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-material/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/package-star/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-material/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/generateUtilityClass/generateUtilityClass.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/generateUtilityClass/generateUtilityClass.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/generateUtilityClass/generateUtilityClass.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/generateUtilityClass/generateUtilityClass.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/generateUtilityClass/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/generateUtilityClass/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/generateUtilityClass/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/generateUtilityClass/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/index.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/not-correct.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/not-correct.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/node_modules/mui-utils/not-correct.js rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/not-correct.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/package.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/package.json similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/tree-shaking/side-effects/input/node_modules/tla/package.json rename to crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/node_modules/mui-utils/package.json diff --git a/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/options.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/options.json new file mode 100644 index 0000000000000..af13697f09f93 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/mui-utils/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "reexports-only" +} diff --git a/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/esm.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/esm.js new file mode 100644 index 0000000000000..9ff8c3a18aa5a --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/esm.js @@ -0,0 +1,6 @@ +import * as self from "./esm"; +export * as self from "./esm"; + +export const getSelf = function getSelf() { + return self; +}; diff --git a/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/index.js new file mode 100644 index 0000000000000..7ebea6326beb5 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/input/index.js @@ -0,0 +1,11 @@ +import { getSelf, self } from "./esm"; +import * as esm from "./esm"; +const requiredEsm = require("./esm"); + +it("should have the same identity on all namespace objects", async () => { + expect(getSelf()).toBe(esm); + expect(self).toBe(esm); + expect(requiredEsm).toBe(esm); + const importedEsm = await import("./esm"); + expect(importedEsm).toBe(esm); +}); diff --git a/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/options.json b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/options.json new file mode 100644 index 0000000000000..af13697f09f93 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/namespace-object-identity/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "reexports-only" +} diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/input/index.js new file mode 100644 index 0000000000000..b2a8a3837c2dc --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/input/index.js @@ -0,0 +1 @@ +import "../../../side-effects-optimization/basic/input/index.js"; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/options.json b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/.basic/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/cjs.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/cjs.js new file mode 100644 index 0000000000000..f745c705c66bd --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/cjs.js @@ -0,0 +1,10 @@ +const state = {}; + +module.exports = { + getCjsState: function getCjsState(e) { + return state; + }, + getCjsState2: function getCjsState2(e) { + return state; + }, +}; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/esm.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/esm.js new file mode 100644 index 0000000000000..c1befcf470b56 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/esm.js @@ -0,0 +1,9 @@ +const state = {}; + +export const getState = function getState(e) { + return state; +}; + +export const getState2 = function getState2(e) { + return state; +}; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/index.js new file mode 100644 index 0000000000000..34edc31f9f974 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/input/index.js @@ -0,0 +1,10 @@ +import { getCjsState, getCjsState2 } from "./cjs"; +import { getState, getState2 } from "./esm"; + +it("should not duplicate cjs modules", () => { + expect(getCjsState()).toBe(getCjsState2()); +}); + +it("should not duplicate ES modules", () => { + expect(getState()).toBe(getState2()); +}); diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/options.json b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/duplicate-modules/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/input/index.js index 30838b215a56e..d1ec2d616cfd1 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/input/index.js +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/input/index.js @@ -1,21 +1 @@ -import * as NS1 from "mui-material/generateUtilityClass"; -import * as NS2 from "mui-utils"; -import * as NS3 from "mui-utils/generateUtilityClass"; - -it("should import renamed exports correctly", () => { - const ns = Object(NS1); - expect(typeof ns.default).toBe("function"); - expect(ns.default()).toBe("ok"); -}); - -it("should import renamed exports correctly", () => { - const ns = Object(NS2); - expect(typeof ns.unstable_generateUtilityClass).toBe("function"); - expect(ns.unstable_generateUtilityClass()).toBe("ok"); -}); - -it("should import renamed exports correctly", () => { - const ns = Object(NS3); - expect(typeof ns.default).toBe("function"); - expect(ns.default()).toBe("ok"); -}); +import "../../../side-effects-optimization/mui-utils/input/index.js"; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/options.json b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/options.json index af13697f09f93..000d78a6b3cbb 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/options.json +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/mui-utils/options.json @@ -1,3 +1,3 @@ { - "treeShakingMode": "reexports-only" + "treeShakingMode": "module-fragments" } diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/esm.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/esm.js new file mode 100644 index 0000000000000..e5072a48b7c38 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/esm.js @@ -0,0 +1,5 @@ +export const state = {}; + +export const getState = function getState(e) { + return state; +}; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/index.js new file mode 100644 index 0000000000000..2518ef44bc1ba --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/input/index.js @@ -0,0 +1,12 @@ +import { getState, state } from "./esm"; +import * as esm from "./esm"; + +it("should not allow to modify exports", () => { + const initialState = getState(); + expect(getState()).toBe(state); + expect(() => (esm.state = { not: "allowed" })).toThrow(); + expect(() => (esm.newExport = { not: "allowed" })).toThrow(); + expect(getState()).toBe(initialState); + expect(state).toBe(initialState); + expect(esm.state).toBe(initialState); +}); diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/options.json b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/no-write-access/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/a.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/a.js new file mode 100644 index 0000000000000..fd18d3bf7d373 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/a.js @@ -0,0 +1,3 @@ +import { a } from "./module"; + +export default a; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/b.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/b.js new file mode 100644 index 0000000000000..bd9f02cc977cd --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/b.js @@ -0,0 +1,3 @@ +import { b } from "./module"; + +export default b; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/index.js new file mode 100644 index 0000000000000..e3a3673d4852c --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/index.js @@ -0,0 +1,7 @@ +it("should load chunk a", async () => { + await expect(import("./a")).resolves.toHaveProperty("default", "a"); +}); + +it("should load chunk b", async () => { + await expect(import("./b")).resolves.toHaveProperty("default", "b"); +}); diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/module.js b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/module.js new file mode 100644 index 0000000000000..4b7aee241e63f --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/input/module.js @@ -0,0 +1,4 @@ +const a = "a"; +const b = "b"; + +export { a, b }; diff --git a/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/options.json b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/split-chunks/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot.rs b/crates/turbopack-tests/tests/snapshot.rs index 38784020847c6..3b5de21750c11 100644 --- a/crates/turbopack-tests/tests/snapshot.rs +++ b/crates/turbopack-tests/tests/snapshot.rs @@ -20,7 +20,7 @@ use turbo_tasks_fs::{ }; use turbo_tasks_memory::MemoryBackend; use turbopack::{ - ecmascript::{EcmascriptInputTransform, EcmascriptModuleAsset}, + ecmascript::{EcmascriptInputTransform, EcmascriptModuleAsset, TreeShakingMode}, module_options::{ JsxTransformOptions, ModuleOptionsContext, ModuleRule, ModuleRuleCondition, ModuleRuleEffect, @@ -90,6 +90,8 @@ struct SnapshotOptions { environment: SnapshotEnvironment, #[serde(default)] use_swc_css: bool, + #[serde(default)] + tree_shaking_mode: Option, } #[derive(Debug, Deserialize, Default)] @@ -116,6 +118,7 @@ impl Default for SnapshotOptions { runtime_type: default_runtime_type(), environment: Default::default(), use_swc_css: Default::default(), + tree_shaking_mode: Default::default(), } } } @@ -275,6 +278,7 @@ async fn run_test(resource: String) -> Result> { .cell(), )], custom_rules: vec![custom_rules], + tree_shaking_mode: options.tree_shaking_mode, ..Default::default() } .into(), diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js new file mode 100644 index 0000000000000..cf2e6dc9fa6a2 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js @@ -0,0 +1,7 @@ +async function main() { + const lib = await import("./lib"); + console.log(lib.cat); +} + + +main() diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js new file mode 100644 index 0000000000000..40b1b7ca274be --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js @@ -0,0 +1,14 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript, async loader) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { + +__turbopack_export_value__((__turbopack_import__) => { + return Promise.all([ + "output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js" +].map((chunk) => __turbopack_load__(chunk))).then(() => { + return __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); + }); +}); + +})()), +}]); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js.map new file mode 100644 index 0000000000000..c15d7ec00382d --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_029950.js.map @@ -0,0 +1,5 @@ +{ + "version": 3, + "sources": [], + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js new file mode 100644 index 0000000000000..be6247239c001 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js @@ -0,0 +1,226 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dogRef": [ + ()=>dogRef, + (v)=>dogRef = v + ], + "getDog": [ + ()=>getDog, + (v)=>getDog = v + ], + "setDog": [ + ()=>setDog, + (v)=>setDog = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +function getDog() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +function setDog(newDog) { + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"] = newDog; +} +const dogRef = { + initial: __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"], + get: getDog, + set: setDog +}; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "getChimera": [ + ()=>getChimera, + (v)=>getChimera = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +function getChimera() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "initialCat": [ + ()=>initialCat, + (v)=>initialCat = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +const initialCat = __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"]; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$dynamic$2d$import$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js.map new file mode 100644 index 0000000000000..78c31ef11784a --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_189889.js.map @@ -0,0 +1,29 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,qOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,qOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,qOAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 51, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 59, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 64, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 72, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 77, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,OAAO"}}, + {"offset": {"line": 89, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 94, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,OAAO"}}, + {"offset": {"line": 106, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 111, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS;IACP,OAAO,qOAAA,CAAA,MAAG;AACZ;AAMA,SAAS,OAAO,MAAM;IACpB,qOAAA,CAAA,MAAG,GAAG;AACR;AAMO,MAAM,SAAS;IACpB,SAAS,qOAAA,CAAA,MAAG;IACZ,KAAK;IACL,KAAK;AACP"}}, + {"offset": {"line": 144, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 149, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgCO,SAAS;IACd,OAAO,qOAAA,CAAA,MAAG,GAAG,qOAAA,CAAA,MAAG;AAClB"}}, + {"offset": {"line": 166, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 171, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA8BO,MAAM,aAAa,qOAAA,CAAA,MAAG"}}, + {"offset": {"line": 184, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 189, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 205, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 210, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 221, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js new file mode 100644 index 0000000000000..58e10b6c798b3 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js @@ -0,0 +1,14 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)": (function({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname, m: module, e: exports, t: require }) { !function() { + +async function main() { + const lib = await __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript, async loader) ")(__turbopack_import__); + console.log(lib.cat); +} +main(); + +}.call(this) }), +}]); + +//# sourceMappingURL=a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js.map new file mode 100644 index 0000000000000..6fd70ea1838f4 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/output/a587c_tests_snapshot_basic-tree-shake_dynamic-import_input_index_26d958.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js"],"sourcesContent":["async function main() {\n const lib = await import(\"./lib\");\n console.log(lib.cat);\n}\n\n\nmain()\n"],"names":[],"mappings":"AAAA,eAAe;IACb,MAAM,MAAM;IACZ,QAAQ,GAAG,CAAC,IAAI,GAAG;AACrB;AAGA"}}, + {"offset": {"line": 9, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js new file mode 100644 index 0000000000000..715232bc56a60 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js @@ -0,0 +1,4 @@ +import { fakeCat } from "./module"; + + +console.log(fakeCat) diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js new file mode 100644 index 0000000000000..072af1e0a25e7 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js @@ -0,0 +1,2 @@ +export { cat as fakeCat } from './lib' + diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js new file mode 100644 index 0000000000000..e1c498e1489bc --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js @@ -0,0 +1,122 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js [test] (ecmascript) ": (function({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname, m: module, e: exports, t: require }) { !function() { + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; + +}.call(this) }), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "fakeCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$module$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$module$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__fakeCat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/module.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; +; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$module$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__fakeCat$3e$__["fakeCat"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$named$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js.map new file mode 100644 index 0000000000000..9dd1c5623e120 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0f9f9f._.js.map @@ -0,0 +1,23 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,mOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,mOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,mOAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 50, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 55, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 60, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 68, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 73, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 81, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 86, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 94, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 99, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js"],"sourcesContent":["import { fakeCat } from \"./module\";\n\n\nconsole.log(fakeCat)\n"],"names":[],"mappings":";;;;;;;AAGA,QAAQ,GAAG,CAAC,oOAAA,CAAA,UAAO"}}, + {"offset": {"line": 107, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 112, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 117, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js new file mode 100644 index 0000000000000..ccbfaeaf89af9 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js @@ -0,0 +1,3 @@ +import {lib} from './module' + +console.log(lib.cat) diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js new file mode 100644 index 0000000000000..389c321467ba8 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js @@ -0,0 +1,2 @@ +export * as lib from './lib' + diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js new file mode 100644 index 0000000000000..17430ea1ab8cf --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js @@ -0,0 +1,271 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js [test] (ecmascript) ": (function({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname, m: module, e: exports, t: require }) { !function() { + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; + +}.call(this) }), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dogRef": [ + ()=>dogRef, + (v)=>dogRef = v + ], + "getDog": [ + ()=>getDog, + (v)=>getDog = v + ], + "setDog": [ + ()=>setDog, + (v)=>setDog = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +function getDog() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +function setDog(newDog) { + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"] = newDog; +} +const dogRef = { + initial: __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"], + get: getDog, + set: setDog +}; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "getChimera": [ + ()=>getChimera, + (v)=>getChimera = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +function getChimera() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "initialCat": [ + ()=>initialCat, + (v)=>initialCat = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +const initialCat = __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"]; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "lib": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$facade$3e$__ +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$facade$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$module$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$module$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__lib$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/module.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; +; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$module$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__lib$3e$__["lib"].cat); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$export$2d$namespace$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js.map new file mode 100644 index 0000000000000..75c6e746401d7 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_b8c6d3._.js.map @@ -0,0 +1,37 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,uOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,uOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,uOAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 50, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 55, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 60, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 68, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 73, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 81, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 86, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,OAAO"}}, + {"offset": {"line": 98, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 103, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,OAAO"}}, + {"offset": {"line": 115, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 120, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS;IACP,OAAO,uOAAA,CAAA,MAAG;AACZ;AAMA,SAAS,OAAO,MAAM;IACpB,uOAAA,CAAA,MAAG,GAAG;AACR;AAMO,MAAM,SAAS;IACpB,SAAS,uOAAA,CAAA,MAAG;IACZ,KAAK;IACL,KAAK;AACP"}}, + {"offset": {"line": 153, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 158, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgCO,SAAS;IACd,OAAO,uOAAA,CAAA,MAAG,GAAG,uOAAA,CAAA,MAAG;AAClB"}}, + {"offset": {"line": 175, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 180, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA8BO,MAAM,aAAa,uOAAA,CAAA,MAAG"}}, + {"offset": {"line": 193, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 198, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 214, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 219, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 230, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 235, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 243, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 248, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js"],"sourcesContent":["import {lib} from './module'\n\nconsole.log(lib.cat)\n"],"names":[],"mappings":";;;;;;;AAEA,QAAQ,GAAG,CAAC,oOAAA,CAAA,MAAG,CAAC,GAAG"}}, + {"offset": {"line": 256, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 261, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 266, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js new file mode 100644 index 0000000000000..054969d300c94 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js @@ -0,0 +1,5 @@ +import {cat as c,dogRef,initialCat,getChimera} from './lib' + +console.log(c) + +// TODO: Execution diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js new file mode 100644 index 0000000000000..4a9a722af723c --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js @@ -0,0 +1,101 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; +; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"]) // TODO: Execution +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2d$all$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js.map new file mode 100644 index 0000000000000..6a6af32ecb35c --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_c16bea._.js.map @@ -0,0 +1,19 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,0OAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,0OAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,0OAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 51, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 59, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 64, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 72, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 77, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js"],"sourcesContent":["import {cat as c,dogRef,initialCat,getChimera} from './lib'\n\nconsole.log(c)\n\n// TODO: Execution\n"],"names":[],"mappings":";;;;;;;AAEA,QAAQ,GAAG,CAAC,oOAAA,CAAA,MAAC,EAEb,kBAAkB"}}, + {"offset": {"line": 86, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 91, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 96, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js new file mode 100644 index 0000000000000..4dcab2bb4c1a1 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js @@ -0,0 +1,3 @@ +import {cat as c} from './lib' + +console.log(c) diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js new file mode 100644 index 0000000000000..4e1f9828b167d --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js @@ -0,0 +1,100 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; +; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$named$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js.map new file mode 100644 index 0000000000000..8fa87a3e24d6a --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/output/crates_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_3e6aa0._.js.map @@ -0,0 +1,19 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,mOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,mOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,mOAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 51, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 59, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 64, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 72, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 77, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js"],"sourcesContent":["import {cat as c} from './lib'\n\nconsole.log(c)\n"],"names":[],"mappings":";;;;;;;AAEA,QAAQ,GAAG,CAAC,6NAAA,CAAA,MAAC"}}, + {"offset": {"line": 85, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 90, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 95, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js new file mode 100644 index 0000000000000..e34da4ad41e81 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js @@ -0,0 +1,3 @@ +import * as lib from './lib' + +console.log(lib.cat) diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js new file mode 100644 index 0000000000000..694f55c6ff38e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js @@ -0,0 +1,249 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dogRef": [ + ()=>dogRef, + (v)=>dogRef = v + ], + "getDog": [ + ()=>getDog, + (v)=>getDog = v + ], + "setDog": [ + ()=>setDog, + (v)=>setDog = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +function getDog() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +function setDog(newDog) { + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"] = newDog; +} +const dogRef = { + initial: __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"], + get: getDog, + set: setDog +}; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "getChimera": [ + ()=>getChimera, + (v)=>getChimera = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +function getChimera() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "initialCat": [ + ()=>initialCat, + (v)=>initialCat = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +const initialCat = __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"]; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$facade$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; +; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$facade$3e$__.cat); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js.map new file mode 100644 index 0000000000000..aec639f49d3aa --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_66459d._.js.map @@ -0,0 +1,33 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,uOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,uOAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,uOAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 51, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 59, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 64, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 72, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 77, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,OAAO"}}, + {"offset": {"line": 89, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 94, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,OAAO"}}, + {"offset": {"line": 106, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 111, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS;IACP,OAAO,uOAAA,CAAA,MAAG;AACZ;AAMA,SAAS,OAAO,MAAM;IACpB,uOAAA,CAAA,MAAG,GAAG;AACR;AAMO,MAAM,SAAS;IACpB,SAAS,uOAAA,CAAA,MAAG;IACZ,KAAK;IACL,KAAK;AACP"}}, + {"offset": {"line": 144, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 149, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgCO,SAAS;IACd,OAAO,uOAAA,CAAA,MAAG,GAAG,uOAAA,CAAA,MAAG;AAClB"}}, + {"offset": {"line": 166, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 171, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA8BO,MAAM,aAAa,uOAAA,CAAA,MAAG"}}, + {"offset": {"line": 184, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 189, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 205, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 210, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 221, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 226, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js"],"sourcesContent":["import * as lib from './lib'\n\nconsole.log(lib.cat)\n"],"names":[],"mappings":";;;;;;;AAEA,QAAQ,GAAG,CAAC,6NAAI,GAAG"}}, + {"offset": {"line": 234, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 239, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 244, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js new file mode 100644 index 0000000000000..cf872380adb2e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js @@ -0,0 +1 @@ +import './lib' diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js new file mode 100644 index 0000000000000..b7cc51a4304d0 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js @@ -0,0 +1,70 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js [test] (ecmascript) ": (function({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname, m: module, e: exports, t: require }) { !function() { + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +"module evaluation"; +; + +}.call(this) }), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$side$2d$effect$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js.map new file mode 100644 index 0000000000000..b05a105248c7c --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/output/79fb1_turbopack-tests_tests_snapshot_basic-tree-shake_import-side-effect_input_86a812._.js.map @@ -0,0 +1,15 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,4OAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,4OAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,4OAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 50, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 55, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 60, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 65, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js new file mode 100644 index 0000000000000..f484400d495cf --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js @@ -0,0 +1 @@ +const {cat} = require('./lib') diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js new file mode 100644 index 0000000000000..2b4cb2ac03e61 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js @@ -0,0 +1,231 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dogRef": [ + ()=>dogRef, + (v)=>dogRef = v + ], + "getDog": [ + ()=>getDog, + (v)=>getDog = v + ], + "setDog": [ + ()=>setDog, + (v)=>setDog = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +function getDog() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +function setDog(newDog) { + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"] = newDog; +} +const dogRef = { + initial: __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"], + get: getDog, + set: setDog +}; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "getChimera": [ + ()=>getChimera, + (v)=>getChimera = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +function getChimera() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "initialCat": [ + ()=>initialCat, + (v)=>initialCat = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +const initialCat = __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"]; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$require$2d$side$2d$effect$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js [test] (ecmascript)": (function({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname, m: module, e: exports, t: require }) { !function() { + +const { cat } = __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) "); + +}.call(this) }), +}]); + +//# sourceMappingURL=a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js.map new file mode 100644 index 0000000000000..493da0561f66b --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/output/a587c_tests_snapshot_basic-tree-shake_require-side-effect_input_cc94f5._.js.map @@ -0,0 +1,31 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,6OAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,6OAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,6OAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 51, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 59, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 64, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 72, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 77, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,OAAO"}}, + {"offset": {"line": 89, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 94, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,OAAO"}}, + {"offset": {"line": 106, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 111, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS;IACP,OAAO,6OAAA,CAAA,MAAG;AACZ;AAMA,SAAS,OAAO,MAAM;IACpB,6OAAA,CAAA,MAAG,GAAG;AACR;AAMO,MAAM,SAAS;IACpB,SAAS,6OAAA,CAAA,MAAG;IACZ,KAAK;IACL,KAAK;AACP"}}, + {"offset": {"line": 144, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 149, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgCO,SAAS;IACd,OAAO,6OAAA,CAAA,MAAG,GAAG,6OAAA,CAAA,MAAG;AAClB"}}, + {"offset": {"line": 166, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 171, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA8BO,MAAM,aAAa,6OAAA,CAAA,MAAG"}}, + {"offset": {"line": 184, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 189, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 205, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 210, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 221, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 225, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js"],"sourcesContent":["const {cat} = require('./lib')\n"],"names":[],"mappings":"AAAA,MAAM,EAAC,GAAG,EAAC"}}, + {"offset": {"line": 226, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js new file mode 100644 index 0000000000000..868a25222a78e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js @@ -0,0 +1,35 @@ +let dog = "dog"; + +dog += "!"; + +console.log(dog); + +function getDog() { + return dog; +} + +dog += "!"; + +console.log(dog); + +function setDog(newDog) { + dog = newDog; +} + +dog += "!"; + +console.log(dog); + +export const dogRef = { + initial: dog, + get: getDog, + set: setDog, +}; + +export let cat = "cat"; + +export const initialCat = cat; + +export function getChimera() { + return cat + dog; +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/options.json b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/options.json new file mode 100644 index 0000000000000..000d78a6b3cbb --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/options.json @@ -0,0 +1,3 @@ +{ + "treeShakingMode": "module-fragments" +} diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js new file mode 100644 index 0000000000000..a39a105a255a6 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js @@ -0,0 +1,226 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>dog, + (v)=>dog = v + ] +}); +let dog = "dog"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__5$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +"module evaluation"; +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); +console.log(__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"]); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": [ + ()=>cat, + (v)=>cat = v + ] +}); +let cat = "cat"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__6$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dog": [ + ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__["dog"], + (v)=>$expr = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__7$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +dog += "!"; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "dogRef": [ + ()=>dogRef, + (v)=>dogRef = v + ], + "getDog": [ + ()=>getDog, + (v)=>getDog = v + ], + "setDog": [ + ()=>setDog, + (v)=>setDog = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +function getDog() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +function setDog(newDog) { + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"] = newDog; +} +const dogRef = { + initial: __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"], + get: getDog, + set: setDog +}; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "getChimera": [ + ()=>getChimera, + (v)=>getChimera = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +function getChimera() { + return __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"] + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__8$3e$__["dog"]; +} +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "initialCat": [ + ()=>initialCat, + (v)=>initialCat = v + ] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +const initialCat = __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$internal__part__9$3e$__["cat"]; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__cat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__dogRef$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__getChimera$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$export__initialCat$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; +; +; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) ": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => { +"use strict"; + +__turbopack_esm__({ + "cat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["cat"], + "dogRef": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["dogRef"], + "getChimera": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["getChimera"], + "initialCat": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__["initialCat"] +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$module__evaluation$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$tree$2d$shake$2d$test$2d$1$2f$input$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$exports$3e$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) "); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +; + +})()), +}]); + +//# sourceMappingURL=a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js.map b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js.map new file mode 100644 index 0000000000000..9031eb5d15ae0 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/output/a587c_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_64a65d.js.map @@ -0,0 +1,29 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 5, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AAAA,IAAI,MAAM"}}, + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 18, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO"}}, + {"offset": {"line": 30, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,QAAQ,GAAG,CAAC,gPAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,gPAAA,CAAA,MAAG;AAQf,QAAQ,GAAG,CAAC,gPAAA,CAAA,MAAG"}}, + {"offset": {"line": 46, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 51, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;AA4BO,IAAI,MAAM"}}, + {"offset": {"line": 59, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 64, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 72, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 77, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,OAAO"}}, + {"offset": {"line": 89, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 94, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,OAAO"}}, + {"offset": {"line": 106, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 111, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS;IACP,OAAO,gPAAA,CAAA,MAAG;AACZ;AAMA,SAAS,OAAO,MAAM;IACpB,gPAAA,CAAA,MAAG,GAAG;AACR;AAMO,MAAM,SAAS;IACpB,SAAS,gPAAA,CAAA,MAAG;IACZ,KAAK;IACL,KAAK;AACP"}}, + {"offset": {"line": 144, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 149, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgCO,SAAS;IACd,OAAO,gPAAA,CAAA,MAAG,GAAG,gPAAA,CAAA,MAAG;AAClB"}}, + {"offset": {"line": 166, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 171, "column": 0}, "map": {"version":3,"sources":["turbopack://[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js"],"sourcesContent":["let dog = \"dog\";\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction getDog() {\n return dog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nfunction setDog(newDog) {\n dog = newDog;\n}\n\ndog += \"!\";\n\nconsole.log(dog);\n\nexport const dogRef = {\n initial: dog,\n get: getDog,\n set: setDog,\n};\n\nexport let cat = \"cat\";\n\nexport const initialCat = cat;\n\nexport function getChimera() {\n return cat + dog;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA8BO,MAAM,aAAa,gPAAA,CAAA,MAAG"}}, + {"offset": {"line": 184, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 189, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 205, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 210, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":""}}, + {"offset": {"line": 221, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js new file mode 100644 index 0000000000000..f5c9fc12f7cc9 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js @@ -0,0 +1,6 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js", + {}, + {"otherChunks":["output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js"],"runtimeModuleIds":["[project]/crates/turbopack-tests/tests/snapshot/mdx/error/input/index.js [test] (ecmascript)"]} +]); +// Dummy runtime \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js.map b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js.map new file mode 100644 index 0000000000000..c15d7ec00382d --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_743c8b.js.map @@ -0,0 +1,5 @@ +{ + "version": 3, + "sources": [], + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js new file mode 100644 index 0000000000000..54b9be29e22f1 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js @@ -0,0 +1,9 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/mdx/error/input/index.js [test] (ecmascript)": (function({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname, m: module, e: exports, t: require }) { !function() { + +const e = new Error("Could not parse module '[project]/crates/turbopack-tests/tests/snapshot/mdx/error/input/index.js'"); +e.code = 'MODULE_UNPARSEABLE'; +throw e; +}.call(this) }), +}]); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js.map b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js.map new file mode 100644 index 0000000000000..c15d7ec00382d --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/mdx/error/output/crates_turbopack-tests_tests_snapshot_mdx_error_input_index_a3c4fd.js.map @@ -0,0 +1,5 @@ +{ + "version": 3, + "sources": [], + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index 5390f338ed6f4..1bf2ef160b21b 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -23,11 +23,21 @@ function defineProp(obj, name1, options) { value: "Module" }); for(const key in getters){ - defineProp(exports, key, { - get: getters[key], - enumerable: true - }); + const item = getters[key]; + if (Array.isArray(item)) { + defineProp(exports, key, { + get: item[0], + set: item[1], + enumerable: true + }); + } else { + defineProp(exports, key, { + get: item, + enumerable: true + }); + } } + Object.seal(exports); } /** * Makes the module an ESM with exports diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index d90f62c71f49a..22e06488b38f7 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -2,9 +2,9 @@ "version": 3, "sources": [], "sections": [ - {"offset": {"line": 3, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Function | Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype ModuleContextMap = Record;\n\ninterface ModuleContextEntry {\n id: () => ModuleId;\n module: () => any;\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n // async import call\n import(moduleId: ModuleId): Promise;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\nfunction ensureDynamicExports(module: Module, exports: Exports) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n ensureDynamicExports(module, exports);\n\n if (typeof object === \"object\" && object !== null) {\n module[REEXPORTED_OBJECTS]!.push(object);\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction createNS(raw: BaseModule[\"exports\"]): EsmNamespaceObject {\n if (typeof raw === \"function\") {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args);\n };\n } else {\n return Object.create(null);\n }\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n createNS(raw),\n raw && (raw as any).__esModule\n ));\n}\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n typeof require === \"function\"\n ? require\n : function require() {\n throw new Error(\"Unexpected use of runtime require\");\n };\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: ModuleId): Exports {\n if (hasOwnProperty.call(map, id)) {\n return map[id].module();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n }\n\n moduleContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n moduleContext.resolve = (id: ModuleId): ModuleId => {\n if (hasOwnProperty.call(map, id)) {\n return map[id].id();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n };\n\n moduleContext.import = async (id: ModuleId) => {\n return await (moduleContext(id) as Promise);\n };\n\n return moduleContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n\n ensureDynamicExports(module, module.exports);\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, \"x:/\");\n const values: Record = {};\n for (const key in realUrl) values[key] = (realUrl as any)[key];\n values.href = inputUrl;\n values.pathname = inputUrl.replace(/[?#].*/, \"\");\n values.origin = values.protocol = \"\";\n values.toString = values.toJSON = (..._args: Array) => inputUrl;\n for (const key in values)\n Object.defineProperty(this, key, {\n enumerable: true,\n configurable: true,\n value: values[key],\n });\n};\n\nrelativeURL.prototype = URL.prototype;\n"],"names":[],"mappings":"AAAA;;;;;CAKC,GAED,uDAAuD,GAEvD,6CAA6C;AAU7C,MAAM,qBAAqB,OAAO;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,KAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,QAC5B,OAAO,cAAc,CAAC,KAAK,OAAM;AACrC;AAEA;;CAEC,GACD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AAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF;AAEA;;;;;;;;;CASC,GACD,MAAM,cAAc,SAAS,YAAuB,QAAgB;IAClE,MAAM,UAAU,IAAI,IAAI,UAAU;IAClC,MAAM,SAA8B,CAAC;IACrC,IAAK,MAAM,OAAO,QAAS,MAAM,CAAC,IAAI,GAAG,AAAC,OAAe,CAAC,IAAI;IAC9D,OAAO,IAAI,GAAG;IACd,OAAO,QAAQ,GAAG,SAAS,OAAO,CAAC,UAAU;IAC7C,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG;IAClC,OAAO,QAAQ,GAAG,OAAO,MAAM,GAAG,CAAC,GAAG,QAAsB;IAC5D,IAAK,MAAM,OAAO,OAChB,OAAO,cAAc,CAAC,IAAI,EAAE,KAAK;QAC/B,YAAY;QACZ,cAAc;QACd,OAAO,MAAM,CAAC,IAAI;IACpB;AACJ;AAEA,YAAY,SAAS,GAAG,IAAI,SAAS"}}, - {"offset": {"line": 307, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/// \n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: ModuleId) {\n let raw;\n try {\n raw = await import(id);\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`);\n }\n\n if (raw && raw.__esModule && raw.default && \"default\" in raw.default) {\n return interopEsm(raw.default, createNS(raw), true);\n }\n\n return raw;\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(id);\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`);\n }\n\n if (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, createNS(raw), true);\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[];\n }\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAe,eAAe,EAAY;IACxC,IAAI;IACJ,IAAI;QACF,MAAM,MAAM,MAAM,CAAC;IACrB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,OAAO,IAAI,UAAU,IAAI,IAAI,OAAO,IAAI,aAAa,IAAI,OAAO,EAAE;QACpE,OAAO,WAAW,IAAI,OAAO,EAAE,SAAS,MAAM;IAChD;IAEA,OAAO;AACT;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,SAAS,MAAM;AACxC;AAEA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAIA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, - {"offset": {"line": 346, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["declare var RUNTIME_PUBLIC_PATH: string;\ndeclare var OUTPUT_ROOT: string;\ndeclare var ASSET_PREFIX: string;\n\nconst path = require(\"path\");\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.relative(\n path.join(OUTPUT_ROOT, RUNTIME_PUBLIC_PATH),\n \".\"\n);\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath);\n }\n return ABSOLUTE_ROOT;\n}\n"],"names":[],"mappings":"AAIA,MAAM,OAAO,QAAQ;AAErB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAM,yBAAyB,KAAK,QAAQ,CAC1C,KAAK,IAAI,CAAC,aAAa,sBACvB;AAEF,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAC9C,mGAAmG;AACnG,MAAM,gBAAgB,KAAK,OAAO,CAAC,YAAY;AAE/C;;;;;;;CAOC,GACD,SAAS,oBAAoB,UAAmB;IAC9C,IAAI,YAAY;QACd,OAAO,KAAK,IAAI,CAAC,eAAe;IAClC;IACA,OAAO;AACT"}}, - {"offset": {"line": 366, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared-node/node-wasm-utils.ts"],"sourcesContent":["/// \n\nfunction readWebAssemblyAsResponse(path: string) {\n const { createReadStream } = require(\"fs\") as typeof import(\"fs\");\n const { Readable } = require(\"stream\") as typeof import(\"stream\");\n\n const stream = createReadStream(path);\n\n // @ts-ignore unfortunately there's a slight type mismatch with the stream.\n return new Response(Readable.toWeb(stream), {\n headers: {\n \"content-type\": \"application/wasm\",\n },\n });\n}\n\nasync function compileWebAssemblyFromPath(\n path: string\n): Promise {\n const response = readWebAssemblyAsResponse(path);\n\n return await WebAssembly.compileStreaming(response);\n}\n\nasync function instantiateWebAssemblyFromPath(\n path: string,\n importsObj: WebAssembly.Imports\n): Promise {\n const response = readWebAssemblyAsResponse(path);\n\n const { instance } = await WebAssembly.instantiateStreaming(\n response,\n importsObj\n );\n\n return instance.exports;\n}\n"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,SAAS,0BAA0B,IAAY;IAC7C,MAAM,EAAE,gBAAgB,EAAE,GAAG,QAAQ;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ;IAE7B,MAAM,SAAS,iBAAiB;IAEhC,2EAA2E;IAC3E,OAAO,IAAI,SAAS,SAAS,KAAK,CAAC,SAAS;QAC1C,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,eAAe,2BACb,IAAY;IAEZ,MAAM,WAAW,0BAA0B;IAE3C,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C;AAEA,eAAe,+BACb,IAAY,EACZ,UAA+B;IAE/B,MAAM,WAAW,0BAA0B;IAE3C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,oBAAoB,CACzD,UACA;IAGF,OAAO,SAAS,OAAO;AACzB"}}, - {"offset": {"line": 387, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n };\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`;\n case SourceType.Parent:\n return `parent module ${source.parentId}`;\n }\n}\n\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\ntype ResolveAbsolutePath = (modulePath?: string) => string;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n P: ResolveAbsolutePath;\n R: ResolvePathFromModule;\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst url = require(\"url\");\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId);\n const exportedPath = exported?.default ?? exported;\n if (typeof exportedPath !== \"string\") {\n return exported as any;\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length);\n const resolved = path.resolve(\n ABSOLUTE_ROOT,\n OUTPUT_ROOT,\n strippedAssetPrefix\n );\n\n return url.pathToFileURL(resolved);\n };\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(chunkData, source);\n } else {\n return loadChunkPath(chunkData.path, source);\n }\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!chunkPath.endsWith(\".js\")) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return;\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath);\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`;\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`;\n }\n\n throw new Error(errorMessage, {\n cause: e,\n });\n }\n}\n\nasync function loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkData, source);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\n}\n\nfunction loadWebAssembly(chunkPath: ChunkPath, imports: WebAssembly.Imports) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath);\n\n return instantiateWebAssemblyFromPath(resolved, imports);\n}\n\nfunction loadWebAssemblyModule(chunkPath: ChunkPath) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath);\n\n return compileWebAssemblyFromPath(resolved);\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id];\n if (typeof moduleFactory !== \"function\") {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n };\n moduleCache[id] = module;\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module);\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n g: globalThis,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject);\n }\n\n return module;\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId];\n if (module) {\n if (module.error) {\n throw module.error;\n }\n return module;\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath);\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,+DAA+D;AAC/D,+DAA+D;AAC/D,0DAA0D;;UAErD;IACH;;;GAGC;IAED;;GAEC;GARE,eAAA;AAsBL,SAAS,oBAAoB,MAAkB;IAC7C,OAAQ,OAAO,IAAI;QACjB;YACE,OAAO,CAAC,kBAAkB,EAAE,OAAO,SAAS,CAAC,CAAC;QAChD;YACE,OAAO,CAAC,cAAc,EAAE,OAAO,QAAQ,CAAC,CAAC;IAC7C;AACF;AAkBA,MAAM,MAAM,QAAQ;AAEpB,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAE/C;;CAEC,GACD,SAAS,4BACP,QAAuC;IAEvC,OAAO,SAAS,sBAAsB,QAAgB;QACpD,MAAM,WAAW,SAAS;QAC1B,MAAM,eAAe,UAAU,WAAW;QAC1C,IAAI,OAAO,iBAAiB,UAAU;YACpC,OAAO;QACT;QAEA,MAAM,sBAAsB,aAAa,KAAK,CAAC,aAAa,MAAM;QAClE,MAAM,WAAW,KAAK,OAAO,CAC3B,eACA,aACA;QAGF,OAAO,IAAI,aAAa,CAAC;IAC3B;AACF;AAEA,SAAS,UAAU,SAAoB,EAAE,MAAmB;IAC1D,IAAI,OAAO,cAAc,UAAU;QACjC,OAAO,cAAc,WAAW;IAClC,OAAO;QACL,OAAO,cAAc,UAAU,IAAI,EAAE;IACvC;AACF;AAEA,SAAS,cAAc,SAAoB,EAAE,MAAmB;IAC9D,IAAI,CAAC,UAAU,QAAQ,CAAC,QAAQ;Q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QAAO,eAAe;IACnD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAAS,iCACP,EAAY,EACZ,YAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,GAAG;IAE9B,IAAI,aAAa,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG;QAC5C,aAAa,QAAQ,CAAC,IAAI,CAAC;IAC7B;IAEA,IAAI,SAAQ;QACV,IAAI,QAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,IAAI;QACJ,UAAU,aAAa,EAAE;IAC3B;AACF;AAEA;;CAEC,GACD,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,IAAI;QAAsB;IAAU;AAC3E;AAEA;;CAEC,GACD,SAAS,8BACP,QAAkB,EAClB,SAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,SAAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] + {"offset": {"line": 3, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Function | Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype ModuleContextMap = Record;\n\ninterface ModuleContextEntry {\n id: () => ModuleId;\n module: () => any;\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n // async import call\n import(moduleId: ModuleId): Promise;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(\n exports: Exports,\n getters: Record any) | [() => any, (v: any) => void]>\n) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n const item = getters[key];\n if (Array.isArray(item)) {\n defineProp(exports, key, {\n get: item[0],\n set: item[1],\n enumerable: true,\n });\n } else {\n defineProp(exports, key, { get: item, enumerable: true });\n }\n }\n Object.seal(exports);\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\nfunction ensureDynamicExports(module: Module, exports: Exports) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n ensureDynamicExports(module, exports);\n\n if (typeof object === \"object\" && object !== null) {\n module[REEXPORTED_OBJECTS]!.push(object);\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction createNS(raw: BaseModule[\"exports\"]): EsmNamespaceObject {\n if (typeof raw === \"function\") {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args);\n };\n } else {\n return Object.create(null);\n }\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n createNS(raw),\n raw && (raw as any).__esModule\n ));\n}\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n typeof require === \"function\"\n ? require\n : function require() {\n throw new Error(\"Unexpected use of runtime require\");\n };\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: ModuleId): Exports {\n if (hasOwnProperty.call(map, id)) {\n return map[id].module();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n }\n\n moduleContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n moduleContext.resolve = (id: ModuleId): ModuleId => {\n if (hasOwnProperty.call(map, id)) {\n return map[id].id();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n };\n\n moduleContext.import = async (id: ModuleId) => {\n return await (moduleContext(id) as Promise);\n };\n\n return moduleContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n\n ensureDynamicExports(module, module.exports);\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, \"x:/\");\n const values: Record = {};\n for (const key in realUrl) values[key] = (realUrl as any)[key];\n values.href = inputUrl;\n values.pathname = inputUrl.replace(/[?#].*/, \"\");\n values.origin = values.protocol = \"\";\n values.toString = values.toJSON = (..._args: Array) => inputUrl;\n for (const key in values)\n Object.defineProperty(this, key, {\n enumerable: true,\n configurable: true,\n value: values[key],\n });\n};\n\nrelativeURL.prototype = URL.prototype;\n"],"names":[],"mappings":"AAAA;;;;;CAKC,GAED,uDAAuD,GAEvD,6CAA6C;AAU7C,MAAM,qBAAqB,OAAO;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,KAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,QAC5B,OAAO,cAAc,CAAC,KAAK,OAAM;AACrC;AAEA;;CAEC,GACD,SAAS,IACP,OAAgB,EAChB,OAAoE;IAEpE,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,MAAM,OAAO,OAAO,CAAC,IAAI;QACzB,IAAI,MAAM,OAAO,CAAC,OAAO;YACvB,WAAW,SAAS,KAAK;gBACvB,KAAK,IAAI,CAAC,EAAE;gBACZ,KAAK,IAAI,CAAC,EAAE;gBACZ,YAAY;YACd;QACF,OAAO;YACL,WAAW,SAAS,KAAK;gBAAE,KAAK;gBAAM,YAAY;YAAK;QAC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Q,GAAG;IACnB;AACF;AAEA;;;;;;;;;CASC,GACD,MAAM,cAAc,SAAS,YAAuB,QAAgB;IAClE,MAAM,UAAU,IAAI,IAAI,UAAU;IAClC,MAAM,SAA8B,CAAC;IACrC,IAAK,MAAM,OAAO,QAAS,MAAM,CAAC,IAAI,GAAG,AAAC,OAAe,CAAC,IAAI;IAC9D,OAAO,IAAI,GAAG;IACd,OAAO,QAAQ,GAAG,SAAS,OAAO,CAAC,UAAU;IAC7C,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG;IAClC,OAAO,QAAQ,GAAG,OAAO,MAAM,GAAG,CAAC,GAAG,QAAsB;IAC5D,IAAK,MAAM,OAAO,OAChB,OAAO,cAAc,CAAC,IAAI,EAAE,KAAK;QAC/B,YAAY;QACZ,cAAc;QACd,OAAO,MAAM,CAAC,IAAI;IACpB;AACJ;AAEA,YAAY,SAAS,GAAG,IAAI,SAAS"}}, + {"offset": {"line": 317, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/// \n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: ModuleId) {\n let raw;\n try {\n raw = await import(id);\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`);\n }\n\n if (raw && raw.__esModule && raw.default && \"default\" in raw.default) {\n return interopEsm(raw.default, createNS(raw), true);\n }\n\n return raw;\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(id);\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`);\n }\n\n if (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, createNS(raw), true);\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[];\n }\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAe,eAAe,EAAY;IACxC,IAAI;IACJ,IAAI;QACF,MAAM,MAAM,MAAM,CAAC;IACrB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,OAAO,IAAI,UAAU,IAAI,IAAI,OAAO,IAAI,aAAa,IAAI,OAAO,EAAE;QACpE,OAAO,WAAW,IAAI,OAAO,EAAE,SAAS,MAAM;IAChD;IAEA,OAAO;AACT;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,SAAS,MAAM;AACxC;AAEA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAIA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, + {"offset": {"line": 356, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["declare var RUNTIME_PUBLIC_PATH: string;\ndeclare var OUTPUT_ROOT: string;\ndeclare var ASSET_PREFIX: string;\n\nconst path = require(\"path\");\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.relative(\n path.join(OUTPUT_ROOT, RUNTIME_PUBLIC_PATH),\n \".\"\n);\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath);\n }\n return ABSOLUTE_ROOT;\n}\n"],"names":[],"mappings":"AAIA,MAAM,OAAO,QAAQ;AAErB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAM,yBAAyB,KAAK,QAAQ,CAC1C,KAAK,IAAI,CAAC,aAAa,sBACvB;AAEF,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAC9C,mGAAmG;AACnG,MAAM,gBAAgB,KAAK,OAAO,CAAC,YAAY;AAE/C;;;;;;;CAOC,GACD,SAAS,oBAAoB,UAAmB;IAC9C,IAAI,YAAY;QACd,OAAO,KAAK,IAAI,CAAC,eAAe;IAClC;IACA,OAAO;AACT"}}, + {"offset": {"line": 376, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared-node/node-wasm-utils.ts"],"sourcesContent":["/// \n\nfunction readWebAssemblyAsResponse(path: string) {\n const { createReadStream } = require(\"fs\") as typeof import(\"fs\");\n const { Readable } = require(\"stream\") as typeof import(\"stream\");\n\n const stream = createReadStream(path);\n\n // @ts-ignore unfortunately there's a slight type mismatch with the stream.\n return new Response(Readable.toWeb(stream), {\n headers: {\n \"content-type\": \"application/wasm\",\n },\n });\n}\n\nasync function compileWebAssemblyFromPath(\n path: string\n): Promise {\n const response = readWebAssemblyAsResponse(path);\n\n return await WebAssembly.compileStreaming(response);\n}\n\nasync function instantiateWebAssemblyFromPath(\n path: string,\n importsObj: WebAssembly.Imports\n): Promise {\n const response = readWebAssemblyAsResponse(path);\n\n const { instance } = await WebAssembly.instantiateStreaming(\n response,\n importsObj\n );\n\n return instance.exports;\n}\n"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,SAAS,0BAA0B,IAAY;IAC7C,MAAM,EAAE,gBAAgB,EAAE,GAAG,QAAQ;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ;IAE7B,MAAM,SAAS,iBAAiB;IAEhC,2EAA2E;IAC3E,OAAO,IAAI,SAAS,SAAS,KAAK,CAAC,SAAS;QAC1C,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,eAAe,2BACb,IAAY;IAEZ,MAAM,WAAW,0BAA0B;IAE3C,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C;AAEA,eAAe,+BACb,IAAY,EACZ,UAA+B;IAE/B,MAAM,WAAW,0BAA0B;IAE3C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,oBAAoB,CACzD,UACA;IAGF,OAAO,SAAS,OAAO;AACzB"}}, + {"offset": {"line": 397, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n };\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`;\n case SourceType.Parent:\n return `parent module ${source.parentId}`;\n }\n}\n\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\ntype ResolveAbsolutePath = (modulePath?: string) => string;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n P: ResolveAbsolutePath;\n R: ResolvePathFromModule;\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst url = require(\"url\");\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId);\n const exportedPath = exported?.default ?? exported;\n if (typeof exportedPath !== \"string\") {\n return exported as any;\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length);\n const resolved = path.resolve(\n ABSOLUTE_ROOT,\n OUTPUT_ROOT,\n strippedAssetPrefix\n );\n\n return url.pathToFileURL(resolved);\n };\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(chunkData, source);\n } else {\n return loadChunkPath(chunkData.path, source);\n }\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!chunkPath.endsWith(\".js\")) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return;\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath);\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`;\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`;\n }\n\n throw new Error(errorMessage, {\n cause: e,\n });\n }\n}\n\nasync function loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkData, source);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\n}\n\nfunction loadWebAssembly(chunkPath: ChunkPath, imports: WebAssembly.Imports) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath);\n\n return instantiateWebAssemblyFromPath(resolved, imports);\n}\n\nfunction loadWebAssemblyModule(chunkPath: ChunkPath) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath);\n\n return compileWebAssemblyFromPath(resolved);\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id];\n if (typeof moduleFactory !== \"function\") {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n };\n moduleCache[id] = module;\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module);\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n g: globalThis,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject);\n }\n\n return module;\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId];\n if (module) {\n if (module.error) {\n throw module.error;\n }\n return module;\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath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AC,IAAI,CAAC;IAC7B;IAEA,IAAI,SAAQ;QACV,IAAI,QAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,IAAI;QACJ,UAAU,aAAa,EAAE;IAC3B;AACF;AAEA;;CAEC,GACD,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,IAAI;QAAsB;IAAU;AAC3E;AAEA;;CAEC,GACD,SAAS,8BACP,QAAkB,EAClB,SAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,SAAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] } \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js index d7214a29d62ba..d16668c612a9d 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js @@ -33,11 +33,21 @@ function defineProp(obj, name1, options) { value: "Module" }); for(const key in getters){ - defineProp(exports, key, { - get: getters[key], - enumerable: true - }); + const item = getters[key]; + if (Array.isArray(item)) { + defineProp(exports, key, { + get: item[0], + set: item[1], + enumerable: true + }); + } else { + defineProp(exports, key, { + get: item, + enumerable: true + }); + } } + Object.seal(exports); } /** * Makes the module an ESM with exports diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js.map index acac954d76c5d..4ec7a0b4404c0 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_40d141.js.map @@ -2,8 +2,8 @@ "version": 3, "sources": [], "sections": [ - {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Function | Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype ModuleContextMap = Record;\n\ninterface ModuleContextEntry {\n id: () => ModuleId;\n module: () => any;\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n // async import call\n import(moduleId: ModuleId): Promise;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\nfunction ensureDynamicExports(module: Module, exports: Exports) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n ensureDynamicExports(module, exports);\n\n if (typeof object === \"object\" && object !== null) {\n module[REEXPORTED_OBJECTS]!.push(object);\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction createNS(raw: BaseModule[\"exports\"]): EsmNamespaceObject {\n if (typeof raw === \"function\") {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args);\n };\n } else {\n return Object.create(null);\n }\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n createNS(raw),\n raw && (raw as any).__esModule\n ));\n}\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n typeof require === \"function\"\n ? require\n : function require() {\n throw new Error(\"Unexpected use of runtime require\");\n };\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: ModuleId): Exports {\n if (hasOwnProperty.call(map, id)) {\n return map[id].module();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n }\n\n moduleContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n moduleContext.resolve = (id: ModuleId): ModuleId => {\n if (hasOwnProperty.call(map, id)) {\n return map[id].id();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n };\n\n moduleContext.import = async (id: ModuleId) => {\n return await (moduleContext(id) as Promise);\n };\n\n return moduleContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n\n ensureDynamicExports(module, module.exports);\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, \"x:/\");\n const values: Record = {};\n for (const key in realUrl) values[key] = (realUrl as any)[key];\n values.href = inputUrl;\n values.pathname = inputUrl.replace(/[?#].*/, \"\");\n values.origin = values.protocol = \"\";\n values.toString = values.toJSON = (..._args: Array) => inputUrl;\n for (const key in values)\n Object.defineProperty(this, key, {\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bopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n R: ResolvePathFromModule;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\n};\n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nclass UpdateApplyError extends Error {\n name = \"UpdateApplyError\";\n\n dependencyChain: string[];\n\n constructor(message: string, dependencyChain: string[]) {\n super(message);\n this.dependencyChain = dependencyChain;\n }\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\n}\n\n/**\n * Returns an absolute url to an asset.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId);\n return exported?.default ?? exported;\n };\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id];\n if (typeof moduleFactory !== \"function\") {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n const hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const sourceInfo: SourceInfo = { type: SourceType.Parent, parentId: id };\n\n runModuleExecutionHooks(module, (refresh) => {\n const r = commonJsRequire.bind(null, module);\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n t: runtimeRequire,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunk.bind(null, sourceInfo),\n w: loadWebAssembly.bind(null, sourceInfo),\n u: loadWebAssemblyModule.bind(null, sourceInfo),\n g: globalThis,\n U: relativeURL,\n k: refresh,\n R: createResolvePathFromModule(r),\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject);\n }\n\n return module;\n}\n\n/**\n * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n helpers.getRefreshBoundarySignature(prevExports),\n helpers.getRefreshBoundarySignature(currentExports)\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new UpdateApplyError(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`,\n effect.dependencyChain\n );\n case \"self-declined\":\n throw new UpdateApplyError(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`,\n effect.dependencyChain\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(update: ChunkListUpdate) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(update: EcmascriptMergedUpdate) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n\n // NOTE(jridgewell) Check returns the list of updated modules, but we don't\n // want the webpack code paths to ever update (the turbopack paths handle\n // this already).\n check: () => Promise.resolve(null),\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Gets or instantiates a runtime module.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId];\n if (module) {\n if (module.error) {\n throw module.error;\n }\n return module;\n }\n\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\")}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":"AAAA;;;;;;CAMC,GAED,uDAAuD,GAEvD,yDAAyD;AACzD,uCAAuC;AACvC,wCAAwC;AACxC,0CAA0C;AAE1C,yEAAyE;AACzE,4EAA4E;AAC5E,wDAAwD;;UAiDnD;IACH;;;GAGC;IAED;;GAEC;IAED;;;GAGC;GAbE,eAAA;AAwCL,MAAM,yBAAyB;IAC7B,OAAO,mBAAmB;IAE1B,gBAA0B;IAE1B,YAAY,OAAe,EAAE,eAAyB,CAAE;QACtD,KAAK,CAAC;QACN,IAAI,CAAC,eAAe,GAAG;IACzB;AACF;AAEA,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAC/C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;AACF"}}, - {"offset": {"line": 1331, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction fetchWebAssembly(wasmChunkPath: ChunkPath) {\n return fetch(getChunkRelativeUrl(wasmChunkPath));\n}\n\nasync function loadWebAssembly(\n _source: SourceInfo,\n wasmChunkPath: ChunkPath,\n importsObj: WebAssembly.Imports\n): Promise {\n const req = fetchWebAssembly(wasmChunkPath);\n\n const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);\n\n return instance.exports;\n}\n\nasync function loadWebAssemblyModule(\n _source: SourceInfo,\n wasmChunkPath: ChunkPath\n): Promise {\n const req = fetchWebAssembly(wasmChunkPath);\n\n return await WebAssembly.compileStreaming(req);\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n // TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.\n const decodedChunkUrl = decodeURI(chunkUrl);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(\n `link[href=\"${chunkUrl}\"],link[href^=\"${chunkUrl}?\"],link[href=\"${decodedChunkUrl}\"],link[href^=\"${decodedChunkUrl}?\"]`\n );\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(\n `script[src=\"${chunkUrl}\"],script[src^=\"${chunkUrl}?\"],script[src=\"${decodedChunkUrl}\"],script[src^=\"${decodedChunkUrl}?\"]`\n );\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n const decodedChunkUrl = decodeURI(chunkUrl);\n\n const previousLinks = document.querySelectorAll(\n `link[rel=stylesheet][href=\"${chunkUrl}\"],link[rel=stylesheet][href^=\"${chunkUrl}?\"],link[rel=stylesheet][href=\"${decodedChunkUrl}\"],link[rel=stylesheet][href^=\"${decodedChunkUrl}?\"]`\n );\n\n if (previousLinks.length == 0) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n\n if (navigator.userAgent.includes(\"Firefox\")) {\n // Firefox won't reload CSS files that were previously loaded on the current page,\n // we need to add a query param to make sure CSS is actually reloaded from the server.\n //\n // I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506\n //\n // Safari has a similar issue, but only if you have a `` tag\n // pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726\n link.href = `${chunkUrl}?ts=${Date.now()}`;\n } else {\n link.href = chunkUrl;\n }\n\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old ones. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n for (const previousLink of Array.from(previousLinks))\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLinks[0].parentElement!.insertBefore(\n link,\n previousLinks[0].nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n const decodedChunkUrl = decodeURI(chunkUrl);\n\n if (chunkPath.endsWith(\".css\")) {\n const previousLinks = document.querySelectorAll(\n `link[rel=stylesheet][href=\"${chunkUrl}\"],link[rel=stylesheet][href^=\"${chunkUrl}?\"],link[rel=stylesheet][href=\"${decodedChunkUrl}\"],link[rel=stylesheet][href^=\"${decodedChunkUrl}?\"]`\n );\n if (previousLinks.length > 0) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n } else {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n }\n } else if (chunkPath.endsWith(\".js\")) {\n const previousScripts = document.querySelectorAll(\n `script[src=\"${chunkUrl}\"],script[src^=\"${chunkUrl}?\"],script[src=\"${decodedChunkUrl}\"],script[src^=\"${decodedChunkUrl}?\"]`\n );\n if (previousScripts.length > 0) {\n // There is this edge where the script already failed loading, but we\n // can't detect that. The Promise will never resolve in this case.\n for (const script of Array.from(previousScripts)) {\n script.addEventListener(\"error\", () => {\n resolver.reject();\n });\n }\n } else {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${encodeURI(\n location.origin + CHUNK_BASE_PATH + url\n )}`;\n if (map)\n code += `\\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tC,OAAO,GAAG,GAAG;gBACb,yEAAyE;gBACzE,wEAAwE;gBACxE,eAAe;gBACf,OAAO,OAAO,GAAG;oBACf,SAAS,MAAM;gBACjB;gBACA,SAAS,IAAI,CAAC,WAAW,CAAC;YAC5B;QACF,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,UAAU,CAAC;QACpE;QAEA,OAAO,SAAS,OAAO;IACzB;AACF,CAAC;AAED,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,UAC3B,SAAS,MAAM,GAAG,kBAAkB,KACpC,CAAC;IACH,IAAI,KACF,QAAQ,CAAC,kEAAkE,EAAE,KAC3E,KACA,CAAC;IACL,OAAO,KAAK;AACd"}}, - {"offset": {"line": 1553, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] + {"offset": {"line": 13, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Function | Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype ModuleContextMap = Record;\n\ninterface ModuleContextEntry {\n id: () => ModuleId;\n module: () => any;\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n // async import call\n import(moduleId: ModuleId): Promise;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(\n exports: Exports,\n getters: Record any) | [() => any, (v: any) => void]>\n) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n const item = getters[key];\n if (Array.isArray(item)) {\n defineProp(exports, key, {\n get: item[0],\n set: item[1],\n enumerable: true,\n });\n } else {\n defineProp(exports, key, { get: item, enumerable: true });\n }\n }\n Object.seal(exports);\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\nfunction ensureDynamicExports(module: Module, exports: Exports) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n ensureDynamicExports(module, exports);\n\n if (typeof object === \"object\" && object !== null) {\n module[REEXPORTED_OBJECTS]!.push(object);\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction createNS(raw: BaseModule[\"exports\"]): EsmNamespaceObject {\n if (typeof raw === \"function\") {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args);\n };\n } else {\n return Object.create(null);\n }\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n createNS(raw),\n raw && (raw as any).__esModule\n ));\n}\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n typeof require === \"function\"\n ? require\n : function require() {\n throw new Error(\"Unexpected use of runtime require\");\n };\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: ModuleId): Exports {\n if (hasOwnProperty.call(map, id)) {\n return map[id].module();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n }\n\n moduleContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n moduleContext.resolve = (id: ModuleId): ModuleId => {\n if (hasOwnProperty.call(map, id)) {\n return map[id].id();\n }\n\n const e = new Error(`Cannot find module '${name}'`);\n (e as any).code = \"MODULE_NOT_FOUND\";\n throw e;\n };\n\n moduleContext.import = async (id: ModuleId) => {\n return await (moduleContext(id) as Promise);\n };\n\n return moduleContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n\n ensureDynamicExports(module, module.exports);\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, \"x:/\");\n const values: Record = {};\n for (const key in realUrl) values[key] = (realUrl as any)[key];\n values.href = inputUrl;\n values.pathname = inputUrl.replace(/[?#].*/, \"\");\n values.origin = values.protocol = \"\";\n values.toString = values.toJSON = (..._args: Array) => inputUrl;\n for (const key in values)\n Object.defineProperty(this, key, {\n enumerable: true,\n configurable: true,\n value: values[key],\n });\n};\n\nrelativeURL.prototype = URL.prototype;\n"],"names":[],"mappings":"AAAA;;;;;CAKC,GAED,uDAAuD,GAEvD,6CAA6C;AAU7C,MAAM,qBAAqB,OAAO;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,KAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,QAC5B,OAAO,cAAc,CAAC,KAAK,OAAM;AACrC;AAEA;;CAEC,GACD,SAAS,IACP,OAAgB,EAChB,OAAoE;IAEpE,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,MAAM,OAAO,OAAO,CAAC,IAAI;QACzB,IAAI,MAAM,OAAO,CAAC,OAAO;YACvB,WAAW,SAAS,KAAK;gBACvB,KAAK,IAAI,CAAC,EAAE;gBACZ,KAAK,IAAI,CAAC,EAAE;gBACZ,YAAY;YACd;QACF,OAAO;YACL,WAAW,SAAS,KAAK;gBAAE,KAAK;gBAAM,YAAY;YAAK;QACzD;IACF;IACA,OAAO,IAAI,CAAC;AACd;AAEA;;CAEC,GACD,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC,OAAO,eAAe,GAAG,OAAO,OAAO;IACvC,IAAI,SAAS;AACf;AAEA,SAAS,qBAAqB,MAAc,EAAE,OAAgB;IAC5D,IAAI,oBAAoB,MAAM,CAAC,mBAAmB;IAElD,IAAI,CAAC,mBAAmB;QACtB,oBAAoB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O,CAAC,UAAU;IAC7C,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG;IAClC,OAAO,QAAQ,GAAG,OAAO,MAAM,GAAG,CAAC,GAAG,QAAsB;IAC5D,IAAK,MAAM,OAAO,OAChB,OAAO,cAAc,CAAC,IAAI,EAAE,KAAK;QAC/B,YAAY;QACZ,cAAc;QACd,OAAO,MAAM,CAAC,IAAI;IACpB;AACJ;AAEA,YAAY,SAAS,GAAG,IAAI,SAAS"}}, + {"offset": {"line": 327, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n R: ResolvePathFromModule;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\n};\n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nclass UpdateApplyError extends Error {\n name = \"UpdateApplyError\";\n\n dependencyChain: string[];\n\n constructor(message: string, dependencyChain: string[]) {\n super(message);\n this.dependencyChain = dependencyChain;\n }\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\n}\n\n/**\n * Returns an absolute url to an asset.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId);\n return exported?.default ?? exported;\n };\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id];\n if (typeof moduleFactory !== \"function\") {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n const hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const sourceInfo: SourceInfo = { type: SourceType.Parent, parentId: id };\n\n runModuleExecutionHooks(module, (refresh) => {\n const r = commonJsRequire.bind(null, module);\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n t: runtimeRequire,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunk.bind(null, sourceInfo),\n w: loadWebAssembly.bind(null, sourceInfo),\n u: loadWebAssemblyModule.bind(null, sourceInfo),\n g: globalThis,\n U: relativeURL,\n k: refresh,\n R: createResolvePathFromModule(r),\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject);\n }\n\n return module;\n}\n\n/**\n * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n helpers.getRefreshBoundarySignature(prevExports),\n helpers.getRefreshBoundarySignature(currentExports)\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new UpdateApplyError(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`,\n effect.dependencyChain\n );\n case \"self-declined\":\n throw new UpdateApplyError(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`,\n effect.dependencyChain\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(update: ChunkListUpdate) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(update: EcmascriptMergedUpdate) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n\n // NOTE(jridgewell) Check returns the list of updated modules, but we don't\n // want the webpack code paths to ever update (the turbopack paths handle\n // this already).\n check: () => Promise.resolve(null),\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Gets or instantiates a runtime module.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId];\n if (module) {\n if (module.error) {\n throw module.error;\n }\n return module;\n }\n\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\")}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":"AAAA;;;;;;CAMC,GAED,uDAAuD,GAEvD,yDAAyD;AACzD,uCAAuC;AACvC,wCAAwC;AACxC,0CAA0C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9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, + {"offset": {"line": 1341, "column": 0}, "map": {"version":3,"sources":["turbopack://[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction fetchWebAssembly(wasmChunkPath: ChunkPath) {\n return fetch(getChunkRelativeUrl(wasmChunkPath));\n}\n\nasync function loadWebAssembly(\n _source: SourceInfo,\n wasmChunkPath: ChunkPath,\n importsObj: WebAssembly.Imports\n): Promise {\n const req = fetchWebAssembly(wasmChunkPath);\n\n const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);\n\n return instance.exports;\n}\n\nasync function loadWebAssemblyModule(\n _source: SourceInfo,\n wasmChunkPath: ChunkPath\n): Promise {\n const req = fetchWebAssembly(wasmChunkPath);\n\n return await WebAssembly.compileStreaming(req);\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n // TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.\n const decodedChunkUrl = decodeURI(chunkUrl);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(\n `link[href=\"${chunkUrl}\"],link[href^=\"${chunkUrl}?\"],link[href=\"${decodedChunkUrl}\"],link[href^=\"${decodedChunkUrl}?\"]`\n );\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(\n `script[src=\"${chunkUrl}\"],script[src^=\"${chunkUrl}?\"],script[src=\"${decodedChunkUrl}\"],script[src^=\"${decodedChunkUrl}?\"]`\n );\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n const decodedChunkUrl = decodeURI(chunkUrl);\n\n const previousLinks = document.querySelectorAll(\n `link[rel=stylesheet][href=\"${chunkUrl}\"],link[rel=stylesheet][href^=\"${chunkUrl}?\"],link[rel=stylesheet][href=\"${decodedChunkUrl}\"],link[rel=stylesheet][href^=\"${decodedChunkUrl}?\"]`\n );\n\n if (previousLinks.length == 0) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n\n if (navigator.userAgent.includes(\"Firefox\")) {\n // Firefox won't reload CSS files that were previously loaded on the current page,\n // we need to add a query param to make sure CSS is actually reloaded from the server.\n //\n // I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506\n //\n // Safari has a similar issue, but only if you have a `` tag\n // pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726\n link.href = `${chunkUrl}?ts=${Date.now()}`;\n } else {\n link.href = chunkUrl;\n }\n\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old ones. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n for (const previousLink of Array.from(previousLinks))\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLinks[0].parentElement!.insertBefore(\n link,\n previousLinks[0].nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n const decodedChunkUrl = decodeURI(chunkUrl);\n\n if (chunkPath.endsWith(\".css\")) {\n const previousLinks = document.querySelectorAll(\n `link[rel=stylesheet][href=\"${chunkUrl}\"],link[rel=stylesheet][href^=\"${chunkUrl}?\"],link[rel=stylesheet][href=\"${decodedChunkUrl}\"],link[rel=stylesheet][href^=\"${decodedChunkUrl}?\"]`\n );\n if (previousLinks.length > 0) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n } else {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n }\n } else if (chunkPath.endsWith(\".js\")) {\n const previousScripts = document.querySelectorAll(\n `script[src=\"${chunkUrl}\"],script[src^=\"${chunkUrl}?\"],script[src=\"${decodedChunkUrl}\"],script[src^=\"${decodedChunkUrl}?\"]`\n );\n if (previousScripts.length > 0) {\n // There is this edge where the script already failed loading, but we\n // can't detect that. The Promise will never resolve in this case.\n for (const script of Array.from(previousScripts)) {\n script.addEventListener(\"error\", () => {\n resolver.reject();\n });\n }\n } else {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${encodeURI(\n location.origin + CHUNK_BASE_PATH + url\n )}`;\n if (map)\n code += `\\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(\n map\n )}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAAA;;;;;CAKC,GAED,gDAAgD;AAChD,0DAA0D;AAS1D,IAAI;AAEJ,SAAS,eAAe,OAAgC;IACtD,OAAO;AACT;AAEA,SAAS,iBAAiB,aAAwB;IAChD,OAAO,MAAM,oBAAoB;AACnC;AAEA,eAAe,gBACb,OAAmB,EACnB,aAAwB,EACxB,UAA+B;IAE/B,MAAM,MAAM,iBAAiB;IAE7B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,oBAAoB,CAAC,KAAK;IAEjE,OAAO,SAAS,OAAO;AACzB;AAEA,eAAe,sBACb,OAAmB,EACnB,aAAwB;IAExB,MAAM,MAAM,iBAAiB;IAE7B,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C;AAEA,CAAC;IACC,UAAU;QACR,MAAM,eAAc,SAAS,EAAE,MAAM;YACnC,MAAM,WAAW,oBAAoB;YACrC,SAAS,OAAO;YAEhB,IAAI,UAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,kBAAkB,OAAO,WAAW,CAAE;gBAC/C,MAAM,iBAAiB,aAAa;gBACpC,iFAAiF;gBACjF,oBAAoB;YACtB;YAEA,kFAAkF;YAClF,MAAM,QAAQ,GAAG,CACf,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,iBACtB,UAAU;oBAAE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CAAC,YAAY,EAAE,SAAS,gBAAgB,EAAE,SAAS,gBAAgB,EAAE,gBAAgB,gBAAgB,EAAE,gBAAgB,GAAG,CAAC;YAE7H,IAAI,gBAAgB,MAAM,GAAG,GAAG;gBAC9B,qEAAqE;gBACrE,kEAAkE;gBAClE,KAAK,MAAM,UAAU,MAAM,IAAI,CAAC,iBAAkB;oBAChD,OAAO,gBAAgB,CAAC,SAAS;wBAC/B,SAAS,MAAM;oBACjB;gBACF;YACF,OAAO;gBACL,MAAM,SAAS,SAAS,aAAa,CAAC;gBACtC,OAAO,GAAG,GAAG;gBACb,yEAAyE;gBACzE,wEAAwE;gBACxE,eAAe;gBACf,OAAO,OAAO,GAAG;oBACf,SAAS,MAAM;gBACjB;gBACA,SAAS,IAAI,CAAC,WAAW,CAAC;YAC5B;QACF,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,UAAU,CAAC;QACpE;QAEA,OAAO,SAAS,OAAO;IACzB;AACF,CAAC;AAED,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,UAC3B,SAAS,MAAM,GAAG,kBAAkB,KACpC,CAAC;IACH,IAAI,KACF,QAAQ,CAAC,kEAAkE,EAAE,KAC3E,KACA,CAAC;IACL,OAAO,KAAK;AACd"}}, + {"offset": {"line": 1563, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] } \ No newline at end of file diff --git a/crates/turbopack/src/lib.rs b/crates/turbopack/src/lib.rs index 480213a10bf53..1cea6fdd3ce1c 100644 --- a/crates/turbopack/src/lib.rs +++ b/crates/turbopack/src/lib.rs @@ -165,14 +165,30 @@ async fn apply_module_type( } else { let options = options.await?; match options.tree_shaking_mode { - Some(TreeShakingMode::ModuleFragments) => Vc::upcast( - if let Some(part) = part { - builder.build_part(part) - } else { - builder.build_part(ModulePart::exports()) - } - .await?, - ), + Some(TreeShakingMode::ModuleFragments) => { + let side_effect_free_packages = + module_asset_context.side_effect_free_packages(); + + let module = builder.clone().build(); + + Vc::upcast( + if let Some(part) = part { + if let ModulePart::Evaluation = *part.await? { + if *module + .is_marked_as_side_effect_free(side_effect_free_packages) + .await? + { + return Ok(ProcessResult::Ignore.cell()); + } + } + + builder.build_part(part) + } else { + builder.build_part(ModulePart::facade()) + } + .await?, + ) + } Some(TreeShakingMode::ReexportsOnly) => { let side_effect_free_packages = module_asset_context.side_effect_free_packages(); @@ -408,23 +424,6 @@ impl ModuleAssetContext { ) -> Vc { process_default(self, source, reference_type, Vec::new()) } - - #[turbo_tasks::function] - pub async fn side_effect_free_packages(self: Vc) -> Result> { - let pkgs = &*self - .await? - .module_options_context - .await? - .side_effect_free_packages; - - let mut globs = Vec::with_capacity(pkgs.len()); - - for pkg in pkgs { - globs.push(Glob::new(format!("**/node_modules/{{{}}}/**", pkg))); - } - - Ok(Glob::alternatives(globs)) - } } #[turbo_tasks::function] @@ -740,6 +739,23 @@ impl AssetContext for ModuleAssetContext { }, ) } + + #[turbo_tasks::function] + async fn side_effect_free_packages(self: Vc) -> Result> { + let pkgs = &*self + .await? + .module_options_context + .await? + .side_effect_free_packages; + + let mut globs = Vec::with_capacity(pkgs.len()); + + for pkg in pkgs { + globs.push(Glob::new(format!("**/node_modules/{{{}}}/**", pkg))); + } + + Ok(Glob::alternatives(globs)) + } } #[turbo_tasks::function] diff --git a/crates/turbopack/src/module_options/mod.rs b/crates/turbopack/src/module_options/mod.rs index f2d7bc83e3b30..571490016cec0 100644 --- a/crates/turbopack/src/module_options/mod.rs +++ b/crates/turbopack/src/module_options/mod.rs @@ -84,6 +84,7 @@ impl ModuleOptions { ref enable_typeof_window_inlining, .. } = *module_options_context.await?; + if !rules.is_empty() { let path_value = path.await?; diff --git a/crates/turbopack/src/module_options/module_options_context.rs b/crates/turbopack/src/module_options/module_options_context.rs index ac068c1496ba7..f8b4e6b841dab 100644 --- a/crates/turbopack/src/module_options/module_options_context.rs +++ b/crates/turbopack/src/module_options/module_options_context.rs @@ -109,7 +109,7 @@ pub struct JsxTransformOptions { } #[turbo_tasks::value(shared)] -#[derive(Default, Clone)] +#[derive(Clone, Default)] #[serde(default)] pub struct ModuleOptionsContext { pub enable_typeof_window_inlining: Option,