From 9cd655304b4a13e9b2d4d97ebb73c5f170461c13 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Thu, 26 Dec 2024 11:35:37 +0800 Subject: [PATCH 01/13] feat: runtime template with dojang --- Cargo.lock | 4 +- Cargo.toml | 2 +- crates/node_binding/binding.d.ts | 10 + .../src/raw_options/raw_output.rs | 20 + crates/rspack_core/Cargo.toml | 1 + .../rspack_core/src/compiler/compilation.rs | 8 +- crates/rspack_core/src/init_fragment.rs | 15 +- crates/rspack_core/src/lib.rs | 2 + crates/rspack_core/src/normal_module.rs | 1 + crates/rspack_core/src/options/output.rs | 52 +- .../rspack_core/src/parser_and_generator.rs | 4 +- crates/rspack_core/src/runtime_module.rs | 3 + crates/rspack_core/src/runtime_template.rs | 257 +++++++++ .../src/runtime_module/amd_define.rs | 21 +- .../src/runtime_module/async_module.rs | 13 +- .../src/runtime_module/auto_public_path.rs | 104 ++-- .../chunk_prefetch_preload_function.rs | 28 +- .../runtime_module/chunk_prefetch_startup.rs | 37 +- .../runtime_module/chunk_prefetch_trigger.rs | 28 +- .../runtime_module/chunk_preload_trigger.rs | 29 +- .../compat_get_default_export.rs | 13 +- .../create_fake_namespace_object.rs | 15 +- .../src/runtime_module/create_script.rs | 29 +- .../src/runtime_module/create_script_url.rs | 29 +- .../runtime_module/define_property_getters.rs | 13 +- .../src/runtime_module/ensure_chunk.rs | 53 +- .../runtime_module/esm_module_decorator.rs | 13 +- .../src/runtime_module/get_chunk_filename.rs | 37 +- .../get_chunk_update_filename.rs | 28 +- .../src/runtime_module/get_full_hash.rs | 24 +- .../src/runtime_module/get_main_filename.rs | 29 +- .../get_trusted_types_policy.rs | 40 +- .../src/runtime_module/global.rs | 13 +- .../src/runtime_module/has_own_property.rs | 13 +- .../runtime_module/make_namespace_object.rs | 13 +- .../runtime_module/node_module_decorator.rs | 13 +- .../src/runtime_module/nonce.rs | 15 +- .../src/runtime_module/on_chunk_loaded.rs | 13 +- .../src/runtime_module/public_path.rs | 27 +- .../src/runtime_module/relative_url.rs | 13 +- .../src/runtime_module/rspack_unique_id.rs | 27 +- .../src/runtime_module/rspack_version.rs | 26 +- .../src/runtime_module/runtime/amd_define.ejs | 3 + .../runtime_module/runtime/async_module.ejs | 76 +++ .../runtime_module/runtime/async_module.js | 76 --- .../runtime/auto_public_path.ejs | 25 + .../chunk_prefetch_preload_function.ejs | 6 + .../chunk_prefetch_preload_function.js | 6 - .../runtime/chunk_prefetch_startup.ejs | 3 + .../runtime/chunk_prefetch_trigger.ejs | 7 + .../runtime/chunk_prefetch_trigger.js | 7 - .../runtime/chunk_preload_trigger.ejs | 5 + .../runtime/chunk_preload_trigger.js | 5 - .../runtime/compat_get_default_export.ejs | 11 + .../runtime/compat_get_default_export.js | 11 - ...ct.js => create_fake_namespace_object.ejs} | 12 +- .../runtime_module/runtime/create_script.ejs | 1 + .../runtime/create_script_url.ejs | 1 + .../runtime/define_property_getters.ejs | 7 + .../runtime/define_property_getters.js | 7 - .../runtime_module/runtime/ensure_chunk.ejs | 11 + .../runtime_module/runtime/ensure_chunk.js | 11 - ...inline.js => ensure_chunk_with_inline.ejs} | 4 +- ..._decorator.js => esm_module_decorator.ejs} | 4 +- .../runtime/get_chunk_filename.ejs | 8 + .../runtime/get_chunk_update_filename.ejs | 1 + .../runtime_module/runtime/get_full_hash.ejs | 1 + .../runtime_module/runtime/get_full_hash.js | 3 - .../runtime/get_main_filename.ejs | 1 + ...policy.js => get_trusted_types_policy.ejs} | 10 +- .../runtime_module/runtime/get_unique_id.ejs | 1 + .../runtime_module/runtime/get_unique_id.js | 1 - .../runtime_module/runtime/get_version.ejs | 1 + .../src/runtime_module/runtime/get_version.js | 3 - .../runtime/{global.js => global.ejs} | 2 +- .../runtime/has_own_property.ejs | 1 + .../runtime/has_own_property.js | 3 - ...ce_object.js => make_namespace_object.ejs} | 2 +- ...decorator.js => node_module_decorator.ejs} | 2 +- .../src/runtime_module/runtime/nonce.ejs | 1 + ...on_chunk_loaded.js => on_chunk_loaded.ejs} | 10 +- .../runtime_module/runtime/public_path.ejs | 1 + .../src/runtime_module/runtime/public_path.js | 1 - .../{relative_url.js => relative_url.ejs} | 8 +- .../runtime_module/runtime/runtime_module.ejs | 1 + .../runtime/startup_chunk_dependencies.ejs | 4 + .../runtime/startup_entrypoint.ejs | 8 + .../runtime/startup_entrypoint.js | 10 - .../runtime/startup_entrypoint_with_async.ejs | 9 + .../runtime/startup_entrypoint_with_async.js | 11 - .../runtime_module/runtime/system_context.ejs | 1 + .../src/runtime_module/runtime_id.rs | 25 +- .../startup_chunk_dependencies.rs | 28 +- .../src/runtime_module/startup_entry_point.rs | 20 +- .../src/runtime_module/system_context.rs | 21 +- .../tests/__snapshots__/Config.test.js.snap | 45 +- .../tests/__snapshots__/StatsAPI.test.js.snap | 24 +- .../__snapshots__/StatsOutput.test.js.snap | 130 ++--- .../variant/__snapshots__/output.snap.txt | 2 +- .../__snapshots__/output.snap.txt | 6 +- .../hashbang/__snapshots__/output.snap.txt | 2 +- .../provide/__snapshots__/output.snap.txt | 2 +- .../__snapshots__/output.snap.txt | 6 +- .../__snapshots__/output.snap.txt | 4 +- .../__snapshots__/output.snap.txt | 4 +- .../minify/__snapshots__/output.snap.txt | 4 +- .../parsing/rspack-issue-6934/index.js | 2 +- .../rspack-issue-6934/rspack.config.js | 2 +- .../duplicate/output.snap.txt | 15 +- .../request/output.snap.txt | 15 +- .../resource/output.snap.txt | 15 +- .../resource/output.snap.txt | 15 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 14 +- .../__snapshots__/web/1.snap.txt | 14 +- .../chunk/asset/__snapshots__/web/1.snap.txt | 6 +- .../chunk/asset/__snapshots__/web/2.snap.txt | 6 +- .../chunk/asset/__snapshots__/web/3.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 12 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/2.snap.txt | 6 +- .../__snapshots__/web/3.snap.txt | 6 +- .../multi-chunk/__snapshots__/web/1.snap.txt | 18 +- .../multi-chunk/__snapshots__/web/2.snap.txt | 18 +- .../multi-chunk/__snapshots__/web/3.snap.txt | 18 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../css-extract/__snapshots__/web/1.snap.txt | 10 +- .../__snapshots__/web/1.snap.txt | 6 +- .../css-modules/__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/2.snap.txt | 6 +- .../css/recovery/__snapshots__/web/2.snap.txt | 6 +- .../issue-10174/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../decline/__snapshots__/web/1.snap.txt | 8 +- .../events/__snapshots__/web/1.snap.txt | 20 +- .../self-decline/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/2.snap.txt | 8 +- .../__snapshots__/web/3.snap.txt | 10 +- .../unaccepted/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../module-hot/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 8 +- .../auto-import/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../hot-index/__snapshots__/web/1.snap.txt | 8 +- .../hot-index/__snapshots__/web/2.snap.txt | 8 +- .../hot-index/__snapshots__/web/3.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/2.snap.txt | 6 +- .../__snapshots__/web/3.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/2.snap.txt | 6 +- .../__snapshots__/web/3.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 10 +- .../plugins/html/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 12 +- .../__snapshots__/web/3.snap.txt | 28 +- .../accept/__snapshots__/web/1.snap.txt | 6 +- .../bubble-async/__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 6 +- .../circular/__snapshots__/web/1.snap.txt | 10 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/2.snap.txt | 10 +- .../__snapshots__/web/3.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/2.snap.txt | 10 +- .../hmr-circular/__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 12 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 8 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/1.snap.txt | 6 +- .../__snapshots__/web/2.snap.txt | 6 +- .../__snapshots__/web/3.snap.txt | 6 +- .../disable/__snapshots__/web/1.snap.txt | 8 +- .../disable/__snapshots__/web/2.snap.txt | 8 +- .../disable/__snapshots__/web/3.snap.txt | 8 +- .../enable/__snapshots__/web/1.snap.txt | 8 +- .../enable/__snapshots__/web/2.snap.txt | 8 +- .../enable/__snapshots__/web/3.snap.txt | 8 +- .../stats/chunks/__snapshots__/web/1.snap.txt | 8 +- .../accept/__snapshots__/web/1.snap.txt | 6 +- .../status/check/__snapshots__/web/1.snap.txt | 8 +- .../used-exports/__snapshots__/web/1.snap.txt | 8 +- .../issue-5597/__snapshots__/web/1.snap.txt | 28 +- .../issue-5597/__snapshots__/web/2.snap.txt | 28 +- .../issue-5597/__snapshots__/web/3.snap.txt | 28 +- .../issue-5597/__snapshots__/web/4.snap.txt | 28 +- .../issue-5597/__snapshots__/web/5.snap.txt | 28 +- .../issue-5597/__snapshots__/web/6.snap.txt | 28 +- .../issue-5597/__snapshots__/web/7.snap.txt | 28 +- .../tests/statsAPICases/asset-info.js | 2 +- .../build-time-executed-runtime.js | 16 +- .../tests/statsAPICases/chunk-group.js | 28 +- .../tests/statsAPICases/chunks.js | 2 +- .../tests/statsAPICases/exports.js | 4 +- .../tests/statsAPICases/nested-modules.js | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../basic/__snapshots__/treeshaking.snap.txt | 2 +- .../bb/__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 10 +- .../__snapshots__/treeshaking.snap.txt | 10 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 16 +- .../__snapshots__/treeshaking.snap.txt | 18 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 12 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 6 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 6 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 8 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 6 +- .../__snapshots__/treeshaking.snap.txt | 2 +- .../__snapshots__/treeshaking.snap.txt | 6 +- .../__snapshots__/treeshaking.snap.txt | 24 +- .../__snapshots__/treeshaking.snap.txt | 10 +- .../__snapshots__/treeshaking.snap.txt | 12 +- .../__snapshots__/treeshaking.snap.txt | 10 +- .../__snapshots__/treeshaking.snap.txt | 6 +- .../__snapshots__/treeshaking.snap.txt | 4 +- .../__snapshots__/treeshaking.snap.txt | 12 +- .../__snapshots__/treeshaking.snap.txt | 12 +- .../__snapshots__/treeshaking.snap.txt | 10 +- .../__snapshots__/treeshaking.snap.txt | 2 +- packages/rspack/etc/core.api.md | 48 +- packages/rspack/src/config/adapter.ts | 32 +- .../StatsTestCases.basictest.js.snap | 544 +++++++++--------- 288 files changed, 2141 insertions(+), 1747 deletions(-) create mode 100644 crates/rspack_core/src/runtime_template.rs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/amd_define.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/auto_public_path.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_startup.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{create_fake_namespace_object.js => create_fake_namespace_object.ejs} (62%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script_url.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{ensure_chunk_with_inline.js => ensure_chunk_with_inline.ejs} (67%) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{esm_module_decorator.js => esm_module_decorator.ejs} (76%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_update_filename.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_main_filename.ejs rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{get_trusted_types_policy.js => get_trusted_types_policy.ejs} (50%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{global.js => global.ejs} (82%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{make_namespace_object.js => make_namespace_object.ejs} (78%) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{node_module_decorator.js => node_module_decorator.ejs} (58%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/nonce.ejs rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{on_chunk_loaded.js => on_chunk_loaded.ejs} (71%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{relative_url.js => relative_url.ejs} (66%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/runtime_module.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_chunk_dependencies.ejs create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/system_context.ejs diff --git a/Cargo.lock b/Cargo.lock index 3055de237674..e13068b7431b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4377,6 +4377,7 @@ dependencies = [ "rspack_ast", "rspack_cacheable", "rspack_collections", + "rspack_dojang", "rspack_error", "rspack_fs", "rspack_futures", @@ -4405,8 +4406,7 @@ dependencies = [ [[package]] name = "rspack_dojang" version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c6a270521e3fb5e430a3c43282cff5da7c3717e0081f6b10999968c1bf5d01" +source = "git+https://github.com/rspack-contrib/rspack-dojang.git?branch=feat%2Fpub-templates#05d338081cbf2adafcc7200674f40d42ad500dc9" dependencies = [ "html-escape", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index a1fac4012bbf..4c3d5c95bdee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,7 +105,7 @@ swc_node_comments = { version = "=5.0.0" } pnp = { version = "0.9.0" } -rspack_dojang = { version = "0.1.9" } +rspack_dojang = { version = "0.1.9", git = "https://github.com/rspack-contrib/rspack-dojang.git", branch = "feat/pub-templates" } # all rspack workspace dependencies diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index dee43e5da8ad..7c4195e551b6 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -1374,6 +1374,16 @@ export interface RawEnvironment { const?: boolean arrowFunction?: boolean nodePrefixForCoreModules?: boolean + asyncFunction?: boolean + bigIntLiteral?: boolean + destructuring?: boolean + document?: boolean + dynamicImport?: boolean + forOf?: boolean + globalThis?: boolean + module?: boolean + optionalChaining?: boolean + templateLiteral?: boolean } export interface RawEvalDevToolModulePluginOptions { diff --git a/crates/rspack_binding_values/src/raw_options/raw_output.rs b/crates/rspack_binding_values/src/raw_options/raw_output.rs index ae4a23b6ae0e..3cc2fad41330 100644 --- a/crates/rspack_binding_values/src/raw_options/raw_output.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_output.rs @@ -46,6 +46,16 @@ pub struct RawEnvironment { pub r#const: Option, pub arrow_function: Option, pub node_prefix_for_core_modules: Option, + pub async_function: Option, + pub big_int_literal: Option, + pub destructuring: Option, + pub document: Option, + pub dynamic_import: Option, + pub for_of: Option, + pub global_this: Option, + pub module: Option, + pub optional_chaining: Option, + pub template_literal: Option, } impl From for Environment { @@ -54,6 +64,16 @@ impl From for Environment { r#const: value.r#const, arrow_function: value.arrow_function, node_prefix_for_core_modules: value.node_prefix_for_core_modules, + async_function: value.async_function, + big_int_literal: value.big_int_literal, + destructuring: value.destructuring, + document: value.document, + dynamic_import: value.dynamic_import, + for_of: value.for_of, + global_this: value.global_this, + module: value.module, + optional_chaining: value.optional_chaining, + template_literal: value.template_literal, } } } diff --git a/crates/rspack_core/Cargo.toml b/crates/rspack_core/Cargo.toml index ce8bc9ed7a35..0311b467c324 100644 --- a/crates/rspack_core/Cargo.toml +++ b/crates/rspack_core/Cargo.toml @@ -32,6 +32,7 @@ ropey = { workspace = true } rspack_ast = { workspace = true } rspack_cacheable = { workspace = true } rspack_collections = { workspace = true } +rspack_dojang = { workspace = true } rspack_error = { workspace = true } rspack_fs = { workspace = true } rspack_futures = { workspace = true } diff --git a/crates/rspack_core/src/compiler/compilation.rs b/crates/rspack_core/src/compiler/compilation.rs index 4a52a29f546d..0b1bb695170a 100644 --- a/crates/rspack_core/src/compiler/compilation.rs +++ b/crates/rspack_core/src/compiler/compilation.rs @@ -51,7 +51,8 @@ use crate::{ DependencyType, Entry, EntryData, EntryOptions, EntryRuntime, Entrypoint, ExecuteModuleId, Filename, ImportVarMap, LocalFilenameFn, Logger, ModuleFactory, ModuleGraph, ModuleGraphPartial, ModuleIdentifier, ModuleIdsArtifact, PathData, ResolverFactory, RuntimeGlobals, RuntimeModule, - RuntimeSpecMap, SharedPluginDriver, SideEffectsOptimizeArtifact, SourceType, Stats, + RuntimeSpecMap, RuntimeTemplate, SharedPluginDriver, SideEffectsOptimizeArtifact, SourceType, + Stats, }; pub type BuildDependency = ( @@ -219,6 +220,7 @@ pub struct Compilation { pub build_dependencies: IndexSet>, pub value_cache_versions: ValueCacheVersions, + pub runtime_template: RuntimeTemplate, import_var_map: IdentifierDashMap, @@ -273,6 +275,8 @@ impl Compilation { output_filesystem: Arc, ) -> Self { let incremental = Incremental::new(options.experiments.incremental); + let runtime_template = RuntimeTemplate::new(options.output.environment); + Self { id: CompilationId::new(), hot_index: 0, @@ -341,6 +345,7 @@ impl Compilation { intermediate_filesystem, output_filesystem, + runtime_template, } } @@ -2142,6 +2147,7 @@ impl Compilation { module.attach(*chunk_ukey); self.chunk_graph.add_module(runtime_module_identifier); + self.runtime_template.add_templates(module.template()); self .chunk_graph .connect_chunk_and_module(*chunk_ukey, runtime_module_identifier); diff --git a/crates/rspack_core/src/init_fragment.rs b/crates/rspack_core/src/init_fragment.rs index efe6b3dfdc62..41a80613c8ee 100644 --- a/crates/rspack_core/src/init_fragment.rs +++ b/crates/rspack_core/src/init_fragment.rs @@ -157,6 +157,7 @@ fn first(fragments: Vec>>) -> Box pub trait InitFragmentRenderContext { fn add_runtime_requirements(&mut self, requirement: RuntimeGlobals); fn runtime_condition_expression(&mut self, runtime_condition: &RuntimeCondition) -> String; + fn returning_function(&self, return_value: &str, args: Option<&str>) -> String; } pub trait InitFragment: IntoAny + DynHash + DynClone + Debug + Sync + Send { @@ -269,6 +270,10 @@ impl InitFragmentRenderContext for GenerateContext<'_> { self.runtime_requirements, ) } + + fn returning_function(&self, return_value: &str, args: Option<&str>) -> String { + self.runtime_template.returning_function(return_value, args) + } } pub struct ChunkRenderContext; @@ -281,6 +286,10 @@ impl InitFragmentRenderContext for ChunkRenderContext { fn runtime_condition_expression(&mut self, _runtime_condition: &RuntimeCondition) -> String { unreachable!("should not call runtime condition expression in chunk render context") } + + fn returning_function(&self, _return_value: &str, _args: Option<&str>) -> String { + unreachable!("should not call returning function in chunk render context") + } } #[derive(Debug, Clone, Hash)] @@ -359,7 +368,11 @@ impl InitFragment for ESMExportInitFragment { .iter() .map(|s| { let prop = property_name(&s.0)?; - Ok(format!("{}: function() {{ return {}; }}", prop, s.1)) + Ok(format!( + "{}: {}", + prop, + context.returning_function(&s.1, None) + )) }) .collect::>>()? .join(",\n ") diff --git a/crates/rspack_core/src/lib.rs b/crates/rspack_core/src/lib.rs index 55d6220a205e..744cbdf8c905 100644 --- a/crates/rspack_core/src/lib.rs +++ b/crates/rspack_core/src/lib.rs @@ -15,6 +15,8 @@ pub use dependencies_block::{ AsyncDependenciesBlock, AsyncDependenciesBlockIdentifier, DependenciesBlock, }; mod fake_namespace_object; +mod runtime_template; +pub use runtime_template::*; mod template; pub use fake_namespace_object::*; pub use template::Template; diff --git a/crates/rspack_core/src/normal_module.rs b/crates/rspack_core/src/normal_module.rs index c1c9ad8347f1..ed575d090d35 100644 --- a/crates/rspack_core/src/normal_module.rs +++ b/crates/rspack_core/src/normal_module.rs @@ -663,6 +663,7 @@ impl Module for NormalModule { requested_source_type: *source_type, runtime, concatenation_scope: concatenation_scope.as_mut(), + runtime_template: &compilation.runtime_template, }, )?; code_generation_result.add(*source_type, CachedSource::new(generation_result).boxed()); diff --git a/crates/rspack_core/src/options/output.rs b/crates/rspack_core/src/options/output.rs index aec742287742..83db043f762c 100644 --- a/crates/rspack_core/src/options/output.rs +++ b/crates/rspack_core/src/options/output.rs @@ -468,11 +468,21 @@ pub struct LibraryCustomUmdObject { pub root: Option>, } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Environment { pub r#const: Option, pub arrow_function: Option, pub node_prefix_for_core_modules: Option, + pub async_function: Option, + pub big_int_literal: Option, + pub destructuring: Option, + pub document: Option, + pub dynamic_import: Option, + pub for_of: Option, + pub global_this: Option, + pub module: Option, + pub optional_chaining: Option, + pub template_literal: Option, } impl Environment { @@ -487,4 +497,44 @@ impl Environment { pub fn supports_node_prefix_for_core_modules(&self) -> bool { self.node_prefix_for_core_modules.unwrap_or_default() } + + pub fn supports_async_function(&self) -> bool { + self.async_function.unwrap_or_default() + } + + pub fn supports_big_int_literal(&self) -> bool { + self.big_int_literal.unwrap_or_default() + } + + pub fn supports_destructuring(&self) -> bool { + self.destructuring.unwrap_or_default() + } + + pub fn supports_document(&self) -> bool { + self.document.unwrap_or_default() + } + + pub fn supports_dynamic_import(&self) -> bool { + self.dynamic_import.unwrap_or_default() + } + + pub fn supports_for_of(&self) -> bool { + self.for_of.unwrap_or_default() + } + + pub fn supports_global_this(&self) -> bool { + self.global_this.unwrap_or_default() + } + + pub fn supports_module(&self) -> bool { + self.module.unwrap_or_default() + } + + pub fn supports_optional_chaining(&self) -> bool { + self.optional_chaining.unwrap_or_default() + } + + pub fn supports_template_literal(&self) -> bool { + self.template_literal.unwrap_or_default() + } } diff --git a/crates/rspack_core/src/parser_and_generator.rs b/crates/rspack_core/src/parser_and_generator.rs index c38e91609647..595787aebc38 100644 --- a/crates/rspack_core/src/parser_and_generator.rs +++ b/crates/rspack_core/src/parser_and_generator.rs @@ -14,7 +14,8 @@ use swc_core::common::Span; use crate::{ AsyncDependenciesBlock, BoxDependency, BoxLoader, BuildInfo, BuildMeta, CodeGenerationData, Compilation, CompilerOptions, DependencyTemplate, Module, ModuleDependency, ModuleIdentifier, - ModuleLayer, ModuleType, NormalModule, ParserOptions, RuntimeGlobals, RuntimeSpec, SourceType, + ModuleLayer, ModuleType, NormalModule, ParserOptions, RuntimeGlobals, RuntimeSpec, + RuntimeTemplate, SourceType, }; use crate::{ChunkGraph, ConcatenationScope, Context, ModuleGraph}; @@ -82,6 +83,7 @@ pub struct GenerateContext<'a> { pub requested_source_type: SourceType, pub runtime: Option<&'a RuntimeSpec>, pub concatenation_scope: Option<&'a mut ConcatenationScope>, + pub runtime_template: &'a RuntimeTemplate, } #[cacheable_dyn] diff --git a/crates/rspack_core/src/runtime_module.rs b/crates/rspack_core/src/runtime_module.rs index 2675684eba85..a42af2b4e38a 100644 --- a/crates/rspack_core/src/runtime_module.rs +++ b/crates/rspack_core/src/runtime_module.rs @@ -23,6 +23,9 @@ pub trait RuntimeModule: Module + CustomSourceRuntimeModule { fn should_isolate(&self) -> bool { true } + fn template(&self) -> Vec<(String, String)> { + vec![] + } fn generate_with_custom( &self, diff --git a/crates/rspack_core/src/runtime_template.rs b/crates/rspack_core/src/runtime_template.rs new file mode 100644 index 000000000000..8f2ab084fa15 --- /dev/null +++ b/crates/rspack_core/src/runtime_template.rs @@ -0,0 +1,257 @@ +use std::{ + collections::HashMap, + fmt::Debug, + sync::{LazyLock, Mutex}, +}; + +use itertools::Itertools; +use rspack_dojang::{Context, Dojang, Operand}; +use rspack_error::{miette, Result}; +use serde_json::{Map, Value}; + +use crate::{Environment, RuntimeGlobals}; + +pub struct RuntimeTemplate { + environment: Environment, + dojang: Dojang, +} + +static RUNTIME_GLOBALS_VALUE: LazyLock> = LazyLock::new(|| { + RuntimeGlobals::all() + .iter_names() + .map(|(name, value)| (name.to_string(), Value::String(value.to_string()))) + .collect::>() +}); + +impl Debug for RuntimeTemplate { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("runtime_template") + .field("environment", &self.environment) + .finish() + } +} + +impl RuntimeTemplate { + pub fn new(environment: Environment) -> Self { + let mut dojang = Dojang::new(); + + if environment.supports_arrow_function() { + dojang + .add_function_1("basicFunction".into(), basic_function_arrow) + .expect("failed to add template function `basicFunction`"); + dojang + .add_function_2("returningFunction".into(), returning_function_arrow) + .expect("failed to add template function `returningFunction`"); + dojang + .add_function_2("expressionFunction".into(), expression_function_arrow) + .expect("failed to add template function `expressionFunction`"); + dojang + .add_function_0("emptyFunction".into(), empty_function_arrow) + .expect("failed to add template function `emptyFunction`"); + } else { + dojang + .add_function_1("basicFunction".into(), basic_function) + .expect("failed to add template function `basicFunction`"); + dojang + .add_function_2("returningFunction".into(), returning_function) + .expect("failed to add template function `returningFunction`"); + dojang + .add_function_2("expressionFunction".into(), expression_function) + .expect("failed to add template function `expressionFunction`"); + dojang + .add_function_0("emptyFunction".into(), empty_function) + .expect("failed to add template function `emptyFunction`"); + } + + if environment.supports_destructuring() { + dojang + .add_function_2("destructureArray".into(), array_destructure) + .expect("failed to add template function `destructureArray`"); + } else { + dojang + .add_function_2("destructureArray".into(), array_variable) + .expect("failed to add template function `destructureArray`"); + } + Self { + environment, + dojang, + } + } + + pub fn add_templates(&mut self, templates: Vec<(String, String)>) { + for (key, template) in templates { + if !self.dojang.templates.contains_key(&key) { + // println!("Adding template: {}", key); + self + .dojang + .add_with_option(key.clone(), template) + .unwrap_or_else(|_| panic!("failed to add template {key}")); + } + } + } + + pub fn render( + &self, + key: &str, + params: Option, + ) -> Result { + let mut render_params = Value::Object(RUNTIME_GLOBALS_VALUE.clone()); + + if let Some(params) = params { + match params { + Value::Object(params) => { + for (k, v) in params { + render_params + .as_object_mut() + .unwrap_or_else(|| unreachable!()) + .insert(k, v); + } + } + _ => panic!("Should recive a map value"), + } + } + + if let Some((executer, file_content)) = self.dojang.templates.get(key) { + executer + .render( + &mut Context::new(render_params), + &self.dojang.templates, + &self.dojang.functions, + file_content, + &mut Mutex::new(HashMap::new()), + ) + .map_err(|err| { + miette::Error::msg(format!( + "Runtime module: failed to render template {key} from: {err}" + )) + }) + } else { + Err(miette::Error::msg(format!( + "Runtime module: Template {} is not found", + key + ))) + } + } + + pub fn returning_function(&self, return_value: &str, args: Option<&str>) -> String { + if self.environment.supports_arrow_function() { + format!("({}) => ({})", args.unwrap_or_default(), return_value) + } else { + format!( + "function({}) {{ return {}; }}", + args.unwrap_or_default(), + return_value + ) + } + } +} + +fn to_string(val: &Operand) -> String { + match val { + Operand::Value(val) => val.as_str().unwrap_or_default().to_string(), + _ => String::default(), + } +} + +fn join_to_string(val: &Operand, sep: &str) -> String { + match val { + Operand::Array(items) => items.iter().map(to_string).join(sep), + _ => to_string(val), + } +} + +fn basic_function_arrow(args: Operand) -> Operand { + Operand::Value(Value::from(format!( + r#"({}) =>"#, + join_to_string(&args, ", ") + ))) +} + +fn basic_function(args: Operand) -> Operand { + Operand::Value(Value::from(format!( + r#"function({})"#, + join_to_string(&args, ", ") + ))) +} + +fn returning_function_arrow(return_value: Operand, args: Operand) -> Operand { + Operand::Value(Value::from(format!( + "({}) => ({})", + join_to_string(&args, ", "), + to_string(&return_value) + ))) +} + +fn expression_function(expression: Operand, args: Operand) -> Operand { + Operand::Value(Value::from(format!( + "function({}) {{ {}; }}", + join_to_string(&args, ", "), + to_string(&expression) + ))) +} + +fn expression_function_arrow(expression: Operand, args: Operand) -> Operand { + Operand::Value(Value::from(format!( + "({}) => ({})", + join_to_string(&args, ", "), + to_string(&expression) + ))) +} + +fn returning_function(return_value: Operand, args: Operand) -> Operand { + Operand::Value(Value::from(format!( + "function({}) {{ return {}; }}", + join_to_string(&args, ", "), + to_string(&return_value) + ))) +} + +fn array_destructure(items: Operand, value: Operand) -> Operand { + Operand::Value(Value::from(format!( + "var [{}] = {};", + join_to_string(&items, ", "), + to_string(&value) + ))) +} + +fn array_variable(items: Operand, value: Operand) -> Operand { + let value_name = to_string(&value); + let items = match items { + Operand::Array(items) => items + .iter() + .enumerate() + .map(|(idx, item)| { + let item_name = to_string(item); + if item_name.is_empty() { + String::default() + } else { + format!("var {} = {}[{}];", item_name, value_name, idx) + } + }) + .join("\n"), + Operand::Value(val) => val + .as_str() + .unwrap_or_default() + .split(",") + .enumerate() + .map(|(idx, item)| { + let item_name = item.trim().to_string(); + if item_name.is_empty() { + String::default() + } else { + format!("var {} = {}[{}];", item_name, value_name, idx) + } + }) + .join("\n"), + _ => String::default(), + }; + Operand::Value(Value::from(items)) +} + +fn empty_function() -> Operand { + Operand::Value(Value::from("function() {}")) +} + +fn empty_function_arrow() -> Operand { + Operand::Value(Value::from("function() {}")) +} diff --git a/crates/rspack_plugin_runtime/src/runtime_module/amd_define.rs b/crates/rspack_plugin_runtime/src/runtime_module/amd_define.rs index 0f1d282541a0..78bdc1477fba 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/amd_define.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/amd_define.rs @@ -2,7 +2,7 @@ use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, rspack_sources::{BoxSource, RawStringSource, SourceExt}, - Compilation, RuntimeGlobals, RuntimeModule, + Compilation, RuntimeModule, }; #[impl_runtime_module] @@ -22,13 +22,16 @@ impl RuntimeModule for AmdDefineRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from(format!( - "{} = function () {{ throw new Error('define cannot be used indirect'); }}", - RuntimeGlobals::AMD_DEFINE.name() - )) - .boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/amd_define.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs b/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs index 3bc90a5bbfde..c88945c14d0b 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/async_module.rs @@ -17,11 +17,20 @@ impl Default for AsyncRuntimeModule { } impl RuntimeModule for AsyncRuntimeModule { - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/async_module.js")).boxed()) + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } fn name(&self) -> Identifier { self.id } + + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/async_module.ejs").to_string(), + )] + } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs b/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs index 985b9d0c4e07..e8d88c818080 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs @@ -3,7 +3,7 @@ use rspack_core::{ get_js_chunk_filename_template, impl_runtime_module, rspack_sources::{BoxSource, RawStringSource, SourceExt}, ChunkUkey, Compilation, OutputOptions, PathData, RuntimeGlobals, RuntimeModule, - RuntimeModuleStage, SourceType, + RuntimeModuleStage, RuntimeTemplate, SourceType, }; use super::utils::get_undo_path; @@ -34,6 +34,13 @@ impl RuntimeModule for AutoPublicPathRuntimeModule { RuntimeModuleStage::Attach } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/auto_public_path.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk = self.chunk.expect("The chunk should be attached"); let chunk = compilation.chunk_by_ukey.expect_get(&chunk); @@ -63,15 +70,22 @@ impl RuntimeModule for AutoPublicPathRuntimeModule { )?; Ok( RawStringSource::from(auto_public_path_template( + &compilation.runtime_template, + &self.id, &filename, &compilation.options.output, - )) + )?) .boxed(), ) } } -fn auto_public_path_template(filename: &str, output: &OutputOptions) -> String { +fn auto_public_path_template( + runtime_template: &RuntimeTemplate, + id: &str, + filename: &str, + output: &OutputOptions, +) -> rspack_error::Result { let output_path = output.path.as_str().to_string(); let undo_path = get_undo_path(filename, output_path, false); let assign = if undo_path.is_empty() { @@ -82,45 +96,53 @@ fn auto_public_path_template(filename: &str, output: &OutputOptions) -> String { RuntimeGlobals::PUBLIC_PATH ) }; - let global = RuntimeGlobals::GLOBAL.name(); let import_meta_name = output.import_meta_name.clone(); - let script_url_template = if output.script_type.eq("module") { - format!( - r#"var scriptUrl; - if (typeof {import_meta_name}.url === "string") scriptUrl = {import_meta_name}.url - "# - ) - .to_string() - } else { - format!( - r#"var scriptUrl; - if ({global}.importScripts) scriptUrl = {global}.location + ""; - var document = {global}.document; - if (!scriptUrl && document) {{ - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) {{ - var scripts = document.getElementsByTagName("script"); - if (scripts.length) {{ - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - }} - }} - }} - "# - ) - }; - format!( - r#" - {script_url_template} - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - {assign} - "# + runtime_template.render( + id, + Some(serde_json::json!({ + "script_type": output.script_type, + "IMPORT_META_NAME": import_meta_name, + "ASSIGN": assign + })), ) + + // let script_url_template = if output.script_type.eq("module") { + // format!( + // r#"var scriptUrl; + // if (typeof {import_meta_name}.url === "string") scriptUrl = {import_meta_name}.url + // "# + // ) + // .to_string() + // } else { + // format!( + // r#"var scriptUrl; + // if ({global}.importScripts) scriptUrl = {global}.location + ""; + // var document = {global}.document; + // if (!scriptUrl && document) {{ + // // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // // but an attacker could try to inject `` + // // and use `` + // if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + // if (!scriptUrl) {{ + // var scripts = document.getElementsByTagName("script"); + // if (scripts.length) {{ + // var i = scripts.length - 1; + // while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + // }} + // }} + // }} + // "# + // ) + // }; + // format!( + // r#" + // {script_url_template} + // // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", + // // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', + // if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); + // scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); + // {assign} + // "# + // ) } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs index 9c9f38be95fb..fe69f24962d4 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_preload_function.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -36,15 +35,22 @@ impl RuntimeModule for ChunkPrefetchPreloadFunctionRuntimeModule { self.id } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/chunk_prefetch_preload_function.js") - .cow_replace("$RUNTIME_FUNCTION$", &self.runtime_function.to_string()) - .cow_replace("$RUNTIME_HANDLERS$", &self.runtime_handlers.to_string()) - .into_owned(), - ) - .boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/chunk_prefetch_preload_function.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "$RUNTIME_HANDLERS$": &self.runtime_handlers.to_string(), + "$RUNTIME_FUNCTION$": &self.runtime_function.to_string(), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs index 4b8dfdccbeac..6c6698041c86 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs @@ -33,11 +33,17 @@ impl RuntimeModule for ChunkPrefetchStartupRuntimeModule { self.chunk = Some(chunk); } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/chunk_prefetch_startup.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk_ukey = self.chunk.expect("chunk do not attached"); - Ok( - RawStringSource::from( - self + + let source = self .startup_chunks .iter() .map(|(group_chunks, child_chunks)| { @@ -85,21 +91,16 @@ impl RuntimeModule for ChunkPrefetchStartupRuntimeModule { } }; - format!( - r#" - {}(0, {}, function() {{ - {} - }}, 5); - "#, - RuntimeGlobals::ON_CHUNKS_LOADED, - serde_json::to_string(&group_chunk_ids).expect("invalid json tostring"), - body - ) - }) - .join("\n"), - ) - .boxed(), - ) + // TODO: add params + let source = compilation.runtime_template.render(&self.id, Some(serde_json::json!({ + "GROUP_CHUNK_IDS": serde_json::to_string(&group_chunk_ids).expect("invalid json tostring"), + "BODY": body, + })))?; + + Ok(source) + }).collect::>>()?.join("\n"); + + Ok(RawStringSource::from(source).boxed()) } fn stage(&self) -> RuntimeModuleStage { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs index f68c697740eb..d59a168bdd4d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_trigger.rs @@ -1,6 +1,5 @@ use std::hash::BuildHasherDefault; -use cow_utils::CowUtils; use indexmap::IndexMap; use rspack_cacheable::with::AsMap; use rspack_collections::Identifier; @@ -34,18 +33,21 @@ impl RuntimeModule for ChunkPrefetchTriggerRuntimeModule { self.id } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/chunk_prefetch_trigger.js") - .cow_replace( - "$CHUNK_MAP$", - &serde_json::to_string(&self.chunk_map).expect("invalid json tostring"), - ) - .into_owned(), - ) - .boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/chunk_prefetch_trigger.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "CHUNK_MAP": &self.chunk_map, + })), + )?; + Ok(RawStringSource::from(source).boxed()) } fn stage(&self) -> RuntimeModuleStage { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs index 51137b01df8e..8b938946a957 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_preload_trigger.rs @@ -1,6 +1,5 @@ use std::hash::BuildHasherDefault; -use cow_utils::CowUtils; use indexmap::IndexMap; use rspack_cacheable::with::AsMap; use rspack_collections::Identifier; @@ -34,18 +33,22 @@ impl RuntimeModule for ChunkPreloadTriggerRuntimeModule { self.id } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/chunk_preload_trigger.js") - .cow_replace( - "$CHUNK_MAP$", - &serde_json::to_string(&self.chunk_map).expect("invalid json tostring"), - ) - .into_owned(), - ) - .boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/chunk_preload_trigger.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "CHUNK_MAP": &self.chunk_map, + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } fn stage(&self) -> RuntimeModuleStage { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs b/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs index 56eb8e0fe84c..de6a57f927f7 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/compat_get_default_export.rs @@ -24,7 +24,16 @@ impl RuntimeModule for CompatGetDefaultExportRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/compat_get_default_export.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/compat_get_default_export.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs b/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs index c641e0e28a75..bf8c787b5675 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/create_fake_namespace_object.rs @@ -24,9 +24,16 @@ impl RuntimeModule for CreateFakeNamespaceObjectRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from_static(include_str!("runtime/create_fake_namespace_object.js")).boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/create_fake_namespace_object.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/create_script.rs b/crates/rspack_plugin_runtime/src/runtime_module/create_script.rs index 743f5ba17ecb..4310db01e28e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/create_script.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/create_script.rs @@ -22,25 +22,28 @@ impl RuntimeModule for CreateScriptRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/create_script.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from(format!( - r#" - {} = function(script){{ - return {}; - }}; - "#, - RuntimeGlobals::CREATE_SCRIPT, - if compilation.options.output.trusted_types.is_some() { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "RETURN": if compilation.options.output.trusted_types.is_some() { format!( "{}().createScript(script)", RuntimeGlobals::GET_TRUSTED_TYPES_POLICY ) } else { "script".to_string() - } - )) - .boxed(), - ) + }, + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs b/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs index b1d3fcfb173c..988743872341 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/create_script_url.rs @@ -22,25 +22,28 @@ impl RuntimeModule for CreateScriptUrlRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/create_script_url.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from(format!( - r#" - {} = function(url){{ - return {}; - }}; - "#, - RuntimeGlobals::CREATE_SCRIPT_URL, - if compilation.options.output.trusted_types.is_some() { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "RETURN": if compilation.options.output.trusted_types.is_some() { format!( "{}().createScriptURL(url)", RuntimeGlobals::GET_TRUSTED_TYPES_POLICY ) } else { "url".to_string() - } - )) - .boxed(), - ) + }, + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs b/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs index 1dde0c2019ab..6399eb6dcb30 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/define_property_getters.rs @@ -22,7 +22,16 @@ impl RuntimeModule for DefinePropertyGettersRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/define_property_getters.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/define_property_getters.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs b/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs index 623fc811661f..72102ed26104 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/ensure_chunk.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -26,27 +25,43 @@ impl RuntimeModule for EnsureChunkRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![ + ( + self.id.to_string(), + include_str!("runtime/ensure_chunk.ejs").to_string(), + ), + ( + format!("{}-inline", self.id), + include_str!("runtime/ensure_chunk_with_inline.ejs").to_string(), + ), + ] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk_ukey = self.chunk.expect("should have chunk"); let runtime_requirements = get_chunk_runtime_requirements(compilation, &chunk_ukey); - Ok( - RawStringSource::from( - match runtime_requirements.contains(RuntimeGlobals::ENSURE_CHUNK_HANDLERS) { - true => include_str!("runtime/ensure_chunk.js") - .cow_replace( - "$FETCH_PRIORITY$", - if runtime_requirements.contains(RuntimeGlobals::HAS_FETCH_PRIORITY) { - ", fetchPriority" - } else { - "" - }, - ) - .into_owned(), - false => include_str!("runtime/ensure_chunk_with_inline.js").to_string(), - }, - ) - .boxed(), - ) + let source = if runtime_requirements.contains(RuntimeGlobals::ENSURE_CHUNK_HANDLERS) { + let fetch_priority = if runtime_requirements.contains(RuntimeGlobals::HAS_FETCH_PRIORITY) { + ", fetchPriority" + } else { + "" + }; + + compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "ARGS": format!("chunkId{}", fetch_priority), + "FETCH_PRIORITY": fetch_priority, + })), + )? + } else { + compilation + .runtime_template + .render(&format!("{}-inline", self.id), None)? + }; + + Ok(RawStringSource::from(source).boxed()) } fn attach(&mut self, chunk: ChunkUkey) { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/esm_module_decorator.rs b/crates/rspack_plugin_runtime/src/runtime_module/esm_module_decorator.rs index e723b34f93fd..4c2dda0b936d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/esm_module_decorator.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/esm_module_decorator.rs @@ -22,7 +22,16 @@ impl RuntimeModule for ESMModuleDecoratorRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/esm_module_decorator.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/esm_module_decorator.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs index 4cb23da2395c..898aff5bab5e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs @@ -82,6 +82,13 @@ impl RuntimeModule for GetChunkFilenameRuntimeModule { true } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_chunk_filename.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunks = self .chunk @@ -344,25 +351,17 @@ impl RuntimeModule for GetChunkFilenameRuntimeModule { } } } - Ok( - RawStringSource::from(format!( - "// This function allow to reference chunks - {} = function (chunkId) {{ - // return url for filenames not based on template - {} - // return url for filenames based on template - return {}; - }}; - ", - self.global, - static_urls - .iter() - .map(|(filename, chunk_ids)| stringify_static_chunk_map(filename, chunk_ids)) - .join("\n"), - dynamic_url.unwrap_or_else(|| format!("\"\" + chunkId + \".{}\"", self.content_type)) - )) - .boxed(), - ) + + let source = compilation.runtime_template.render(&self.id, Some(serde_json::json!({ + "$GLOBAL$": self.global, + "STATIC_URLS": static_urls + .iter() + .map(|(filename, chunk_ids)| stringify_static_chunk_map(filename, chunk_ids)) + .join("\n"), + "DYNAMIC_URL":dynamic_url.unwrap_or_else(|| format!("\"\" + chunkId + \".{}\"", self.content_type)), + })))?; + + Ok(RawStringSource::from(source).boxed()) } fn attach(&mut self, chunk: ChunkUkey) { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs index 968dc989d1af..72e6b9c74d66 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_update_filename.rs @@ -27,6 +27,14 @@ impl RuntimeModule for GetChunkUpdateFilenameRuntimeModule { fn name(&self) -> Identifier { self.id } + + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_chunk_update_filename.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { if let Some(chunk_ukey) = self.chunk { let chunk = compilation.chunk_by_ukey.expect_get(&chunk_ukey); @@ -49,17 +57,15 @@ impl RuntimeModule for GetChunkUpdateFilenameRuntimeModule { .runtime(chunk.runtime().as_str()), ) .always_ok(); - Ok( - RawStringSource::from(format!( - "{} = function (chunkId) {{ - return '{}'; - }}; - ", - RuntimeGlobals::GET_CHUNK_UPDATE_SCRIPT_FILENAME, - filename - )) - .boxed(), - ) + + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "FILENAME": format!("'{}'", filename), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } else { unreachable!("should attach chunk for get_main_filename") } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs index 788ebec72acc..7c9e645185e4 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_full_hash.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -23,15 +22,22 @@ impl RuntimeModule for GetFullHashRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_full_hash.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/get_full_hash.js") - .cow_replace("$HASH$", compilation.get_hash().unwrap_or("XXXX")) - .into_owned(), - ) - .boxed(), - ) + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "HASH": format!("\"{}\"", compilation.get_hash().unwrap_or("XXXX")) + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } fn full_hash(&self) -> bool { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs index c439e5e51dbf..bbe4ba5255fc 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_main_filename.rs @@ -1,3 +1,5 @@ +use std::vec; + use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -30,6 +32,13 @@ impl RuntimeModule for GetMainFilenameRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_main_filename.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { if let Some(chunk_ukey) = self.chunk { let chunk = compilation.chunk_by_ukey.expect_get(&chunk_ukey); @@ -54,16 +63,16 @@ impl RuntimeModule for GetMainFilenameRuntimeModule { .hash(format!("\" + {}() + \"", RuntimeGlobals::GET_FULL_HASH).as_str()) .runtime(chunk.runtime().as_str()), )?; - Ok( - RawStringSource::from(format!( - "{} = function () {{ - return \"{}\"; - }}; - ", - self.global, filename - )) - .boxed(), - ) + + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "FILENAME": format!("\"{}\"", filename), + "$GLOBAL$": self.global.name(), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } else { unreachable!("should attach chunk for get_main_filename") } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs index c45498caa066..98db75f3593f 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_trusted_types_policy.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -29,6 +28,13 @@ impl RuntimeModule for GetTrustedTypesPolicyRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_trusted_types_policy.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let trusted_types = compilation .options @@ -45,10 +51,6 @@ impl RuntimeModule for GetTrustedTypesPolicyRuntimeModule { OnPolicyCreationFailure::Continue ); - let result = include_str!("runtime/get_trusted_types_policy.js").cow_replace( - "$policyName$", - &trusted_types.policy_name.clone().unwrap_or_default(), - ); let mut policy_content: Vec = Vec::new(); if create_script { policy_content.push( @@ -88,22 +90,18 @@ impl RuntimeModule for GetTrustedTypesPolicyRuntimeModule { } else { "".to_string() }; - Ok( - RawStringSource::from( - result - .cow_replace("$policyContent$", policy_content.join(",\n").as_ref()) - .cow_replace( - "$wrapPolicyCreationTryCatchStart$", - wrap_policy_creation_try_catch_start, - ) - .cow_replace( - "$wrapPolicyCreationTryCatchEnd$", - &wrap_policy_creation_try_catch_end, - ) - .into_owned(), - ) - .boxed(), - ) + + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "POLICY_CONTENT": policy_content.join(",\n"), + "WRAP_POLICY_CREATION_TRY_CATCH_START": wrap_policy_creation_try_catch_start, + "WARP_POLICY_CREATION_TRY_CATCH_END": wrap_policy_creation_try_catch_end, + "POLICY_NAME": &trusted_types.policy_name.clone().unwrap_or_default(), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } fn attach(&mut self, chunk: ChunkUkey) { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/global.rs b/crates/rspack_plugin_runtime/src/runtime_module/global.rs index f41383e66465..c246fa93ce40 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/global.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/global.rs @@ -22,7 +22,16 @@ impl RuntimeModule for GlobalRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/global.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/global.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs b/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs index a570ef6f6eec..80ddd880ee5d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/has_own_property.rs @@ -22,7 +22,16 @@ impl RuntimeModule for HasOwnPropertyRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/has_own_property.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/has_own_property.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs b/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs index 5ce2eceb7112..b3ae94cebeff 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/make_namespace_object.rs @@ -22,7 +22,16 @@ impl RuntimeModule for MakeNamespaceObjectRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/make_namespace_object.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/make_namespace_object.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs b/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs index 5da6a58001d5..8e7879c0be33 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/node_module_decorator.rs @@ -22,7 +22,16 @@ impl RuntimeModule for NodeModuleDecoratorRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/node_module_decorator.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/node_module_decorator.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs b/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs index f3f0026924f8..1e61305c31e5 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/nonce.rs @@ -2,7 +2,7 @@ use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, rspack_sources::{BoxSource, RawStringSource, SourceExt}, - Compilation, RuntimeGlobals, RuntimeModule, + Compilation, RuntimeModule, }; #[impl_runtime_module] @@ -22,7 +22,16 @@ impl RuntimeModule for NonceRuntimeModule { self.id } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from(format!("{} = undefined;", RuntimeGlobals::SCRIPT_NONCE)).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/nonce.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs b/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs index 2088c80bcd4e..47026eb86feb 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/on_chunk_loaded.rs @@ -22,7 +22,16 @@ impl RuntimeModule for OnChunkLoadedRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/on_chunk_loaded.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/on_chunk_loaded.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs b/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs index 13f0935fc49b..530ca085e54f 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/public_path.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ has_hash_placeholder, impl_runtime_module, @@ -24,18 +23,22 @@ impl RuntimeModule for PublicPathRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/public_path.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/public_path.js") - .cow_replace( - "__PUBLIC_PATH_PLACEHOLDER__", - &PublicPath::render_filename(compilation, &self.public_path), - ) - .into_owned(), - ) - .boxed(), - ) + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "PUBLIC_PATH_PLACEHOLDER": &PublicPath::render_filename(compilation, &self.public_path), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } // be cacheable only when the template does not contain a hash placeholder diff --git a/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs b/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs index 857aa2722d94..76bfdca639cf 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/relative_url.rs @@ -22,7 +22,16 @@ impl RuntimeModule for RelativeUrlRuntimeModule { self.id } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok(RawStringSource::from_static(include_str!("runtime/relative_url.js")).boxed()) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/relative_url.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/rspack_unique_id.rs b/crates/rspack_plugin_runtime/src/runtime_module/rspack_unique_id.rs index a69ab17c09b1..75ddab936840 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/rspack_unique_id.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/rspack_unique_id.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -31,16 +30,22 @@ impl RuntimeModule for RspackUniqueIdRuntimeModule { fn name(&self) -> Identifier { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_unique_id.ejs").to_string(), + )] + } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/get_unique_id.js") - .cow_replace("$BUNDLER_NAME$", &self.bundler_name) - .cow_replace("$BUNDLER_VERSION$", &self.bundler_version) - .into_owned(), - ) - .boxed(), - ) + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "BUNDLER_NAME": &self.bundler_name, + "BUNDLER_VERSION":&self.bundler_version, + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs b/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs index 67ab51f9b854..cc89febf9776 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/rspack_version.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, @@ -24,14 +23,21 @@ impl RuntimeModule for RspackVersionRuntimeModule { self.id } - fn generate(&self, _: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from( - include_str!("runtime/get_version.js") - .cow_replace("$VERSION$", &self.version) - .into_owned(), - ) - .boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/get_version.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "VERSION": format!("\"{}\"", &self.version), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/amd_define.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/amd_define.ejs new file mode 100644 index 000000000000..6a09fa091a4e --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/amd_define.ejs @@ -0,0 +1,3 @@ +<%- AMD_DEFINE %> = function () { + throw new Error('define cannot be used indirect'); +} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs new file mode 100644 index 000000000000..13a7fae275af --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs @@ -0,0 +1,76 @@ +var webpackQueues = + typeof Symbol === "function" + ? Symbol("webpack queues") + : "__webpack_queues__"; +var webpackExports = + typeof Symbol === "function" + ? Symbol("webpack exports") + : "<%- EXPORTS %>"; +var webpackError = + typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__"; +var resolveQueue = <%- basicFunction("queue") %> { + if (queue && queue.d < 1) { + queue.d = 1; + queue.forEach(<%- expressionFunction("fn.r--", "fn") %>); + queue.forEach(<%- expressionFunction("fn.r-- ? fn.r++ : fn()", "fn") %>); + } +} +var wrapDeps = <%- basicFunction("deps") %> { + return deps.map(<%- basicFunction("dep") %> { + if (dep !== null && typeof dep === "object") { + if (dep[webpackQueues]) return dep; + if (dep.then) { + var queue = []; + queue.d = 0; + dep.then(<%- basicFunction("r") %> { + obj[webpackExports] = r; + resolveQueue(queue); + },<%- basicFunction("e") %> { + obj[webpackError] = e; + resolveQueue(queue); + }); + var obj = {}; + obj[webpackQueues] = <%- expressionFunction("fn(queue)", "fn") %>; + return obj; + } + } + var ret = {}; + ret[webpackQueues] = <%- emptyFunction() %>; + ret[webpackExports] = dep; + return ret; + }); +}; +<%- ASYNC_MODULE %> = <%- basicFunction("module, body, hasAwait") %> { + var queue; + hasAwait && ((queue = []).d = -1); + var depQueues = new Set(); + var exports = module.exports; + var currentDeps; + var outerResolve; + var reject; + var promise = new Promise(<%- basicFunction("resolve, rej") %> { + reject = rej; + outerResolve = resolve; + }); + promise[webpackExports] = exports; + promise[webpackQueues] = <%- basicFunction("fn") %> { queue && fn(queue), depQueues.forEach(fn), promise["catch"](<%- emptyFunction() %>); }; + module.exports = promise; + body(<%- basicFunction("deps") %> { + currentDeps = wrapDeps(deps); + var fn; + var getResult = <%- basicFunction("") %> { + return currentDeps.map(<%- basicFunction("d") %> { + if (d[webpackError]) throw d[webpackError]; + return d[webpackExports]; + }); + } + var promise = new Promise(<%- basicFunction("resolve") %> { + fn = <%- expressionFunction("resolve(getResult)", "") %>; + fn.r = 0; + var fnQueue = <%- expressionFunction("q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)))", "q") %>; + currentDeps.map(<%- expressionFunction("dep[webpackQueues](fnQueue)", "dep") %>); + }); + return fn.r ? promise : getResult(); + }, <%- expressionFunction("(err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)", "err") %>); + queue && queue.d < 0 && (queue.d = 0); +}; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.js deleted file mode 100644 index aef77b26d9fb..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.js +++ /dev/null @@ -1,76 +0,0 @@ -var webpackQueues = - typeof Symbol === "function" - ? Symbol("webpack queues") - : "__webpack_queues__"; -var webpackExports = - typeof Symbol === "function" - ? Symbol("webpack exports") - : "__webpack_exports__"; -var webpackError = - typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__"; -var resolveQueue = function (queue) { - if (queue && queue.d < 1) { - queue.d = 1; - queue.forEach(function (fn) { fn.r--; }); - queue.forEach(function (fn) { fn.r-- ? fn.r++ : fn(); }); - } -} -var wrapDeps = function (deps) { - return deps.map(function (dep) { - if (dep !== null && typeof dep === "object") { - if (dep[webpackQueues]) return dep; - if (dep.then) { - var queue = []; - queue.d = 0; - dep.then(function (r) { - obj[webpackExports] = r; - resolveQueue(queue); - }, function (e) { - obj[webpackError] = e; - resolveQueue(queue); - }); - var obj = {}; - obj[webpackQueues] = function (fn) { fn(queue); }; - return obj; - } - } - var ret = {}; - ret[webpackQueues] = function () { }; - ret[webpackExports] = dep; - return ret; - }); -}; -__webpack_require__.a = function (module, body, hasAwait) { - var queue; - hasAwait && ((queue = []).d = -1); - var depQueues = new Set(); - var exports = module.exports; - var currentDeps; - var outerResolve; - var reject; - var promise = new Promise(function (resolve, rej) { - reject = rej; - outerResolve = resolve; - }); - promise[webpackExports] = exports; - promise[webpackQueues] = function (fn) { queue && fn(queue), depQueues.forEach(fn), promise["catch"](function () { }); }; - module.exports = promise; - body(function (deps) { - currentDeps = wrapDeps(deps); - var fn; - var getResult = function () { - return currentDeps.map(function (d) { - if (d[webpackError]) throw d[webpackError]; - return d[webpackExports]; - }); - } - var promise = new Promise(function (resolve) { - fn = function () { resolve(getResult); }; - fn.r = 0; - var fnQueue = function (q) { q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))); }; - currentDeps.map(function (dep) { dep[webpackQueues](fnQueue); }); - }); - return fn.r ? promise : getResult(); - }, function (err) { (err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue); }); - queue && queue.d < 0 && (queue.d = 0); -}; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/auto_public_path.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/auto_public_path.ejs new file mode 100644 index 000000000000..c05e529d29b7 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/auto_public_path.ejs @@ -0,0 +1,25 @@ +var scriptUrl; +<% if (script_type == "module") { %> +if (typeof <%- IMPORT_META_NAME %>.url === "string") scriptUrl = <%- IMPORT_META_NAME %>.url +<% } else { %> +if (<%- GLOBAL %>.importScripts) scriptUrl = <%- GLOBAL %>.location + ""; +var document = <%- GLOBAL %>.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} +<% } %> +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +<%- ASSIGN %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.ejs new file mode 100644 index 000000000000..3d2cd7ff88b2 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.ejs @@ -0,0 +1,6 @@ +<%- $RUNTIME_HANDLERS$ %> = {}; +<%- $RUNTIME_FUNCTION$ %> = <%- basicFunction("chunkId") %> { + Object.keys(<%- $RUNTIME_HANDLERS$ %>).map(function (key) { + <%- $RUNTIME_HANDLERS$ %>[key](chunkId); + }); +} diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.js deleted file mode 100644 index a6c49e51a342..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_preload_function.js +++ /dev/null @@ -1,6 +0,0 @@ -$RUNTIME_HANDLERS$ = {}; -$RUNTIME_FUNCTION$ = function (chunkId) { - Object.keys($RUNTIME_HANDLERS$).map(function (key) { - $RUNTIME_HANDLERS$[key](chunkId); - }); -} diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_startup.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_startup.ejs new file mode 100644 index 000000000000..067660bc98c9 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_startup.ejs @@ -0,0 +1,3 @@ +<%- ON_CHUNKS_LOADED %>(0, <%- GROUP_CHUNK_IDS %>, <%- basicFunction("") %> { + <%- BODY %> +}, 5); \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.ejs new file mode 100644 index 000000000000..37e6f997fffd --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.ejs @@ -0,0 +1,7 @@ +var chunkToChildrenMap = <%- CHUNK_MAP %>; +<%- ENSURE_CHUNK_HANDLERS %>.prefetch = <%- basicFunction("chunkId, promises") %> { + Promise.all(promises).then(<%- basicFunction("") %> { + var chunks = chunkToChildrenMap[chunkId]; + Array.isArray(chunks) && chunks.map(<%- PREFETCH_CHUNK %>); + }); +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.js deleted file mode 100644 index e144e7a35d9c..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_prefetch_trigger.js +++ /dev/null @@ -1,7 +0,0 @@ -var chunkToChildrenMap = $CHUNK_MAP$; -__webpack_require__.f.prefetch = function (chunkId, promises) { - Promise.all(promises).then(function () { - var chunks = chunkToChildrenMap[chunkId]; - Array.isArray(chunks) && chunks.map(__webpack_require__.E); - }); -}; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.ejs new file mode 100644 index 000000000000..89e345d0027e --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.ejs @@ -0,0 +1,5 @@ +var chunkToChildrenMap = <%- CHUNK_MAP %>; +<%- ENSURE_CHUNK_HANDLERS %>.preload = <%- basicFunction("chunkId") %> { + var chunks = chunkToChildrenMap[chunkId]; + Array.isArray(chunks) && chunks.map(<%- PRELOAD_CHUNK %>); +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.js deleted file mode 100644 index bca221978bf5..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/chunk_preload_trigger.js +++ /dev/null @@ -1,5 +0,0 @@ -var chunkToChildrenMap = $CHUNK_MAP$; -__webpack_require__.f.preload = function (chunkId) { - var chunks = chunkToChildrenMap[chunkId]; - Array.isArray(chunks) && chunks.map(__webpack_require__.G); -}; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.ejs new file mode 100644 index 000000000000..b95389c7220d --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.ejs @@ -0,0 +1,11 @@ +// getDefaultExport function for compatibility with non-ESM modules +<%- COMPAT_GET_DEFAULT_EXPORT %> = <%- basicFunction("module") %> { + var getter = module && module.__esModule ? + <%- returningFunction("module['default']", "") %> : + <%- returningFunction("module", "") %> + <%- DEFINE_PROPERTY_GETTERS %>(getter, { a: getter }); + return getter; +}; + + + diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.js deleted file mode 100644 index 6f8de3d294b9..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/compat_get_default_export.js +++ /dev/null @@ -1,11 +0,0 @@ -// getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { - var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); - return getter; -}; - - - diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_fake_namespace_object.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_fake_namespace_object.ejs similarity index 62% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/create_fake_namespace_object.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/create_fake_namespace_object.ejs index e6e87a1bb2fa..bfde4766ed1d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_fake_namespace_object.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_fake_namespace_object.ejs @@ -1,4 +1,4 @@ -var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__ }; +var getProto = Object.getPrototypeOf ? <%- returningFunction("Object.getPrototypeOf(obj)", "obj") %> : <%- returningFunction("obj.__proto__", "obj") %>; var leafPrototypes; // create a fake namespace object // mode & 1: value is a module id, require it @@ -6,7 +6,7 @@ var leafPrototypes; // mode & 4: return value when already ns object // mode & 16: return value when it's Promise-like // mode & 8|1: behave like require -__webpack_require__.t = function(value, mode) { +<%- CREATE_FAKE_NAMESPACE_OBJECT %> = function(value, mode) { if(mode & 1) value = this(value); if(mode & 8) return value; if(typeof value === 'object' && value) { @@ -14,13 +14,13 @@ __webpack_require__.t = function(value, mode) { if((mode & 16) && typeof value.then === 'function') return value; } var ns = Object.create(null); - __webpack_require__.r(ns); + <%- MAKE_NAMESPACE_OBJECT %>(ns); var def = {}; leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { - Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; } }); + Object.getOwnPropertyNames(current).forEach(<%- basicFunction("key") %> { def[key] = <%- returningFunction("value[key]", "") %> }); } - def['default'] = function() { return value }; - __webpack_require__.d(ns, def); + def['default'] = <%- returningFunction("value", "") %>; + <%- DEFINE_PROPERTY_GETTERS %>(ns, def); return ns; }; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script.ejs new file mode 100644 index 000000000000..e4804473199a --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script.ejs @@ -0,0 +1 @@ +<%- CREATE_SCRIPT %> = <%- returningFunction(RETURN, "script") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script_url.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script_url.ejs new file mode 100644 index 000000000000..002b8eae09ae --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/create_script_url.ejs @@ -0,0 +1 @@ +<%- CREATE_SCRIPT_URL %> = <%- returningFunction(RETURN, "url") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.ejs new file mode 100644 index 000000000000..71ce6f734fd4 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.ejs @@ -0,0 +1,7 @@ +<%- DEFINE_PROPERTY_GETTERS %> = <%- basicFunction("exports, definition") %> { + for(var key in definition) { + if(<%- HAS_OWN_PROPERTY %>(definition, key) && !<%- HAS_OWN_PROPERTY %>(exports, key)) { + Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); + } + } +}; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.js deleted file mode 100644 index b0272221ed11..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/define_property_getters.js +++ /dev/null @@ -1,7 +0,0 @@ -__webpack_require__.d = function(exports, definition) { - for(var key in definition) { - if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { - Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); - } - } -}; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.ejs new file mode 100644 index 000000000000..426792e20078 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.ejs @@ -0,0 +1,11 @@ +<%- ENSURE_CHUNK_HANDLERS %> = {}; +// This file contains only the entry chunk. +// The chunk loading function for additional chunks +<%- ENSURE_CHUNK %> = <%- basicFunction(ARGS) %> { + return Promise.all( + Object.keys(<%- ENSURE_CHUNK_HANDLERS %>).reduce(<%- basicFunction("promises, key") %> { + <%- ENSURE_CHUNK_HANDLERS %>[key](chunkId, promises<%- FETCH_PRIORITY %>); + return promises; + }, []) + ); +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.js deleted file mode 100644 index 01c946f2ef70..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk.js +++ /dev/null @@ -1,11 +0,0 @@ -__webpack_require__.f = {}; -// This file contains only the entry chunk. -// The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId$FETCH_PRIORITY$) { - return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { - __webpack_require__.f[key](chunkId, promises$FETCH_PRIORITY$); - return promises; - }, []) - ); -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk_with_inline.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk_with_inline.ejs similarity index 67% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk_with_inline.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk_with_inline.ejs index 6c0c800a4670..ce94fb2b260e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk_with_inline.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/ensure_chunk_with_inline.ejs @@ -1,6 +1,4 @@ // The chunk loading function for additional chunks // Since all referenced chunks are already included // in this file, this function is empty here. -__webpack_require__.e = function () { - return Promise.resolve(); -}; +<%- ENSURE_CHUNK %> = <%- returningFunction("Promise.resolve()", "") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/esm_module_decorator.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/esm_module_decorator.ejs similarity index 76% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/esm_module_decorator.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/esm_module_decorator.ejs index fcd475149e9e..55a349c9a319 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/esm_module_decorator.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/esm_module_decorator.ejs @@ -1,9 +1,9 @@ -__webpack_require__.hmd = function (module) { +<%- ESM_MODULE_DECORATOR %> = <%- basicFunction("module") %> { module = Object.create(module); if (!module.children) module.children = []; Object.defineProperty(module, 'exports', { enumerable: true, - set: function () { + set: <%- basicFunction("") %> { throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id); } }); diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs new file mode 100644 index 000000000000..6e15578c2bb3 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs @@ -0,0 +1,8 @@ +// This function allow to reference chunks +<%- $GLOBAL$ %> = <%- basicFunction("chunkId") %> { + // return url for filenames not based on template + <%- STATIC_URLS %> + + // return url for filenames based on template + return <%- DYNAMIC_URL %> +} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_update_filename.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_update_filename.ejs new file mode 100644 index 000000000000..6a0a0f97a788 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_update_filename.ejs @@ -0,0 +1 @@ +<%- GET_CHUNK_UPDATE_SCRIPT_FILENAME %> = <%- returningFunction(FILENAME, "chunkId") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.ejs new file mode 100644 index 000000000000..b356d8445324 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.ejs @@ -0,0 +1 @@ +<%- GET_FULL_HASH %> = <%- returningFunction(HASH, "") %> diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.js deleted file mode 100644 index 4cd7db8a1e03..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_full_hash.js +++ /dev/null @@ -1,3 +0,0 @@ -__webpack_require__.h = function () { - return "$HASH$"; -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_main_filename.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_main_filename.ejs new file mode 100644 index 000000000000..19127b47fe2f --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_main_filename.ejs @@ -0,0 +1 @@ +<%- $GLOBAL$ %> = <%- returningFunction(FILENAME, "") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_trusted_types_policy.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_trusted_types_policy.ejs similarity index 50% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/get_trusted_types_policy.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/get_trusted_types_policy.ejs index d53b92dfcd74..a62925ccc386 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_trusted_types_policy.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_trusted_types_policy.ejs @@ -1,14 +1,14 @@ var policy; -__webpack_require__.tt = function () { +<%- GET_TRUSTED_TYPES_POLICY %> = <%- basicFunction("") %> { // Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet. if (policy === undefined) { policy = { - $policyContent$ + <%- POLICY_CONTENT %> }; if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) { - $wrapPolicyCreationTryCatchStart$ - policy = trustedTypes.createPolicy("$policyName$", policy); - $wrapPolicyCreationTryCatchEnd$ + <%- WRAP_POLICY_CREATION_TRY_CATCH_START %> + policy = trustedTypes.createPolicy("<%- POLICY_NAME %>", policy); + <%- WARP_POLICY_CREATION_TRY_CATCH_END %> } } return policy; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.ejs new file mode 100644 index 000000000000..825b273dc681 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.ejs @@ -0,0 +1 @@ +<%- RSPACK_UNIQUE_ID %> = "bundler=<%- BUNDLER_NAME %>@<%- BUNDLER_VERSION %>"; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.js deleted file mode 100644 index 899c0fb6a70a..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.js +++ /dev/null @@ -1 +0,0 @@ -__webpack_require__.ruid = "bundler=$BUNDLER_NAME$@$BUNDLER_VERSION$"; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.ejs new file mode 100644 index 000000000000..e9539499d11d --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.ejs @@ -0,0 +1 @@ +<%- RSPACK_VERSION %> = <%- returningFunction(VERSION, "") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.js deleted file mode 100644 index 1cddc9040bee..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_version.js +++ /dev/null @@ -1,3 +0,0 @@ -__webpack_require__.rv = function () { - return "$VERSION$"; -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/global.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/global.ejs similarity index 82% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/global.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/global.ejs index 077c7c282a3e..6a508eefe773 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/global.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/global.ejs @@ -1,4 +1,4 @@ -__webpack_require__.g = (function () { +<%- GLOBAL %> = (function () { if (typeof globalThis === 'object') return globalThis; try { return this || new Function('return this')(); diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.ejs new file mode 100644 index 000000000000..31c07a53899b --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.ejs @@ -0,0 +1 @@ +<%- HAS_OWN_PROPERTY %> = <%- returningFunction("Object.prototype.hasOwnProperty.call(obj, prop)", "obj, prop") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.js deleted file mode 100644 index 8a6d219728d0..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/has_own_property.js +++ /dev/null @@ -1,3 +0,0 @@ -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.ejs similarity index 78% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.ejs index 2a78f70459c3..03e7edd8b2de 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.ejs @@ -1,5 +1,5 @@ // define __esModule on exports -__webpack_require__.r = function(exports) { +<%- MAKE_NAMESPACE_OBJECT %> = <%- basicFunction("exports") %> { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/node_module_decorator.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/node_module_decorator.ejs similarity index 58% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/node_module_decorator.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/node_module_decorator.ejs index cda9b9197988..9dad442f7ecc 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/node_module_decorator.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/node_module_decorator.ejs @@ -1,4 +1,4 @@ -__webpack_require__.nmd = function (module) { +<%- NODE_MODULE_DECORATOR %> = <%- basicFunction("module") %> { module.paths = []; if (!module.children) module.children = []; return module; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/nonce.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/nonce.ejs new file mode 100644 index 000000000000..649ae86ecab6 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/nonce.ejs @@ -0,0 +1 @@ +<%- SCRIPT_NONCE %> = undefined; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.ejs similarity index 71% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.ejs index 331bf9299a08..626c4c2c8fde 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.ejs @@ -1,5 +1,5 @@ var deferred = []; -__webpack_require__.O = function (result, chunkIds, fn, priority) { +<%- ON_CHUNKS_LOADED %> = <%- basicFunction("result, chunkIds, fn, priority") %> { if (chunkIds) { priority = priority || 0; for (var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) @@ -9,16 +9,12 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { } var notFulfilled = Infinity; for (var i = 0; i < deferred.length; i++) { - var chunkIds = deferred[i][0], - fn = deferred[i][1], - priority = deferred[i][2]; + <%- destructureArray("chunkIds, fn, priority", "deferred[i]") %> var fulfilled = true; for (var j = 0; j < chunkIds.length; j++) { if ( (priority & (1 === 0) || notFulfilled >= priority) && - Object.keys(__webpack_require__.O).every(function (key) { - return __webpack_require__.O[key](chunkIds[j]); - }) + Object.keys(<%- ON_CHUNKS_LOADED %>).every(<%- returningFunction("__webpack_require__.O[key](chunkIds[j])", "key") %>) ) { chunkIds.splice(j--, 1); } else { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.ejs new file mode 100644 index 000000000000..87b2ce2f524f --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.ejs @@ -0,0 +1 @@ +<%- PUBLIC_PATH %> = "<%- PUBLIC_PATH_PLACEHOLDER %>"; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.js deleted file mode 100644 index 8fd3cbd2506b..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/public_path.js +++ /dev/null @@ -1 +0,0 @@ -__webpack_require__.p = "__PUBLIC_PATH_PLACEHOLDER__"; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/relative_url.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/relative_url.ejs similarity index 66% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/relative_url.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/relative_url.ejs index e83a647b4f7b..c9fb589d2063 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/relative_url.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/relative_url.ejs @@ -1,13 +1,11 @@ -__webpack_require__.U = function RelativeURL(url) { +<%- RELATIVE_URL %> = function RelativeURL(url) { var realUrl = new URL(url, "x:/"); var values = {}; for (var key in realUrl) values[key] = realUrl[key]; values.href = url; values.pathname = url.replace(/[?#].*/, ""); values.origin = values.protocol = ""; - values.toString = values.toJSON = function () { - return url; - }; + values.toString = values.toJSON = <%- returningFunction("url", "") %> for (var key in values) Object.defineProperty(this, key, { enumerable: true, configurable: true, value: values[key] }); }; -__webpack_require__.U.prototype = URL.prototype; \ No newline at end of file +<%- RELATIVE_URL %>.prototype = URL.prototype; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/runtime_module.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/runtime_module.ejs new file mode 100644 index 000000000000..5f4f9618ef5a --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/runtime_module.ejs @@ -0,0 +1 @@ +<%- RUNTIME_ID %> = <%- ID %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_chunk_dependencies.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_chunk_dependencies.ejs new file mode 100644 index 000000000000..beeee68a52c7 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_chunk_dependencies.ejs @@ -0,0 +1,4 @@ +var next = <%- STARTUP %> +<%- STARTUP %> = <%- basicFunction("") %> { + <%- BODY %> +} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.ejs new file mode 100644 index 000000000000..1913fb16b0c2 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.ejs @@ -0,0 +1,8 @@ +<%- STARTUP_ENTRYPOINT %> = <%- basicFunction("result, chunkIds, fn") %> { + // arguments: chunkIds, moduleId are deprecated + var moduleId = chunkIds; + if (!fn) chunkIds = result, fn = <%- returningFunction("__webpack_require__(__webpack_require__.s = moduleId)", "") %> + chunkIds.map(<%- ENSURE_CHUNK %>, <%- REQUIRE %>) + var r = fn(); + return r === undefined ? result : r; +} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.js deleted file mode 100644 index 8a2a151547e4..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.js +++ /dev/null @@ -1,10 +0,0 @@ -__webpack_require__.X = function (result, chunkIds, fn) { - // arguments: chunkIds, moduleId are deprecated - var moduleId = chunkIds; - if (!fn) chunkIds = result, fn = function () { - return __webpack_require__(__webpack_require__.s = moduleId); - }; - chunkIds.map(__webpack_require__.e, __webpack_require__) - var r = fn(); - return r === undefined ? result : r; -} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.ejs new file mode 100644 index 000000000000..30b458ddb0e9 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.ejs @@ -0,0 +1,9 @@ +<%- STARTUP_ENTRYPOINT %> = <%- basicFunction("result, chunkIds, fn") %> { + // arguments: chunkIds, moduleId are deprecated + var moduleId = chunkIds; + if (!fn) chunkIds = result, fn = <%- returningFunction("__webpack_require__(__webpack_require__.s = moduleId)", "") %> + return Promise.all(chunkIds.map(<%- ENSURE_CHUNK %>, <%- REQUIRE %>)).then(<%- basicFunction("") %> { + var r = fn(); + return r === undefined ? result : r; + }); +} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.js deleted file mode 100644 index e5cf205a26b7..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.js +++ /dev/null @@ -1,11 +0,0 @@ -__webpack_require__.X = function (result, chunkIds, fn) { - // arguments: chunkIds, moduleId are deprecated - var moduleId = chunkIds; - if (!fn) chunkIds = result, fn = function () { - return __webpack_require__(__webpack_require__.s = moduleId); - }; - return Promise.all(chunkIds.map(__webpack_require__.e, __webpack_require__)).then(function () { - var r = fn(); - return r === undefined ? result : r; - }); -} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/system_context.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/system_context.ejs new file mode 100644 index 000000000000..f407b190605a --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/system_context.ejs @@ -0,0 +1 @@ +<%- SYSTEM_CONTEXT %> = __system_context__ \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs b/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs index adb134a7c3b6..9792e1fc4d22 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime_id.rs @@ -3,7 +3,7 @@ use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, rspack_sources::{BoxSource, RawStringSource, SourceExt}, - ChunkUkey, Compilation, RuntimeGlobals, RuntimeModule, + ChunkUkey, Compilation, RuntimeModule, }; #[impl_runtime_module] @@ -28,6 +28,13 @@ impl RuntimeModule for RuntimeIdRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/runtime_module.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { if let Some(chunk_ukey) = self.chunk { let chunk = compilation.chunk_by_ukey.expect_get(&chunk_ukey); @@ -47,14 +54,14 @@ impl RuntimeModule for RuntimeIdRuntimeModule { .to_string(), ); - Ok( - RawStringSource::from(format!( - "{} = {};", - RuntimeGlobals::RUNTIME_ID, - serde_json::to_string(&id).expect("Invalid json string") - )) - .boxed(), - ) + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "ID": serde_json::to_string(&id).expect("Invalid json string"), + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } else { unreachable!("should attach chunk for css_loading") } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs b/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs index 34ac85d8b340..c9883f2512ae 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/startup_chunk_dependencies.rs @@ -31,6 +31,13 @@ impl RuntimeModule for StartupChunkDependenciesRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/startup_chunk_dependencies.ejs").to_string(), + )] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { if let Some(chunk_ukey) = self.chunk { let chunk_ids = compilation @@ -78,18 +85,15 @@ impl RuntimeModule for StartupChunkDependenciesRuntimeModule { .join("\n") }; - Ok( - RawStringSource::from(format!( - r#"var next = {}; - {} = function() {{ - {} - }};"#, - RuntimeGlobals::STARTUP, - RuntimeGlobals::STARTUP, - body - )) - .boxed(), - ) + // TODO: write body to ejs template + let source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "BODY": body, + })), + )?; + + Ok(RawStringSource::from(source).boxed()) } else { unreachable!("should have chunk for StartupChunkDependenciesRuntimeModule") } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs b/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs index f52deb941dd5..5abe98b0aabe 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/startup_entry_point.rs @@ -26,12 +26,20 @@ impl RuntimeModule for StartupEntrypointRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - let source = if self.async_chunk_loading { - include_str!("runtime/startup_entrypoint_with_async.js") - } else { - include_str!("runtime/startup_entrypoint.js") - }; + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + if self.async_chunk_loading { + include_str!("runtime/startup_entrypoint_with_async.ejs").to_string() + } else { + include_str!("runtime/startup_entrypoint.ejs").to_string() + }, + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + Ok(RawStringSource::from(source).boxed()) } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs b/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs index 81d1a35cc7e1..84c86d13b232 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/system_context.rs @@ -2,7 +2,7 @@ use rspack_collections::Identifier; use rspack_core::{ impl_runtime_module, rspack_sources::{BoxSource, RawStringSource, SourceExt}, - Compilation, RuntimeGlobals, RuntimeModule, + Compilation, RuntimeModule, }; #[impl_runtime_module] @@ -22,13 +22,16 @@ impl RuntimeModule for SystemContextRuntimeModule { self.id } - fn generate(&self, _compilation: &Compilation) -> rspack_error::Result { - Ok( - RawStringSource::from(format!( - "{} = __system_context__", - RuntimeGlobals::SYSTEM_CONTEXT - )) - .boxed(), - ) + fn template(&self) -> Vec<(String, String)> { + vec![( + self.id.to_string(), + include_str!("runtime/system_context.ejs").to_string(), + )] + } + + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { + let source = compilation.runtime_template.render(&self.id, None)?; + + Ok(RawStringSource::from(source).boxed()) } } diff --git a/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap index 8015f1cfc80f..408eda667711 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap @@ -442,11 +442,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -456,7 +456,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -466,10 +466,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ @@ -590,11 +587,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -604,7 +601,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -614,10 +611,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ @@ -675,11 +669,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -689,7 +683,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -699,10 +693,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap index 6814b04256d3..1b64a7153c08 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap @@ -298,7 +298,7 @@ Object { isOverSizeLimit: false, name: main.js, related: Array [], - size: 441, + size: 412, type: asset, }, ], @@ -655,7 +655,7 @@ Object { size: 192, sizes: Object { javascript: 192, - runtime: 677, + runtime: 648, }, type: chunk, }, @@ -665,10 +665,10 @@ Object { assets: Array [ Object { name: main.js, - size: 441, + size: 412, }, ], - assetsSize: 441, + assetsSize: 412, auxiliaryAssets: Array [], auxiliaryAssetsSize: 0, childAssets: Object {}, @@ -1285,9 +1285,9 @@ Object { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 290, + size: 285, sizes: Object { - runtime: 290, + runtime: 285, }, type: module, usedExports: null, @@ -1327,9 +1327,9 @@ Object { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 107, + size: 88, sizes: Object { - runtime: 107, + runtime: 88, }, type: module, usedExports: null, @@ -1369,9 +1369,9 @@ Object { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 280, + size: 275, sizes: Object { - runtime: 280, + runtime: 275, }, type: module, usedExports: null, @@ -1383,10 +1383,10 @@ Object { assets: Array [ Object { name: main.js, - size: 441, + size: 412, }, ], - assetsSize: 441, + assetsSize: 412, auxiliaryAssets: Array [], auxiliaryAssetsSize: 0, childAssets: Object {}, diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap index f65566e8ea4f..53403d00696c 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap @@ -2,10 +2,10 @@ exports[`statsOutput statsOutput/auxiliary-files-test should print correct stats for 1`] = ` PublicPath: auto -asset bundle.js 2.6 KiB {909} [emitted] (name: main) +asset bundle.js 2.49 KiB {909} [emitted] (name: main) asset 98396dbfd5c74c34.png 7 bytes ({909}) [emitted] [immutable] [from: raw.png] (auxiliary name: main) -Entrypoint main 2.6 KiB (7 bytes) = bundle.js 2.6 KiB (98396dbfd5c74c34.png 7 bytes) -chunk {909} (runtime: main) bundle.js (main) 7 bytes (asset) 159 bytes (javascript) 1.61 KiB (runtime) [entry] [rendered] +Entrypoint main 2.49 KiB (7 bytes) = bundle.js 2.49 KiB (98396dbfd5c74c34.png 7 bytes) +chunk {909} (runtime: main) bundle.js (main) 7 bytes (asset) 159 bytes (javascript) 1.51 KiB (runtime) [entry] [rendered] > ./index main ./index.js + 1 modules [686] 117 bytes {909} [depth 0] [code generated] [no exports] @@ -51,15 +51,15 @@ modules by path ./ 235 bytes (javascript) 7 bytes (asset) [no exports] [no exports used] esm import ./raw.png ./index.js -runtime modules 1.61 KiB - webpack/runtime/auto_public_path 1.39 KiB {909} [code generated] +runtime modules 1.51 KiB + webpack/runtime/auto_public_path 1.29 KiB {909} [code generated] [no exports] [used exports unknown] webpack/runtime/global 223 bytes {909} [code generated] [no exports] [used exports unknown] -Rspack compiled successfully (6f7f39d3a0485d93) +Rspack compiled successfully (307a07d4a8103670) `; exports[`statsOutput statsOutput/builtin-swc-loader-parse-error should print correct stats for 1`] = ` @@ -86,10 +86,10 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/css-concat should print correct stats for 1`] = ` -asset main.js 3.78 KiB [emitted] (name: main) +asset main.js 3.59 KiB [emitted] (name: main) asset main.css 24 bytes [emitted] (name: main) -Entrypoint main 3.8 KiB = main.js 3.78 KiB main.css 24 bytes -runtime modules 2.26 KiB 6 modules +Entrypoint main 3.61 KiB = main.js 3.59 KiB main.css 24 bytes +runtime modules 2.08 KiB 6 modules cacheable modules 62 bytes (javascript) 23 bytes (css) ./index.js 20 bytes [built] [code generated] ./foo.css 42 bytes (javascript) 23 bytes (css) [built] [code generated] @@ -97,9 +97,9 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/filename should print correct stats for 1`] = ` -asset 909.xxxx.js 9.14 KiB [emitted] (name: main) -asset 521.xxxx.js 337 bytes [emitted] -runtime modules 7.54 KiB 11 modules +asset 909.xxxx.js 8.88 KiB [emitted] (name: main) +asset 521.xxxx.js 322 bytes [emitted] +runtime modules 7.28 KiB 11 modules cacheable modules 70 bytes ./index.js 38 bytes [built] [code generated] ./dynamic.js 32 bytes [built] [code generated] @@ -107,14 +107,14 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/hot+production should print correct stats for 1`] = ` -asset main.js 33.5 KiB [emitted] (name: main) -runtime modules 31.2 KiB 12 modules +asset main.js 33.3 KiB [emitted] (name: main) +runtime modules 30.9 KiB 12 modules ./index.js 25 bytes [built] [code generated] Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/ignore-plugin should print correct stats for 1`] = ` -runtime modules 107 bytes 1 module +runtime modules 88 bytes 1 module ./index.js 103 bytes [built] [code generated] /tests/statsOutputCases/ignore-plugin/locals|sync|/^\\.\\/.*$/ 160 bytes [built] [code generated] ./locals/en.js 30 bytes [built] [code generated] @@ -143,25 +143,25 @@ Rspack compiled with 1 error exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct stats for 1`] = ` 1 chunks: - asset bundle1.js 3.66 KiB [emitted] (name: main) - chunk (runtime: main) bundle1.js (main) 219 bytes (javascript) 1.84 KiB (runtime) <{909}> >{909}< [entry] [rendered] + asset bundle1.js 3.57 KiB [emitted] (name: main) + chunk (runtime: main) bundle1.js (main) 219 bytes (javascript) 1.75 KiB (runtime) <{909}> >{909}< [entry] [rendered] dependent modules 96 bytes [dependent] 4 modules ./index.js 123 bytes [built] [code generated] 1 chunks (Rspack x.x.x) compiled successfully in X s 2 chunks: - asset bundle2.js 10.6 KiB [emitted] (name: main) + asset bundle2.js 10.3 KiB [emitted] (name: main) asset 76.bundle2.js 497 bytes [emitted] (name: c) chunk (runtime: main) 76.bundle2.js (c) 74 bytes <{76}> <{909}> >{76}< [rendered] dependent modules 44 bytes [dependent] 2 modules ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle2.js (main) 145 bytes (javascript) 8.73 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle2.js (main) 145 bytes (javascript) 8.4 KiB (runtime) >{76}< [entry] [rendered] dependent modules 22 bytes [dependent] 1 module ./index.js 123 bytes [built] [code generated] 2 chunks (Rspack x.x.x) compiled successfully in X s 3 chunks: - asset bundle3.js 10.6 KiB [emitted] (name: main) + asset bundle3.js 10.3 KiB [emitted] (name: main) asset 76.bundle3.js 387 bytes [emitted] (name: c) asset 345.bundle3.js 186 bytes [emitted] chunk (runtime: main) 345.bundle3.js 44 bytes <{76}> [rendered] @@ -169,13 +169,13 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s ./e.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle3.js (c) 30 bytes <{909}> >{345}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle3.js (main) 145 bytes (javascript) 8.73 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle3.js (main) 145 bytes (javascript) 8.4 KiB (runtime) >{76}< [entry] [rendered] dependent modules 22 bytes [dependent] 1 module ./index.js 123 bytes [built] [code generated] 3 chunks (Rspack x.x.x) compiled successfully in X s 4 chunks: - asset bundle4.js 10.6 KiB [emitted] (name: main) + asset bundle4.js 10.3 KiB [emitted] (name: main) asset 76.bundle4.js 387 bytes [emitted] (name: c) asset 697.bundle4.js 130 bytes [emitted] asset 753.bundle4.js 130 bytes [emitted] @@ -185,7 +185,7 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s ./d.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle4.js (c) 30 bytes <{909}> >{697}< >{753}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle4.js (main) 145 bytes (javascript) 8.73 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle4.js (main) 145 bytes (javascript) 8.4 KiB (runtime) >{76}< [entry] [rendered] dependent modules 22 bytes [dependent] 1 module ./index.js 123 bytes [built] [code generated] 4 chunks (Rspack x.x.x) compiled successfully in X s @@ -200,7 +200,7 @@ DEBUG LOG from TestLoader|/tests/statsOutputCases/logging-loade `; exports[`statsOutput statsOutput/match-resource-data-url should print correct stats for 1`] = ` -runtime modules 677 bytes 3 modules +runtime modules 648 bytes 3 modules ./index.js 150 bytes [built] [code generated] ./a.js!=!data:javascript,var __looooooooo.. 98 bytes [built] [code generated] `; @@ -218,8 +218,8 @@ Rspack compiled with 1 error `; exports[`statsOutput statsOutput/named-chunk-group should print correct stats for 1`] = ` -Entrypoint main 9.13 KiB = main.js -Chunk Group cimanyd 337 bytes = cimanyd.js +Entrypoint main 8.87 KiB = main.js +Chunk Group cimanyd 322 bytes = cimanyd.js `; exports[`statsOutput statsOutput/nonexistent-import-source-error should print correct stats for 1`] = ` @@ -234,48 +234,48 @@ Rspack compiled with 1 error `; exports[`statsOutput statsOutput/optimization-chunk-ids-natural should print correct stats for 1`] = ` -Entrypoint e1 10.7 KiB = e1.js -Entrypoint e2 10.6 KiB = e2.js +Entrypoint e1 10.4 KiB = e1.js +Entrypoint e2 10.3 KiB = e2.js chunk (runtime: e1) 0.js 24 bytes [rendered] chunk (runtime: e1) 1.js 52 bytes [rendered] chunk (runtime: e1, e2) 2.js 22 bytes [rendered] -chunk (runtime: e1) e1.js (e1) 74 bytes (javascript) 8.72 KiB (runtime) [entry] [rendered] -chunk (runtime: e2) e2.js (e2) 51 bytes (javascript) 8.72 KiB (runtime) [entry] [rendered] +chunk (runtime: e1) e1.js (e1) 74 bytes (javascript) 8.39 KiB (runtime) [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 51 bytes (javascript) 8.39 KiB (runtime) [entry] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk should print correct stats for 1`] = ` -Entrypoint e1 4.07 KiB = e1~runtime.js 3.68 KiB e1.js 391 bytes -Entrypoint e2 4.07 KiB = e2~runtime.js 3.68 KiB e2.js 391 bytes +Entrypoint e1 3.98 KiB = e1~runtime.js 3.59 KiB e1.js 391 bytes +Entrypoint e2 3.98 KiB = e2~runtime.js 3.59 KiB e2.js 391 bytes chunk (runtime: e1~runtime) e1.js (e1) 27 bytes [entry] [rendered] -chunk (runtime: e1~runtime) e1~runtime.js (e1~runtime) 2.58 KiB [initial] [rendered] +chunk (runtime: e1~runtime) e1~runtime.js (e1~runtime) 2.5 KiB [initial] [rendered] chunk (runtime: e2~runtime) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: e2~runtime) e2~runtime.js (e2~runtime) 2.58 KiB [initial] [rendered] +chunk (runtime: e2~runtime) e2~runtime.js (e2~runtime) 2.5 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk-multiple should print correct stats for 1`] = ` -Entrypoint e1 4.07 KiB = runtime~e1.js 3.68 KiB e1.js 391 bytes -Entrypoint e2 4.07 KiB = runtime~e2.js 3.68 KiB e2.js 391 bytes +Entrypoint e1 3.98 KiB = runtime~e1.js 3.59 KiB e1.js 391 bytes +Entrypoint e2 3.98 KiB = runtime~e2.js 3.59 KiB e2.js 391 bytes chunk (runtime: runtime~e1) e1.js (e1) 27 bytes [entry] [rendered] chunk (runtime: runtime~e2) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.58 KiB [initial] [rendered] -chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.58 KiB [initial] [rendered] +chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.5 KiB [initial] [rendered] +chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.5 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk-single should print correct stats for 1`] = ` -Entrypoint e1 4.06 KiB = runtime.js 3.68 KiB e1.js 391 bytes -Entrypoint e2 4.06 KiB = runtime.js 3.68 KiB e2.js 391 bytes +Entrypoint e1 3.97 KiB = runtime.js 3.59 KiB e1.js 391 bytes +Entrypoint e2 3.97 KiB = runtime.js 3.59 KiB e2.js 391 bytes chunk (runtime: runtime) e1.js (e1) 27 bytes [entry] [rendered] chunk (runtime: runtime) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: runtime) runtime.js (runtime) 2.58 KiB [initial] [rendered] +chunk (runtime: runtime) runtime.js (runtime) 2.49 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk-true should print correct stats for 1`] = ` -Entrypoint e1 4.07 KiB = runtime~e1.js 3.68 KiB e1.js 391 bytes -Entrypoint e2 4.07 KiB = runtime~e2.js 3.68 KiB e2.js 391 bytes +Entrypoint e1 3.98 KiB = runtime~e1.js 3.59 KiB e1.js 391 bytes +Entrypoint e2 3.98 KiB = runtime~e2.js 3.59 KiB e2.js 391 bytes chunk (runtime: runtime~e1) e1.js (e1) 27 bytes [entry] [rendered] chunk (runtime: runtime~e2) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.58 KiB [initial] [rendered] -chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.58 KiB [initial] [rendered] +chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.5 KiB [initial] [rendered] +chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.5 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/parse-error should print correct stats for 1`] = ` @@ -298,11 +298,11 @@ Rspack compiled with 1 error `; exports[`statsOutput statsOutput/performance-disabled should print correct stats for 1`] = ` -asset main.js 304 KiB [emitted] (name: main) +asset main.js 303 KiB [emitted] (name: main) asset 697.js 130 bytes [emitted] asset 753.js 130 bytes [emitted] -Entrypoint main 304 KiB = main.js -runtime modules 8.72 KiB 12 modules +Entrypoint main 303 KiB = main.js +runtime modules 8.39 KiB 12 modules cacheable modules 293 KiB ./index.js 49 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -314,11 +314,11 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/performance-error should print correct stats for 1`] = ` -asset main.js 304 KiB [emitted] [big] (name: main) +asset main.js 303 KiB [emitted] [big] (name: main) asset 697.js 130 bytes [emitted] asset 753.js 130 bytes [emitted] -Entrypoint main [big] 304 KiB = main.js -runtime modules 8.72 KiB 12 modules +Entrypoint main [big] 303 KiB = main.js +runtime modules 8.39 KiB 12 modules cacheable modules 293 KiB ./index.js 48 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -328,11 +328,11 @@ cacheable modules 293 KiB ./e.js 22 bytes [built] [code generated] ERROR in × asset size limit: The following asset(s) exceed the recommended size limit (244.141 KiB). This can impact web performance.Assets: - │ main.js (303.818 KiB) + │ main.js (303.492 KiB) ERROR in × entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244.141 KiB). This can impact web performance.Entrypoints: - │ main (303.818 KiB) + │ main (303.492 KiB) │ main.js @@ -340,11 +340,11 @@ Rspack x.x.x compiled with 2 errors in X s `; exports[`statsOutput statsOutput/performance-no-hints should print correct stats for 1`] = ` -asset main.js 304 KiB [emitted] [big] (name: main) +asset main.js 303 KiB [emitted] [big] (name: main) asset 697.js 130 bytes [emitted] asset 753.js 130 bytes [emitted] -Entrypoint main [big] 304 KiB = main.js -runtime modules 8.72 KiB 12 modules +Entrypoint main [big] 303 KiB = main.js +runtime modules 8.39 KiB 12 modules cacheable modules 293 KiB ./index.js 48 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -366,7 +366,7 @@ chunk (runtime: main) a2.js (a2) 1 bytes <{74}> [rendered] chunk (runtime: main) b.js (b) 203 bytes <{909}> >{438}< >{439}< >{826}< (prefetch: {826} {438}) (preload: {439}) [rendered] chunk (runtime: main) c.js (c) 134 bytes <{909}> >{380}< >{433}< (preload: {433} {380}) [rendered] chunk (runtime: main) b1.js (b1) 1 bytes <{751}> [rendered] -chunk (runtime: main) main.js (main) 195 bytes (javascript) 12 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered] +chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.5 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered] `; exports[`statsOutput statsOutput/reasons should print correct stats for 1`] = ` @@ -395,7 +395,7 @@ Rspack x.x.x compiled with 1 error in X s exports[`statsOutput statsOutput/resolve-unexpected-exports-in-pkg-error should print correct stats for 1`] = ` asset bundle.js 1.38 KiB [emitted] (name: main) -runtime modules 280 bytes 1 module +runtime modules 275 bytes 1 module ./index.js 39 bytes [built] [code generated] [1 error] ERROR in ./index.js 1:0-22 @@ -406,9 +406,9 @@ Rspack x.x.x compiled with 1 error in X s exports[`statsOutput statsOutput/runtime-modules should print correct stats for 1`] = ` ./index.js 19 bytes [built] [code generated] -webpack/runtime/define_property_getters 290 bytes [code generated] -webpack/runtime/has_own_property 107 bytes [code generated] -webpack/runtime/make_namespace_object 280 bytes [code generated] +webpack/runtime/define_property_getters 285 bytes [code generated] +webpack/runtime/has_own_property 88 bytes [code generated] +webpack/runtime/make_namespace_object 275 bytes [code generated] `; exports[`statsOutput statsOutput/runtime-specific-exports should print correct stats for 1`] = ` @@ -438,15 +438,15 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/simple-export should print correct stats for 1`] = ` -asset bundle.js 1.71 KiB [emitted] (name: main) -runtime modules 677 bytes 3 modules +asset bundle.js 1.66 KiB [emitted] (name: main) +runtime modules 648 bytes 3 modules ./index.js 26 bytes [built] [code generated] Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/simple-module-source should print correct stats for 1`] = ` -asset bundle.js 2.06 KiB [emitted] (name: main) -runtime modules 702 bytes 3 modules +asset bundle.js 2 KiB [emitted] (name: main) +runtime modules 640 bytes 3 modules orphan modules 1 bytes [orphan] 1 module cacheable modules 82 bytes ./index.js 75 bytes [built] [code generated] diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt index 7757bcf16a6f..bfa5cc54f225 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt @@ -1,3 +1,3 @@ ```html title=output.html -Rspack App +Rspack App ``` \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/builtins-define/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/builtins-define/__snapshots__/output.snap.txt index 8e31d1432333..ed10d6534fee 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/builtins-define/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/builtins-define/__snapshots__/output.snap.txt @@ -196,9 +196,9 @@ console.log(console.log(console.log)); "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - DO_NOT_CONVERTED7: function() { return DO_NOT_CONVERTED7; }, - DO_NOT_CONVERTED9: function() { return DO_NOT_CONVERTED9; }, - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + DO_NOT_CONVERTED7: () => (DO_NOT_CONVERTED7), + DO_NOT_CONVERTED9: () => (DO_NOT_CONVERTED9), + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); const DO_NOT_CONVERTED7 = 402; const DO_NOT_CONVERTED9 = 403; diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/hashbang/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/hashbang/__snapshots__/output.snap.txt index 2b0e373abbfb..3033d4f0fddd 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/hashbang/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/hashbang/__snapshots__/output.snap.txt @@ -14,7 +14,7 @@ console.log("index", _lib__WEBPACK_IMPORTED_MODULE_0__.foo); "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - foo: function() { return foo; } + foo: () => (foo) }); //#!/usr/bin/env node diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/provide/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/provide/__snapshots__/output.snap.txt index 182aed505e22..987b4d0fd52f 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/provide/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-javascript/provide/__snapshots__/output.snap.txt @@ -22,7 +22,7 @@ function a() { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); const lib = { get: () => { diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/__snapshots__/output.snap.txt index b22c926ddff4..b537eec7d08b 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-wasm/imports-multiple/__snapshots__/output.snap.txt @@ -25,8 +25,8 @@ var __webpack_exports__ = (__webpack_exec__("./index.js")); __webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - getNumber: function() { return getNumber; }, - result: function() { return result; } + getNumber: () => (getNumber), + result: () => (result) }); /* ESM import */var _wasm_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./wasm.wasm"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_wasm_wasm__WEBPACK_IMPORTED_MODULE_0__]); @@ -46,7 +46,7 @@ __webpack_async_result__(); __webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - getNumber: function() { return getNumber; } + getNumber: () => (getNumber) }); /* ESM import */var _wasm_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./wasm.wasm"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_wasm_wasm__WEBPACK_IMPORTED_MODULE_0__]); diff --git a/packages/rspack-test-tools/tests/builtinCases/rspack/dynamic-import/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/rspack/dynamic-import/__snapshots__/output.snap.txt index 8d01898a4ac3..ca461c9a8b6c 100644 --- a/packages/rspack-test-tools/tests/builtinCases/rspack/dynamic-import/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/rspack/dynamic-import/__snapshots__/output.snap.txt @@ -4,7 +4,7 @@ "./child/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = "a"; @@ -20,7 +20,7 @@ const a = "a"; "./child/b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - b: function() { return b; } + b: () => (b) }); const b = "b"; diff --git a/packages/rspack-test-tools/tests/builtinCases/samples/mangle-exports/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/samples/mangle-exports/__snapshots__/output.snap.txt index 144cc64cc246..0b247beb363c 100644 --- a/packages/rspack-test-tools/tests/builtinCases/samples/mangle-exports/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/samples/mangle-exports/__snapshots__/output.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - K: function() { return answer; } + K: () => (answer) }); const answer = 103330; @@ -18,7 +18,7 @@ _lib__WEBPACK_IMPORTED_MODULE_0__/* .answer */.K; }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - K: function() { return /* reexport safe */ _answer__WEBPACK_IMPORTED_MODULE_0__.K; } + K: () => (/* reexport safe */ _answer__WEBPACK_IMPORTED_MODULE_0__.K) }); /* ESM import */var _answer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./answer.js"); diff --git a/packages/rspack-test-tools/tests/builtinCases/swc-loader/minify/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/swc-loader/minify/__snapshots__/output.snap.txt index 7024748be625..4e688c279c78 100644 --- a/packages/rspack-test-tools/tests/builtinCases/swc-loader/minify/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/swc-loader/minify/__snapshots__/output.snap.txt @@ -4,8 +4,8 @@ "./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - Button: function() { return Button; }, - button: function() { return button; } + Button: () => (Button), + button: () => (button) }); /*! Legal Comment */ // normal comment const Button = ()=>/*#__PURE__*/ jsx('button', {}); diff --git a/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/index.js b/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/index.js index 04d39e0d119b..9ac71ab4a068 100644 --- a/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/index.js +++ b/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/index.js @@ -3,5 +3,5 @@ import { A } from './b.js'; it("should not generate duplicated ESM exports when using named exports and named exports from", () => { A; let file = fs.readFileSync(__filename, "utf-8") - expect(file.split(`A: function() { return /* reexport safe */`)).toHaveLength(3) + expect(file.split(`A: () => (/* reexport safe */`)).toHaveLength(3) }) diff --git a/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/rspack.config.js b/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/rspack.config.js index f1afd4c151e1..5f638a51e8e4 100644 --- a/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/rspack.config.js +++ b/packages/rspack-test-tools/tests/configCases/parsing/rspack-issue-6934/rspack.config.js @@ -1,3 +1,3 @@ module.exports = { - mode: "development" + mode: "development", } diff --git a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/duplicate/output.snap.txt b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/duplicate/output.snap.txt index 3a2196d84c8b..fccd48c98dc4 100644 --- a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/duplicate/output.snap.txt +++ b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/duplicate/output.snap.txt @@ -46,11 +46,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -60,7 +60,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -70,10 +70,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. diff --git a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/request/output.snap.txt b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/request/output.snap.txt index d52cca5667ed..6f2e2681842b 100644 --- a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/request/output.snap.txt +++ b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/request/output.snap.txt @@ -41,11 +41,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -55,7 +55,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -65,10 +65,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. diff --git a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/resource/output.snap.txt b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/resource/output.snap.txt index 830103cbf730..c381d29473db 100644 --- a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/resource/output.snap.txt +++ b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#afterResolve/resource/output.snap.txt @@ -41,11 +41,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -55,7 +55,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -65,10 +65,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. diff --git a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/output.snap.txt b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/output.snap.txt index cec5dc81a4c5..ec0b61ada61f 100644 --- a/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/output.snap.txt +++ b/packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/output.snap.txt @@ -41,11 +41,11 @@ return module.exports; // webpack/runtime/compat_get_default_export (() => { // getDefaultExport function for compatibility with non-ESM modules -__webpack_require__.n = function (module) { +__webpack_require__.n = (module) => { var getter = module && module.__esModule ? - function () { return module['default']; } : - function () { return module; }; - __webpack_require__.d(getter, { a: getter }); + () => (module['default']) : + () => (module) + __webpack_require__.d(getter, { a: getter }); return getter; }; @@ -55,7 +55,7 @@ __webpack_require__.n = function (module) { })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -65,10 +65,7 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); /************************************************************************/ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. diff --git a/packages/rspack-test-tools/tests/hotCases/asset/parser-and-generator-states/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/asset/parser-and-generator-states/__snapshots__/web/1.snap.txt index 2bd2f713c711..86cbe1261698 100644 --- a/packages/rspack-test-tools/tests/hotCases/asset/parser-and-generator-states/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/asset/parser-and-generator-states/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 696 +- Update: main.LAST_HASH.hot-update.js, size: 663 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _logo_svg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./logo.svg */ "./logo.svg"); @@ -47,9 +47,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import-webpackhot/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import-webpackhot/__snapshots__/web/1.snap.txt index 5b4bd78acb22..96e3ec62a7ba 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import-webpackhot/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import-webpackhot/__snapshots__/web/1.snap.txt @@ -8,9 +8,9 @@ - Bundle: chunk2_js.chunk.CURRENT_HASH.js - Bundle: chunk_js.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 51 -- Update: chunk2_js.LAST_HASH.hot-update.js, size: 303 -- Update: chunk_js.LAST_HASH.hot-update.js, size: 302 -- Update: main.LAST_HASH.hot-update.js, size: 201 +- Update: chunk2_js.LAST_HASH.hot-update.js, size: 288 +- Update: chunk_js.LAST_HASH.hot-update.js, size: 287 +- Update: main.LAST_HASH.hot-update.js, size: 183 ## Manifest @@ -39,7 +39,7 @@ self["webpackHotUpdate"]('chunk2_js', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -66,7 +66,7 @@ self["webpackHotUpdate"]('chunk_js', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -92,9 +92,7 @@ var value = 2; self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import/__snapshots__/web/1.snap.txt index 55f845199d7e..d1d58b1e0976 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/accept-system-import/__snapshots__/web/1.snap.txt @@ -8,9 +8,9 @@ - Bundle: chunk2_js.chunk.CURRENT_HASH.js - Bundle: chunk_js.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 51 -- Update: chunk2_js.LAST_HASH.hot-update.js, size: 303 -- Update: chunk_js.LAST_HASH.hot-update.js, size: 302 -- Update: main.LAST_HASH.hot-update.js, size: 201 +- Update: chunk2_js.LAST_HASH.hot-update.js, size: 288 +- Update: chunk_js.LAST_HASH.hot-update.js, size: 287 +- Update: main.LAST_HASH.hot-update.js, size: 183 ## Manifest @@ -39,7 +39,7 @@ self["webpackHotUpdate"]('chunk2_js', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -66,7 +66,7 @@ self["webpackHotUpdate"]('chunk_js', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -92,9 +92,7 @@ var value = 2; self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/1.snap.txt index f320ad2ec4b6..b3ef2640bf26 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 39 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/2.snap.txt index 8605353286e1..ce38b3f00085 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 511 +- Update: main.LAST_HASH.hot-update.js, size: 493 ## Manifest @@ -47,9 +47,7 @@ module.exports = __webpack_require__.p + "98396dbfd5c74c34.png"; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/3.snap.txt index 531c6d956953..56c38c3182e0 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/asset/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 39 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 4; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/ensure-chunk-change-to-promise-all/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/ensure-chunk-change-to-promise-all/__snapshots__/web/1.snap.txt index c7b0d8f9f4c3..103ebf0c7c9c 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/ensure-chunk-change-to-promise-all/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/ensure-chunk-change-to-promise-all/__snapshots__/web/1.snap.txt @@ -8,8 +8,8 @@ - Bundle: file_js.chunk.CURRENT_HASH.js - Bundle: vendors-node_modules_vue_js.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 94 -- Update: file_js.LAST_HASH.hot-update.js, size: 448 -- Update: main.LAST_HASH.hot-update.js, size: 715 +- Update: file_js.LAST_HASH.hot-update.js, size: 433 +- Update: main.LAST_HASH.hot-update.js, size: 682 ## Manifest @@ -38,7 +38,7 @@ self["webpackHotUpdate"]('file_js', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - Vue: function() { return /* reexport safe */ vue__WEBPACK_IMPORTED_MODULE_0__.Vue; } + Vue: () => (/* reexport safe */ vue__WEBPACK_IMPORTED_MODULE_0__.Vue) }); /* ESM import */var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue.js"); @@ -66,7 +66,7 @@ self["webpackHotUpdate"]('main', { "./chunk.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - test: function() { return test; } + test: () => (test) }); function test(count) { return Promise.all(/*! import() */ [__webpack_require__.e("vendors-node_modules_vue_js"), __webpack_require__.e("file_js")]).then(__webpack_require__.bind(__webpack_require__, /*! ./file */ "./file.js")).then(({ React, Vue }) => count === 0 ? React : Vue) @@ -78,9 +78,7 @@ function test(count) { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt index 1607da4e9847..2c683ddd9642 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt @@ -13,7 +13,7 @@ - Update: a.LAST_HASH.hot-update.js, size: 96 - Update: b.LAST_HASH.hot-update.js, size: 96 - Update: main.LAST_HASH.hot-update.js, size: 99 -- Update: runtime.LAST_HASH.hot-update.js, size: 204 +- Update: runtime.LAST_HASH.hot-update.js, size: 186 ## Manifest @@ -107,9 +107,7 @@ module.exports = 2; self["webpackHotUpdate"]('runtime', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt index 46d4cd6c677e..40f942230670 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt @@ -13,7 +13,7 @@ - Update: a.LAST_HASH.hot-update.js, size: 96 - Update: b.LAST_HASH.hot-update.js, size: 96 - Update: main.LAST_HASH.hot-update.js, size: 99 -- Update: runtime.LAST_HASH.hot-update.js, size: 204 +- Update: runtime.LAST_HASH.hot-update.js, size: 186 ## Manifest @@ -107,9 +107,7 @@ module.exports = 3; self["webpackHotUpdate"]('runtime', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt index bec9759ccc22..7d0b7a1b4c46 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt @@ -13,7 +13,7 @@ - Update: a.LAST_HASH.hot-update.js, size: 96 - Update: b.LAST_HASH.hot-update.js, size: 96 - Update: main.LAST_HASH.hot-update.js, size: 99 -- Update: runtime.LAST_HASH.hot-update.js, size: 204 +- Update: runtime.LAST_HASH.hot-update.js, size: 186 ## Manifest @@ -107,9 +107,7 @@ module.exports = 4; self["webpackHotUpdate"]('runtime', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/1.snap.txt index aad9c663bfe1..cb6e60d47af7 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/1.snap.txt @@ -10,9 +10,9 @@ - Manifest: a.LAST_HASH.hot-update.json, size: 35 - Manifest: b.LAST_HASH.hot-update.json, size: 35 - Manifest: main.LAST_HASH.hot-update.json, size: 35 -- Update: a.LAST_HASH.hot-update.js, size: 246 -- Update: b.LAST_HASH.hot-update.js, size: 246 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: a.LAST_HASH.hot-update.js, size: 228 +- Update: b.LAST_HASH.hot-update.js, size: 228 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -62,9 +62,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -94,9 +92,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -126,9 +122,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/2.snap.txt index 9a46334daa9c..6eeb815b4528 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/2.snap.txt @@ -10,9 +10,9 @@ - Manifest: a.LAST_HASH.hot-update.json, size: 35 - Manifest: b.LAST_HASH.hot-update.json, size: 35 - Manifest: main.LAST_HASH.hot-update.json, size: 35 -- Update: a.LAST_HASH.hot-update.js, size: 246 -- Update: b.LAST_HASH.hot-update.js, size: 246 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: a.LAST_HASH.hot-update.js, size: 228 +- Update: b.LAST_HASH.hot-update.js, size: 228 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -62,9 +62,7 @@ module.exports = 3; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -94,9 +92,7 @@ module.exports = 3; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -126,9 +122,7 @@ module.exports = 3; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/3.snap.txt index c846eb51f690..feb9d5864d7f 100644 --- a/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/chunk/multi-chunk/__snapshots__/web/3.snap.txt @@ -10,9 +10,9 @@ - Manifest: a.LAST_HASH.hot-update.json, size: 35 - Manifest: b.LAST_HASH.hot-update.json, size: 35 - Manifest: main.LAST_HASH.hot-update.json, size: 35 -- Update: a.LAST_HASH.hot-update.js, size: 246 -- Update: b.LAST_HASH.hot-update.js, size: 246 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: a.LAST_HASH.hot-update.js, size: 228 +- Update: b.LAST_HASH.hot-update.js, size: 228 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -62,9 +62,7 @@ module.exports = 4; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -94,9 +92,7 @@ module.exports = 4; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -126,9 +122,7 @@ module.exports = 4; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept-webpackhot/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept-webpackhot/__snapshots__/web/1.snap.txt index bbc38b9c4151..80206c491363 100644 --- a/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept-webpackhot/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept-webpackhot/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 529 +- Update: main.LAST_HASH.hot-update.js, size: 496 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("ok2"); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept/__snapshots__/web/1.snap.txt index 69ad0c5b8b6a..4664fd7e1adc 100644 --- a/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/code-generation/this-in-accept/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 529 +- Update: main.LAST_HASH.hot-update.js, size: 496 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("ok2"); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/context/request-position/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/context/request-position/__snapshots__/web/1.snap.txt index 7f8e290f292b..084fdabc29bd 100644 --- a/packages/rspack-test-tools/tests/hotCases/context/request-position/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/context/request-position/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ - Bundle: bundle.js - Bundle: lib_a_js.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 616 +- Update: main.LAST_HASH.hot-update.js, size: 583 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - fn: function() { return fn; } + fn: () => (fn) }); const fn = async function () { const name = "a"; @@ -50,9 +50,7 @@ const fn = async function () { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/css/css-extract/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/css-extract/__snapshots__/web/1.snap.txt index 0c412a7c43c0..6cebadd5d7bc 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/css-extract/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/css-extract/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 1128 +- Update: main.LAST_HASH.hot-update.js, size: 1080 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./entry.js": (function (module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _index_module_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index.module.css */ "./index.module.css"); @@ -49,7 +49,7 @@ module.hot.accept(); "./index.module.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); // extracted by css-extract-rspack-plugin /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"bar":"_Alo8UbXpU8DX8Ym"}); @@ -59,9 +59,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/css/css-loading-unique-name/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/css-loading-unique-name/__snapshots__/web/1.snap.txt index f8cbb28133e5..d90e9b3d3b5e 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/css-loading-unique-name/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/css-loading-unique-name/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 365 +- Update: main.LAST_HASH.hot-update.js, size: 347 ## Manifest @@ -42,9 +42,7 @@ module.hot.accept(); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/css/css-modules/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/css-modules/__snapshots__/web/1.snap.txt index a4dc6e50bbf9..e936a2ded576 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/css-modules/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/css-modules/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 725 +- Update: main.LAST_HASH.hot-update.js, size: 707 ## Manifest @@ -52,9 +52,7 @@ __webpack_require__.r(module.exports = exports); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/__snapshots__/web/1.snap.txt index 8fc9f2a8c3fc..645f5ad6089d 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 827 +- Update: main.LAST_HASH.hot-update.js, size: 809 ## Manifest @@ -53,9 +53,7 @@ __webpack_require__.r(module.exports = exports); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/__snapshots__/web/2.snap.txt index cc785520d3b3..cb598abb9afb 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/recovery-cacheable/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.hot-update.js, size: 1059 +- Update: main.hot-update.js, size: 1041 ## Manifest @@ -63,9 +63,7 @@ __webpack_require__.r(__webpack_exports__); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/css/recovery/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/css/recovery/__snapshots__/web/2.snap.txt index 441e4d510c94..27b594679c10 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/recovery/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/css/recovery/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.hot-update.js, size: 6905 +- Update: main.hot-update.js, size: 6887 ## Manifest @@ -289,9 +289,7 @@ __webpack_require__.r(__webpack_exports__); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/determinism/issue-10174/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/determinism/issue-10174/__snapshots__/web/1.snap.txt index 591e3b7d3565..223d698b9358 100644 --- a/packages/rspack-test-tools/tests/hotCases/determinism/issue-10174/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/determinism/issue-10174/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 522 +- Update: main.LAST_HASH.hot-update.js, size: 489 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./hot.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt index 933aaee006d9..4b48a32d1720 100644 --- a/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt @@ -8,7 +8,7 @@ - Bundle: chunk1_js.chunk.CURRENT_HASH.js - Manifest: [runtime of chunk2_js].LAST_HASH.hot-update.json, size: 65 - Manifest: main.LAST_HASH.hot-update.json, size: 41 -- Update: main.LAST_HASH.hot-update.js, size: 18282 +- Update: main.LAST_HASH.hot-update.js, size: 18249 ## Manifest @@ -46,7 +46,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (42); @@ -56,9 +56,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); // webpack/runtime/jsonp_chunk_loading diff --git a/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared/__snapshots__/web/1.snap.txt index 2feba367b533..c079a2cbc94e 100644 --- a/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ - Bundle: bundle.js - Bundle: chunk1_js.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 52 -- Update: main.LAST_HASH.hot-update.js, size: 526 +- Update: main.LAST_HASH.hot-update.js, size: 493 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (42); @@ -46,9 +46,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/decline-webpackhot/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/decline-webpackhot/__snapshots__/web/1.snap.txt index 20cb2e615bc2..2accda3bde42 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/decline-webpackhot/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/decline-webpackhot/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 520 +- Update: main.LAST_HASH.hot-update.js, size: 487 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/decline/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/decline/__snapshots__/web/1.snap.txt index db405ce390f2..d2e5d713f153 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/decline/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/decline/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 520 +- Update: main.LAST_HASH.hot-update.js, size: 487 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/events/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/events/__snapshots__/web/1.snap.txt index f0c626a1e5de..313fffdd2882 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/events/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/events/__snapshots__/web/1.snap.txt @@ -12,7 +12,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 2569 +- Update: main.LAST_HASH.hot-update.js, size: 2446 ## Manifest @@ -47,7 +47,7 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -56,7 +56,7 @@ __webpack_require__.d(__webpack_exports__, { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -65,7 +65,7 @@ __webpack_require__.d(__webpack_exports__, { "./e.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -74,7 +74,7 @@ __webpack_require__.d(__webpack_exports__, { "./g.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -83,7 +83,7 @@ __webpack_require__.d(__webpack_exports__, { "./i.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); throw new Error("Error while loading module i"); @@ -93,7 +93,7 @@ throw new Error("Error while loading module i"); "./j.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); throw new Error("Error while loading module j"); @@ -103,7 +103,7 @@ throw new Error("Error while loading module j"); "./l.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); throw new Error("Error while loading module l"); @@ -114,9 +114,7 @@ throw new Error("Error while loading module l"); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/self-decline/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/self-decline/__snapshots__/web/1.snap.txt index 27de30714da5..219da966df19 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/self-decline/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/self-decline/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 520 +- Update: main.LAST_HASH.hot-update.js, size: 487 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/1.snap.txt index bf440c850686..405da34925e3 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 520 +- Update: main.LAST_HASH.hot-update.js, size: 487 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -46,9 +46,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/2.snap.txt index 55a650d93e5b..a7f4d6d3b3c4 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/2.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 520 +- Update: main.LAST_HASH.hot-update.js, size: 487 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -46,9 +46,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/3.snap.txt index 2a5ccc0dd752..d1ffb228e190 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted-ignored/__snapshots__/web/3.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 837 +- Update: main.LAST_HASH.hot-update.js, size: 789 ## Manifest @@ -37,7 +37,7 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (4); @@ -46,7 +46,7 @@ __webpack_require__.d(__webpack_exports__, { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -56,9 +56,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted/__snapshots__/web/1.snap.txt index 81606b838d3e..fca4806807b1 100644 --- a/packages/rspack-test-tools/tests/hotCases/errors/unaccepted/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/errors/unaccepted/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 520 +- Update: main.LAST_HASH.hot-update.js, size: 487 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/import-meta-webpack-hot/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/import-meta-webpack-hot/__snapshots__/web/1.snap.txt index e12621b513b7..f113c771b16a 100644 --- a/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/import-meta-webpack-hot/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/import-meta-webpack-hot/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 466 +- Update: main.LAST_HASH.hot-update.js, size: 433 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./node_modules/dep1/file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -45,9 +45,7 @@ var value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/module-hot/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/module-hot/__snapshots__/web/1.snap.txt index 259de692d461..af6747da8905 100644 --- a/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/module-hot/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/esm-dependency-import/module-hot/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 466 +- Update: main.LAST_HASH.hot-update.js, size: 433 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./node_modules/dep1/file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -45,9 +45,7 @@ var value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-default/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-default/__snapshots__/web/1.snap.txt index 111bf0bd8db2..f8cd0426dae5 100644 --- a/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-default/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-default/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-multiple/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-multiple/__snapshots__/web/1.snap.txt index f0812282d018..a8f14fa314c0 100644 --- a/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-multiple/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/harmony/auto-import-multiple/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 513 +- Update: main.LAST_HASH.hot-update.js, size: 480 ## Manifest @@ -42,7 +42,7 @@ module.exports = 20; "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -52,9 +52,7 @@ var value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/harmony/auto-import/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/harmony/auto-import/__snapshots__/web/1.snap.txt index 47b5b9a45433..845b3573300e 100644 --- a/packages/rspack-test-tools/tests/hotCases/harmony/auto-import/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/harmony/auto-import/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 448 +- Update: main.LAST_HASH.hot-update.js, size: 415 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -45,9 +45,7 @@ var value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/harmony/auto-reexport/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/harmony/auto-reexport/__snapshots__/web/1.snap.txt index e74ef8d864af..fe6bff7820cd 100644 --- a/packages/rspack-test-tools/tests/hotCases/harmony/auto-reexport/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/harmony/auto-reexport/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 450 +- Update: main.LAST_HASH.hot-update.js, size: 417 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); const value = 2; @@ -45,9 +45,7 @@ const value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/harmony/cjs-analyze-changed/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/harmony/cjs-analyze-changed/__snapshots__/web/1.snap.txt index c18e94fa647c..7acd8b27bac4 100644 --- a/packages/rspack-test-tools/tests/hotCases/harmony/cjs-analyze-changed/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/harmony/cjs-analyze-changed/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 833 +- Update: main.LAST_HASH.hot-update.js, size: 800 ## Manifest @@ -42,7 +42,7 @@ exports["default"] = 1; "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _file__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./file */ "./file.js"); @@ -55,9 +55,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/1.snap.txt index 59bd0b57bb50..9412b71dc3bc 100644 --- a/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 523 +- Update: main.LAST_HASH.hot-update.js, size: 490 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/2.snap.txt index 5b72aebf9019..970bd9e57652 100644 --- a/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 523 +- Update: main.LAST_HASH.hot-update.js, size: 490 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/3.snap.txt index 70864be61974..9465926854d8 100644 --- a/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/hash/hot-index/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 522 +- Update: main.LAST_HASH.hot-update.js, size: 489 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -44,9 +44,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/1.snap.txt index 3612bbd99e18..ac0c58d9892a 100644 --- a/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 275 +- Update: main.LAST_HASH.hot-update.js, size: 257 ## Manifest @@ -40,9 +40,7 @@ module.exports = {"a":2,"b":1} },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/2.snap.txt index 36b4de027940..f4dab93deda6 100644 --- a/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 275 +- Update: main.LAST_HASH.hot-update.js, size: 257 ## Manifest @@ -40,9 +40,7 @@ module.exports = {"a":2,"b":2} },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/3.snap.txt index 91f94bf345f8..338075488610 100644 --- a/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/invalidate/conditional-accept/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 275 +- Update: main.LAST_HASH.hot-update.js, size: 257 ## Manifest @@ -40,9 +40,7 @@ module.exports = {"a":3,"b":3} },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/loader/import-module-1/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/loader/import-module-1/__snapshots__/web/1.snap.txt index 094ea9abcf69..304a9a0281dc 100644 --- a/packages/rspack-test-tools/tests/hotCases/loader/import-module-1/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/loader/import-module-1/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./loader.js!./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/loader/import-module-2/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/loader/import-module-2/__snapshots__/web/1.snap.txt index aa6ef9e670ac..b68fd250e900 100644 --- a/packages/rspack-test-tools/tests/hotCases/loader/import-module-2/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/loader/import-module-2/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 257 +- Update: main.LAST_HASH.hot-update.js, size: 239 ## Manifest @@ -39,9 +39,7 @@ module.exports = 3; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/make/clean_isolated_module/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/make/clean_isolated_module/__snapshots__/web/1.snap.txt index 78aec34b36ff..5705a3b45897 100644 --- a/packages/rspack-test-tools/tests/hotCases/make/clean_isolated_module/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/make/clean_isolated_module/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 45 -- Update: main.LAST_HASH.hot-update.js, size: 522 +- Update: main.LAST_HASH.hot-update.js, size: 489 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("a"); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/module-graph/import-order-change/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/module-graph/import-order-change/__snapshots__/web/1.snap.txt index c506401c5642..f204819a7c7b 100644 --- a/packages/rspack-test-tools/tests/hotCases/module-graph/import-order-change/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/module-graph/import-order-change/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 560 +- Update: main.LAST_HASH.hot-update.js, size: 542 ## Manifest @@ -45,9 +45,7 @@ __webpack_require__.r(__webpack_exports__); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/auto-reexport/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/auto-reexport/__snapshots__/web/1.snap.txt index e74ef8d864af..fe6bff7820cd 100644 --- a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/auto-reexport/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/auto-reexport/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 450 +- Update: main.LAST_HASH.hot-update.js, size: 417 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); const value = 2; @@ -45,9 +45,7 @@ const value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt index 1607da4e9847..2c683ddd9642 100644 --- a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/1.snap.txt @@ -13,7 +13,7 @@ - Update: a.LAST_HASH.hot-update.js, size: 96 - Update: b.LAST_HASH.hot-update.js, size: 96 - Update: main.LAST_HASH.hot-update.js, size: 99 -- Update: runtime.LAST_HASH.hot-update.js, size: 204 +- Update: runtime.LAST_HASH.hot-update.js, size: 186 ## Manifest @@ -107,9 +107,7 @@ module.exports = 2; self["webpackHotUpdate"]('runtime', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt index 46d4cd6c677e..40f942230670 100644 --- a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/2.snap.txt @@ -13,7 +13,7 @@ - Update: a.LAST_HASH.hot-update.js, size: 96 - Update: b.LAST_HASH.hot-update.js, size: 96 - Update: main.LAST_HASH.hot-update.js, size: 99 -- Update: runtime.LAST_HASH.hot-update.js, size: 204 +- Update: runtime.LAST_HASH.hot-update.js, size: 186 ## Manifest @@ -107,9 +107,7 @@ module.exports = 3; self["webpackHotUpdate"]('runtime', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt index bec9759ccc22..7d0b7a1b4c46 100644 --- a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/multi-chunk-single-runtime/__snapshots__/web/3.snap.txt @@ -13,7 +13,7 @@ - Update: a.LAST_HASH.hot-update.js, size: 96 - Update: b.LAST_HASH.hot-update.js, size: 96 - Update: main.LAST_HASH.hot-update.js, size: 99 -- Update: runtime.LAST_HASH.hot-update.js, size: 204 +- Update: runtime.LAST_HASH.hot-update.js, size: 186 ## Manifest @@ -107,9 +107,7 @@ module.exports = 4; self["webpackHotUpdate"]('runtime', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/re-export-optimization/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/re-export-optimization/__snapshots__/web/1.snap.txt index d2bbfe5a8592..c65fa2956019 100644 --- a/packages/rspack-test-tools/tests/hotCases/newTreeshaking/re-export-optimization/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/newTreeshaking/re-export-optimization/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 1172 +- Update: main.LAST_HASH.hot-update.js, size: 1124 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./bar.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ('bar'); @@ -45,7 +45,7 @@ __webpack_require__.d(__webpack_exports__, { "./entry.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _reexport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reexport */ "./foo.js"); /* ESM import */var _reexport__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./reexport */ "./bar.js"); @@ -58,9 +58,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/plugins/html/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/plugins/html/__snapshots__/web/1.snap.txt index f0c69f5a2edb..5d7b0b5f39ba 100644 --- a/packages/rspack-test-tools/tests/hotCases/plugins/html/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/plugins/html/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 449 +- Update: main.LAST_HASH.hot-update.js, size: 416 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); const value = 1; @@ -44,9 +44,7 @@ const value = 1; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/1.snap.txt index dc5ac342b96e..bd6566308cc3 100644 --- a/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 810 +- Update: main.LAST_HASH.hot-update.js, size: 747 ## Manifest @@ -35,9 +35,9 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - getError: function() { return getError; }, - id: function() { return id; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + getError: () => (getError), + id: () => (id) }); module.hot.data.store.error = false; module.hot.data.store.value = 2; @@ -52,9 +52,7 @@ throw new Error("Failed"); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt index 1f5352e1fee0..a5b274b7b2dd 100644 --- a/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 1222 +- Update: main.LAST_HASH.hot-update.js, size: 1064 ## Manifest @@ -36,9 +36,9 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - getError: function() { return getError; }, - id: function() { return id; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + getError: () => (getError), + id: () => (id) }); module.hot.data.store.error = false; module.hot.data.store.value = 4; @@ -52,21 +52,17 @@ const id = module.id; },function(__webpack_require__) { // webpack/runtime/define_property_getters (() => { - - __webpack_require__.d = function (exports, definition) { - for (var key in definition) { - if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { - Object.defineProperty(exports, key, { configurable: true, enumerable: true, get: definition[key] }); - } - } - }; - +__webpack_require__.d = (exports, definition) => { + for(var key in definition) { + if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { + Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); + } + } +}; })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/accept/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/accept/__snapshots__/web/1.snap.txt index fa9e705de20f..b986c40bef74 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/accept/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/accept/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/bubble-async/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/bubble-async/__snapshots__/web/1.snap.txt index 5698f1efc836..db70850aaa7f 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/bubble-async/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/bubble-async/__snapshots__/web/1.snap.txt @@ -8,7 +8,7 @@ - Bundle: file_js.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 38 - Update: file_js.LAST_HASH.hot-update.js, size: 102 -- Update: main.LAST_HASH.hot-update.js, size: 201 +- Update: main.LAST_HASH.hot-update.js, size: 183 ## Manifest @@ -58,9 +58,7 @@ module.exports = 2; self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/bubble-update/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/bubble-update/__snapshots__/web/1.snap.txt index 761bba4dfd75..6a8cb8e9592b 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/bubble-update/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/bubble-update/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/circular/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/circular/__snapshots__/web/1.snap.txt index cb2050149588..6a1ab92a36c8 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/circular/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/circular/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 1033 +- Update: main.LAST_HASH.hot-update.js, size: 985 ## Manifest @@ -37,7 +37,7 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var ___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ */ "./index.js"); /* ESM import */var _b__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./b */ "./b.js"); @@ -50,7 +50,7 @@ __webpack_require__.d(__webpack_exports__, { "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -60,9 +60,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/1.snap.txt index e81a2f56bf8b..f810e6d0241c 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/1.snap.txt @@ -8,7 +8,7 @@ - Bundle: b_js.CURRENT_HASH.js - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 42 -- Update: main.LAST_HASH.hot-update.js, size: 642 +- Update: main.LAST_HASH.hot-update.js, size: 609 ## Manifest @@ -37,7 +37,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.e(/*! import() */ "b_js").then(__webpack_require__.bind(__webpack_require__, /*! ./b */ "./b.js"))); @@ -47,9 +47,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/2.snap.txt index eaf7621e073b..0098b55b660d 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/2.snap.txt @@ -8,8 +8,8 @@ - Bundle: b_js.CURRENT_HASH.js - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 35 -- Update: b_js.LAST_HASH.hot-update.js, size: 381 -- Update: main.LAST_HASH.hot-update.js, size: 201 +- Update: b_js.LAST_HASH.hot-update.js, size: 366 +- Update: main.LAST_HASH.hot-update.js, size: 183 ## Manifest @@ -38,7 +38,7 @@ self["webpackHotUpdate"]('b_js', { "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("version b2"); @@ -64,9 +64,7 @@ __webpack_require__.d(__webpack_exports__, { self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/3.snap.txt index d68530b91be2..cd6d2009a6a6 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-chunk/__snapshots__/web/3.snap.txt @@ -8,7 +8,7 @@ - Bundle: a_js.CURRENT_HASH.js - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 42 -- Update: main.LAST_HASH.hot-update.js, size: 642 +- Update: main.LAST_HASH.hot-update.js, size: 609 ## Manifest @@ -37,7 +37,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.e(/*! import() */ "a_js").then(__webpack_require__.bind(__webpack_require__, /*! ./a */ "./a.js"))); @@ -47,9 +47,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/1.snap.txt index acdcf524d905..2b5726181a2f 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 36 -- Update: main.LAST_HASH.hot-update.js, size: 761 +- Update: main.LAST_HASH.hot-update.js, size: 728 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -52,9 +52,7 @@ __webpack_require__.r(__webpack_exports__); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/2.snap.txt index f02537764d6d..037197067448 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/dispose-removed-module/__snapshots__/web/2.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 36 -- Update: main.LAST_HASH.hot-update.js, size: 899 +- Update: main.LAST_HASH.hot-update.js, size: 851 ## Manifest @@ -37,7 +37,7 @@ self["webpackHotUpdate"]('main', { "./a.js": (function (module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (module.id); @@ -45,7 +45,7 @@ __webpack_require__.d(__webpack_exports__, { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return /* reexport safe */ _a__WEBPACK_IMPORTED_MODULE_0__["default"]; } + "default": () => (/* reexport safe */ _a__WEBPACK_IMPORTED_MODULE_0__["default"]) }); /* ESM import */var _a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a */ "./a.js"); @@ -55,9 +55,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/hmr-circular/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/hmr-circular/__snapshots__/web/1.snap.txt index 514de241d952..dd0092cb5a0f 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/hmr-circular/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/hmr-circular/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 45 -- Update: main.LAST_HASH.hot-update.js, size: 537 +- Update: main.LAST_HASH.hot-update.js, size: 504 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./entry.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("new_entry.js"); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/import-after-download/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/import-after-download/__snapshots__/web/1.snap.txt index 8606311ea0dc..cc4c7ce12369 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/import-after-download/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/import-after-download/__snapshots__/web/1.snap.txt @@ -9,8 +9,8 @@ - Bundle: chunk_js.CURRENT_HASH.js - Bundle: unaffected-chunk_js.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 39 -- Update: chunk_js.LAST_HASH.hot-update.js, size: 379 -- Update: main.LAST_HASH.hot-update.js, size: 523 +- Update: chunk_js.LAST_HASH.hot-update.js, size: 364 +- Update: main.LAST_HASH.hot-update.js, size: 490 ## Manifest @@ -39,7 +39,7 @@ self["webpackHotUpdate"]('chunk_js', { "./inner.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (20); @@ -66,7 +66,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -76,9 +76,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/replace-runtime-module/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/replace-runtime-module/__snapshots__/web/1.snap.txt index 82cca6263439..8e52fec8d2c3 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/replace-runtime-module/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/replace-runtime-module/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ - Bundle: b.chunk.CURRENT_HASH.js - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 39 -- Update: main.LAST_HASH.hot-update.js, size: 643 +- Update: main.LAST_HASH.hot-update.js, size: 610 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.e(/*! import() | b */ "b").then(__webpack_require__.bind(__webpack_require__, /*! ./b */ "./b.js"))); @@ -46,9 +46,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/require-disposed-module-warning/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/require-disposed-module-warning/__snapshots__/web/1.snap.txt index d62ab6eb35fd..9536ab8757a0 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/require-disposed-module-warning/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/require-disposed-module-warning/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 36 -- Update: main.LAST_HASH.hot-update.js, size: 676 +- Update: main.LAST_HASH.hot-update.js, size: 643 ## Manifest @@ -36,7 +36,7 @@ self["webpackHotUpdate"]('main', { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("b"); @@ -51,9 +51,7 @@ module.exports = () => __webpack_require__(/*! ./b */ "./b.js"); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-and-dispose/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-and-dispose/__snapshots__/web/1.snap.txt index 320b4a9e4660..c3f62b8a43e7 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-and-dispose/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-and-dispose/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 258 +- Update: main.LAST_HASH.hot-update.js, size: 240 ## Manifest @@ -41,9 +41,7 @@ module.hot.data.callback(); },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-factory/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-factory/__snapshots__/web/1.snap.txt index 736a897b2c12..8ff9393dbdaa 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-factory/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/self-accept-factory/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 521 +- Update: main.LAST_HASH.hot-update.js, size: 503 ## Manifest @@ -51,9 +51,7 @@ module.exports = 1; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-modules/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-modules/__snapshots__/web/1.snap.txt index ef61ec4aaa1c..ac2ff27e0329 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-modules/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-modules/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 311 +- Update: main.LAST_HASH.hot-update.js, size: 293 ## Manifest @@ -47,9 +47,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/1.snap.txt index b9cba5e2c246..f790cbdb2333 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/2.snap.txt index ee2117a8e74d..8669a58c642c 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 3; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/3.snap.txt index 81b3d8d2a46c..02a5ae000eec 100644 --- a/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/runtime/update-multiple-times/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 4; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/1.snap.txt index 864589267b4a..357a2678310e 100644 --- a/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 523 +- Update: main.LAST_HASH.hot-update.js, size: 490 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/2.snap.txt index fcd8b95b3f70..9c7fa5cb3b6d 100644 --- a/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 523 +- Update: main.LAST_HASH.hot-update.js, size: 490 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/3.snap.txt index d0dd9e2a8a6a..2d8d461c9800 100644 --- a/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/source-map/disable/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 522 +- Update: main.LAST_HASH.hot-update.js, size: 489 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -44,9 +44,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/1.snap.txt index fc5ed8ed785a..396555151930 100644 --- a/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 577 +- Update: main.LAST_HASH.hot-update.js, size: 544 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/2.snap.txt index 6798c0012285..d26840cb9fdc 100644 --- a/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 577 +- Update: main.LAST_HASH.hot-update.js, size: 544 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -45,9 +45,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/3.snap.txt index bb725fcdd901..12dc894784bc 100644 --- a/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/source-map/enable/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 576 +- Update: main.LAST_HASH.hot-update.js, size: 543 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -44,9 +44,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/stats/chunks/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/stats/chunks/__snapshots__/web/1.snap.txt index 19af95c801a5..48a653a2709b 100644 --- a/packages/rspack-test-tools/tests/hotCases/stats/chunks/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/stats/chunks/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 522 +- Update: main.LAST_HASH.hot-update.js, size: 489 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -44,9 +44,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/status/accept/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/status/accept/__snapshots__/web/1.snap.txt index fa9e705de20f..b986c40bef74 100644 --- a/packages/rspack-test-tools/tests/hotCases/status/accept/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/status/accept/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 249 +- Update: main.LAST_HASH.hot-update.js, size: 231 ## Manifest @@ -40,9 +40,7 @@ module.exports = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/status/check/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/status/check/__snapshots__/web/1.snap.txt index e60ba0c675d7..31ef7dc788ec 100644 --- a/packages/rspack-test-tools/tests/hotCases/status/check/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/status/check/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 448 +- Update: main.LAST_HASH.hot-update.js, size: 415 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./file.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); var value = 2; @@ -45,9 +45,7 @@ var value = 2; },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/unexpected-invalidation/used-exports/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/unexpected-invalidation/used-exports/__snapshots__/web/1.snap.txt index e4a6bdb766d2..a76dcce8313b 100644 --- a/packages/rspack-test-tools/tests/hotCases/unexpected-invalidation/used-exports/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/unexpected-invalidation/used-exports/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 610 +- Update: main.LAST_HASH.hot-update.js, size: 577 ## Manifest @@ -35,7 +35,7 @@ self["webpackHotUpdate"]('main', { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return /* reexport safe */ _subject__WEBPACK_IMPORTED_MODULE_0__.def; } + "default": () => (/* reexport safe */ _subject__WEBPACK_IMPORTED_MODULE_0__.def) }); /* ESM import */var _subject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subject */ "./subject.js"); @@ -46,9 +46,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/1.snap.txt index 3dce7bf06334..1093b64e999c 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/1.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/2.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/2.snap.txt index c55def59c49c..c11f2210795b 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/2.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/2.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (2); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/3.snap.txt index 00a993111624..80a38ceb0017 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/3.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (3); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/4.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/4.snap.txt index a23b3ed6068c..171c81517c7e 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/4.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/4.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (4); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (4); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (4); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (4); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/5.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/5.snap.txt index 8c7986123644..9cbc9707bb62 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/5.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/5.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (5); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (5); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (5); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (5); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/6.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/6.snap.txt index 12251627d733..9bb843a26b2f 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/6.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/6.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (6); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (6); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (6); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (6); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/7.snap.txt b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/7.snap.txt index de154d56ff66..7ece424a4fa7 100644 --- a/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/7.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/worker/issue-5597/__snapshots__/web/7.snap.txt @@ -14,10 +14,10 @@ - Manifest: [runtime of workerA_js].LAST_HASH.hot-update.json, size: 62 - Manifest: [runtime of workerB_js].LAST_HASH.hot-update.json, size: 62 - Manifest: main.LAST_HASH.hot-update.json, size: 62 -- Update: main.LAST_HASH.hot-update.js, size: 201 -- Update: shared.LAST_HASH.hot-update.js, size: 703 -- Update: workerA_js.LAST_HASH.hot-update.js, size: 532 -- Update: workerB_js.LAST_HASH.hot-update.js, size: 532 +- Update: main.LAST_HASH.hot-update.js, size: 183 +- Update: shared.LAST_HASH.hot-update.js, size: 673 +- Update: workerA_js.LAST_HASH.hot-update.js, size: 499 +- Update: workerB_js.LAST_HASH.hot-update.js, size: 499 ## Manifest @@ -61,9 +61,7 @@ self["webpackHotUpdate"]('main', {},function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -89,7 +87,7 @@ self["webpackHotUpdate"]('shared', { "./moduleAs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (7); @@ -98,7 +96,7 @@ __webpack_require__.d(__webpack_exports__, { "./moduleBs.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (7); @@ -125,7 +123,7 @@ self["webpackHotUpdate"]('workerA_js', { "./moduleA.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (7); @@ -135,9 +133,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); @@ -162,7 +158,7 @@ self["webpackHotUpdate"]('workerB_js', { "./moduleB.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (7); @@ -172,9 +168,7 @@ __webpack_require__.d(__webpack_exports__, { },function(__webpack_require__) { // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "CURRENT_HASH"; -}; +__webpack_require__.h = () => ("CURRENT_HASH") })(); diff --git a/packages/rspack-test-tools/tests/statsAPICases/asset-info.js b/packages/rspack-test-tools/tests/statsAPICases/asset-info.js index 86198f61062e..26749fc4b381 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/asset-info.js +++ b/packages/rspack-test-tools/tests/statsAPICases/asset-info.js @@ -91,7 +91,7 @@ module.exports = { isOverSizeLimit: false, name: main.js, related: Array [], - size: 2759, + size: 2654, type: asset, }, ] diff --git a/packages/rspack-test-tools/tests/statsAPICases/build-time-executed-runtime.js b/packages/rspack-test-tools/tests/statsAPICases/build-time-executed-runtime.js index 6a826581b409..f61c71252655 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/build-time-executed-runtime.js +++ b/packages/rspack-test-tools/tests/statsAPICases/build-time-executed-runtime.js @@ -72,9 +72,9 @@ module.exports = { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 305, + size: 267, sizes: Object { - runtime: 305, + runtime: 267, }, type: module, usedExports: null, @@ -112,9 +112,9 @@ module.exports = { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 290, + size: 285, sizes: Object { - runtime: 290, + runtime: 285, }, type: module, usedExports: null, @@ -152,9 +152,9 @@ module.exports = { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 107, + size: 88, sizes: Object { - runtime: 107, + runtime: 88, }, type: module, usedExports: null, @@ -192,9 +192,9 @@ module.exports = { preOrderIndex: undefined, providedExports: Array [], reasons: Array [], - size: 280, + size: 275, sizes: Object { - runtime: 280, + runtime: 275, }, type: module, usedExports: null, diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js b/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js index 563e4231d3d2..24ed3d4b0b0a 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js @@ -26,17 +26,17 @@ module.exports = { assets: Array [ Object { name: main.js, - size: 14505, + size: 14017, }, ], - assetsSize: 14505, + assetsSize: 14017, auxiliaryAssets: Array [ Object { name: main.js.map, - size: 684, + size: 676, }, ], - auxiliaryAssetsSize: 684, + auxiliaryAssetsSize: 676, childAssets: Object {}, children: Object { prefetch: Array [ @@ -44,10 +44,10 @@ module.exports = { assets: Array [ Object { name: chunk.js, - size: 858, + size: 843, }, ], - assetsSize: 858, + assetsSize: 843, auxiliaryAssets: Array [ Object { name: chunk.js.map, @@ -77,10 +77,10 @@ module.exports = { assets: Array [ Object { name: chunk.js, - size: 858, + size: 843, }, ], - assetsSize: 858, + assetsSize: 843, auxiliaryAssets: Array [ Object { name: chunk.js.map, @@ -215,17 +215,17 @@ module.exports = { assets: Array [ Object { name: main.js, - size: 14505, + size: 14017, }, ], - assetsSize: 14505, + assetsSize: 14017, auxiliaryAssets: Array [ Object { name: main.js.map, - size: 684, + size: 676, }, ], - auxiliaryAssetsSize: 684, + auxiliaryAssetsSize: 676, childAssets: Object {}, children: Object { prefetch: Array [ @@ -233,10 +233,10 @@ module.exports = { assets: Array [ Object { name: chunk.js, - size: 858, + size: 843, }, ], - assetsSize: 858, + assetsSize: 843, auxiliaryAssets: Array [ Object { name: chunk.js.map, diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunks.js b/packages/rspack-test-tools/tests/statsAPICases/chunks.js index 9c45f25b95ac..dcbcbd66b843 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunks.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunks.js @@ -235,7 +235,7 @@ module.exports = { size: 85, sizes: Object { javascript: 85, - runtime: 9129, + runtime: 8795, }, type: chunk, }, diff --git a/packages/rspack-test-tools/tests/statsAPICases/exports.js b/packages/rspack-test-tools/tests/statsAPICases/exports.js index 6fec2a418f26..5cae8c234d51 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/exports.js +++ b/packages/rspack-test-tools/tests/statsAPICases/exports.js @@ -24,9 +24,9 @@ module.exports = { expect(typeof stats?.hash).toBe("string"); expect(stats?.toJson(statsOptions)).toMatchSnapshot(); expect(stats?.toString(statsOptions)).toMatchInlineSnapshot(` - asset main.js 441 bytes [emitted] (name: main) + asset main.js 412 bytes [emitted] (name: main) orphan modules 192 bytes [orphan] 4 modules - runtime modules 677 bytes 3 modules + runtime modules 648 bytes 3 modules ./fixtures/esm/abc.js + 3 modules 192 bytes [code generated] [no exports] [no exports used] diff --git a/packages/rspack-test-tools/tests/statsAPICases/nested-modules.js b/packages/rspack-test-tools/tests/statsAPICases/nested-modules.js index 0d4aabcbe590..9d518ddc898f 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/nested-modules.js +++ b/packages/rspack-test-tools/tests/statsAPICases/nested-modules.js @@ -286,9 +286,9 @@ module.exports = { `); expect(stats?.toString(statsOptions).replace(/\d+ ms/g, "X ms")) .toMatchInlineSnapshot(` - asset main.js 441 bytes [emitted] (name: main) + asset main.js 412 bytes [emitted] (name: main) orphan modules 192 bytes [orphan] 4 modules - runtime modules 677 bytes 3 modules + runtime modules 648 bytes 3 modules ./fixtures/esm/abc.js + 3 modules 192 bytes [code generated] | orphan modules 192 bytes [orphan] 4 modules Rspack compiled successfully diff --git a/packages/rspack-test-tools/tests/treeShakingCases/array-side-effects/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/array-side-effects/__snapshots__/treeshaking.snap.txt index 4eb254e91048..d03ffdd30e28 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/array-side-effects/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/array-side-effects/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - app: function() { return app; } + app: () => (app) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); @@ -23,7 +23,7 @@ app.prototype.result = _lib__WEBPACK_IMPORTED_MODULE_0__.result; }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - result: function() { return result; } + result: () => (result) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/assign-with-side-effects/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/assign-with-side-effects/__snapshots__/treeshaking.snap.txt index d5d09ff6a628..260a7022ba10 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/assign-with-side-effects/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/assign-with-side-effects/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - app: function() { return app; } + app: () => (app) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); @@ -23,7 +23,7 @@ app.prototype.result = _lib__WEBPACK_IMPORTED_MODULE_0__.result; }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - result: function() { return result; } + result: () => (result) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/basic/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/basic/__snapshots__/treeshaking.snap.txt index 7028da6ea291..5629dd865e77 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/basic/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/basic/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - answer: function() { return answer; } + answer: () => (answer) }); const answer = 103330; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/bb/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/bb/__snapshots__/treeshaking.snap.txt index f78fdf14ecaf..488a8f95ddc7 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/bb/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/bb/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - ccc: function() { return ccc; } + ccc: () => (ccc) }); const ccc = 30; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/cjs-export-computed-property/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/cjs-export-computed-property/__snapshots__/treeshaking.snap.txt index 242d6840e5ab..ac5a7683021e 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/cjs-export-computed-property/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/cjs-export-computed-property/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./antd/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - locales: function() { return locales; } + locales: () => (locales) }); /* ESM import */var _locale_zh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./locale_zh.js"); @@ -26,7 +26,7 @@ function test() {} }), "./locale_zh.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _zh_locale__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./zh_locale.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/cjs-tree-shaking-basic/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/cjs-tree-shaking-basic/__snapshots__/treeshaking.snap.txt index d4db1624cf2d..abfd0d48dc6c 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/cjs-tree-shaking-basic/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/cjs-tree-shaking-basic/__snapshots__/treeshaking.snap.txt @@ -4,7 +4,7 @@ "./answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - answer: function() { return answer; } + answer: () => (answer) }); const answer = 42; @@ -21,7 +21,7 @@ __webpack_require__("./answer.js"); }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - myanswer: function() { return myanswer; } + myanswer: () => (myanswer) }); const myanswer = "anyser"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/class-extend/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/class-extend/__snapshots__/treeshaking.snap.txt index d22c931afca3..2936f8f33d85 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/class-extend/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/class-extend/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - v: function() { return v; } + v: () => (v) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); @@ -28,7 +28,7 @@ _app__WEBPACK_IMPORTED_MODULE_0__.v; }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); class Lib {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/context-module/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/context-module/__snapshots__/treeshaking.snap.txt index 9b825cc91531..629bfba25a46 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/context-module/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/context-module/__snapshots__/treeshaking.snap.txt @@ -4,7 +4,7 @@ "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); const value = "dynamic"; @@ -14,7 +14,7 @@ const value = "dynamic"; "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - value: function() { return value; } + value: () => (value) }); const value = "dynamic"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/cyclic-reference-export-all/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/cyclic-reference-export-all/__snapshots__/treeshaking.snap.txt index 6295f6dce7cb..227047cb2bf7 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/cyclic-reference-export-all/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/cyclic-reference-export-all/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./src/App.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _containers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/containers/containers.js"); @@ -21,8 +21,8 @@ const Index = () => { "./src/containers/containers.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - PlatformProvider: function() { return /* reexport safe */ _platform_container__WEBPACK_IMPORTED_MODULE_0__.PlatformProvider; }, - usePlatform: function() { return /* reexport safe */ _platform_container__WEBPACK_IMPORTED_MODULE_0__.usePlatform; } + PlatformProvider: () => (/* reexport safe */ _platform_container__WEBPACK_IMPORTED_MODULE_0__.PlatformProvider), + usePlatform: () => (/* reexport safe */ _platform_container__WEBPACK_IMPORTED_MODULE_0__.usePlatform) }); /* ESM import */var _platform_container__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/containers/platform-container/index.js"); @@ -33,8 +33,8 @@ __webpack_require__.d(__webpack_exports__, { }), "./src/containers/platform-container/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - PlatformProvider: function() { return PlatformProvider; }, - usePlatform: function() { return usePlatform; } + PlatformProvider: () => (PlatformProvider), + usePlatform: () => (usePlatform) }); const usePlatform = 3; const PlatformProvider = 1000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/default_export/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/default_export/__snapshots__/treeshaking.snap.txt index 7967a7501b4c..642301083eec 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/default_export/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/default_export/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - answer: function() { return answer; } + answer: () => (answer) }); const answer = 103330; // export default answer; @@ -12,8 +12,8 @@ const answer = 103330; }), "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return result; }, - render: function() { return render; } + "default": () => (result), + render: () => (render) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); @@ -39,8 +39,8 @@ function result() {} }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - myanswer: function() { return myanswer; }, - secret: function() { return secret; } + myanswer: () => (myanswer), + secret: () => (secret) }); /* ESM import */var _answer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./answer.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_1/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_1/__snapshots__/treeshaking.snap.txt index 8a485a1d6223..4691708c9345 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_1/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_1/__snapshots__/treeshaking.snap.txt @@ -8,7 +8,7 @@ const a = "bar"; }), "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); /* ESM import */var _bar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./bar.js"); const a = "foo"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_2/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_2/__snapshots__/treeshaking.snap.txt index 37abdf38ac80..0470212f3178 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_2/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/explicit_named_export_higher_priority_2/__snapshots__/treeshaking.snap.txt @@ -8,7 +8,7 @@ const a = "bar"; }), "./baz.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = "baz"; @@ -16,7 +16,7 @@ const a = "baz"; }), "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return /* reexport safe */ _baz__WEBPACK_IMPORTED_MODULE_0__.a; } + a: () => (/* reexport safe */ _baz__WEBPACK_IMPORTED_MODULE_0__.a) }); /* ESM import */var _baz__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./baz.js"); /* ESM import */var _bar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./bar.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/export-imported-import-all-as/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/export-imported-import-all-as/__snapshots__/treeshaking.snap.txt index 40de78eb419a..a92cb1443ad0 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/export-imported-import-all-as/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/export-imported-import-all-as/__snapshots__/treeshaking.snap.txt @@ -11,7 +11,7 @@ _answer__WEBPACK_IMPORTED_MODULE_0__; "./test.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - result: function() { return result; } + result: () => (result) }); const result = ""; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/export-named-decl-as/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/export-named-decl-as/__snapshots__/treeshaking.snap.txt index d2198c249830..93241dcc7a7e 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/export-named-decl-as/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/export-named-decl-as/__snapshots__/treeshaking.snap.txt @@ -4,7 +4,7 @@ "./src/answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - formatNumber: function() { return /* reexport safe */ _plugin_formatNumber__WEBPACK_IMPORTED_MODULE_0__["default"]; } + formatNumber: () => (/* reexport safe */ _plugin_formatNumber__WEBPACK_IMPORTED_MODULE_0__["default"]) }); /* ESM import */var _plugin_formatNumber__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/plugin/formatNumber.js"); @@ -21,7 +21,7 @@ console.log(_answer__WEBPACK_IMPORTED_MODULE_0__); }), "./src/plugin/formatNumber.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return formatNumber_default; } + "default": () => (formatNumber_default) }); function formatNumber(config) {} const plugin = cls => { diff --git a/packages/rspack-test-tools/tests/treeShakingCases/export-star-chain/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/export-star-chain/__snapshots__/treeshaking.snap.txt index 2f09d7ae0f9f..4e250f228141 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/export-star-chain/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/export-star-chain/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./colors/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - red: function() { return red; } + red: () => (red) }); const red = "red"; @@ -11,7 +11,7 @@ const red = "red"; }), "./colors/b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - blue: function() { return blue; } + blue: () => (blue) }); const blue = "blue"; @@ -19,7 +19,7 @@ const blue = "blue"; }), "./colors/c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - result: function() { return /* reexport safe */ _result__WEBPACK_IMPORTED_MODULE_0__.result; } + result: () => (/* reexport safe */ _result__WEBPACK_IMPORTED_MODULE_0__.result) }); /* ESM import */var _result__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./colors/result.js"); @@ -29,9 +29,9 @@ __webpack_require__.d(__webpack_exports__, { "./colors/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - blue: function() { return /* reexport safe */ _b__WEBPACK_IMPORTED_MODULE_1__.blue; }, - red: function() { return /* reexport safe */ _a__WEBPACK_IMPORTED_MODULE_0__.red; }, - result: function() { return /* reexport safe */ _c__WEBPACK_IMPORTED_MODULE_2__.result; } + blue: () => (/* reexport safe */ _b__WEBPACK_IMPORTED_MODULE_1__.blue), + red: () => (/* reexport safe */ _a__WEBPACK_IMPORTED_MODULE_0__.red), + result: () => (/* reexport safe */ _c__WEBPACK_IMPORTED_MODULE_2__.result) }); /* ESM import */var _a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./colors/a.js"); /* ESM import */var _b__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./colors/b.js"); @@ -44,7 +44,7 @@ __webpack_require__.d(__webpack_exports__, { }), "./colors/result.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - result: function() { return result; } + result: () => (result) }); const result = "ssss"; @@ -62,7 +62,7 @@ _export__WEBPACK_IMPORTED_MODULE_1__.Something; }), "./something/Something.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - Something: function() { return Something; } + Something: () => (Something) }); class Something {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/export_star/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/export_star/__snapshots__/treeshaking.snap.txt index 3039eb507709..95a2df44ebff 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/export_star/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/export_star/__snapshots__/treeshaking.snap.txt @@ -3,9 +3,9 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./bar.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - b: function() { return b; }, - bar: function() { return /* reexport module object */ _foo__WEBPACK_IMPORTED_MODULE_0__; }, - c: function() { return /* reexport safe */ _result__WEBPACK_IMPORTED_MODULE_1__.c; } + b: () => (b), + bar: () => (/* reexport module object */ _foo__WEBPACK_IMPORTED_MODULE_0__), + c: () => (/* reexport safe */ _result__WEBPACK_IMPORTED_MODULE_1__.c) }); /* ESM import */var _foo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./foo.js"); /* ESM import */var _result__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./result.js"); @@ -19,11 +19,11 @@ function b() {} "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - a: function() { return a; }, - b: function() { return /* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__.b; }, - bar: function() { return /* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__.bar; }, - c: function() { return /* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__.c; }, - foo: function() { return foo; } + a: () => (a), + b: () => (/* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__.b), + bar: () => (/* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__.bar), + c: () => (/* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__.c), + foo: () => (foo) }); /* ESM import */var _bar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./bar.js"); /* ESM import */var _result__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./result.js"); @@ -44,7 +44,7 @@ _foo__WEBPACK_IMPORTED_MODULE_0__.bar.a; }), "./result.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - c: function() { return c; } + c: () => (c) }); /* ESM import */var _foo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./foo.js"); /* ESM import */var _bar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./bar.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/export_star_conflict_export_no_error/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/export_star_conflict_export_no_error/__snapshots__/treeshaking.snap.txt index 506b35b81dc1..394728c821d3 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/export_star_conflict_export_no_error/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/export_star_conflict_export_no_error/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./bar.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - b: function() { return b; } + b: () => (b) }); /* ESM import */var _foo_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./foo.js"); /* ESM import */var _result_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./result.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/import-as-default/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/import-as-default/__snapshots__/treeshaking.snap.txt index 3ef1a15abc25..3d1ba3fb6bc6 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/import-as-default/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/import-as-default/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); var a = 1; /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (a); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/import-export-all-as-a-empty-module/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/import-export-all-as-a-empty-module/__snapshots__/treeshaking.snap.txt index 977b0336e4ed..991a8b365aac 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/import-export-all-as-a-empty-module/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/import-export-all-as-a-empty-module/__snapshots__/treeshaking.snap.txt @@ -3,8 +3,8 @@ "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - aaa: function() { return /* reexport module object */ _app__WEBPACK_IMPORTED_MODULE_0__; }, - routes: function() { return routes; } + aaa: () => (/* reexport module object */ _app__WEBPACK_IMPORTED_MODULE_0__), + routes: () => (routes) }); /* ESM import */var _answer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./answer.js"); /* ESM import */var _answer__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_answer__WEBPACK_IMPORTED_MODULE_1__); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/import-optional-chaining/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/import-optional-chaining/__snapshots__/treeshaking.snap.txt index 90ea501b62fc..a4e289113d0e 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/import-optional-chaining/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/import-optional-chaining/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - app: function() { return app; } + app: () => (app) }); const app = "app"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/import-star-as-and-export/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/import-star-as-and-export/__snapshots__/treeshaking.snap.txt index 5f8abd5fd737..3b9a1376d242 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/import-star-as-and-export/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/import-star-as-and-export/__snapshots__/treeshaking.snap.txt @@ -12,7 +12,7 @@ _app__WEBPACK_IMPORTED_MODULE_0__; "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/import-var-assign-side-effects/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/import-var-assign-side-effects/__snapshots__/treeshaking.snap.txt index f0ce770d4f06..186cd92b22c7 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/import-var-assign-side-effects/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/import-var-assign-side-effects/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./Something.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return Something; } + "default": () => (Something) }); class Something {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/inherit_export_map_should_lookup_in_dfs_order/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/inherit_export_map_should_lookup_in_dfs_order/__snapshots__/treeshaking.snap.txt index 48792aebb5fb..3d358b4a6107 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/inherit_export_map_should_lookup_in_dfs_order/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/inherit_export_map_should_lookup_in_dfs_order/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - c: function() { return c; } + c: () => (c) }); const c = "a"; @@ -17,9 +17,9 @@ const c = "bar"; }), "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; }, - b: function() { return /* reexport safe */ _foo__WEBPACK_IMPORTED_MODULE_0__.b; }, - c: function() { return /* reexport safe */ _foo__WEBPACK_IMPORTED_MODULE_0__.c; } + a: () => (a), + b: () => (/* reexport safe */ _foo__WEBPACK_IMPORTED_MODULE_0__.b), + c: () => (/* reexport safe */ _foo__WEBPACK_IMPORTED_MODULE_0__.c) }); /* ESM import */var _foo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./foo.js"); /* ESM import */var _bar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./bar.js"); @@ -31,8 +31,8 @@ const a = 3; }), "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - b: function() { return b; }, - c: function() { return /* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.c; } + b: () => (b), + c: () => (/* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.c) }); /* ESM import */var _a_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./a.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/issue-4637/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/issue-4637/__snapshots__/treeshaking.snap.txt index 16429df2d25c..29566eccef7e 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/issue-4637/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/issue-4637/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "../../../../../node_modules//@swc/helpers/esm/_create_class.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - _: function() { return _create_class; } + _: () => (_create_class) }); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { diff --git a/packages/rspack-test-tools/tests/treeShakingCases/issues_3198/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/issues_3198/__snapshots__/treeshaking.snap.txt index ef3fe2fa71e9..73f078944502 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/issues_3198/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/issues_3198/__snapshots__/treeshaking.snap.txt @@ -10,7 +10,7 @@ _test__WEBPACK_IMPORTED_MODULE_0__.obj.test = 1; }), "./test.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - obj: function() { return obj; } + obj: () => (obj) }); const obj = {}; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable1/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable1/__snapshots__/treeshaking.snap.txt index 3a12adc618bb..175114449e57 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable1/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable1/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./Layout.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - defaults: function() { return defaults; } + defaults: () => (defaults) }); const defaults = { test: 1000 @@ -13,7 +13,7 @@ const defaults = { }), "./export.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - Something: function() { return Something; } + Something: () => (Something) }); /* ESM import */var _Layout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./Layout.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable2/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable2/__snapshots__/treeshaking.snap.txt index 45869bd2a1d3..685cd8d07b8c 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable2/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/local-binding-reachable2/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./Layout.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - defaults: function() { return defaults; } + defaults: () => (defaults) }); const defaults = { test: 1000 @@ -13,7 +13,7 @@ const defaults = { }), "./export.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - Something: function() { return Something; } + Something: () => (Something) }); /* ESM import */var _Layout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./Layout.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects1/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects1/__snapshots__/treeshaking.snap.txt index f760bbc13dac..efe1a813353d 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects1/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects1/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 3; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects2/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects2/__snapshots__/treeshaking.snap.txt index 3e39bdba8710..65ee85019e3b 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects2/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/module-rule-side-effects2/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 3; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/named-export-decl-with-src-eval/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/named-export-decl-with-src-eval/__snapshots__/treeshaking.snap.txt index 937273c1ad92..db512cef4620 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/named-export-decl-with-src-eval/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/named-export-decl-with-src-eval/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - cccc: function() { return cccc; } + cccc: () => (cccc) }); function cccc() {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/named_export_alias/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/named_export_alias/__snapshots__/treeshaking.snap.txt index dbf13daaa71b..95ed0adeeb1a 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/named_export_alias/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/named_export_alias/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./Something.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - something: function() { return something; } + something: () => (something) }); function something() {} @@ -11,7 +11,7 @@ function something() {} }), "./export.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return a; } + "default": () => (a) }); /* ESM import */var _Something__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./Something.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/namespace-access-var-decl-rhs/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/namespace-access-var-decl-rhs/__snapshots__/treeshaking.snap.txt index e88651a8da8f..05f1bebe27fa 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/namespace-access-var-decl-rhs/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/namespace-access-var-decl-rhs/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = { a: "" @@ -13,7 +13,7 @@ const a = { }), "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - b: function() { return b; } + b: () => (b) }); const b = { b: "" @@ -31,7 +31,7 @@ console.log(_lib__WEBPACK_IMPORTED_MODULE_0__.getDocPermissionTextSendMe); }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - getDocPermissionTextSendMe: function() { return getDocPermissionTextSendMe; } + getDocPermissionTextSendMe: () => (getDocPermissionTextSendMe) }); /* ESM import */var _enum_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./a.js"); /* ESM import */var _enum_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./b.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/nested-import-3/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/nested-import-3/__snapshots__/treeshaking.snap.txt index d61715e01f94..ebd679dff659 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/nested-import-3/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/nested-import-3/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 103330; const b = 103330; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/nested-import-4/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/nested-import-4/__snapshots__/treeshaking.snap.txt index d61715e01f94..ebd679dff659 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/nested-import-4/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/nested-import-4/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./answer.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 103330; const b = 103330; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/prune-bailout-module/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/prune-bailout-module/__snapshots__/treeshaking.snap.txt index 115069b8502f..56ed55ee7d7d 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/prune-bailout-module/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/prune-bailout-module/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (300); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/pure-iife-return/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/pure-iife-return/__snapshots__/treeshaking.snap.txt index f549609ef9fe..45a44ef29f38 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/pure-iife-return/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/pure-iife-return/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - A: function() { return A; } + A: () => (A) }); const A = 1; const B = 1; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/pure_comments_magic_comments/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/pure_comments_magic_comments/__snapshots__/treeshaking.snap.txt index edf2078ba78d..398e456302b8 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/pure_comments_magic_comments/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/pure_comments_magic_comments/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); function res() { diff --git a/packages/rspack-test-tools/tests/treeShakingCases/react-redux-like/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/react-redux-like/__snapshots__/treeshaking.snap.txt index d7f88c404cf2..152e789192dd 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/react-redux-like/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/react-redux-like/__snapshots__/treeshaking.snap.txt @@ -12,7 +12,7 @@ _foo__WEBPACK_IMPORTED_MODULE_1__["default"]; }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); function Provider() {} @@ -22,7 +22,7 @@ function Provider() {} }), "./selector.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return useSelector; } + "default": () => (useSelector) }); function useSelector() { return ""; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as-multi-level-nested/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as-multi-level-nested/__snapshots__/treeshaking.snap.txt index 9ac1a963c61d..58c6a39e6e2b 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as-multi-level-nested/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as-multi-level-nested/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./package/autogen/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); function a() {} @@ -16,7 +16,7 @@ function dddd() {} }), "./package/autogen/aa.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - aa: function() { return aa; } + aa: () => (aa) }); const aa = 3; const cc = 3; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as/__snapshots__/treeshaking.snap.txt index cbb106335ee0..24c4d343dce7 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/reexport-all-as/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./package/autogen/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); function a() {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/reexport_default_as/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/reexport_default_as/__snapshots__/treeshaking.snap.txt index f087c76dad9a..d6a3b163bb58 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/reexport_default_as/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/reexport_default_as/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./bar.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return test; } + "default": () => (test) }); function test() {} @@ -11,7 +11,7 @@ function test() {} }), "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - Select: function() { return /* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__["default"]; } + Select: () => (/* reexport safe */ _bar__WEBPACK_IMPORTED_MODULE_0__["default"]) }); /* ESM import */var _bar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./bar.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/reexport_entry_elimination/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/reexport_entry_elimination/__snapshots__/treeshaking.snap.txt index f61226eeac52..0794a3f3728c 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/reexport_entry_elimination/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/reexport_entry_elimination/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _c_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./c.js"); @@ -13,7 +13,7 @@ __webpack_require__.d(__webpack_exports__, { }), "./c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (10); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rename-export-from-import/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rename-export-from-import/__snapshots__/treeshaking.snap.txt index 2417c46e757c..15554b217b10 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rename-export-from-import/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rename-export-from-import/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - q: function() { return /* reexport safe */ _lib__WEBPACK_IMPORTED_MODULE_0__.question; } + q: () => (/* reexport safe */ _lib__WEBPACK_IMPORTED_MODULE_0__.question) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); @@ -21,7 +21,7 @@ _app__WEBPACK_IMPORTED_MODULE_0__.q; }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - question: function() { return question; } + question: () => (question) }); const answer = "1"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports-function-argument/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports-function-argument/__snapshots__/treeshaking.snap.txt index 29be1f9ebe8d..ef8258e9980a 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports-function-argument/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports-function-argument/__snapshots__/treeshaking.snap.txt @@ -3,8 +3,8 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - bar: function() { return bar; }, - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + bar: () => (bar), + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); var foo = function () { return 42; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports/__snapshots__/treeshaking.snap.txt index 8f779f9e77e6..1e05ae15af4a 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unmodified-default-exports/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); var Foo = function () { console.log("side effect"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-called-import/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-called-import/__snapshots__/treeshaking.snap.txt index a8439f776897..d2103301b996 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-called-import/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-called-import/__snapshots__/treeshaking.snap.txt @@ -10,7 +10,7 @@ }), "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _dead__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./dead.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-default-exports/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-default-exports/__snapshots__/treeshaking.snap.txt index 71dc7581ab3d..ae7ec805b680 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-default-exports/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-default-exports/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - foo: function() { return foo; } + foo: () => (foo) }); var foo = { value: 1 }; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-inner-functions-and-classes/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-inner-functions-and-classes/__snapshots__/treeshaking.snap.txt index 313ecd7f3a2f..f22bba6e5d93 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-inner-functions-and-classes/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-inner-functions-and-classes/__snapshots__/treeshaking.snap.txt @@ -24,8 +24,8 @@ console.log(getClass().name); }), "./stuff.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - bar: function() { return bar; }, - baz: function() { return Baz; } + bar: () => (bar), + baz: () => (Baz) }); function foo() { console.log("outer foo"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-var/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-var/__snapshots__/treeshaking.snap.txt index f3692f9e3730..d69095ad6d36 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-var/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/rollup-unused-var/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./foo.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - foo: function() { return foo; } + foo: () => (foo) }); var foo = "lol"; var bar = "wut"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-analyzed/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-analyzed/__snapshots__/treeshaking.snap.txt index dc8a99597428..d5eccabc20ab 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-analyzed/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-analyzed/__snapshots__/treeshaking.snap.txt @@ -11,7 +11,7 @@ }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-export-default-expr/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-export-default-expr/__snapshots__/treeshaking.snap.txt index b470cd11c3d4..1461ed8ddf01 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-export-default-expr/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-export-default-expr/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - b: function() { return b; } + b: () => (b) }); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-flagged-only/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-flagged-only/__snapshots__/treeshaking.snap.txt index 92744145d305..793b9b024b3a 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-flagged-only/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-flagged-only/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - something: function() { return /* reexport safe */ _lib__WEBPACK_IMPORTED_MODULE_0__["default"]; } + something: () => (/* reexport safe */ _lib__WEBPACK_IMPORTED_MODULE_0__["default"]) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); /* ESM import */var _src_a__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/a.js"); @@ -22,7 +22,7 @@ __webpack_require__.d(__webpack_exports__, { }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-prune/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-prune/__snapshots__/treeshaking.snap.txt index b38659b0d521..5331935d4e72 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-prune/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-prune/__snapshots__/treeshaking.snap.txt @@ -12,7 +12,7 @@ }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - something: function() { return something; } + something: () => (something) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-two/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-two/__snapshots__/treeshaking.snap.txt index dc8a99597428..d5eccabc20ab 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/side-effects-two/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/side-effects-two/__snapshots__/treeshaking.snap.txt @@ -11,7 +11,7 @@ }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/simple-namespace-access/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/simple-namespace-access/__snapshots__/treeshaking.snap.txt index 756b0fd9dbd4..b0ac68211660 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/simple-namespace-access/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/simple-namespace-access/__snapshots__/treeshaking.snap.txt @@ -13,8 +13,8 @@ console.log(_maths_js__WEBPACK_IMPORTED_MODULE_0__.square); }), "./maths.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - square: function() { return square; }, - xxx: function() { return /* reexport module object */ _test_js__WEBPACK_IMPORTED_MODULE_0__; } + square: () => (square), + xxx: () => (/* reexport module object */ _test_js__WEBPACK_IMPORTED_MODULE_0__) }); /* ESM import */var _test_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./test.js"); // maths.js @@ -38,7 +38,7 @@ function cube(x) { }), "./test.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - test: function() { return test; } + test: () => (test) }); function test() {} function ccc() {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/static-class/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/static-class/__snapshots__/treeshaking.snap.txt index fce8b0369ab1..6789e1e133c4 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/static-class/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/static-class/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); /* ESM import */var _b_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./b.js"); @@ -27,7 +27,7 @@ const a = 3; }), "./b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - bb: function() { return bb; } + bb: () => (bb) }); const bb = 2; const cc = 3; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/transitive-bailout/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/transitive-bailout/__snapshots__/treeshaking.snap.txt index 63405ec323ad..b7ad28656470 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/transitive-bailout/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/transitive-bailout/__snapshots__/treeshaking.snap.txt @@ -3,8 +3,8 @@ "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - a: function() { return a; }, - b: function() { return b; } + a: () => (a), + b: () => (b) }); const a = 3; const b = 3; @@ -31,8 +31,8 @@ _answer__WEBPACK_IMPORTED_MODULE_0__.test; "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - a: function() { return /* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.a; }, - b: function() { return /* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.b; } + a: () => (/* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.a), + b: () => (/* reexport safe */ _a_js__WEBPACK_IMPORTED_MODULE_0__.b) }); /* ESM import */var _a_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./a.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/transitive_side_effects_when_analyze/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/transitive_side_effects_when_analyze/__snapshots__/treeshaking.snap.txt index 9d6d6b53ab0a..29cf8aedf923 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/transitive_side_effects_when_analyze/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/transitive_side_effects_when_analyze/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); /* ESM import */var _side_effects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./side-effects.js"); /* ESM import */var _side_effects_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_side_effects_js__WEBPACK_IMPORTED_MODULE_0__); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-false-with-side-effect-true/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-false-with-side-effect-true/__snapshots__/treeshaking.snap.txt index 5a8dad18aa18..be04387080b0 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-false-with-side-effect-true/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-false-with-side-effect-true/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./ b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - b: function() { return b; } + b: () => (b) }); const b = 3; @@ -11,7 +11,7 @@ const b = 3; }), "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 3; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/__snapshots__/treeshaking.snap.txt index 75cf0d163890..e9bcd3a2fdd2 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-interop/__snapshots__/treeshaking.snap.txt @@ -4,7 +4,7 @@ "./bar.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return test; } + "default": () => (test) }); function test() {} @@ -20,7 +20,7 @@ function test() {} "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); __webpack_require__.e(/* import() */ "bar_js").then(__webpack_require__.bind(__webpack_require__, "./bar.js")).then(mod => { console.log(mod); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-lazy-import/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-lazy-import/__snapshots__/treeshaking.snap.txt index 136a5de1cab0..c075712d18a8 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-lazy-import/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/tree-shaking-lazy-import/__snapshots__/treeshaking.snap.txt @@ -4,7 +4,7 @@ "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _test__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./test.js"); @@ -18,7 +18,7 @@ function myanswer() { }), "./test.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); function test() {} @@ -35,7 +35,7 @@ function test() {} (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - answer: function() { return answer; } + answer: () => (answer) }); const answer = 30; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/unused-class-rename/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/unused-class-rename/__snapshots__/treeshaking.snap.txt index 2c07dd070052..447c319d08e4 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/unused-class-rename/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/unused-class-rename/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - test: function() { return test; } + test: () => (test) }); function test() {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/var-function-expr/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/var-function-expr/__snapshots__/treeshaking.snap.txt index 8be8b491f157..3a740b536fa2 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/var-function-expr/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/var-function-expr/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./app.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - app: function() { return app; } + app: () => (app) }); /* ESM import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib.js"); @@ -30,8 +30,8 @@ var app3 = (0,_lib__WEBPACK_IMPORTED_MODULE_0__.something)("app3"); }), "./lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - result: function() { return result; }, - something: function() { return something; } + result: () => (result), + something: () => (something) }); const secret = "888"; const result = 20000; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-export-default-named/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-export-default-named/__snapshots__/treeshaking.snap.txt index 92beaec80372..c1b653c9172e 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-export-default-named/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-export-default-named/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return abc; } + "default": () => (abc) }); /* ESM import */var _dep_a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./dep.js?a"); @@ -38,7 +38,7 @@ abc(); }), "./d.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return def; } + "default": () => (def) }); /* ESM import */var _dep_d__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./dep.js?d"); @@ -53,8 +53,8 @@ class def { }), "./dep.js?a": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - x: function() { return x; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + x: () => (x) }); const x = "x"; @@ -64,7 +64,7 @@ const x = "x"; }), "./dep.js?b": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); const x = "x"; @@ -74,8 +74,8 @@ const x = "x"; }), "./dep.js?c": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - x: function() { return x; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + x: () => (x) }); const x = "x"; @@ -85,8 +85,8 @@ const x = "x"; }), "./dep.js?d": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - x: function() { return x; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + x: () => (x) }); const x = "x"; @@ -96,7 +96,7 @@ const x = "x"; }), "./dep.js?e": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); const x = "x"; @@ -106,8 +106,8 @@ const x = "x"; }), "./dep.js?f": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - x: function() { return x; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + x: () => (x) }); const x = "x"; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-switch/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-switch/__snapshots__/treeshaking.snap.txt index 99848ae854b3..f33ea879ded8 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-switch/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-inner-graph-switch/__snapshots__/treeshaking.snap.txt @@ -16,7 +16,7 @@ __webpack_require__.r(__webpack_exports__); "./import-module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - test: function() { return test; } + test: () => (test) }); /* ESM import */var _module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./module.js"); @@ -40,7 +40,7 @@ it("should generate correct code when pure expressions are in dead branches", () "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _some_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./some-module.js"); @@ -91,9 +91,9 @@ function useDocument(obj) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - Block: function() { return Block; }, - Document: function() { return Document; }, - Inline: function() { return Inline; } + Block: () => (Block), + Document: () => (Document), + Inline: () => (Inline) }); class Block { static doSomething() {} diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular/__snapshots__/treeshaking.snap.txt index db3c304219c3..69b7e3ce473f 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular/__snapshots__/treeshaking.snap.txt @@ -35,11 +35,11 @@ it("export should be unused when only unused functions use it", () => { }), "./inner.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - A: function() { return A; }, - B: function() { return B; }, - exportAUsed: function() { return exportAUsed; }, - exportBUsed: function() { return exportBUsed; }, - exportCUsed: function() { return exportCUsed; } + A: () => (A), + B: () => (B), + exportAUsed: () => (exportAUsed), + exportBUsed: () => (exportBUsed), + exportCUsed: () => (exportCUsed) }); function A(s) { return s + "A"; @@ -59,7 +59,7 @@ const exportCUsed = false; }), "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - y: function() { return y; } + y: () => (y) }); /* ESM import */var _inner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./inner.js"); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular2/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular2/__snapshots__/treeshaking.snap.txt index 5f3cc6838fe6..6b78d3ab00ca 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular2/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-circular2/__snapshots__/treeshaking.snap.txt @@ -22,11 +22,11 @@ it("should be able to handle circular referenced", () => { }), "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; }, - f3: function() { return f3; }, - x: function() { return x; }, - y: function() { return y; }, - z: function() { return z; } + a: () => (a), + f3: () => (f3), + x: () => (x), + y: () => (y), + z: () => (z) }); function x() { return [y, z]; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-no-side-effects/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-no-side-effects/__snapshots__/treeshaking.snap.txt index 007bb15f4f8b..7eec044680f6 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-no-side-effects/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-no-side-effects/__snapshots__/treeshaking.snap.txt @@ -11,8 +11,8 @@ it("should be able to load package without side effects where modules are unused "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - test: function() { return test; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + test: () => (test) }); /* ESM import */var _package__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./package/index.js"); @@ -26,7 +26,7 @@ function test() {} "./package/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-try-globals/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-try-globals/__snapshots__/treeshaking.snap.txt index ddce81ed2e88..baf324934f75 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-try-globals/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-innergraph-try-globals/__snapshots__/treeshaking.snap.txt @@ -21,8 +21,8 @@ it("should not threat globals as pure", () => { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.d(__webpack_exports__, { - ok: function() { return ok; }, - ok2: function() { return ok2; } + ok: () => (ok), + ok2: () => (ok2) }); try { var x = NOT_DEFINED; diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-reexport-namespace-and-default/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-reexport-namespace-and-default/__snapshots__/treeshaking.snap.txt index 8d6ae3628221..769c8cbc5d5a 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-reexport-namespace-and-default/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-reexport-namespace-and-default/__snapshots__/treeshaking.snap.txt @@ -29,7 +29,7 @@ it("default export should be used", () => { "./module.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - mod: function() { return mod; } + mod: () => (mod) }); /* ESM import */var _package1_script__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./package1/script.js"); /* ESM import */var _package2_script__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./package2/script.js"); @@ -42,7 +42,7 @@ const mod = _package2_script__WEBPACK_IMPORTED_MODULE_1__["default"]; }), "./package1/script.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - exportDefaultUsed: function() { return exportDefaultUsed; } + exportDefaultUsed: () => (exportDefaultUsed) }); /* ESM import */var _script1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./package1/script1.js"); @@ -62,7 +62,7 @@ const exportDefaultUsed = false; }), "./package1/script2.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - exportDefaultUsed: function() { return exportDefaultUsed; } + exportDefaultUsed: () => (exportDefaultUsed) }); /* ESM default export */ function __WEBPACK_DEFAULT_EXPORT__() { @@ -76,8 +76,8 @@ const exportDefaultUsed = false; }), "./package2/script.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; }, - exportDefaultUsed: function() { return exportDefaultUsed; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__), + exportDefaultUsed: () => (exportDefaultUsed) }); /* ESM import */var _script1__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./package2/script1.js"); @@ -90,7 +90,7 @@ const exportDefaultUsed = true; }), "./package2/script1.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (1); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-all-used/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-all-used/__snapshots__/treeshaking.snap.txt index 64f60ffd2535..b25f1c827e8b 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-all-used/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-all-used/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "../node_modules/pmodule/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); var a = "a"; @@ -19,7 +19,7 @@ var c = "c"; }), "../node_modules/pmodule/b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - x: function() { return x; } + x: () => (x) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); var x = "x"; @@ -35,7 +35,7 @@ var y = "y"; }), "../node_modules/pmodule/c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - z: function() { return z; } + z: () => (z) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); var z = "z"; @@ -49,7 +49,7 @@ var z = "z"; }), "../node_modules/pmodule/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); @@ -64,8 +64,8 @@ __webpack_require__.d(__webpack_exports__, { }), "../node_modules/pmodule/tracker.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - log: function() { return log; }, - track: function() { return track; } + log: () => (log), + track: () => (track) }); function track(file) { log.push(file); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-simple-unused/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-simple-unused/__snapshots__/treeshaking.snap.txt index 5954cfc6f63c..ec41f6f7e154 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-simple-unused/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/webpack-side-effects-simple-unused/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "../node_modules/pmodule/b.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - x: function() { return x; } + x: () => (x) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); var x = "x"; @@ -19,7 +19,7 @@ var y = "y"; }), "../node_modules/pmodule/c.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - z: function() { return z; } + z: () => (z) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); var z = "z"; @@ -33,7 +33,7 @@ var z = "z"; }), "../node_modules/pmodule/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - "default": function() { return __WEBPACK_DEFAULT_EXPORT__; } + "default": () => (__WEBPACK_DEFAULT_EXPORT__) }); /* ESM import */var _tracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/pmodule/tracker.js"); @@ -48,8 +48,8 @@ __webpack_require__.d(__webpack_exports__, { }), "../node_modules/pmodule/tracker.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - log: function() { return log; }, - track: function() { return track; } + log: () => (log), + track: () => (track) }); function track(file) { log.push(file); diff --git a/packages/rspack-test-tools/tests/treeShakingCases/with-assets/__snapshots__/treeshaking.snap.txt b/packages/rspack-test-tools/tests/treeShakingCases/with-assets/__snapshots__/treeshaking.snap.txt index dce54b7aa8f1..6fd9b5a7a044 100644 --- a/packages/rspack-test-tools/tests/treeShakingCases/with-assets/__snapshots__/treeshaking.snap.txt +++ b/packages/rspack-test-tools/tests/treeShakingCases/with-assets/__snapshots__/treeshaking.snap.txt @@ -3,7 +3,7 @@ (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { "./a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.d(__webpack_exports__, { - a: function() { return a; } + a: () => (a) }); const a = 3; diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index 452bc770c870..fe89724db8d5 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -240,7 +240,7 @@ export const BannerPlugin: { new (args: BannerPluginArgument): { name: BuiltinPluginName; _args: [args: BannerPluginArgument]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1181,7 +1181,7 @@ export const ContextReplacementPlugin: { new (resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): { name: BuiltinPluginName; _args: [resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1192,7 +1192,7 @@ export const CopyRspackPlugin: { new (copy: CopyRspackPluginOptions): { name: BuiltinPluginName; _args: [copy: CopyRspackPluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1326,7 +1326,7 @@ export const DefinePlugin: { new (define: DefinePluginOptions): { name: BuiltinPluginName; _args: [define: DefinePluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1573,7 +1573,7 @@ const ElectronTargetPlugin: { new (context?: string | undefined): { name: BuiltinPluginName; _args: [context?: string | undefined]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1584,7 +1584,7 @@ const EnableChunkLoadingPlugin: { new (type: string): { name: BuiltinPluginName; _args: [type: string]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1617,7 +1617,7 @@ const EnableWasmLoadingPlugin: { new (type: string): { name: BuiltinPluginName; _args: [type: string]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1877,7 +1877,7 @@ export const EvalDevToolModulePlugin: { new (options: EvalDevToolModulePluginOptions): { name: BuiltinPluginName; _args: [options: EvalDevToolModulePluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1890,7 +1890,7 @@ export const EvalSourceMapDevToolPlugin: { new (options: SourceMapDevToolPluginOptions): { name: BuiltinPluginName; _args: [options: SourceMapDevToolPluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -2138,7 +2138,7 @@ const FetchCompileAsyncWasmPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -2335,7 +2335,7 @@ const HtmlRspackPluginImpl: { new (c?: HtmlRspackPluginOptions | undefined): { name: BuiltinPluginName; _args: [c?: HtmlRspackPluginOptions | undefined]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler): BuiltinPlugin; apply(compiler: Compiler): void; }; @@ -2398,7 +2398,7 @@ export const IgnorePlugin: { new (options: IgnorePluginOptions): { name: BuiltinPluginName; _args: [options: IgnorePluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3262,7 +3262,7 @@ export const LightningCssMinimizerRspackPlugin: { new (options?: LightningCssMinimizerRspackPluginOptions | undefined): { name: BuiltinPluginName; _args: [options?: LightningCssMinimizerRspackPluginOptions | undefined]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3299,7 +3299,7 @@ const LimitChunkCountPlugin: { new (options: LimitChunkCountOptions): { name: BuiltinPluginName; _args: [options: LimitChunkCountOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3963,7 +3963,7 @@ const NodeTargetPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3986,7 +3986,7 @@ export const NoEmitOnErrorsPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4216,7 +4216,7 @@ const OriginEntryPlugin: { new (context: string, entry: string, options?: string | EntryOptions | undefined): { name: BuiltinPluginName; _args: [context: string, entry: string, options?: string | EntryOptions | undefined]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4608,7 +4608,7 @@ export const ProgressPlugin: { new (progress?: ProgressPluginArgument): { name: BuiltinPluginName; _args: [progress?: ProgressPluginArgument]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4622,7 +4622,7 @@ export const ProvidePlugin: { new (provide: ProvidePluginOptions): { name: BuiltinPluginName; _args: [provide: ProvidePluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4927,7 +4927,7 @@ const RemoveDuplicateModulesPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -9735,7 +9735,7 @@ const RuntimeChunkPlugin: { new (options: RawRuntimeChunkOptions): { name: BuiltinPluginName; _args: [options: RawRuntimeChunkOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -10035,7 +10035,7 @@ export const SourceMapDevToolPlugin: { new (options: SourceMapDevToolPluginOptions): { name: BuiltinPluginName; _args: [options: SourceMapDevToolPluginOptions]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -10339,7 +10339,7 @@ export const SwcJsMinimizerRspackPlugin: { new (options?: SwcJsMinimizerRspackPluginOptions | undefined): { name: BuiltinPluginName; _args: [options?: SwcJsMinimizerRspackPluginOptions | undefined]; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -11069,7 +11069,7 @@ export const WarnCaseSensitiveModulesPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "environment" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; + affectedHooks: "done" | "environment" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; diff --git a/packages/rspack/src/config/adapter.ts b/packages/rspack/src/config/adapter.ts index d62f23c663b5..9c847c3cb7b7 100644 --- a/packages/rspack/src/config/adapter.ts +++ b/packages/rspack/src/config/adapter.ts @@ -12,6 +12,7 @@ import { type RawCssModuleGeneratorOptions, type RawCssModuleParserOptions, type RawCssParserOptions, + type RawEnvironment, type RawFuncUseCtx, type RawGeneratorOptions, type RawJavascriptParserOptions, @@ -19,6 +20,7 @@ import { type RawModuleRule, type RawModuleRuleUse, type RawOptions, + type RawOutputOptions, type RawParserOptions, type RawRuleSetCondition, RawRuleSetConditionType, @@ -58,6 +60,7 @@ import type { JsonParserOptions, Node, Optimization, + Output, ParserOptionsByModuleType, Resolve, RuleSetCondition, @@ -79,7 +82,7 @@ export const getRawOptions = ( name: options.name, mode, context: options.context!, - output: options.output as Required, + output: getRawOutput(options.output), resolve: getRawResolve(options.resolve), resolveLoader: getRawResolve(options.resolveLoader), module: getRawModule(options.module, { @@ -102,6 +105,33 @@ export const getRawOptions = ( }; }; +function getRawOutput(output: Output): RawOutputOptions { + return { + ...(output as Required), + environment: getRawOutputEnvironment(output.environment) + }; +} + +function getRawOutputEnvironment( + environment: Output["environment"] = {} +): RawEnvironment { + return { + const: Boolean(environment.const), + arrowFunction: Boolean(environment.arrowFunction), + nodePrefixForCoreModules: Boolean(environment.nodePrefixForCoreModules), + asyncFunction: Boolean(environment.asyncFunction), + bigIntLiteral: Boolean(environment.bigIntLiteral), + destructuring: Boolean(environment.destructuring), + document: Boolean(environment.document), + dynamicImport: Boolean(environment.dynamicImport), + forOf: Boolean(environment.forOf), + globalThis: Boolean(environment.globalThis), + module: Boolean(environment.module), + optionalChaining: Boolean(environment.optionalChaining), + templateLiteral: Boolean(environment.templateLiteral) + }; +} + function getRawExtensionAlias( alias: Resolve["extensionAlias"] = {} ): RawOptions["resolve"]["extensionAlias"] { diff --git a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap index ec2e9d0a7d39..50b30b085b30 100644 --- a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap @@ -2,9 +2,9 @@ exports[`StatsTestCases should print correct stats for asset 1`] = ` "asset c560fa876f51d750.png 26.1 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main) -asset bundle.js 13.1 KiB [emitted] (name: main) +asset bundle.js 13 KiB [emitted] (name: main) asset static/file.html 12 bytes [emitted] [from: static/file.html] (auxiliary name: main) -runtime modules 1.61 KiB 2 modules +runtime modules 1.51 KiB 2 modules modules by path ./ 9.34 KiB (javascript) 14.6 KiB (asset) modules by path ./images/ 8.86 KiB (javascript) 14.6 KiB (asset) ./images/file.png 42 bytes (javascript) 14.6 KiB (asset) [built] [code generated] @@ -24,10 +24,10 @@ Rspack x.x.x compiled successfully in X.23" exports[`StatsTestCases should print correct stats for asset-concat 1`] = ` "asset c560fa876f51d750.png 26.1 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main) -asset bundle.js 12.3 KiB [emitted] (name: main) +asset bundle.js 12.2 KiB [emitted] (name: main) asset static/file.html 12 bytes [emitted] [from: static/file.html] (auxiliary name: main) orphan modules 9.43 KiB [orphan] 8 modules -runtime modules 1.61 KiB 2 modules +runtime modules 1.51 KiB 2 modules cacheable modules 9.59 KiB (javascript) 14.6 KiB (asset) ./index.js + 9 modules 9.51 KiB [code generated] ./images/file.png 42 bytes (javascript) 14.6 KiB (asset) [built] [code generated] @@ -49,7 +49,7 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto > ./b ./index.js 2:0-47 dependent modules 80 bytes [dependent] 4 modules ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) disabled/a.js (a) 165 bytes (javascript) 7.28 KiB (runtime) [entry] [rendered] + chunk (runtime: a) disabled/a.js (a) 165 bytes (javascript) 7.14 KiB (runtime) [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) disabled/b.js (b) 116 bytes [entry] [rendered] @@ -58,7 +58,7 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto chunk (runtime: c) disabled/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 7.35 KiB (runtime) [entry] [rendered] + chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 7.21 KiB (runtime) [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) disabled/async-g.js (async-g) 65 bytes [rendered] @@ -95,7 +95,7 @@ default: > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.31 KiB (runtime) [entry] [rendered] + chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) default/b.js (b) 116 bytes [entry] [rendered] @@ -109,7 +109,7 @@ default: chunk (runtime: c) default/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.36 KiB (runtime) [entry] [rendered] + chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) default/async-g.js (async-g) 45 bytes [rendered] @@ -130,7 +130,7 @@ vendors: > ./b ./index.js 2:0-47 dependent modules 80 bytes [dependent] 4 modules ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) vendors/a.js (a) 165 bytes (javascript) 7.28 KiB (runtime) [entry] [rendered] + chunk (runtime: a) vendors/a.js (a) 165 bytes (javascript) 7.14 KiB (runtime) [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) vendors/b.js (b) 116 bytes [entry] [rendered] @@ -139,7 +139,7 @@ vendors: chunk (runtime: c) vendors/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 7.35 KiB (runtime) [entry] [rendered] + chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 7.21 KiB (runtime) [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) vendors/async-g.js (async-g) 65 bytes [rendered] @@ -149,10 +149,10 @@ vendors: vendors (Rspack x.x.x) compiled successfully multiple-vendors: - Entrypoint main 11.1 KiB = multiple-vendors/libs.js 6.1 KiB multiple-vendors/main.js 4.99 KiB - Entrypoint a 11.1 KiB = multiple-vendors/libs.js 6.1 KiB multiple-vendors/a.js 4.99 KiB - Entrypoint b 11.1 KiB = multiple-vendors/libs.js 6.1 KiB multiple-vendors/b.js 4.99 KiB - Entrypoint c 11.1 KiB = multiple-vendors/libs.js 6.1 KiB multiple-vendors/c.js 4.99 KiB + Entrypoint main 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/main.js 4.88 KiB + Entrypoint a 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/a.js 4.88 KiB + Entrypoint b 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/b.js 4.88 KiB + Entrypoint c 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/c.js 4.88 KiB chunk (runtime: a, b, c, main) multiple-vendors/libs.js (libs) (id hint: libs) 709 bytes [initial] [rendered] split chunk (cache group: libs) > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 @@ -164,21 +164,21 @@ multiple-vendors: > ./ main dependent modules 562 bytes [dependent] 10 modules ./index.js 147 bytes [built] [code generated] - chunk (runtime: a) multiple-vendors/a.js (a) 3.38 KiB [entry] [rendered] + chunk (runtime: a) multiple-vendors/a.js (a) 3.26 KiB [entry] [rendered] > ./a a - chunk (runtime: b) multiple-vendors/b.js (b) 3.38 KiB [entry] [rendered] + chunk (runtime: b) multiple-vendors/b.js (b) 3.26 KiB [entry] [rendered] > ./b b - chunk (runtime: c) multiple-vendors/c.js (c) 3.38 KiB [entry] [rendered] + chunk (runtime: c) multiple-vendors/c.js (c) 3.26 KiB [entry] [rendered] > ./c c - chunk (runtime: main) multiple-vendors/main.js (main) 3.38 KiB [entry] [rendered] + chunk (runtime: main) multiple-vendors/main.js (main) 3.26 KiB [entry] [rendered] > ./ main multiple-vendors (Rspack x.x.x) compiled successfully all: - Entrypoint main 10.9 KiB = all/605.js 762 bytes all/main.js 10.1 KiB - Entrypoint a 10.6 KiB = all/272.js 497 bytes all/a.js 10.1 KiB - Entrypoint b 4.24 KiB = all/726.js 258 bytes all/b.js 3.99 KiB - Entrypoint c 4.24 KiB = all/29.js 257 bytes all/c.js 3.99 KiB + Entrypoint main 10.7 KiB = all/605.js 762 bytes all/main.js 9.92 KiB + Entrypoint a 10.4 KiB = all/272.js 497 bytes all/a.js 9.92 KiB + Entrypoint b 4.15 KiB = all/726.js 258 bytes all/b.js 3.9 KiB + Entrypoint c 4.15 KiB = all/29.js 257 bytes all/c.js 3.9 KiB chunk (runtime: main) all/199.js (id hint: vendors) 116 bytes [rendered] split chunk (cache group: vendors) > ./b ./index.js 2:0-47 ./b.js 116 bytes [built] [code generated] @@ -213,16 +213,16 @@ all: chunk (runtime: b) all/726.js (id hint: vendors) 116 bytes [initial] [rendered] split chunk (cache group: vendors) > ./b b ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) all/a.js (a) 8.36 KiB [entry] [rendered] + chunk (runtime: a) all/a.js (a) 8.15 KiB [entry] [rendered] > ./a a - chunk (runtime: b) all/b.js (b) 2.58 KiB [entry] [rendered] + chunk (runtime: b) all/b.js (b) 2.49 KiB [entry] [rendered] > ./b b - chunk (runtime: c) all/c.js (c) 2.58 KiB [entry] [rendered] + chunk (runtime: c) all/c.js (c) 2.49 KiB [entry] [rendered] > ./c c chunk (runtime: a, main) all/889.js (id hint: vendors) 45 bytes [rendered] split chunk (cache group: vendors) > ./g ./a.js 6:0-47 ./g.js 45 bytes [built] [code generated] - chunk (runtime: main) all/main.js (main) 8.36 KiB [entry] [rendered] + chunk (runtime: main) all/main.js (main) 8.15 KiB [entry] [rendered] > ./ main chunk (runtime: main) all/910.js (id hint: vendors) 185 bytes [rendered] split chunk (cache group: vendors) > ./a ./index.js 1:0-47 @@ -251,7 +251,7 @@ chunk (runtime: main) 751.bundle.js (b) 49 bytes <{76}> <{909}> >{76}< [rendered ./module-b.js 49 bytes [built] [code generated] chunk (runtime: main) 76.bundle.js (c) 98 bytes <{74}> <{751}> >{74}< >{751}< [rendered] ./module-c.js 98 bytes [built] [code generated] -chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 8.45 KiB (runtime) >{74}< >{751}< [entry] [rendered] +chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 8.25 KiB (runtime) >{74}< >{751}< [entry] [rendered] ./index.js 98 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; @@ -277,10 +277,10 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for commons-chunk-min-size-Infinity 1`] = ` -"asset entry-1.js 4.39 KiB [emitted] (name: entry-1) +"asset entry-1.js 4.3 KiB [emitted] (name: entry-1) asset vendor-1.js 242 bytes [emitted] (name: vendor-1) (id hint: vendor-1) -Entrypoint entry-1 4.63 KiB = vendor-1.js 242 bytes entry-1.js 4.39 KiB -runtime modules 2.58 KiB 3 modules +Entrypoint entry-1 4.54 KiB = vendor-1.js 242 bytes entry-1.js 4.3 KiB +runtime modules 2.49 KiB 3 modules modules by path ./modules/*.js 132 bytes ./modules/a.js 22 bytes [built] [code generated] ./modules/b.js 22 bytes [built] [code generated] @@ -341,8 +341,8 @@ Rspack x.x.x compiled successfully in X.23" exports[`StatsTestCases should print correct stats for exclude-with-loader 1`] = ` "hidden assets 34 bytes 1 asset -asset bundle.js 4.64 KiB [emitted] (name: main) -runtime modules 2.27 KiB 5 modules +asset bundle.js 4.47 KiB [emitted] (name: main) +runtime modules 2.14 KiB 5 modules hidden modules 99 bytes 2 modules cacheable modules 119 bytes ./index.js 77 bytes [built] [code generated] @@ -358,7 +358,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for graph-correctness-entries 1`] = ` -"chunk (runtime: e1) e1.js (e1) 49 bytes (javascript) 8.48 KiB (runtime) >{74}< [entry] [rendered] +"chunk (runtime: e1) e1.js (e1) 49 bytes (javascript) 8.27 KiB (runtime) >{74}< [entry] [rendered] ./e1.js 49 bytes [built] [code generated] entry ./e1 chunk (runtime: e1, e2) a.js (a) 49 bytes <{605}> <{76}> >{751}< [rendered] @@ -372,14 +372,14 @@ chunk (runtime: e1, e2) c.js (c) 49 bytes <{751}> <{844}> >{74}< [rendered] ./module-c.js 49 bytes [built] [code generated] import() ./module-c ./e2.js import() ./module-c ./module-b.js -chunk (runtime: e2) e2.js (e2) 49 bytes (javascript) 8.48 KiB (runtime) >{76}< [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 49 bytes (javascript) 8.27 KiB (runtime) >{76}< [entry] [rendered] ./e2.js 49 bytes [built] [code generated] entry ./e2 Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for graph-correctness-modules 1`] = ` -"chunk (runtime: e1) e1.js (e1) 119 bytes (javascript) 8.79 KiB (runtime) >{74}< >{984}< [entry] [rendered] +"chunk (runtime: e1) e1.js (e1) 119 bytes (javascript) 8.54 KiB (runtime) >{74}< >{984}< [entry] [rendered] ./e1.js 70 bytes [built] [code generated] entry ./e1 ./module-x.js 49 bytes [dependent] [built] [code generated] @@ -397,7 +397,7 @@ chunk (runtime: e1, e2) c.js (c) 49 bytes <{751}> <{844}> >{74}< [rendered] ./module-c.js 49 bytes [built] [code generated] import() ./module-c ./e2.js import() ./module-c ./module-b.js -chunk (runtime: e2) e2.js (e2) 119 bytes (javascript) 8.79 KiB (runtime) >{76}< >{984}< [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 119 bytes (javascript) 8.54 KiB (runtime) >{76}< >{984}< [entry] [rendered] ./e2.js 70 bytes [built] [code generated] entry ./e2 ./module-x.js 49 bytes [dependent] [built] [code generated] @@ -436,7 +436,7 @@ chunk (runtime: main) id-equals-name_js0.js 21 bytes [rendered] ./id-equals-name.js 21 bytes [built] [code generated] chunk (runtime: main) id-equals-name_js_3.js 21 bytes [rendered] ./id-equals-name.js?3 21 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 639 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] +chunk (runtime: main) main.js (main) 639 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] ./index.js 639 bytes [built] [code generated] chunk (runtime: main) tree.js (tree) 137 bytes [rendered] dependent modules 98 bytes [dependent] 3 modules @@ -456,16 +456,16 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for immutable 1`] = ` -"asset a309a604082e563a.js 10.4 KiB [emitted] [immutable] (name: main) +"asset 5da07eb45c1ef960.js 10.2 KiB [emitted] [immutable] (name: main) asset 7342054f673663df.js 167 bytes [emitted] [immutable]" `; exports[`StatsTestCases should print correct stats for import-context-filter 1`] = ` -"asset entry.js 10.1 KiB [emitted] (name: entry) -asset 228.js 422 bytes [emitted] -asset 271.js 422 bytes [emitted] -asset 536.js 422 bytes [emitted] -runtime modules 7.27 KiB 9 modules +"asset entry.js 9.95 KiB [emitted] (name: entry) +asset 228.js 407 bytes [emitted] +asset 271.js 407 bytes [emitted] +asset 536.js 407 bytes [emitted] +runtime modules 7.12 KiB 9 modules cacheable modules 724 bytes modules by path ./templates/*.js 114 bytes ./templates/bar.js 38 bytes [built] [code generated] @@ -477,10 +477,10 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-weak 1`] = ` -"asset entry.js 10.2 KiB [emitted] (name: entry) +"asset entry.js 10 KiB [emitted] (name: entry) asset 332.js 285 bytes [emitted] asset 313.js 130 bytes [emitted] -runtime modules 8.44 KiB 10 modules +runtime modules 8.24 KiB 10 modules cacheable modules 179 bytes ./entry.js 120 bytes [built] [code generated] ./modules/a.js 37 bytes [built] [code generated] @@ -489,10 +489,10 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-weak-parser-option 1`] = ` -"asset entry.js 10.2 KiB [emitted] (name: entry) +"asset entry.js 10 KiB [emitted] (name: entry) asset 332.js 285 bytes [emitted] asset 313.js 130 bytes [emitted] -runtime modules 8.44 KiB 10 modules +runtime modules 8.24 KiB 10 modules cacheable modules 153 bytes ./entry.js 94 bytes [built] [code generated] ./modules/a.js 37 bytes [built] [code generated] @@ -501,7 +501,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-with-invalid-options-comments 1`] = ` -"runtime modules 9.49 KiB 12 modules +"runtime modules 9.27 KiB 12 modules cacheable modules 559 bytes ./index.js 50 bytes [built] [code generated] ./chunk.js 401 bytes [built] [code generated] [2 warnings] @@ -540,20 +540,20 @@ Rspack x.x.x compiled with 2 warnings" `; exports[`StatsTestCases should print correct stats for issue-7577 1`] = ` -"asset a-runtime~main-8ed37b9e446eb01b.js 3.69 KiB [emitted] [immutable] (name: runtime~main) +"asset a-runtime~main-bee03820f30f4a05.js 3.6 KiB [emitted] [immutable] (name: runtime~main) asset a-main-f9892dc0f961d982.js 387 bytes [emitted] [immutable] (name: main) asset a-all-a_js-cace9eea394248e7.js 128 bytes [emitted] [immutable] (id hint: all) -Entrypoint main 4.19 KiB = a-runtime~main-8ed37b9e446eb01b.js 3.69 KiB a-all-a_js-cace9eea394248e7.js 128 bytes a-main-f9892dc0f961d982.js 387 bytes -runtime modules 2.59 KiB 3 modules +Entrypoint main 4.1 KiB = a-runtime~main-bee03820f30f4a05.js 3.6 KiB a-all-a_js-cace9eea394248e7.js 128 bytes a-main-f9892dc0f961d982.js 387 bytes +runtime modules 2.5 KiB 3 modules ./a.js 18 bytes [built] [code generated] Rspack x.x.x compiled successfully in X.23 -asset b-runtime~main-d374c52d52a8c105.js 4.38 KiB [emitted] [immutable] (name: runtime~main) +asset b-runtime~main-76389ef10c5c9516.js 4.25 KiB [emitted] [immutable] (name: runtime~main) asset b-all-b_js-f689e3be6ed05e06.js 453 bytes [emitted] [immutable] (id hint: all) asset b-main-a97968a81f0fafdb.js 420 bytes [emitted] [immutable] (name: main) asset b-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 5.41 KiB = b-runtime~main-d374c52d52a8c105.js 4.38 KiB b-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes b-all-b_js-f689e3be6ed05e06.js 453 bytes b-main-a97968a81f0fafdb.js 420 bytes -runtime modules 3.17 KiB 5 modules +Entrypoint main 5.27 KiB = b-runtime~main-76389ef10c5c9516.js 4.25 KiB b-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes b-all-b_js-f689e3be6ed05e06.js 453 bytes b-main-a97968a81f0fafdb.js 420 bytes +runtime modules 3.04 KiB 5 modules cacheable modules 40 bytes ./b.js 17 bytes [built] [code generated] ./node_modules/vendor.js 23 bytes [built] [code generated] @@ -562,11 +562,11 @@ Rspack x.x.x compiled successfully in X.23 assets by chunk 862 bytes (id hint: all) asset c-all-b_js-b683c5304b71900e.js 480 bytes [emitted] [immutable] (id hint: all) asset c-all-c_js-2c876c6ecab93d9b.js 382 bytes [emitted] [immutable] (id hint: all) -asset c-runtime~main-d7f987785eb841d4.js 11.1 KiB [emitted] [immutable] (name: runtime~main) -asset c-main-1b0ba12f79ed8053.js 643 bytes [emitted] [immutable] (name: main) +asset c-runtime~main-54907b49863c22c2.js 10.8 KiB [emitted] [immutable] (name: runtime~main) +asset c-main-5df1191222ffdffb.js 588 bytes [emitted] [immutable] (name: main) asset c-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 12.1 KiB = c-runtime~main-d7f987785eb841d4.js 11.1 KiB c-all-c_js-2c876c6ecab93d9b.js 382 bytes c-main-1b0ba12f79ed8053.js 643 bytes -runtime modules 9.7 KiB 13 modules +Entrypoint main 11.8 KiB = c-runtime~main-54907b49863c22c2.js 10.8 KiB c-all-c_js-2c876c6ecab93d9b.js 382 bytes c-main-5df1191222ffdffb.js 588 bytes +runtime modules 9.39 KiB 13 modules cacheable modules 101 bytes ./c.js 61 bytes [built] [code generated] ./b.js 17 bytes [built] [code generated] @@ -576,8 +576,8 @@ Rspack x.x.x compiled successfully in X.23" exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1`] = ` "1 chunks: - asset bundle1.js 4.06 KiB [emitted] (name: main) - chunk (runtime: main) bundle1.js (main) 357 bytes (javascript) 1.84 KiB (runtime) <{909}> >{909}< [entry] [rendered] + asset bundle1.js 3.97 KiB [emitted] (name: main) + chunk (runtime: main) bundle1.js (main) 357 bytes (javascript) 1.75 KiB (runtime) <{909}> >{909}< [entry] [rendered] ./a.js 22 bytes [dependent] [built] [code generated] ./c.js 30 bytes [dependent] [built] [code generated] ./d.js 22 bytes [dependent] [built] [code generated] @@ -597,7 +597,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1 chunks (Rspack x.x.x) compiled with 1 warning in X.23 2 chunks: - asset bundle2.js 10.6 KiB [emitted] (name: main) + asset bundle2.js 10.4 KiB [emitted] (name: main) asset 76.bundle2.js 553 bytes [emitted] (name: c) chunk (runtime: main) 76.bundle2.js (c) 96 bytes <{76}> <{909}> >{76}< [rendered] dependent modules 44 bytes [dependent] @@ -605,7 +605,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin ./e.js 22 bytes [dependent] [built] [code generated] ./a.js 22 bytes [built] [code generated] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle2.js (main) 261 bytes (javascript) 8.45 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle2.js (main) 261 bytes (javascript) 8.25 KiB (runtime) >{76}< [entry] [rendered] ./index.js 101 bytes [built] [code generated] [1 warning] Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] @@ -621,7 +621,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 2 chunks (Rspack x.x.x) compiled with 1 warning in X.23 3 chunks: - asset bundle3.js 10.6 KiB [emitted] (name: main) + asset bundle3.js 10.4 KiB [emitted] (name: main) asset 76.bundle3.js 387 bytes [emitted] (name: c) asset 588.bundle3.js 242 bytes [emitted] chunk (runtime: main) 588.bundle3.js 66 bytes <{76}> <{909}> [rendered] @@ -630,7 +630,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin ./e.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle3.js (c) 30 bytes <{909}> >{588}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle3.js (main) 261 bytes (javascript) 8.45 KiB (runtime) >{588}< >{76}< [entry] [rendered] + chunk (runtime: main) bundle3.js (main) 261 bytes (javascript) 8.25 KiB (runtime) >{588}< >{76}< [entry] [rendered] ./index.js 101 bytes [built] [code generated] [1 warning] Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] @@ -646,7 +646,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 3 chunks (Rspack x.x.x) compiled with 1 warning in X.23 4 chunks: - asset bundle4.js 10.6 KiB [emitted] (name: main) + asset bundle4.js 10.4 KiB [emitted] (name: main) asset 76.bundle4.js 387 bytes [emitted] (name: c) asset 345.bundle4.js 186 bytes [emitted] asset 272.bundle4.js 130 bytes [emitted] @@ -657,7 +657,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin ./e.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle4.js (c) 30 bytes <{909}> >{345}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle4.js (main) 261 bytes (javascript) 8.45 KiB (runtime) >{272}< >{76}< [entry] [rendered] + chunk (runtime: main) bundle4.js (main) 261 bytes (javascript) 8.25 KiB (runtime) >{272}< >{76}< [entry] [rendered] ./index.js 101 bytes [built] [code generated] [1 warning] Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] @@ -726,23 +726,23 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for module-assets 1`] = ` -"assets by path *.js 9.02 KiB - asset main.js 8.58 KiB [emitted] (name: main) +"assets by path *.js 8.88 KiB + asset main.js 8.44 KiB [emitted] (name: main) asset b.js 226 bytes [emitted] (name: b) asset a.js 225 bytes [emitted] (name: a) assets by path *.png 42 KiB asset 1.png 21 KiB [emitted] [from: node_modules/a/1.png] asset 2.png 21 KiB [emitted] [from: node_modules/a/2.png] -Entrypoint main 8.58 KiB = main.js +Entrypoint main 8.44 KiB = main.js Chunk Group a 225 bytes = a.js Chunk Group b 226 bytes = b.js chunk (runtime: main) a.js (a) 36 bytes [rendered] ./node_modules/a/index.js 36 bytes [built] [code generated] chunk (runtime: main) b.js (b) 18 bytes [rendered] ./node_modules/b/index.js 18 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 82 bytes (javascript) 7.01 KiB (runtime) [entry] [rendered] +chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.87 KiB (runtime) [entry] [rendered] ./index.js 82 bytes [built] [code generated] -runtime modules 7.01 KiB 8 modules +runtime modules 6.87 KiB 8 modules orphan modules 98 bytes [orphan] 2 modules modules with assets 136 bytes ./index.js 82 bytes [built] [code generated] @@ -752,12 +752,12 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for module-deduplication 1`] = ` -"asset e1.js 10 KiB [emitted] (name: e1) -asset e2.js 10 KiB [emitted] (name: e2) -asset e3.js 10 KiB [emitted] (name: e3) -asset 106.js 768 bytes [emitted] -asset 511.js 768 bytes [emitted] -asset 637.js 768 bytes [emitted] +"asset e1.js 9.84 KiB [emitted] (name: e1) +asset e2.js 9.84 KiB [emitted] (name: e2) +asset e3.js 9.84 KiB [emitted] (name: e3) +asset 106.js 753 bytes [emitted] +asset 511.js 753 bytes [emitted] +asset 637.js 753 bytes [emitted] asset 263.js 504 bytes [emitted] asset 400.js 504 bytes [emitted] asset 806.js 504 bytes [emitted] @@ -771,20 +771,20 @@ chunk (runtime: e3) 400.js 61 bytes [rendered] chunk (runtime: e1, e3) 511.js 81 bytes [rendered] ./async2.js 61 bytes [built] [code generated] ./f.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e1) e1.js (e1) 249 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] +chunk (runtime: e1) e1.js (e1) 249 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] ./e1.js + 2 modules 209 bytes [code generated] chunk (runtime: e2, e3) 637.js 81 bytes [rendered] ./async1.js 61 bytes [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e3) e3.js (e3) 249 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] +chunk (runtime: e3) e3.js (e3) 249 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e3.js + 2 modules 209 bytes [code generated] ./h.js 20 bytes [dependent] [built] [code generated] chunk (runtime: e2) 806.js 61 bytes [rendered] ./async2.js 61 bytes [built] [code generated] -chunk (runtime: e2) e2.js (e2) 249 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 249 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e2.js + 2 modules 209 bytes [code generated] ./f.js 20 bytes [dependent] [built] [code generated] @@ -792,16 +792,16 @@ Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for module-deduplication-named 1`] = ` -"asset e1.js 9.87 KiB [emitted] (name: e1) -asset e2.js 9.87 KiB [emitted] (name: e2) -asset e3.js 9.87 KiB [emitted] (name: e3) -asset async1.js 880 bytes [emitted] (name: async1) -asset async2.js 879 bytes [emitted] (name: async2) -asset async3.js 879 bytes [emitted] (name: async3) +"asset e1.js 9.7 KiB [emitted] (name: e1) +asset e2.js 9.7 KiB [emitted] (name: e2) +asset e3.js 9.7 KiB [emitted] (name: e3) +asset async1.js 865 bytes [emitted] (name: async1) +asset async2.js 864 bytes [emitted] (name: async2) +asset async3.js 864 bytes [emitted] (name: async3) chunk (runtime: e1, e2, e3) async3.js (async3) 135 bytes [rendered] ./async3.js 115 bytes [built] [code generated] ./h.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e1) e1.js (e1) 242 bytes (javascript) 7.32 KiB (runtime) [entry] [rendered] +chunk (runtime: e1) e1.js (e1) 242 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] ./e1.js + 2 modules 202 bytes [code generated] @@ -811,11 +811,11 @@ chunk (runtime: e1, e2, e3) async2.js (async2) 135 bytes [rendered] chunk (runtime: e1, e2, e3) async1.js (async1) 135 bytes [rendered] ./async1.js 115 bytes [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e3) e3.js (e3) 242 bytes (javascript) 7.32 KiB (runtime) [entry] [rendered] +chunk (runtime: e3) e3.js (e3) 242 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e3.js + 2 modules 202 bytes [code generated] ./h.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e2) e2.js (e2) 242 bytes (javascript) 7.32 KiB (runtime) [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 242 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e2.js + 2 modules 202 bytes [code generated] ./f.js 20 bytes [dependent] [built] [code generated] @@ -925,10 +925,10 @@ Rspack x.x.x compiled with 2 errors in X.23" `; exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] = ` -"Chunk Group async-a 1020 bytes = a-727.js 250 bytes a-async-a.js 766 bytes -Chunk Group async-b 1020 bytes = a-727.js 250 bytes a-async-b.js 766 bytes -Chunk Group async-c 1.25 KiB = a-vendors.js 616 bytes a-async-c.js 669 bytes -Chunk Group main 9.59 KiB = a-main.js +"Chunk Group async-a 1000 bytes = a-727.js 250 bytes a-async-a.js 751 bytes +Chunk Group async-b 1000 bytes = a-727.js 250 bytes a-async-b.js 751 bytes +Chunk Group async-c 1.21 KiB = a-vendors.js 586 bytes a-async-c.js 654 bytes +Chunk Group main 9.41 KiB = a-main.js chunk (runtime: main) a-async-c.js (async-c) 67 bytes [rendered] > ./c ./index.js 3:0-47 ./c.js 67 bytes [built] [code generated] @@ -946,15 +946,15 @@ chunk (runtime: main) a-727.js (id hint: ) 149 bytes [rendered] split chunk (cac > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 7.65 KiB (runtime) [entry] [rendered] +chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 7.47 KiB (runtime) [entry] [rendered] > ./ main ./index.js 146 bytes [built] [code generated] Rspack x.x.x compiled successfully -Entrypoint main 9.59 KiB = b-main.js -Chunk Group async-a 1020 bytes = b-727.js 250 bytes b-async-a.js 766 bytes -Chunk Group async-b 1020 bytes = b-727.js 250 bytes b-async-b.js 766 bytes -Chunk Group async-c 1.25 KiB = b-vendors.js 616 bytes b-async-c.js 669 bytes +Entrypoint main 9.41 KiB = b-main.js +Chunk Group async-a 1000 bytes = b-727.js 250 bytes b-async-a.js 751 bytes +Chunk Group async-b 1000 bytes = b-727.js 250 bytes b-async-b.js 751 bytes +Chunk Group async-c 1.21 KiB = b-vendors.js 586 bytes b-async-c.js 654 bytes chunk (runtime: main) b-async-c.js (async-c) 67 bytes [rendered] > ./c ./index.js 3:0-47 ./c.js 67 bytes [built] [code generated] @@ -972,17 +972,17 @@ chunk (runtime: main) b-727.js (id hint: ) 149 bytes [rendered] split chunk (cac > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 7.65 KiB (runtime) [entry] [rendered] +chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 7.47 KiB (runtime) [entry] [rendered] > ./ main ./index.js 146 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for named-chunks-plugin 1`] = ` -"asset entry.js 4.27 KiB [emitted] (name: entry) +"asset entry.js 4.18 KiB [emitted] (name: entry) asset vendor.js 211 bytes [emitted] (name: vendor) (id hint: vendor) -Entrypoint entry 4.48 KiB = vendor.js 211 bytes entry.js 4.27 KiB -runtime modules 2.58 KiB 3 modules +Entrypoint entry 4.39 KiB = vendor.js 211 bytes entry.js 4.18 KiB +runtime modules 2.49 KiB 3 modules cacheable modules 138 bytes ./entry.js 72 bytes [built] [code generated] ./modules/a.js 22 bytes [built] [code generated] @@ -992,7 +992,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for optimize-chunks 1`] = ` -"asset main.js 9.29 KiB {909} [emitted] (name: main) +"asset main.js 9.16 KiB {909} [emitted] (name: main) asset cir2 from cir1.js 355 bytes {334} [emitted] (name: cir2 from cir1) asset cir1.js 327 bytes {228} [emitted] (name: cir1) asset cir2.js 327 bytes {787} [emitted] (name: cir2) @@ -1024,7 +1024,7 @@ chunk {405} (runtime: main) ac in ab.js (ac in ab) 2 bytes <{909}> [rendered] chunk {787} (runtime: main) cir2.js (cir2) 81 bytes <{909}> >{228}< [rendered] > [10] ./index.js 14:0-54 ./circular2.js [193] 81 bytes {334} {787} [built] [code generated] -chunk {909} (runtime: main) main.js (main) 524 bytes (javascript) 6.82 KiB (runtime) >{228}< >{295}< >{37}< >{405}< >{787}< >{919}< [entry] [rendered] +chunk {909} (runtime: main) main.js (main) 524 bytes (javascript) 6.69 KiB (runtime) >{228}< >{295}< >{37}< >{405}< >{787}< >{919}< [entry] [rendered] > ./index main ./index.js [10] 523 bytes {909} [built] [code generated] ./modules/f.js [544] 1 bytes {909} [dependent] [built] [code generated] @@ -1039,9 +1039,9 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for output-module 1`] = ` -"asset main.mjs 7.91 KiB [emitted] [javascript module] (name: main) -asset 8.mjs 285 bytes [emitted] [javascript module] -runtime modules 6.2 KiB 8 modules +"asset main.mjs 7.84 KiB [emitted] [javascript module] (name: main) +asset 8.mjs 270 bytes [emitted] [javascript module] +runtime modules 6.13 KiB 8 modules orphan modules 225 bytes [orphan] 2 modules cacheable modules 263 bytes ./index.js + 1 modules 225 bytes [code generated] @@ -1202,22 +1202,22 @@ Rspack x.x.x compiled with 3 errors in X s" `; exports[`StatsTestCases should print correct stats for prefetch 1`] = ` -"asset main.js 13.9 KiB {909} [emitted] (name: main) +"asset main.js 13.5 KiB {909} [emitted] (name: main) asset prefetched.js 554 bytes {674} [emitted] (name: prefetched) asset inner2.js 130 bytes {857} [emitted] (name: inner2) asset inner.js 102 bytes {481} [emitted] (name: inner) asset normal.js 102 bytes {615} [emitted] (name: normal) asset prefetched2.js 102 bytes {424} [emitted] (name: prefetched2) asset prefetched3.js 102 bytes {182} [emitted] (name: prefetched3) -Entrypoint main 13.9 KiB = main.js - prefetch: prefetched.js {674} (name: prefetched), prefetched3.js {182} (name: prefetched3), prefetched2.js {424} (name: prefetched2) +Entrypoint main 13.5 KiB = main.js + prefetch: prefetched.js {674} (name: prefetched) chunk {182} (runtime: main) prefetched3.js (prefetched3) 1 bytes <{909}> [rendered] chunk {424} (runtime: main) prefetched2.js (prefetched2) 1 bytes <{909}> [rendered] chunk {481} (runtime: main) inner.js (inner) 1 bytes <{674}> [rendered] chunk {615} (runtime: main) normal.js (normal) 1 bytes <{909}> [rendered] chunk {674} (runtime: main) prefetched.js (prefetched) 228 bytes <{909}> >{481}< >{857}< (prefetch: {857} {481}) [rendered] chunk {857} (runtime: main) inner2.js (inner2) 2 bytes <{674}> [rendered] -chunk {909} (runtime: main) main.js (main) 436 bytes (javascript) 11 KiB (runtime) >{182}< >{424}< >{615}< >{674}< (prefetch: {674} {182} {424}) [entry] [rendered]" +chunk {909} (runtime: main) main.js (main) 436 bytes (javascript) 10.6 KiB (runtime) >{182}< >{424}< >{615}< >{674}< (prefetch: {674}) [entry] [rendered]" `; exports[`StatsTestCases should print correct stats for prefetch-preload-mixed 1`] = ` @@ -1231,26 +1231,26 @@ chunk (runtime: main) a2.js (a2) 1 bytes <{74}> [rendered] chunk (runtime: main) b.js (b) 203 bytes <{909}> >{438}< >{439}< >{826}< (prefetch: {826} {438}) (preload: {439}) [rendered] chunk (runtime: main) c.js (c) 134 bytes <{909}> >{380}< >{433}< (preload: {433} {380}) [rendered] chunk (runtime: main) b1.js (b1) 1 bytes <{751}> [rendered] -chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.7 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered]" +chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.3 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered]" `; exports[`StatsTestCases should print correct stats for preload 1`] = ` -"asset main.js 12.5 KiB [emitted] (name: main) +"asset main.js 12.2 KiB [emitted] (name: main) asset preloaded.js 554 bytes [emitted] (name: preloaded) asset inner2.js 130 bytes [emitted] (name: inner2) asset inner.js 102 bytes [emitted] (name: inner) asset normal.js 102 bytes [emitted] (name: normal) asset preloaded2.js 101 bytes [emitted] (name: preloaded2) asset preloaded3.js 100 bytes [emitted] (name: preloaded3) -Entrypoint main 12.5 KiB = main.js - preload: preloaded.js {154} (name: preloaded), preloaded3.js {551} (name: preloaded3), preloaded2.js {577} (name: preloaded2) +Entrypoint main 12.2 KiB = main.js + preload: preloaded.js {154} (name: preloaded) chunk (runtime: main) preloaded.js (preloaded) 226 bytes (preload: {857} {481}) [rendered] chunk (runtime: main) inner.js (inner) 1 bytes [rendered] chunk (runtime: main) preloaded3.js (preloaded3) 1 bytes [rendered] chunk (runtime: main) preloaded2.js (preloaded2) 1 bytes [rendered] chunk (runtime: main) normal.js (normal) 1 bytes [rendered] chunk (runtime: main) inner2.js (inner2) 2 bytes [rendered] -chunk (runtime: main) main.js (main) 424 bytes (javascript) 9.78 KiB (runtime) (preload: {154} {551} {577}) [entry] [rendered]" +chunk (runtime: main) main.js (main) 424 bytes (javascript) 9.53 KiB (runtime) (preload: {154}) [entry] [rendered]" `; exports[`StatsTestCases should print correct stats for preset-errors-only 1`] = `""`; @@ -1320,61 +1320,61 @@ Rspack x.x.x compiled successfully" exports[`StatsTestCases should print correct stats for related-assets 1`] = ` "default: - assets by path *.br 14 KiB - asset default-main.js.br 12 KiB [emitted] - asset default-main.js.map.br 675 bytes [emitted] + assets by path *.br 13.8 KiB + asset default-main.js.br 11.8 KiB [emitted] + asset default-main.js.map.br 671 bytes [emitted] + 6 assets - assets by path *.gz 14 KiB - asset default-main.js.gz 12 KiB [emitted] - asset default-main.js.map.gz 675 bytes [emitted] + assets by path *.gz 13.8 KiB + asset default-main.js.gz 11.8 KiB [emitted] + asset default-main.js.map.gz 671 bytes [emitted] asset default-chunk_js.js.gz 611 bytes [emitted] + 5 assets - assets by path *.js 12.6 KiB - asset default-main.js 12 KiB [emitted] (name: main) + assets by path *.js 12.4 KiB + asset default-main.js 11.8 KiB [emitted] (name: main) asset default-chunk_js.js 611 bytes [emitted] assets by path *.css 142 bytes asset default-chunk_js.css 73 bytes [emitted] asset default-main.css 69 bytes [emitted] (name: main) relatedAssets: - assets by path *.br 14 KiB - asset relatedAssets-main.js.br 12 KiB [emitted] - asset relatedAssets-main.js.map.br 681 bytes [emitted] + assets by path *.br 13.9 KiB + asset relatedAssets-main.js.br 11.9 KiB [emitted] + asset relatedAssets-main.js.map.br 677 bytes [emitted] + 6 assets - assets by path *.gz 14 KiB - asset relatedAssets-main.js.gz 12 KiB [emitted] - asset relatedAssets-main.js.map.gz 681 bytes [emitted] + assets by path *.gz 13.9 KiB + asset relatedAssets-main.js.gz 11.9 KiB [emitted] + asset relatedAssets-main.js.map.gz 677 bytes [emitted] asset relatedAssets-chunk_js.js.gz 617 bytes [emitted] + 5 assets - assets by path *.js 12.6 KiB - asset relatedAssets-main.js 12 KiB [emitted] (name: main) + assets by path *.js 12.5 KiB + asset relatedAssets-main.js 11.9 KiB [emitted] (name: main) asset relatedAssets-chunk_js.js 617 bytes [emitted] assets by path *.css 154 bytes asset relatedAssets-chunk_js.css 79 bytes [emitted] asset relatedAssets-main.css 75 bytes [emitted] (name: main) exclude1: - hidden assets 28 KiB 16 assets - assets by status 12.7 KiB [emitted] - assets by path *.js 12.6 KiB - asset exclude1-main.js 12 KiB [emitted] (name: main) + hidden assets 27.7 KiB 16 assets + assets by status 12.6 KiB [emitted] + assets by path *.js 12.4 KiB + asset exclude1-main.js 11.9 KiB [emitted] (name: main) asset exclude1-chunk_js.js 612 bytes [emitted] assets by path *.css 144 bytes asset exclude1-chunk_js.css 74 bytes [emitted] asset exclude1-main.css 70 bytes [emitted] (name: main) exclude2: - assets by path *.br 14 KiB - asset exclude2-main.js.br 12 KiB [emitted] - asset exclude2-main.js.map.br 676 bytes [emitted] + assets by path *.br 13.9 KiB + asset exclude2-main.js.br 11.9 KiB [emitted] + asset exclude2-main.js.map.br 672 bytes [emitted] + 6 assets - assets by path *.gz 14 KiB - asset exclude2-main.js.gz 12 KiB [emitted] - asset exclude2-main.js.map.gz 676 bytes [emitted] + assets by path *.gz 13.9 KiB + asset exclude2-main.js.gz 11.9 KiB [emitted] + asset exclude2-main.js.map.gz 672 bytes [emitted] asset exclude2-chunk_js.js.gz 612 bytes [emitted] + 5 assets - assets by path *.js 12.6 KiB - asset exclude2-main.js 12 KiB [emitted] (name: main) + assets by path *.js 12.4 KiB + asset exclude2-main.js 11.9 KiB [emitted] (name: main) asset exclude2-chunk_js.js 612 bytes [emitted] assets by path *.css 144 bytes asset exclude2-chunk_js.css 74 bytes [emitted] @@ -1382,19 +1382,19 @@ exclude2: exclude3: hidden assets 2.89 KiB 10 assets - assets by status 37.8 KiB [emitted] - assets by path *.br 12.9 KiB - asset exclude3-main.js.br 12 KiB [emitted] - asset exclude3-main.js.map.br 676 bytes [emitted] + assets by status 37.4 KiB [emitted] + assets by path *.br 12.7 KiB + asset exclude3-main.js.br 11.9 KiB [emitted] + asset exclude3-main.js.map.br 672 bytes [emitted] asset exclude3-main.css.map.br 171 bytes [emitted] asset exclude3-main.css.br 70 bytes [emitted] - assets by path *.gz 12.9 KiB - asset exclude3-main.js.gz 12 KiB [emitted] - asset exclude3-main.js.map.gz 676 bytes [emitted] + assets by path *.gz 12.7 KiB + asset exclude3-main.js.gz 11.9 KiB [emitted] + asset exclude3-main.js.map.gz 672 bytes [emitted] asset exclude3-main.css.map.gz 171 bytes [emitted] asset exclude3-main.css.gz 70 bytes [emitted] - assets by chunk 12.1 KiB (name: main) - asset exclude3-main.js 12 KiB [emitted] (name: main) + assets by chunk 11.9 KiB (name: main) + asset exclude3-main.js 11.9 KiB [emitted] (name: main) asset exclude3-main.css 70 bytes [emitted] (name: main)" `; @@ -1435,34 +1435,34 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for runtime-chunk 1`] = ` -"Entrypoint e1 4.07 KiB = runtime~e1.js 3.68 KiB e1.js 391 bytes -Entrypoint e2 4.07 KiB = runtime~e2.js 3.68 KiB e2.js 391 bytes +"Entrypoint e1 3.98 KiB = runtime~e1.js 3.59 KiB e1.js 391 bytes +Entrypoint e2 3.98 KiB = runtime~e2.js 3.59 KiB e2.js 391 bytes Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for runtime-chunk-issue-7382 1`] = ` -"Entrypoint e1 4.36 KiB = runtime.js 3.68 KiB all.js 310 bytes e1.js 381 bytes -Entrypoint e2 4.36 KiB = runtime.js 3.68 KiB all.js 310 bytes e2.js 381 bytes +"Entrypoint e1 4.27 KiB = runtime.js 3.59 KiB all.js 310 bytes e1.js 381 bytes +Entrypoint e2 4.27 KiB = runtime.js 3.59 KiB all.js 310 bytes e2.js 381 bytes Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for runtime-chunk-single 1`] = ` -"Entrypoint e1 4.06 KiB = runtime.js 3.68 KiB e1.js 391 bytes -Entrypoint e2 4.06 KiB = runtime.js 3.68 KiB e2.js 391 bytes +"Entrypoint e1 3.97 KiB = runtime.js 3.59 KiB e1.js 391 bytes +Entrypoint e2 3.97 KiB = runtime.js 3.59 KiB e2.js 391 bytes Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for runtime-specific-used-exports 1`] = ` "production: - asset production-a.js 10.7 KiB [emitted] (name: a) - asset production-b.js 10.7 KiB [emitted] (name: b) - asset production-dx_js.js 952 bytes [emitted] - asset production-dw_js-_b3b00.js 928 bytes [emitted] - asset production-dw_js-_b3b01.js 928 bytes [emitted] - asset production-dy_js.js 921 bytes [emitted] - asset production-dz_js.js 921 bytes [emitted] + asset production-a.js 10.5 KiB [emitted] (name: a) + asset production-b.js 10.5 KiB [emitted] (name: b) + asset production-dx_js.js 847 bytes [emitted] + asset production-dw_js-_b3b00.js 838 bytes [emitted] + asset production-dw_js-_b3b01.js 838 bytes [emitted] + asset production-dy_js.js 831 bytes [emitted] + asset production-dz_js.js 831 bytes [emitted] asset production-c.js 45 bytes [emitted] (name: c) - chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] + chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] ./a.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1473,7 +1473,7 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp [only some exports used: x, y] ./reexport.js 37 bytes [dependent] [built] [code generated] [only some exports used: x, y] - chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] + chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] ./b.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1507,7 +1507,7 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp ./dz.js 46 bytes [built] [code generated] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [only some exports used: identity, w, x, y, z] - runtime modules 14.5 KiB 18 modules + runtime modules 14.3 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [no exports used] @@ -1532,14 +1532,14 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp production (Rspack x.x.x) compiled successfully in X.23 development: - asset development-a.js 12.3 KiB [emitted] (name: a) - asset development-b.js 12.3 KiB [emitted] (name: b) - asset development-dw_js.js 1.17 KiB [emitted] - asset development-dx_js.js 1.17 KiB [emitted] - asset development-dy_js.js 1.17 KiB [emitted] - asset development-dz_js.js 1.17 KiB [emitted] + asset development-a.js 11.9 KiB [emitted] (name: a) + asset development-b.js 11.9 KiB [emitted] (name: b) + asset development-dw_js.js 1.07 KiB [emitted] + asset development-dx_js.js 1.07 KiB [emitted] + asset development-dy_js.js 1.07 KiB [emitted] + asset development-dz_js.js 1.07 KiB [emitted] asset development-c.js 419 bytes [emitted] (name: c) - chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 7.28 KiB (runtime) [entry] [rendered] + chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] ./a.js 261 bytes [built] [code generated] [used exports unknown] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1550,7 +1550,7 @@ development: [used exports unknown] ./reexport.js 37 bytes [dependent] [built] [code generated] [used exports unknown] - chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 7.28 KiB (runtime) [entry] [rendered] + chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] ./b.js 261 bytes [built] [code generated] [used exports unknown] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1584,7 +1584,7 @@ development: [used exports unknown] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [used exports unknown] - runtime modules 14.6 KiB 18 modules + runtime modules 14.3 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [used exports unknown] @@ -1613,14 +1613,14 @@ development: development (Rspack x.x.x) compiled successfully in X.23 global: - asset global-a.js 10.8 KiB [emitted] (name: a) - asset global-b.js 10.8 KiB [emitted] (name: b) - asset global-dw_js.js 952 bytes [emitted] - asset global-dx_js.js 952 bytes [emitted] - asset global-dy_js.js 952 bytes [emitted] - asset global-dz_js.js 952 bytes [emitted] + asset global-a.js 10.6 KiB [emitted] (name: a) + asset global-b.js 10.6 KiB [emitted] (name: b) + asset global-dw_js.js 847 bytes [emitted] + asset global-dx_js.js 847 bytes [emitted] + asset global-dy_js.js 847 bytes [emitted] + asset global-dz_js.js 847 bytes [emitted] asset global-c.js 45 bytes [emitted] (name: c) - chunk (runtime: a) global-a.js (a) 605 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] + chunk (runtime: a) global-a.js (a) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] ./a.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1631,7 +1631,7 @@ global: [only some exports used: x, y] ./reexport.js 37 bytes [dependent] [built] [code generated] [only some exports used: x, y] - chunk (runtime: b) global-b.js (b) 605 bytes (javascript) 7.27 KiB (runtime) [entry] [rendered] + chunk (runtime: b) global-b.js (b) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] ./b.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1661,7 +1661,7 @@ global: ./dz.js 46 bytes [built] [code generated] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [only some exports used: identity, w, x, y, z] - runtime modules 14.5 KiB 18 modules + runtime modules 14.3 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [no exports used] @@ -1687,7 +1687,7 @@ global: `; exports[`StatsTestCases should print correct stats for scope-hoisting-multi 1`] = ` -"runtime modules 14.6 KiB 18 modules +"runtime modules 14.3 KiB 18 modules orphan modules 118 bytes [orphan] 4 modules cacheable modules 726 bytes ./first.js 236 bytes [built] [code generated] @@ -1699,7 +1699,7 @@ cacheable modules 726 bytes ./common_lazy_shared.js 25 bytes [built] [code generated] Rspack x.x.x compiled successfully in X.23 -runtime modules 14.6 KiB 18 modules +runtime modules 14.3 KiB 18 modules cacheable modules 1.05 KiB built modules 844 bytes [built] orphan modules 325 bytes [orphan] @@ -1724,9 +1724,9 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for side-effects-issue-7428 1`] = ` -"asset main.js 10.1 KiB [emitted] (name: main) -asset 0.js 578 bytes [emitted] -runtime modules 7.26 KiB 9 modules +"asset main.js 9.92 KiB [emitted] (name: main) +asset 0.js 563 bytes [emitted] +runtime modules 7.12 KiB 9 modules cacheable modules 967 bytes modules by path ./components/src/ 501 bytes orphan modules 315 bytes [orphan] @@ -1813,8 +1813,8 @@ Rspack x.x.x compiled successfully in X.23" exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` "default: - Entrypoint main 9.49 KiB = default/main.js - Entrypoint a 9.05 KiB = default/a.js + Entrypoint main 9.34 KiB = default/main.js + Entrypoint a 8.9 KiB = default/a.js Entrypoint b 192 bytes = default/b.js Entrypoint c 192 bytes = default/c.js chunk (runtime: main) default/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -1844,7 +1844,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.31 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.17 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) default/b.js (b) 116 bytes [entry] [rendered] @@ -1858,7 +1858,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` chunk (runtime: c) default/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.36 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) default/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{74}> <{753}> ={581}= [rendered] @@ -1867,8 +1867,8 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` default (Rspack x.x.x) compiled successfully all-chunks: - Entrypoint main 9.49 KiB = all-chunks/main.js - Entrypoint a 9.05 KiB = all-chunks/a.js + Entrypoint main 9.35 KiB = all-chunks/main.js + Entrypoint a 8.91 KiB = all-chunks/a.js Entrypoint b 192 bytes = all-chunks/b.js Entrypoint c 192 bytes = all-chunks/c.js chunk (runtime: main) all-chunks/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -1898,7 +1898,7 @@ all-chunks: > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) all-chunks/a.js (a) 165 bytes (javascript) 7.32 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: a) all-chunks/a.js (a) 165 bytes (javascript) 7.17 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) all-chunks/b.js (b) 116 bytes [entry] [rendered] @@ -1912,7 +1912,7 @@ all-chunks: chunk (runtime: c) all-chunks/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) all-chunks/main.js (main) 147 bytes (javascript) 7.37 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) all-chunks/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) all-chunks/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{74}> <{753}> ={581}= [rendered] @@ -1921,10 +1921,10 @@ all-chunks: all-chunks (Rspack x.x.x) compiled successfully manual: - Entrypoint main 9.25 KiB = manual/main.js - Entrypoint a 11.6 KiB = manual/vendors.js 880 bytes manual/a.js 10.8 KiB - Entrypoint b 5.63 KiB = manual/vendors.js 880 bytes manual/b.js 4.77 KiB - Entrypoint c 5.63 KiB = manual/vendors.js 880 bytes manual/c.js 4.77 KiB + Entrypoint main 9.11 KiB = manual/main.js + Entrypoint a 11.4 KiB = manual/vendors.js 835 bytes manual/a.js 10.6 KiB + Entrypoint b 5.49 KiB = manual/vendors.js 835 bytes manual/b.js 4.68 KiB + Entrypoint c 5.49 KiB = manual/vendors.js 835 bytes manual/c.js 4.68 KiB chunk (runtime: main) manual/async-c.js (async-c) 156 bytes <{909}> ={192}= [rendered] > ./c ./index.js 3:0-47 dependent modules 40 bytes [dependent] 2 modules @@ -1956,25 +1956,25 @@ manual: > ./b ./index.js 2:0-47 dependent modules 40 bytes [dependent] 2 modules ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) manual/a.js (a) 165 bytes (javascript) 8.36 KiB (runtime) ={192}= >{912}< [entry] [rendered] + chunk (runtime: a) manual/a.js (a) 165 bytes (javascript) 8.15 KiB (runtime) ={192}= >{912}< [entry] [rendered] > ./a a > x a > y a > z a ./a.js 165 bytes [built] [code generated] - chunk (runtime: b) manual/b.js (b) 116 bytes (javascript) 2.86 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: b) manual/b.js (b) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] > ./b b > x b > y b > z b ./b.js 116 bytes [built] [code generated] - chunk (runtime: c) manual/c.js (c) 116 bytes (javascript) 2.86 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: c) manual/c.js (c) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] > ./c c > x c > y c > z c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) manual/main.js (main) 147 bytes (javascript) 7.37 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] + chunk (runtime: main) manual/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) manual/async-g.js (async-g) 65 bytes <{192}> <{250}> <{74}> [rendered] @@ -1984,8 +1984,8 @@ manual: manual (Rspack x.x.x) compiled successfully name-too-long: - Entrypoint main 9.49 KiB = name-too-long/main.js - Entrypoint aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 9.05 KiB = name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js + Entrypoint main 9.35 KiB = name-too-long/main.js + Entrypoint aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8.91 KiB = name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js Entrypoint bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 192 bytes = name-too-long/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.js Entrypoint cccccccccccccccccccccccccccccc 192 bytes = name-too-long/cccccccccccccccccccccccccccccc.js chunk (runtime: main) name-too-long/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -2026,20 +2026,20 @@ name-too-long: > ./b ./index.js 2:0-47 > ./c ./index.js 3:0-47 ./d.js 20 bytes [built] [code generated] - chunk (runtime: main) name-too-long/main.js (main) 147 bytes (javascript) 7.37 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) name-too-long/main.js (main) 147 bytes (javascript) 7.23 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, main) name-too-long/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{753}> <{959}> ={581}= [rendered] > ./g ./a.js 6:0-47 ./g.js 45 bytes [built] [code generated] - chunk (runtime: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 165 bytes (javascript) 7.32 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 165 bytes (javascript) 7.18 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ./a.js 165 bytes [built] [code generated] name-too-long (Rspack x.x.x) compiled successfully custom-chunks-filter: - Entrypoint main 9.5 KiB = custom-chunks-filter/main.js - Entrypoint a 9.06 KiB = custom-chunks-filter/a.js + Entrypoint main 9.36 KiB = custom-chunks-filter/main.js + Entrypoint a 8.92 KiB = custom-chunks-filter/a.js Entrypoint b 192 bytes = custom-chunks-filter/b.js Entrypoint c 192 bytes = custom-chunks-filter/c.js chunk (runtime: main) custom-chunks-filter/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -2069,7 +2069,7 @@ custom-chunks-filter: > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) custom-chunks-filter/a.js (a) 165 bytes (javascript) 7.33 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: a) custom-chunks-filter/a.js (a) 165 bytes (javascript) 7.18 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) custom-chunks-filter/b.js (b) 116 bytes [entry] [rendered] @@ -2083,7 +2083,7 @@ custom-chunks-filter: chunk (runtime: c) custom-chunks-filter/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) custom-chunks-filter/main.js (main) 147 bytes (javascript) 7.38 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) custom-chunks-filter/main.js (main) 147 bytes (javascript) 7.23 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) custom-chunks-filter/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{74}> <{753}> ={581}= [rendered] @@ -2092,10 +2092,10 @@ custom-chunks-filter: custom-chunks-filter (Rspack x.x.x) compiled successfully custom-chunks-filter-in-cache-groups: - Entrypoint main 9.28 KiB = custom-chunks-filter-in-cache-groups/main.js - Entrypoint a 11.2 KiB = custom-chunks-filter-in-cache-groups/598.js 388 bytes custom-chunks-filter-in-cache-groups/a.js 10.8 KiB - Entrypoint b 5.63 KiB = custom-chunks-filter-in-cache-groups/vendors.js 880 bytes custom-chunks-filter-in-cache-groups/b.js 4.77 KiB - Entrypoint c 5.63 KiB = custom-chunks-filter-in-cache-groups/vendors.js 880 bytes custom-chunks-filter-in-cache-groups/c.js 4.77 KiB + Entrypoint main 9.14 KiB = custom-chunks-filter-in-cache-groups/main.js + Entrypoint a 11 KiB = custom-chunks-filter-in-cache-groups/598.js 388 bytes custom-chunks-filter-in-cache-groups/a.js 10.6 KiB + Entrypoint b 5.49 KiB = custom-chunks-filter-in-cache-groups/vendors.js 835 bytes custom-chunks-filter-in-cache-groups/b.js 4.68 KiB + Entrypoint c 5.49 KiB = custom-chunks-filter-in-cache-groups/vendors.js 835 bytes custom-chunks-filter-in-cache-groups/c.js 4.68 KiB chunk (runtime: main) custom-chunks-filter-in-cache-groups/async-c.js (async-c) 156 bytes <{909}> ={192}= [rendered] > ./c ./index.js 3:0-47 dependent modules 40 bytes [dependent] 2 modules @@ -2131,25 +2131,25 @@ custom-chunks-filter-in-cache-groups: ./node_modules/x.js 20 bytes [built] [code generated] ./node_modules/y.js 20 bytes [built] [code generated] ./node_modules/z.js 20 bytes [built] [code generated] - chunk (runtime: a) custom-chunks-filter-in-cache-groups/a.js (a) 165 bytes (javascript) 8.39 KiB (runtime) ={598}= >{912}< [entry] [rendered] + chunk (runtime: a) custom-chunks-filter-in-cache-groups/a.js (a) 165 bytes (javascript) 8.18 KiB (runtime) ={598}= >{912}< [entry] [rendered] > ./a a > x a > y a > z a ./a.js 165 bytes [built] [code generated] - chunk (runtime: b) custom-chunks-filter-in-cache-groups/b.js (b) 116 bytes (javascript) 2.86 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: b) custom-chunks-filter-in-cache-groups/b.js (b) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] > ./b b > x b > y b > z b ./b.js 116 bytes [built] [code generated] - chunk (runtime: c) custom-chunks-filter-in-cache-groups/c.js (c) 116 bytes (javascript) 2.86 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: c) custom-chunks-filter-in-cache-groups/c.js (c) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] > ./c c > x c > y c > z c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) custom-chunks-filter-in-cache-groups/main.js (main) 147 bytes (javascript) 7.4 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] + chunk (runtime: main) custom-chunks-filter-in-cache-groups/main.js (main) 147 bytes (javascript) 7.25 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) custom-chunks-filter-in-cache-groups/async-g.js (async-g) 65 bytes <{192}> <{250}> <{598}> <{74}> [rendered] @@ -2160,7 +2160,7 @@ custom-chunks-filter-in-cache-groups: `; exports[`StatsTestCases should print correct stats for split-chunks-automatic-name 1`] = ` -"Entrypoint main 9.56 KiB = main.js +"Entrypoint main 9.42 KiB = main.js chunk (runtime: main) async-a.js (async-a) (id hint: common) 136 bytes <{main}> ={common-d_js}= ={common-node_modules_x_js}= ={common-node_modules_y_js}= [rendered] > ./a ./index.js 1:0-47 ./a.js + 1 modules 136 bytes [code generated] @@ -2191,14 +2191,14 @@ chunk (runtime: main) common-node_modules_y_js.js (id hint: common) 20 bytes <{m chunk (runtime: main) common-node_modules_z_js.js (id hint: common) 20 bytes <{main}> ={async-c}= ={common-d_js}= ={common-f_js}= ={common-node_modules_x_js}= [rendered] split chunk (cache group: b) > ./c ./index.js 3:0-47 ./node_modules/z.js 20 bytes [built] [code generated] -chunk (runtime: main) main.js (main) (id hint: common) 147 bytes (javascript) 7.27 KiB (runtime) >{async-a}< >{async-b}< >{async-c}< >{common-d_js}< >{common-f_js}< >{common-node_modules_x_js}< >{common-node_modules_y_js}< >{common-node_modules_z_js}< [entry] [rendered] +chunk (runtime: main) main.js (main) (id hint: common) 147 bytes (javascript) 7.12 KiB (runtime) >{async-a}< >{async-b}< >{async-c}< >{common-d_js}< >{common-f_js}< >{common-node_modules_x_js}< >{common-node_modules_y_js}< >{common-node_modules_z_js}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] production (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-chunk-name 1`] = ` -"Entrypoint main 9.21 KiB = default/main.js +"Entrypoint main 9.06 KiB = default/main.js chunk (runtime: main) default/async-a.js (async-a) 20 bytes <{909}> [rendered] > a ./index.js 1:0-45 ./node_modules/a.js 20 bytes [built] [code generated] @@ -2209,14 +2209,14 @@ chunk (runtime: main) default/async-c-1.js (async-c-1) (id hint: vendors) 122 by > c ./index.js 3:0-47 > c ./index.js 4:0-47 ./node_modules/c.js 122 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 192 bytes (javascript) 7.34 KiB (runtime) >{250}< >{262}< >{589}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 192 bytes (javascript) 7.19 KiB (runtime) >{250}< >{262}< >{589}< [entry] [rendered] > ./ main ./index.js 192 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-combinations 1`] = ` -"Entrypoint main 9.68 KiB = main.js +"Entrypoint main 9.53 KiB = main.js chunk (runtime: main) async-c.js (async-c) 132 bytes <{909}> [rendered] > ./c ./index.js 3:0-47 dependent modules 87 bytes [dependent] 1 module @@ -2244,7 +2244,7 @@ chunk (runtime: main) async-d.js (async-d) 132 bytes <{909}> [rendered] > ./d ./index.js 4:0-47 dependent modules 87 bytes [dependent] 1 module ./d.js 45 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 343 bytes (javascript) 7.4 KiB (runtime) >{172}< >{198}< >{250}< >{262}< >{36}< >{407}< >{602}< >{912}< [entry] [rendered] +chunk (runtime: main) main.js (main) 343 bytes (javascript) 7.26 KiB (runtime) >{172}< >{198}< >{250}< >{262}< >{36}< >{407}< >{602}< >{912}< [entry] [rendered] > ./ main ./index.js 343 bytes [built] [code generated] chunk (runtime: main) async-g.js (async-g) 132 bytes <{909}> [rendered] @@ -2255,7 +2255,7 @@ Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-issue-6413 1`] = ` -"Entrypoint main 9.31 KiB = main.js +"Entrypoint main 9.16 KiB = main.js chunk (runtime: main) async-c.js (async-c) 36 bytes <{909}> ={306}= ={418}= [rendered] > ./c ./index.js 3:0-47 ./c.js 36 bytes [built] [code generated] @@ -2275,14 +2275,14 @@ chunk (runtime: main) 418.js (id hint: vendors) 20 bytes <{909}> ={172}= ={250}= > ./b ./index.js 2:0-47 > ./c ./index.js 3:0-47 ./node_modules/x.js 20 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 147 bytes (javascript) 7.33 KiB (runtime) >{172}< >{250}< >{262}< >{306}< >{418}< [entry] [rendered] +chunk (runtime: main) main.js (main) 147 bytes (javascript) 7.19 KiB (runtime) >{172}< >{250}< >{262}< >{306}< >{418}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] default (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-issue-6696 1`] = ` -"Entrypoint main 11 KiB = vendors.js 352 bytes main.js 10.6 KiB +"Entrypoint main 10.7 KiB = vendors.js 337 bytes main.js 10.4 KiB chunk (runtime: main) vendors.js (vendors) (id hint: vendors) 20 bytes ={909}= >{250}< >{262}< [initial] [rendered] split chunk (cache group: vendors) > ./ main ./node_modules/y.js 20 bytes [built] [code generated] @@ -2294,24 +2294,24 @@ chunk (runtime: main) async-b.js (async-b) 49 bytes <{192}> <{909}> [rendered] > ./b ./index.js 3:0-47 dependent modules 20 bytes [dependent] 1 module ./b.js 29 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 134 bytes (javascript) 8.39 KiB (runtime) ={192}= >{250}< >{262}< [entry] [rendered] +chunk (runtime: main) main.js (main) 134 bytes (javascript) 8.17 KiB (runtime) ={192}= >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 134 bytes [built] [code generated] default (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-issue-7401 1`] = ` -"Entrypoint a 4.92 KiB = 418.js 352 bytes a.js 4.58 KiB -Entrypoint b 8.87 KiB = b.js -Chunk Group c 720 bytes = 418.js 352 bytes c.js 368 bytes +"Entrypoint a 4.82 KiB = 418.js 337 bytes a.js 4.49 KiB +Entrypoint b 8.72 KiB = b.js +Chunk Group c 705 bytes = 418.js 337 bytes c.js 368 bytes chunk (runtime: a, b) 418.js (id hint: vendors) 20 bytes <{751}> ={74}= ={76}= [initial] [rendered] split chunk (cache group: defaultVendors) > ./c ./b.js 1:0-41 > ./a a ./node_modules/x.js 20 bytes [built] [code generated] -chunk (runtime: a) a.js (a) 35 bytes (javascript) 2.86 KiB (runtime) ={418}= [entry] [rendered] +chunk (runtime: a) a.js (a) 35 bytes (javascript) 2.77 KiB (runtime) ={418}= [entry] [rendered] > ./a a ./a.js 35 bytes [built] [code generated] -chunk (runtime: b) b.js (b) 43 bytes (javascript) 7.29 KiB (runtime) >{418}< >{76}< [entry] [rendered] +chunk (runtime: b) b.js (b) 43 bytes (javascript) 7.15 KiB (runtime) >{418}< >{76}< [entry] [rendered] > ./b b ./b.js 43 bytes [built] [code generated] chunk (runtime: b) c.js (c) 35 bytes <{751}> ={418}= [rendered] @@ -2321,7 +2321,7 @@ default (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-keep-remaining-size 1`] = ` -"Entrypoint main 9.4 KiB = default/main.js +"Entrypoint main 9.26 KiB = default/main.js chunk (runtime: main) default/async-c.js (async-c) 50 bytes <{909}> ={44}= [rendered] > ./c ./index.js 3:0-47 ./c.js 50 bytes [built] [code generated] @@ -2345,14 +2345,14 @@ chunk (runtime: main) default/async-d.js (async-d) 84 bytes <{909}> ={403}= [ren chunk (runtime: main) default/728.js (id hint: vendors) 126 bytes <{909}> ={250}= [rendered] split chunk (cache group: defaultVendors) > ./a ./index.js 1:0-47 ./node_modules/shared.js?1 126 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 196 bytes (javascript) 7.36 KiB (runtime) >{172}< >{250}< >{262}< >{403}< >{44}< >{602}< >{728}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 196 bytes (javascript) 7.22 KiB (runtime) >{172}< >{250}< >{262}< >{403}< >{44}< >{602}< >{728}< [entry] [rendered] > ./ main ./index.js 196 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-min-size-reduction 1`] = ` -"Entrypoint main 9.57 KiB = default/main.js +"Entrypoint main 9.43 KiB = default/main.js chunk (runtime: main) default/async-c.js (async-c) 50 bytes <{909}> ={44}= [rendered] > ./c ./index.js 3:0-47 ./c.js 50 bytes [built] [code generated] @@ -2377,14 +2377,14 @@ chunk (runtime: main) default/728.js (id hint: vendors) 126 bytes <{909}> ={250} > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./node_modules/shared.js?1 126 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 245 bytes (javascript) 7.38 KiB (runtime) >{172}< >{250}< >{262}< >{407}< >{44}< >{602}< >{728}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 245 bytes (javascript) 7.24 KiB (runtime) >{172}< >{250}< >{262}< >{407}< >{44}< >{602}< >{728}< [entry] [rendered] > ./ main ./index.js 245 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-prefer-bigger-splits 1`] = ` -"Entrypoint main 9.19 KiB = default/main.js +"Entrypoint main 9.05 KiB = default/main.js chunk (runtime: main) default/async-c.js (async-c) 70 bytes <{909}> ={457}= [rendered] > ./c ./index.js 3:0-47 ./c.js 70 bytes [built] [code generated] @@ -2401,7 +2401,7 @@ chunk (runtime: main) default/457.js (id hint: ) 150 bytes <{909}> ={172}= ={262 > ./c ./index.js 3:0-47 ./d.js 63 bytes [built] [code generated] ./f.js 87 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.35 KiB (runtime) >{172}< >{250}< >{262}< >{457}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.21 KiB (runtime) >{172}< >{250}< >{262}< >{457}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] Rspack x.x.x compiled successfully" @@ -2409,56 +2409,56 @@ Rspack x.x.x compiled successfully" exports[`StatsTestCases should print correct stats for split-chunks-runtime-specific 1`] = ` "used-exports: - asset used-exports-c.js 4.6 KiB [emitted] (name: c) - asset used-exports-b.js 4.59 KiB [emitted] (name: b) - asset used-exports-572.js 370 bytes [emitted] + asset used-exports-c.js 4.5 KiB [emitted] (name: c) + asset used-exports-b.js 4.5 KiB [emitted] (name: b) + asset used-exports-572.js 355 bytes [emitted] asset used-exports-a.js 249 bytes [emitted] (name: a) Entrypoint a 249 bytes = used-exports-a.js - Entrypoint b 4.96 KiB = used-exports-572.js 370 bytes used-exports-b.js 4.59 KiB - Entrypoint c 4.96 KiB = used-exports-572.js 370 bytes used-exports-c.js 4.6 KiB + Entrypoint b 4.85 KiB = used-exports-572.js 355 bytes used-exports-b.js 4.5 KiB + Entrypoint c 4.85 KiB = used-exports-572.js 355 bytes used-exports-c.js 4.5 KiB chunk (runtime: b, c) used-exports-572.js (id hint: ) 72 bytes [initial] [rendered] split chunk (cache group: default) ./objects.js 72 bytes [built] [code generated] chunk (runtime: a) used-exports-a.js (a) 126 bytes [entry] [rendered] ./a.js + 1 modules 126 bytes [code generated] - chunk (runtime: b) used-exports-b.js (b) 54 bytes (javascript) 2.86 KiB (runtime) [entry] [rendered] + chunk (runtime: b) used-exports-b.js (b) 54 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] ./b.js 54 bytes [built] [code generated] - chunk (runtime: c) used-exports-c.js (c) 59 bytes (javascript) 2.86 KiB (runtime) [entry] [rendered] + chunk (runtime: c) used-exports-c.js (c) 59 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] ./c.js 59 bytes [built] [code generated] used-exports (Rspack x.x.x) compiled successfully in X.23 no-used-exports: - asset no-used-exports-c.js 4.67 KiB [emitted] (name: c) - asset no-used-exports-b.js 4.67 KiB [emitted] (name: b) - asset no-used-exports-a.js 4.67 KiB [emitted] (name: a) - asset no-used-exports-572.js 533 bytes [emitted] - Entrypoint a 5.19 KiB = no-used-exports-572.js 533 bytes no-used-exports-a.js 4.67 KiB - Entrypoint b 5.19 KiB = no-used-exports-572.js 533 bytes no-used-exports-b.js 4.67 KiB - Entrypoint c 5.19 KiB = no-used-exports-572.js 533 bytes no-used-exports-c.js 4.67 KiB + asset no-used-exports-c.js 4.58 KiB [emitted] (name: c) + asset no-used-exports-b.js 4.57 KiB [emitted] (name: b) + asset no-used-exports-a.js 4.57 KiB [emitted] (name: a) + asset no-used-exports-572.js 503 bytes [emitted] + Entrypoint a 5.06 KiB = no-used-exports-572.js 503 bytes no-used-exports-a.js 4.57 KiB + Entrypoint b 5.06 KiB = no-used-exports-572.js 503 bytes no-used-exports-b.js 4.57 KiB + Entrypoint c 5.07 KiB = no-used-exports-572.js 503 bytes no-used-exports-c.js 4.58 KiB chunk (runtime: a, b, c) no-used-exports-572.js (id hint: ) 72 bytes [initial] [rendered] split chunk (cache group: default) ./objects.js 72 bytes [built] [code generated] - chunk (runtime: a) no-used-exports-a.js (a) 54 bytes (javascript) 2.89 KiB (runtime) [entry] [rendered] + chunk (runtime: a) no-used-exports-a.js (a) 54 bytes (javascript) 2.79 KiB (runtime) [entry] [rendered] ./a.js 54 bytes [built] [code generated] - chunk (runtime: b) no-used-exports-b.js (b) 54 bytes (javascript) 2.89 KiB (runtime) [entry] [rendered] + chunk (runtime: b) no-used-exports-b.js (b) 54 bytes (javascript) 2.8 KiB (runtime) [entry] [rendered] ./b.js 54 bytes [built] [code generated] - chunk (runtime: c) no-used-exports-c.js (c) 59 bytes (javascript) 2.89 KiB (runtime) [entry] [rendered] + chunk (runtime: c) no-used-exports-c.js (c) 59 bytes (javascript) 2.79 KiB (runtime) [entry] [rendered] ./c.js 59 bytes [built] [code generated] no-used-exports (Rspack x.x.x) compiled successfully in X.23 global: - asset global-c.js 4.6 KiB [emitted] (name: c) - asset global-b.js 4.59 KiB [emitted] (name: b) - asset global-a.js 4.59 KiB [emitted] (name: a) - asset global-572.js 353 bytes [emitted] - Entrypoint a 4.94 KiB = global-572.js 353 bytes global-a.js 4.59 KiB - Entrypoint b 4.94 KiB = global-572.js 353 bytes global-b.js 4.59 KiB - Entrypoint c 4.94 KiB = global-572.js 353 bytes global-c.js 4.6 KiB + asset global-c.js 4.5 KiB [emitted] (name: c) + asset global-b.js 4.5 KiB [emitted] (name: b) + asset global-a.js 4.5 KiB [emitted] (name: a) + asset global-572.js 323 bytes [emitted] + Entrypoint a 4.81 KiB = global-572.js 323 bytes global-a.js 4.5 KiB + Entrypoint b 4.82 KiB = global-572.js 323 bytes global-b.js 4.5 KiB + Entrypoint c 4.82 KiB = global-572.js 323 bytes global-c.js 4.5 KiB chunk (runtime: a, b, c) global-572.js (id hint: ) 72 bytes [initial] [rendered] split chunk (cache group: default) ./objects.js 72 bytes [built] [code generated] - chunk (runtime: a) global-a.js (a) 54 bytes (javascript) 2.86 KiB (runtime) [entry] [rendered] + chunk (runtime: a) global-a.js (a) 54 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] ./a.js 54 bytes [built] [code generated] - chunk (runtime: b) global-b.js (b) 54 bytes (javascript) 2.86 KiB (runtime) [entry] [rendered] + chunk (runtime: b) global-b.js (b) 54 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] ./b.js 54 bytes [built] [code generated] - chunk (runtime: c) global-c.js (c) 59 bytes (javascript) 2.86 KiB (runtime) [entry] [rendered] + chunk (runtime: c) global-c.js (c) 59 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] ./c.js 59 bytes [built] [code generated] global (Rspack x.x.x) compiled successfully in X.23" `; From 60ca71bd1f16aa58f80913dd33cf1e838f927aef Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Thu, 26 Dec 2024 14:09:58 +0800 Subject: [PATCH 02/13] fix: typo --- crates/rspack_core/src/runtime_template.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rspack_core/src/runtime_template.rs b/crates/rspack_core/src/runtime_template.rs index 8f2ab084fa15..ed62fbeaa3fc 100644 --- a/crates/rspack_core/src/runtime_template.rs +++ b/crates/rspack_core/src/runtime_template.rs @@ -107,7 +107,7 @@ impl RuntimeTemplate { .insert(k, v); } } - _ => panic!("Should recive a map value"), + _ => panic!("Should receive a map value"), } } From ef0f1f8c0912ae94773c47b69149d2741f269439 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 27 Dec 2024 15:30:34 +0800 Subject: [PATCH 03/13] feat: runtime tempalte with dojang --- .../import_scripts_chunk_loading.rs | 60 ++++++++++++------- .../runtime/import_scripts_chunk_loading.ejs | 18 ++++++ .../runtime/import_scripts_chunk_loading.js | 20 ------- ...import_scripts_chunk_loading_with_hmr.ejs} | 6 +- ...ripts_chunk_loading_with_hmr_manifest.ejs} | 6 +- .../tests/__snapshots__/StatsAPI.test.js.snap | 4 +- .../__snapshots__/StatsOutput.test.js.snap | 2 +- .../tests/statsAPICases/chunks.js | 2 +- 8 files changed, 67 insertions(+), 51 deletions(-) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{import_scripts_chunk_loading_with_hmr.js => import_scripts_chunk_loading_with_hmr.ejs} (71%) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{import_scripts_chunk_loading_with_hmr_manifest.js => import_scripts_chunk_loading_with_hmr_manifest.ejs} (63%) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs index 93d8542d4876..954b717f0f0e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::{DatabaseItem, Identifier}; use rspack_core::{ compile_boolean_matcher, impl_runtime_module, @@ -64,6 +63,23 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![ + ( + self.id.to_string(), + include_str!("runtime/import_scripts_chunk_loading.ejs").to_string(), + ), + ( + format!("{}_with_hmr", self.id), + include_str!("runtime/import_scripts_chunk_loading_with_hmr.ejs").to_string(), + ), + ( + format!("{}_with_hmr_manifest", self.id), + include_str!("runtime/import_scripts_chunk_loading_with_hmr_manifest.ejs").to_string(), + ), + ] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk = compilation .chunk_by_ukey @@ -143,13 +159,16 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { ) }; + let render_source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "BODY": body, + "CHUNK_LOADING_GLOBAL_EXPR": chunk_loading_global_expr, + })), + )?; + // If chunkId not corresponding chunkName will skip load it. - source.add(RawStringSource::from( - include_str!("runtime/import_scripts_chunk_loading.js") - .cow_replace("$BODY$", body.as_str()) - .cow_replace("$CHUNK_LOADING_GLOBAL_EXPR$", &chunk_loading_global_expr) - .into_owned(), - )); + source.add(RawStringSource::from(render_source)); } if with_hmr { @@ -167,17 +186,14 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { RuntimeGlobals::GET_CHUNK_UPDATE_SCRIPT_FILENAME ) }; - source.add(RawStringSource::from( - include_str!("runtime/import_scripts_chunk_loading_with_hmr.js") - .cow_replace("$URL$", &url) - .cow_replace("$globalObject$", &compilation.options.output.global_object) - .cow_replace( - "$hotUpdateGlobal$", - &serde_json::to_string(&compilation.options.output.hot_update_global) - .expect("failed to serde_json::to_string(hot_update_global)"), - ) - .into_owned(), - )); + + let render_source = compilation.runtime_template.render(&format!("{}_with_hmr", &self.id), Some(serde_json::json!({ + "URL": &url, + "GLOBAL_OBJECT": &compilation.options.output.global_object.as_str(), + "HOT_UPDATE_GLOBAL": &serde_json::to_string(&compilation.options.output.hot_update_global).expect("failed to serde_json::to_string(hot_update_global)"), + })))?; + + source.add(RawStringSource::from(render_source)); source.add(RawStringSource::from(generate_javascript_hmr_runtime( "importScripts", ))); @@ -185,9 +201,11 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { if with_hmr_manifest { // TODO: import_scripts_chunk_loading_with_hmr_manifest same as jsonp_chunk_loading_with_hmr_manifest - source.add(RawStringSource::from_static(include_str!( - "runtime/import_scripts_chunk_loading_with_hmr_manifest.js" - ))); + let render_source = compilation + .runtime_template + .render(&format!("{}_with_hmr_manifest", &self.id), None)?; + + source.add(RawStringSource::from(render_source)); } Ok(source.boxed()) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.ejs new file mode 100644 index 000000000000..0ad6ff0ef31a --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.ejs @@ -0,0 +1,18 @@ +// importScripts chunk loading +var installChunk = <%- basicFunction("data") %> { + <%- destructureArray("chunkIds, moreModules, runtime", "data") %> + for (var moduleId in moreModules) { + if (<%- HAS_OWN_PROPERTY %>(moreModules, moduleId)) { + <%- MODULE_FACTORIES %>[moduleId] = moreModules[moduleId]; + } + } + if (runtime) runtime(<%- REQUIRE %>); + while (chunkIds.length) installedChunks[chunkIds.pop()] = 1; + parentChunkLoadingFunction(data); +}; +<%- ENSURE_CHUNK_HANDLERS %>.i = <%- basicFunction("chunkId, promises") %> { + <%- BODY %> +}; +var chunkLoadingGlobal = <%- CHUNK_LOADING_GLOBAL_EXPR %> = <%- CHUNK_LOADING_GLOBAL_EXPR %> || []; +var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal); +chunkLoadingGlobal.push = installChunk; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.js deleted file mode 100644 index b75d934764f5..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.js +++ /dev/null @@ -1,20 +0,0 @@ -// importScripts chunk loading -var installChunk = function (data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; - for (var moduleId in moreModules) { - if (__webpack_require__.o(moreModules, moduleId)) { - __webpack_require__.m[moduleId] = moreModules[moduleId]; - } - } - if (runtime) runtime(__webpack_require__); - while (chunkIds.length) installedChunks[chunkIds.pop()] = 1; - parentChunkLoadingFunction(data); -}; -__webpack_require__.f.i = function (chunkId, promises) { - $BODY$ -}; -var chunkLoadingGlobal = $CHUNK_LOADING_GLOBAL_EXPR$ = $CHUNK_LOADING_GLOBAL_EXPR$ || []; -var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal); -chunkLoadingGlobal.push = installChunk; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr.ejs similarity index 71% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr.ejs index 854dc53a483d..8f8e961d6ace 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr.ejs @@ -1,8 +1,8 @@ function loadUpdateChunk(chunkId, updatedModulesList) { var success = false; - $globalObject$[$hotUpdateGlobal$] = function (_, moreModules, runtime) { + <%- GLOBAL_OBJECT %>[<%- HOT_UPDATE_GLOBAL %>] = <%- basicFunction("_, moreModules, runtime") %> { for (var moduleId in moreModules) { - if (__webpack_require__.o(moreModules, moduleId)) { + if (<%- HAS_OWN_PROPERTY %>(moreModules, moduleId)) { currentUpdate[moduleId] = moreModules[moduleId]; if (updatedModulesList) updatedModulesList.push(moduleId); } @@ -11,6 +11,6 @@ function loadUpdateChunk(chunkId, updatedModulesList) { success = true; }; // start update chunk loading - importScripts($URL$); + importScripts(<%- URL %>); if (!success) throw new Error("Loading update chunk failed for unknown reason"); } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr_manifest.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr_manifest.ejs similarity index 63% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr_manifest.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr_manifest.ejs index ef38356c6b90..473b20849fba 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr_manifest.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading_with_hmr_manifest.ejs @@ -1,7 +1,7 @@ -__webpack_require__.hmrM = function () { +<%- HMR_DOWNLOAD_MANIFEST %> = <%- basicFunction("") %> { if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); - return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then( - function (response) { + return fetch(<%- PUBLIC_PATH %> + <%- GET_UPDATE_MANIFEST_FILENAME %>()).then( + <%- basicFunction("response") %> { if (response.status === 404) return; // no update available if (!response.ok) throw new Error( diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap index 1b64a7153c08..84235ef0c32e 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap @@ -318,7 +318,7 @@ Object { main.js, ], filteredModules: undefined, - hash: bf2cde18064956f4, + hash: 3d690f17d6f5be36, id: 909, idHints: Array [], initial: true, @@ -685,7 +685,7 @@ Object { errorsCount: 0, filteredAssets: undefined, filteredModules: undefined, - hash: 8a4abcf81482ccb3, + hash: a5e7621af4eff87f, modules: Array [ Object { assets: Array [], diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap index 53403d00696c..35ecc4c87b2b 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap @@ -107,7 +107,7 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/hot+production should print correct stats for 1`] = ` -asset main.js 33.3 KiB [emitted] (name: main) +asset main.js 33.2 KiB [emitted] (name: main) runtime modules 30.9 KiB 12 modules ./index.js 25 bytes [built] [code generated] Rspack x.x.x compiled successfully in X s diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunks.js b/packages/rspack-test-tools/tests/statsAPICases/chunks.js index dcbcbd66b843..c1940d5c87a0 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunks.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunks.js @@ -144,7 +144,7 @@ module.exports = { main.js, ], filteredModules: undefined, - hash: ecb98ed10bf9b94d, + hash: 2579eec3dea5af8d, id: 909, idHints: Array [], initial: true, From adabd4cd3c7514a8be9a54e075fa2ca369ad31ae Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Wed, 8 Jan 2025 11:39:53 +0800 Subject: [PATCH 04/13] feat: runtime template with dojang --- crates/rspack/src/builder/mod.rs | 10 + .../src/runtime_module/jsonp_chunk_loading.rs | 174 ++++--- .../runtime_module/readfile_chunk_loading.rs | 132 +++-- .../require_js_chunk_loading.rs | 124 +++-- .../runtime/get_chunk_filename.js | 5 - ...unk_loading.js => jsonp_chunk_loading.ejs} | 18 +- .../jsonp_chunk_loading_with_callback.ejs | 34 ++ .../jsonp_chunk_loading_with_callback.js | 38 -- ...mr.js => jsonp_chunk_loading_with_hmr.ejs} | 12 +- ...jsonp_chunk_loading_with_hmr_manifest.ejs} | 6 +- ...jsonp_chunk_loading_with_on_chunk_load.ejs | 1 + .../jsonp_chunk_loading_with_on_chunk_load.js | 3 - .../jsonp_chunk_loading_with_prefetch.ejs | 14 + .../jsonp_chunk_loading_with_prefetch.js | 14 - .../jsonp_chunk_loading_with_preload.ejs | 15 + .../jsonp_chunk_loading_with_preload.js | 15 - ..._loading.js => readfile_chunk_loading.ejs} | 10 +- ...nk_loading_with_external_install_chunk.ejs | 2 + ...unk_loading_with_external_install_chunk.js | 2 - ...js => readfile_chunk_loading_with_hmr.ejs} | 4 +- ...adfile_chunk_loading_with_hmr_manifest.ejs | 13 + ...eadfile_chunk_loading_with_hmr_manifest.js | 13 - ...> readfile_chunk_loading_with_loading.ejs} | 6 +- ...dfile_chunk_loading_with_on_chunk_load.ejs | 1 + ...adfile_chunk_loading_with_on_chunk_load.js | 3 - .../runtime/require_chunk_loading.ejs | 13 + .../runtime/require_chunk_loading.js | 16 - ...nk_loading_with_external_install_chunk.ejs | 2 + ...unk_loading_with_external_install_chunk.js | 2 - ....js => require_chunk_loading_with_hmr.ejs} | 4 +- ...quire_chunk_loading_with_hmr_manifest.ejs} | 4 +- .../require_chunk_loading_with_loading.ejs | 9 + .../require_chunk_loading_with_loading.js | 9 - ...quire_chunk_loading_with_on_chunk_load.ejs | 1 + ...equire_chunk_loading_with_on_chunk_load.js | 3 - .../__snapshots__/StatsOutput.test.js.snap | 68 +-- .../variant/__snapshots__/output.snap.txt | 2 +- .../__snapshots__/web/1.snap.txt | 30 +- .../__snapshots__/web/3.snap.txt | 18 +- .../tests/statsAPICases/chunk-group.js | 16 +- .../tests/statsAPICases/chunks.js | 4 +- .../StatsTestCases.basictest.js.snap | 458 +++++++++--------- 42 files changed, 754 insertions(+), 574 deletions(-) delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{jsonp_chunk_loading.js => jsonp_chunk_loading.ejs} (68%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{jsonp_chunk_loading_with_hmr.js => jsonp_chunk_loading_with_hmr.ejs} (74%) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{jsonp_chunk_loading_with_hmr_manifest.js => jsonp_chunk_loading_with_hmr_manifest.ejs} (63%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{readfile_chunk_loading.js => readfile_chunk_loading.ejs} (55%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{readfile_chunk_loading_with_hmr.js => readfile_chunk_loading_with_hmr.ejs} (81%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{readfile_chunk_loading_with_loading.js => readfile_chunk_loading_with_loading.ejs} (85%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.js rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{require_chunk_loading_with_hmr.js => require_chunk_loading_with_hmr.ejs} (71%) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{require_chunk_loading_with_hmr_manifest.js => require_chunk_loading_with_hmr_manifest.ejs} (53%) create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.js create mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.ejs delete mode 100644 crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.js diff --git a/crates/rspack/src/builder/mod.rs b/crates/rspack/src/builder/mod.rs index df2b8f92a832..cc055ad3ac85 100644 --- a/crates/rspack/src/builder/mod.rs +++ b/crates/rspack/src/builder/mod.rs @@ -2247,6 +2247,16 @@ impl OutputOptionsBuilder { r#const: tp.and_then(|t| t.r#const), arrow_function: tp.and_then(|t| t.arrow_function), node_prefix_for_core_modules: tp.and_then(|t| t.node_prefix_for_core_modules), + async_function: tp.and_then(|t| t.async_function), + big_int_literal: tp.and_then(|t| t.big_int_literal), + destructuring: tp.and_then(|t| t.destructuring), + for_of: tp.and_then(|t| t.for_of), + global_this: tp.and_then(|t| t.global_this), + optional_chaining: tp.and_then(|t| t.optional_chaining), + document: tp.and_then(|t| t.document), + dynamic_import: tp.and_then(|t| t.dynamic_import), + template_literal: tp.and_then(|t| t.template_literal), + module: tp.and_then(|t| t.module), }; OutputOptions { diff --git a/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs index 1740d38deba8..f855de7bf56c 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::{DatabaseItem, Identifier}; use rspack_core::{ compile_boolean_matcher, impl_runtime_module, @@ -38,6 +37,34 @@ impl JsonpChunkLoadingRuntimeModule { .unwrap_or_else(|| "document.baseURI || self.location.href".to_string()); RawStringSource::from(format!("{} = {};\n", RuntimeGlobals::BASE_URI, base_uri)).boxed() } + + fn template_id(&self, id: TemplateId) -> String { + let base_id = self.id.as_str(); + + format!("{}_{}", base_id, id.as_str()) + } +} + +enum TemplateId { + WithPrefetch, + WithPreload, + WithHmr, + WithHmrManifest, + WithOnChunkLoad, + WithCallback, +} + +impl TemplateId { + fn as_str(&self) -> &str { + match self { + TemplateId::WithPrefetch => "with_prefetch", + TemplateId::WithPreload => "with_preload", + TemplateId::WithHmr => "with_hmr", + TemplateId::WithHmrManifest => "with_hmr_manifest", + TemplateId::WithOnChunkLoad => "with_on_chunk_load", + TemplateId::WithCallback => "with_callback", + } + } } impl RuntimeModule for JsonpChunkLoadingRuntimeModule { @@ -45,6 +72,39 @@ impl RuntimeModule for JsonpChunkLoadingRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![ + ( + self.id.to_string(), + include_str!("runtime/jsonp_chunk_loading.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithPrefetch), + include_str!("runtime/jsonp_chunk_loading_with_prefetch.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithPreload), + include_str!("runtime/jsonp_chunk_loading_with_preload.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithHmr), + include_str!("runtime/jsonp_chunk_loading_with_hmr.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithHmrManifest), + include_str!("runtime/jsonp_chunk_loading_with_hmr_manifest.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithOnChunkLoad), + include_str!("runtime/jsonp_chunk_loading_with_on_chunk_load.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithCallback), + include_str!("runtime/jsonp_chunk_loading_with_callback.ejs").to_string(), + ), + ] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk = compilation .chunk_by_ukey @@ -99,25 +159,22 @@ impl RuntimeModule for JsonpChunkLoadingRuntimeModule { let body = if matches!(has_js_matcher, BooleanMatcher::Condition(false)) { "installedChunks[chunkId] = 0;".to_string() } else { - include_str!("runtime/jsonp_chunk_loading.js") - .cow_replace("$JS_MATCHER$", &js_matcher) - .cow_replace( - "$MATCH_FALLBACK$", - if matches!(has_js_matcher, BooleanMatcher::Condition(true)) { + compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "JS_MATCHER": &js_matcher, + "MATCH_FALLBACK":if matches!(has_js_matcher, BooleanMatcher::Condition(true)) { "" } else { "else installedChunks[chunkId] = 0;\n" }, - ) - .cow_replace( - "$FETCH_PRIORITY$", - if with_fetch_priority { + "FETCH_PRIORITY": if with_fetch_priority { ", fetchPriority" } else { "" }, - ) - .into_owned() + })), + )? }; source.add(RawStringSource::from(format!( @@ -142,12 +199,16 @@ impl RuntimeModule for JsonpChunkLoadingRuntimeModule { format!("link.crossOrigin = {}", cross_origin_loading) } }; - source.add(RawStringSource::from( - include_str!("runtime/jsonp_chunk_loading_with_prefetch.js") - .cow_replace("$JS_MATCHER$", &js_matcher) - .cow_replace("$CROSS_ORIGIN$", cross_origin.as_str()) - .into_owned(), - )); + + let source_with_prefetch = compilation.runtime_template.render( + &self.template_id(TemplateId::WithPrefetch), + Some(serde_json::json!({ + "JS_MATCHER": &js_matcher, + "CROSS_ORIGIN": cross_origin.as_str(), + })), + )?; + + source.add(RawStringSource::from(source_with_prefetch)); } if with_preload && !matches!(has_js_matcher, BooleanMatcher::Condition(false)) { @@ -185,42 +246,47 @@ impl RuntimeModule for JsonpChunkLoadingRuntimeModule { "# }; - source.add(RawStringSource::from( - include_str!("runtime/jsonp_chunk_loading_with_preload.js") - .cow_replace("$JS_MATCHER$", &js_matcher) - .cow_replace("$CROSS_ORIGIN$", cross_origin.as_str()) - .cow_replace("$SCRIPT_TYPE_LINK_PRE$", script_type_link_pre.as_str()) - .cow_replace("$SCRIPT_TYPE_LINK_POST$", script_type_link_post) - .into_owned(), - )); + let source_with_preload = compilation.runtime_template.render( + &self.template_id(TemplateId::WithPreload), + Some(serde_json::json!({ + "JS_MATCHER": &js_matcher, + "CROSS_ORIGIN": cross_origin.as_str(), + "SCRIPT_TYPE_LINK_PRE": script_type_link_pre.as_str(), + "SCRIPT_TYPE_LINK_POST": script_type_link_post, + })), + )?; + + source.add(RawStringSource::from(source_with_preload)); } if with_hmr { - source.add(RawStringSource::from( - include_str!("runtime/jsonp_chunk_loading_with_hmr.js") - .cow_replace("$GLOBAL_OBJECT$", &compilation.options.output.global_object) - .cow_replace( - "$HOT_UPDATE_GLOBAL$", - &serde_json::to_string(&compilation.options.output.hot_update_global) - .expect("failed to serde_json::to_string(hot_update_global)"), - ) - .into_owned(), - )); + let source_with_hmr = compilation.runtime_template.render( + &self.template_id(TemplateId::WithHmr), + Some(serde_json::json!({ + "GLOBAL_OBJECT": &compilation.options.output.global_object, + "HOT_UPDATE_GLOBAL": &serde_json::to_string(&compilation.options.output.hot_update_global) + .expect("failed to serde_json::to_string(hot_update_global)"), + })), + )?; + + source.add(RawStringSource::from(source_with_hmr)); source.add(RawStringSource::from(generate_javascript_hmr_runtime( "jsonp", ))); } if with_hmr_manifest { - source.add(RawStringSource::from_static(include_str!( - "runtime/jsonp_chunk_loading_with_hmr_manifest.js" - ))); + let source_with_hmr_manifest = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithHmrManifest), None)?; + source.add(RawStringSource::from(source_with_hmr_manifest)); } if with_on_chunk_load { - source.add(RawStringSource::from_static(include_str!( - "runtime/jsonp_chunk_loading_with_on_chunk_load.js" - ))); + let source_with_on_chunk_load = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithOnChunkLoad), None)?; + source.add(RawStringSource::from(source_with_on_chunk_load)); } if with_callback || with_loading { @@ -228,18 +294,18 @@ impl RuntimeModule for JsonpChunkLoadingRuntimeModule { r#"{}["{}"]"#, &compilation.options.output.global_object, &compilation.options.output.chunk_loading_global ); - source.add(RawStringSource::from( - include_str!("runtime/jsonp_chunk_loading_with_callback.js") - .cow_replace("$CHUNK_LOADING_GLOBAL_EXPR$", &chunk_loading_global_expr) - .cow_replace( - "$WITH_ON_CHUNK_LOAD$", - match with_on_chunk_load { - true => "return __webpack_require__.O(result);", - false => "", - }, - ) - .into_owned(), - )); + + let source_with_callback = compilation.runtime_template.render( + &self.template_id(TemplateId::WithCallback), + Some(serde_json::json!({ + "CHUNK_LOADING_GLOBAL_EXPR": &chunk_loading_global_expr, + "WITH_ON_CHUNK_LOAD": match with_on_chunk_load { + true => "return __webpack_require__.O(result);", + false => "", + }, + })), + )?; + source.add(RawStringSource::from(source_with_callback)); } Ok(source.boxed()) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs index fb01f2a3ac7b..32268f7f0fe3 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::{DatabaseItem, Identifier}; use rspack_core::{ compile_boolean_matcher, impl_runtime_module, @@ -58,12 +57,68 @@ impl ReadFileChunkLoadingRuntimeModule { }); RawStringSource::from(format!("{} = {};\n", RuntimeGlobals::BASE_URI, base_uri)).boxed() } + + fn template_id(&self, id: TemplateId) -> String { + let base_id = self.id.to_string(); + + format!("{}_{}", base_id, id.as_str()) + } +} + +enum TemplateId { + WithOnChunkLoad, + WithLoading, + WithExternalInstallChunk, + WithHmr, + WithHmrManifest, +} + +impl TemplateId { + fn as_str(&self) -> &'static str { + match self { + TemplateId::WithOnChunkLoad => "with_on_chunk_load", + TemplateId::WithLoading => "with_loading", + TemplateId::WithExternalInstallChunk => "with_external_install_chunk", + TemplateId::WithHmr => "with_hmr", + TemplateId::WithHmrManifest => "with_hmr_manifest", + } + } } impl RuntimeModule for ReadFileChunkLoadingRuntimeModule { fn name(&self) -> Identifier { self.id } + + fn template(&self) -> Vec<(String, String)> { + vec![ + ( + self.template_id(TemplateId::WithOnChunkLoad), + include_str!("runtime/readfile_chunk_loading_with_on_chunk_load.ejs").to_string(), + ), + ( + self.id.to_string(), + include_str!("runtime/readfile_chunk_loading.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithLoading), + include_str!("runtime/readfile_chunk_loading_with_loading.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithExternalInstallChunk), + include_str!("runtime/readfile_chunk_loading_with_external_install_chunk.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithHmr), + include_str!("runtime/readfile_chunk_loading_with_hmr.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithHmrManifest), + include_str!("runtime/readfile_chunk_loading_with_hmr_manifest.ejs").to_string(), + ), + ] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk = compilation .chunk_by_ukey @@ -108,41 +163,43 @@ impl RuntimeModule for ReadFileChunkLoadingRuntimeModule { } if with_on_chunk_load { - source.add(RawStringSource::from_static(include_str!( - "runtime/readfile_chunk_loading_with_on_chunk_load.js" - ))); + let source_with_on_chunk_load = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithOnChunkLoad), None)?; + + source.add(RawStringSource::from(source_with_on_chunk_load)); } if with_loading || with_external_install_chunk { - source.add(RawStringSource::from( - include_str!("runtime/readfile_chunk_loading.js") - .cow_replace( - "$WITH_ON_CHUNK_LOADED$", - match with_on_chunk_load { - true => "__webpack_require__.O();", - false => "", - }, - ) - .into_owned(), - )); + let raw_source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "WITH_ON_CHUNK_LOADED": match with_on_chunk_load { + true => "__webpack_require__.O();", + false => "", + } + })), + )?; + + source.add(RawStringSource::from(raw_source)); } if with_loading { let body = if matches!(has_js_matcher, BooleanMatcher::Condition(false)) { "installedChunks[chunkId] = 0;".to_string() } else { - include_str!("runtime/readfile_chunk_loading_with_loading.js") - .cow_replace("$JS_MATCHER$", &has_js_matcher.render("chunkId")) - .cow_replace("$OUTPUT_DIR$", &root_output_dir) - .cow_replace( - "$MATCH_FALLBACK$", - if matches!(has_js_matcher, BooleanMatcher::Condition(true)) { + compilation.runtime_template.render( + &self.template_id(TemplateId::WithLoading), + Some(serde_json::json!({ + "JS_MATCHER": &has_js_matcher.render("chunkId"), + "OUTPUT_DIR": &root_output_dir, + "MATCH_FALLBACK": if matches!(has_js_matcher, BooleanMatcher::Condition(true)) { "" } else { "else installedChunks[chunkId] = 0;\n" }, - ) - .into_owned() + })), + )? }; source.add(RawStringSource::from(format!( @@ -156,26 +213,33 @@ impl RuntimeModule for ReadFileChunkLoadingRuntimeModule { } if with_external_install_chunk { - source.add(RawStringSource::from_static(include_str!( - "runtime/readfile_chunk_loading_with_external_install_chunk.js" - ))); + let source_with_external_install_chunk = compilation.runtime_template.render( + &self.template_id(TemplateId::WithExternalInstallChunk), + None, + )?; + + source.add(RawStringSource::from(source_with_external_install_chunk)); } if with_hmr { - source.add(RawStringSource::from_static(include_str!( - "runtime/readfile_chunk_loading_with_hmr.js" - ))); + let source_with_hmr = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithHmr), None)?; + source.add(RawStringSource::from(source_with_hmr)); source.add(RawStringSource::from(generate_javascript_hmr_runtime( "readFileVm", ))); } if with_hmr_manifest { - source.add(RawStringSource::from( - include_str!("runtime/readfile_chunk_loading_with_hmr_manifest.js") - .cow_replace("$OUTPUT_DIR$", &root_output_dir) - .into_owned(), - )); + let source_with_hmr_manifest = compilation.runtime_template.render( + &self.template_id(TemplateId::WithHmrManifest), + Some(serde_json::json!({ + "OUTPUT_DIR": &root_output_dir + })), + )?; + + source.add(RawStringSource::from(source_with_hmr_manifest)); } Ok(source.boxed()) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs index 80441acd785e..fcfab526026e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::{DatabaseItem, Identifier}; use rspack_core::{ compile_boolean_matcher, impl_runtime_module, @@ -58,6 +57,31 @@ impl RequireChunkLoadingRuntimeModule { }); RawStringSource::from(format!("{} = {};\n", RuntimeGlobals::BASE_URI, base_uri)).boxed() } + + fn template_id(&self, id: TemplateId) -> String { + let base_id = self.id.to_string(); + format!("{}_{}", &base_id, id.as_str()) + } +} + +enum TemplateId { + WithLoading, + WithOnChunkLoad, + WithExternalInstallChunk, + WithHmr, + WithHmrManifest, +} + +impl TemplateId { + fn as_str(&self) -> &str { + match self { + TemplateId::WithLoading => "with_loading", + TemplateId::WithOnChunkLoad => "with_on_chunk_load", + TemplateId::WithExternalInstallChunk => "with_external_install_chunk", + TemplateId::WithHmr => "with_hmr", + TemplateId::WithHmrManifest => "with_hmr_manifest", + } + } } impl RuntimeModule for RequireChunkLoadingRuntimeModule { @@ -65,6 +89,35 @@ impl RuntimeModule for RequireChunkLoadingRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![ + ( + self.template_id(TemplateId::WithLoading), + include_str!("runtime/require_chunk_loading_with_loading.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithOnChunkLoad), + include_str!("runtime/require_chunk_loading_with_on_chunk_load.ejs").to_string(), + ), + ( + self.id.to_string(), + include_str!("runtime/require_chunk_loading.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithExternalInstallChunk), + include_str!("runtime/require_chunk_loading_with_external_install_chunk.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithHmr), + include_str!("runtime/require_chunk_loading_with_hmr.ejs").to_string(), + ), + ( + self.template_id(TemplateId::WithHmrManifest), + include_str!("runtime/require_chunk_loading_with_hmr_manifest.ejs").to_string(), + ), + ] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk = compilation .chunk_by_ukey @@ -109,23 +162,24 @@ impl RuntimeModule for RequireChunkLoadingRuntimeModule { } if with_on_chunk_load { - source.add(RawStringSource::from_static(include_str!( - "runtime/require_chunk_loading_with_on_chunk_load.js" - ))); + let source_with_on_chunk_load = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithOnChunkLoad), None)?; + source.add(RawStringSource::from(source_with_on_chunk_load)); } if with_loading || with_external_install_chunk { - source.add(RawStringSource::from( - include_str!("runtime/require_chunk_loading.js") - .cow_replace( - "$WITH_ON_CHUNK_LOADED$", - match with_on_chunk_load { - true => "__webpack_require__.O();", - false => "", - }, - ) - .into_owned(), - )); + let raw_source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "WITH_ON_CHUNK_LOADED": match with_on_chunk_load { + true => "__webpack_require__.O();", + false => "", + } + })), + )?; + + source.add(RawStringSource::from(raw_source)); } if with_loading { @@ -140,34 +194,44 @@ impl RuntimeModule for RequireChunkLoadingRuntimeModule { .to_string(), )); } else { - source.add(RawStringSource::from( - include_str!("runtime/require_chunk_loading_with_loading.js") - .cow_replace("$JS_MATCHER$", &has_js_matcher.render("chunkId")) - .cow_replace("$OUTPUT_DIR$", &root_output_dir) - .into_owned(), - )); + let source_with_loading = compilation.runtime_template.render( + &self.template_id(TemplateId::WithLoading), + Some(serde_json::json!({ + "JS_MATCHER": &has_js_matcher.render("chunkId"), + "OUTPUT_DIR": &root_output_dir, + })), + )?; + + source.add(RawStringSource::from(source_with_loading)); } } if with_external_install_chunk { - source.add(RawStringSource::from_static(include_str!( - "runtime/require_chunk_loading_with_external_install_chunk.js" - ))); + let source_with_external_install_chunk = compilation.runtime_template.render( + &self.template_id(TemplateId::WithExternalInstallChunk), + None, + )?; + + source.add(RawStringSource::from(source_with_external_install_chunk)); } if with_hmr { - source.add(RawStringSource::from_static(include_str!( - "runtime/require_chunk_loading_with_hmr.js" - ))); + let source_with_hmr = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithHmr), None)?; + + source.add(RawStringSource::from(source_with_hmr)); source.add(RawStringSource::from(generate_javascript_hmr_runtime( "require", ))); } if with_hmr_manifest { - source.add(RawStringSource::from_static(include_str!( - "runtime/require_chunk_loading_with_hmr_manifest.js" - ))); + let source_with_hmr_manifest = compilation + .runtime_template + .render(&self.template_id(TemplateId::WithHmrManifest), None)?; + + source.add(RawStringSource::from(source_with_hmr_manifest)); } Ok(source.boxed()) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.js deleted file mode 100644 index b61ee684ccce..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.js +++ /dev/null @@ -1,5 +0,0 @@ -// This function allow to reference async chunks -__webpack_require__.u = function (chunkId) { - // return url for filenames based on template - return URL; -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.ejs similarity index 68% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.ejs index 72176a47a34a..784574d6e104 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.ejs @@ -1,5 +1,5 @@ // JSONP chunk loading for javascript -var installedChunkData = __webpack_require__.o(installedChunks, chunkId) +var installedChunkData = <%- HAS_OWN_PROPERTY %>(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; if (installedChunkData !== 0) { @@ -9,24 +9,22 @@ if (installedChunkData !== 0) { if (installedChunkData) { promises.push(installedChunkData[2]); } else { - if ($JS_MATCHER$) { + if (<%- JS_MATCHER %>) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise(<%- expressionFunction("installedChunkData = installedChunks[chunkId] = [resolve, reject]", "resolve, reject") %>); promises.push((installedChunkData[2] = promise)); // start chunk loading - var url = __webpack_require__.p + __webpack_require__.u(chunkId); + var url = <%- PUBLIC_PATH %> + <%- GET_CHUNK_SCRIPT_FILENAME %>(chunkId); // create error before stack unwound to get useful stacktrace later var error = new Error(); var loadingEnded = function (event) { - if (__webpack_require__.o(installedChunks, chunkId)) { + if (<%- HAS_OWN_PROPERTY %>(installedChunks, chunkId)) { installedChunkData = installedChunks[chunkId]; if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -43,7 +41,7 @@ if (installedChunkData !== 0) { } } }; - __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId$FETCH_PRIORITY$); - } $MATCH_FALLBACK$ + __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId<%- FETCH_PRIORITY %>); + } <%- MATCH_FALLBACK %> } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.ejs new file mode 100644 index 000000000000..633196f35f0b --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.ejs @@ -0,0 +1,34 @@ +// install a JSONP callback for chunk loading +var webpackJsonpCallback = <%- basicFunction("parentChunkLoadingFunction, data") %> { + <%- destructureArray("chunkIds, moreModules, runtime", "data") %> + // add "moreModules" to the modules object, + // then flag all "chunkIds" as loaded and fire callback + var moduleId, chunkId, i = 0; + if (chunkIds.some(<%- returningFunction("installedChunks[id] !== 0", "id") %>)) { + for (moduleId in moreModules) { + if (<%- HAS_OWN_PROPERTY %>(moreModules, moduleId)) { + <%- MODULE_FACTORIES %>[moduleId] = moreModules[moduleId]; + } + } + if (runtime) var result = runtime(<%- REQUIRE %>); + } + if (parentChunkLoadingFunction) parentChunkLoadingFunction(data); + for (; i < chunkIds.length; i++) { + chunkId = chunkIds[i]; + if ( + <%- HAS_OWN_PROPERTY %>(installedChunks, chunkId) && + installedChunks[chunkId] + ) { + installedChunks[chunkId][0](); + } + installedChunks[chunkId] = 0; + } + <%- WITH_ON_CHUNK_LOAD %> +}; + +var chunkLoadingGlobal = <%- CHUNK_LOADING_GLOBAL_EXPR %> = <%- CHUNK_LOADING_GLOBAL_EXPR %> || []; +chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +chunkLoadingGlobal.push = webpackJsonpCallback.bind( + null, + chunkLoadingGlobal.push.bind(chunkLoadingGlobal) +); diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.js deleted file mode 100644 index 0cfc39ab21ae..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_callback.js +++ /dev/null @@ -1,38 +0,0 @@ -// install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; - // add "moreModules" to the modules object, - // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { - for (moduleId in moreModules) { - if (__webpack_require__.o(moreModules, moduleId)) { - __webpack_require__.m[moduleId] = moreModules[moduleId]; - } - } - if (runtime) var result = runtime(__webpack_require__); - } - if (parentChunkLoadingFunction) parentChunkLoadingFunction(data); - for (; i < chunkIds.length; i++) { - chunkId = chunkIds[i]; - if ( - __webpack_require__.o(installedChunks, chunkId) && - installedChunks[chunkId] - ) { - installedChunks[chunkId][0](); - } - installedChunks[chunkId] = 0; - } - $WITH_ON_CHUNK_LOAD$ -}; - -var chunkLoadingGlobal = $CHUNK_LOADING_GLOBAL_EXPR$ = $CHUNK_LOADING_GLOBAL_EXPR$ || []; -chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); -chunkLoadingGlobal.push = webpackJsonpCallback.bind( - null, - chunkLoadingGlobal.push.bind(chunkLoadingGlobal) -); diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr.ejs similarity index 74% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr.ejs index f319cb0754e3..161e6cd3b8f4 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr.ejs @@ -2,13 +2,13 @@ var currentUpdatedModulesList; var waitingUpdateResolves = {}; function loadUpdateChunk(chunkId, updatedModulesList) { currentUpdatedModulesList = updatedModulesList; - return new Promise(function (resolve, reject) { + return new Promise(<%- basicFunction("resolve, reject") %> { waitingUpdateResolves[chunkId] = resolve; // start update chunk loading - var url = __webpack_require__.p + __webpack_require__.hu(chunkId); + var url = <%- PUBLIC_PATH %> + <%- GET_CHUNK_UPDATE_SCRIPT_FILENAME %>(chunkId); // create error before stack unwound to get useful stacktrace later var error = new Error(); - var loadingEnded = function (event) { + var loadingEnded = <%- basicFunction("event") %> { if (waitingUpdateResolves[chunkId]) { waitingUpdateResolves[chunkId] = undefined; var errorType = @@ -28,13 +28,13 @@ function loadUpdateChunk(chunkId, updatedModulesList) { reject(error); } }; - __webpack_require__.l(url, loadingEnded); + <%- LOAD_SCRIPT %>(url, loadingEnded); }); } -$GLOBAL_OBJECT$[$HOT_UPDATE_GLOBAL$] = function (chunkId, moreModules, runtime) { +<%- GLOBAL_OBJECT %>[<%- HOT_UPDATE_GLOBAL %>] = <%- basicFunction("chunkId, moreModules, runtime") %> { for (var moduleId in moreModules) { - if (__webpack_require__.o(moreModules, moduleId)) { + if (<%- HAS_OWN_PROPERTY %>(moreModules, moduleId)) { currentUpdate[moduleId] = moreModules[moduleId]; if (currentUpdatedModulesList) currentUpdatedModulesList.push(moduleId); } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr_manifest.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr_manifest.ejs similarity index 63% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr_manifest.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr_manifest.ejs index ab74ccfabbd6..0f023607d7ba 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr_manifest.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_hmr_manifest.ejs @@ -1,8 +1,8 @@ -__webpack_require__.hmrM = function () { +<%- HMR_DOWNLOAD_MANIFEST %> = <%- basicFunction("") %> { if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); - return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then( - function (response) { + return fetch(<%- PUBLIC_PATH %> + <%- GET_UPDATE_MANIFEST_FILENAME %>()).then( + <%- basicFunction("response") %> { if (response.status === 404) return; // no update available if (!response.ok) throw new Error( diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.ejs new file mode 100644 index 000000000000..c59e46e4cf10 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.ejs @@ -0,0 +1 @@ +<%- ON_CHUNKS_LOADED %>.j = <%- returningFunction("installedChunks[chunkId] === 0", "chunkId") %>; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.js deleted file mode 100644 index f763f5a3b1a2..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_on_chunk_load.js +++ /dev/null @@ -1,3 +0,0 @@ -__webpack_require__.O.j = function (chunkId) { - return installedChunks[chunkId] === 0; -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.ejs new file mode 100644 index 000000000000..ad6d01ba070e --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.ejs @@ -0,0 +1,14 @@ +<%- PREFETCH_CHUNK_HANDLERS %>.j = function (chunkId) { + if ((!<%- HAS_OWN_PROPERTY %>(installedChunks, chunkId) || installedChunks[chunkId] === undefined) && <%- JS_MATCHER %>) { + installedChunks[chunkId] = null; + var link = document.createElement('link'); + <%- CROSS_ORIGIN %> + if (<%- SCRIPT_NONCE %>) { + link.setAttribute("nonce", <%- SCRIPT_NONCE %>); + } + link.rel = "prefetch"; + link.as = "script"; + link.href = <%- PUBLIC_PATH %> + <%- GET_CHUNK_SCRIPT_FILENAME %>(chunkId); + document.head.appendChild(link); + } +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.js deleted file mode 100644 index ae594c9e6f24..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch.js +++ /dev/null @@ -1,14 +0,0 @@ -__webpack_require__.F.j = function (chunkId) { - if ((!__webpack_require__.o(installedChunks, chunkId) || installedChunks[chunkId] === undefined) && $JS_MATCHER$) { - installedChunks[chunkId] = null; - var link = document.createElement('link'); - $CROSS_ORIGIN$ - if (__webpack_require__.nc) { - link.setAttribute("nonce", __webpack_require__.nc); - } - link.rel = "prefetch"; - link.as = "script"; - link.href = __webpack_require__.p + __webpack_require__.u(chunkId); - document.head.appendChild(link); - } -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.ejs new file mode 100644 index 000000000000..dbc767fcbc24 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.ejs @@ -0,0 +1,15 @@ +<%- PRELOAD_CHUNK_HANDLERS %>.j = <%- basicFunction("chunkId") %> { + if ((!<%- HAS_OWN_PROPERTY %>(installedChunks, chunkId) || installedChunks[chunkId] === undefined) && <%- JS_MATCHER %>) { + installedChunks[chunkId] = null; + var link = document.createElement('link'); + <%- SCRIPT_TYPE_LINK_PRE %> + link.charset = 'utf-8'; + if (<%- SCRIPT_NONCE %>) { + link.setAttribute("nonce", <%- SCRIPT_NONCE %>); + } + <%- SCRIPT_TYPE_LINK_POST %> + link.href = <%- PUBLIC_PATH %> + <%- GET_CHUNK_SCRIPT_FILENAME %>(chunkId); + <%- CROSS_ORIGIN %> + document.head.appendChild(link); + } +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.js deleted file mode 100644 index 910789c50e25..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload.js +++ /dev/null @@ -1,15 +0,0 @@ -__webpack_require__.H.j = function (chunkId) { - if ((!__webpack_require__.o(installedChunks, chunkId) || installedChunks[chunkId] === undefined) && $JS_MATCHER$) { - installedChunks[chunkId] = null; - var link = document.createElement('link'); - $SCRIPT_TYPE_LINK_PRE$ - link.charset = 'utf-8'; - if (__webpack_require__.nc) { - link.setAttribute("nonce", __webpack_require__.nc); - } - $SCRIPT_TYPE_LINK_POST$ - link.href = __webpack_require__.p + __webpack_require__.u(chunkId); - $CROSS_ORIGIN$ - document.head.appendChild(link); - } -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading.ejs similarity index 55% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading.ejs index 9de9ad107a3f..227e49f596ae 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading.ejs @@ -1,17 +1,17 @@ -var installChunk = function (chunk) { +var installChunk = <%- basicFunction("chunk") %> { var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime; for (var moduleId in moreModules) { - if (__webpack_require__.o(moreModules, moduleId)) { - __webpack_require__.m[moduleId] = moreModules[moduleId]; + if (<%- HAS_OWN_PROPERTY %>(moreModules, moduleId)) { + <%- MODULE_FACTORIES %>[moduleId] = moreModules[moduleId]; } } - if (runtime) runtime(__webpack_require__); + if (runtime) runtime(<%- REQUIRE %> ); for (var i = 0; i < chunkIds.length; i++) { if (installedChunks[chunkIds[i]]) { installedChunks[chunkIds[i]][0](); } installedChunks[chunkIds[i]] = 0; } - $WITH_ON_CHUNK_LOADED$ + <%- WITH_ON_CHUNK_LOADED %> }; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.ejs new file mode 100644 index 000000000000..2540f95aa6a9 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.ejs @@ -0,0 +1,2 @@ +module.exports = <%- REQUIRE %>; +<%- EXTERNAL_INSTALL_CHUNK %> = installChunk; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.js deleted file mode 100644 index 5ed5f0491781..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_external_install_chunk.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = __webpack_require__; -__webpack_require__.C = installChunk; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr.ejs similarity index 81% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr.ejs index 6f11fcbc26ab..1bd5497e488b 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr.ejs @@ -1,6 +1,6 @@ function loadUpdateChunk(chunkId, updatedModulesList) { return new Promise(function(resolve, reject) { - var filename = require('path').join(__dirname, "" + __webpack_require__.hu(chunkId)); + var filename = require('path').join(__dirname, "" + <%- GET_CHUNK_UPDATE_SCRIPT_FILENAME %>(chunkId)); require('fs').readFile(filename, 'utf-8', function(err, content) { if(err) return reject(err); var update = {}; @@ -8,7 +8,7 @@ function loadUpdateChunk(chunkId, updatedModulesList) { var updatedModules = update.modules; var runtime = update.runtime; for(var moduleId in updatedModules) { - if(__webpack_require__.o(updatedModules, moduleId)) { + if(<%- HAS_OWN_PROPERTY %>(updatedModules, moduleId)) { currentUpdate[moduleId] = updatedModules[moduleId]; if(updatedModulesList) updatedModulesList.push(moduleId); } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.ejs new file mode 100644 index 000000000000..dd3a3234d3da --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.ejs @@ -0,0 +1,13 @@ +<%- HMR_DOWNLOAD_MANIFEST %> = <%- basicFunction("") %> { + return new Promise(<%- basicFunction("resolve, reject") %> { + var filename = require('path').join(__dirname, "<%- OUTPUT_DIR %>" + <%- GET_UPDATE_MANIFEST_FILENAME %>()); + require('fs').readFile(filename, 'utf-8', <%- basicFunction("err, content") %> { + if (err) { + if (err.code === "ENOENT") return resolve(); + return reject(err); + } + try { resolve(JSON.parse(content)); } + catch (e) { reject(e); } + }); + }); +} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.js deleted file mode 100644 index 21864b54f8d3..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_hmr_manifest.js +++ /dev/null @@ -1,13 +0,0 @@ -__webpack_require__.hmrM = function () { - return new Promise(function (resolve, reject) { - var filename = require('path').join(__dirname, "$OUTPUT_DIR$" + __webpack_require__.hmrF()); - require('fs').readFile(filename, 'utf-8', function (err, content) { - if (err) { - if (err.code === "ENOENT") return resolve(); - return reject(err); - } - try { resolve(JSON.parse(content)); } - catch (e) { reject(e); } - }); - }); -} \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_loading.ejs similarity index 85% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_loading.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_loading.ejs index 8790e4995ec5..b9ecd6a50f7a 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_loading.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_loading.ejs @@ -4,12 +4,12 @@ if (installedChunkData !== 0) { // 0 means "already installed". if (installedChunkData) { promises.push(installedChunkData[2]); } else { - if ($JS_MATCHER$) { // all chunks have JS + if (<%- JS_MATCHER %>) { // all chunks have JS // load the chunk and return promise to it var promise = new Promise(function (resolve, reject) { installedChunkData = installedChunks[chunkId] = [resolve, reject]; var filename = require('path').join( - __dirname, "$OUTPUT_DIR$" + __webpack_require__.u(chunkId)); + __dirname, "<%- OUTPUT_DIR %>" + <%- GET_CHUNK_SCRIPT_FILENAME %>(chunkId)); require('fs').readFile(filename, 'utf-8', function (err, content) { if (err) return reject(err); var chunk = {}; @@ -22,6 +22,6 @@ if (installedChunkData !== 0) { // 0 means "already installed". }); }); promises.push(installedChunkData[2] = promise); - } $MATCH_FALLBACK$ + } <%- MATCH_FALLBACK %> } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.ejs new file mode 100644 index 000000000000..d3fe7958dca1 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.ejs @@ -0,0 +1 @@ +<%- ON_CHUNKS_LOADED %>.readFileVm = <%- returningFunction("installedChunks[chunkId]===0", "chunkId" ) %>; \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.js deleted file mode 100644 index 93772141ad7e..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/readfile_chunk_loading_with_on_chunk_load.js +++ /dev/null @@ -1,3 +0,0 @@ -__webpack_require__.O.readFileVm = function (chunkId) { - return installedChunks[chunkId] === 0; -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.ejs new file mode 100644 index 000000000000..c2cb807c0799 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.ejs @@ -0,0 +1,13 @@ +// object to store loaded chunks +// "1" means "loaded", otherwise not loaded yet +var installChunk = <%- basicFunction("chunk") %> { + var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime; + for (var moduleId in moreModules) { + if (<%- HAS_OWN_PROPERTY %>(moreModules, moduleId)) { + <%- MODULE_FACTORIES %>[moduleId] = moreModules[moduleId]; + } + } + if (runtime) runtime(<%- REQUIRE %>); + for (var i = 0; i < chunkIds.length; i++) installedChunks[chunkIds[i]] = 1; + <%- WITH_ON_CHUNK_LOADED %> +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.js deleted file mode 100644 index 7664f43aa7c0..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.js +++ /dev/null @@ -1,16 +0,0 @@ -// object to store loaded chunks -// "1" means "loaded", otherwise not loaded yet - -var installChunk = function (chunk) { - var moreModules = chunk.modules, - chunkIds = chunk.ids, - runtime = chunk.runtime; - for (var moduleId in moreModules) { - if (__webpack_require__.o(moreModules, moduleId)) { - __webpack_require__.m[moduleId] = moreModules[moduleId]; - } - } - if (runtime) runtime(__webpack_require__); - for (var i = 0; i < chunkIds.length; i++) installedChunks[chunkIds[i]] = 1; - $WITH_ON_CHUNK_LOADED$ -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.ejs new file mode 100644 index 000000000000..ddec8af6f786 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.ejs @@ -0,0 +1,2 @@ +module.exports = <%- REQUIRE %>; +<%- EXTERNAL_INSTALL_CHUNK %> = installChunk; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.js deleted file mode 100644 index 6af14d695a40..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_external_install_chunk.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = __webpack_require__; -__webpack_require__.C = installChunk; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr.ejs similarity index 71% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr.ejs index b4feab5983d9..f021e14fdce3 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr.ejs @@ -1,9 +1,9 @@ function loadUpdateChunk(chunkId, updatedModulesList) { - var update = require("./" + __webpack_require__.hu(chunkId)); + var update = require("./" + <%- GET_CHUNK_UPDATE_SCRIPT_FILENAME %>(chunkId)); var updatedModules = update.modules; var runtime = update.runtime; for (var moduleId in updatedModules) { - if (__webpack_require__.o(updatedModules, moduleId)) { + if (<%- HAS_OWN_PROPERTY %>(updatedModules, moduleId)) { currentUpdate[moduleId] = updatedModules[moduleId]; if (updatedModulesList) updatedModulesList.push(moduleId); } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr_manifest.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr_manifest.ejs similarity index 53% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr_manifest.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr_manifest.ejs index c9db5176388f..f184c7826798 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr_manifest.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_hmr_manifest.ejs @@ -1,7 +1,7 @@ -__webpack_require__.hmrM = function () { +<%- HMR_DOWNLOAD_MANIFEST %> = <%- basicFunction("") %> { return Promise.resolve() .then(function () { - return require("./" + __webpack_require__.hmrF()); + return require("./" + <%- GET_UPDATE_MANIFEST_FILENAME %>()); })['catch'](function (err) { if (err.code !== 'MODULE_NOT_FOUND') throw err; }); diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.ejs new file mode 100644 index 000000000000..39a299cb2523 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.ejs @@ -0,0 +1,9 @@ +// require() chunk loading for javascript +<%- ENSURE_CHUNK_HANDLERS %>.require = <%- basicFunction("chunkId, promises") %> { + // "1" is the signal for "already loaded" + if (!installedChunks[chunkId]) { + if (<%- JS_MATCHER %>) { + installChunk(require("<%- OUTPUT_DIR %>" + <%- GET_CHUNK_SCRIPT_FILENAME %>(chunkId))); + } else installedChunks[chunkId] = 1; + } +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.js deleted file mode 100644 index bfc347855e3b..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_loading.js +++ /dev/null @@ -1,9 +0,0 @@ -// require() chunk loading for javascript -__webpack_require__.f.require = function (chunkId, promises) { - // "1" is the signal for "already loaded" - if (!installedChunks[chunkId]) { - if ($JS_MATCHER$) { - installChunk(require("$OUTPUT_DIR$" + __webpack_require__.u(chunkId))); - } else installedChunks[chunkId] = 1; - } -}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.ejs new file mode 100644 index 000000000000..b558e714b956 --- /dev/null +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.ejs @@ -0,0 +1 @@ +<%- ON_CHUNKS_LOADED %>.require = <%- returningFunction("installedChunks[chunkId]", "chunkId") %> \ No newline at end of file diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.js deleted file mode 100644 index 1cafb7c3b76e..000000000000 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading_with_on_chunk_load.js +++ /dev/null @@ -1,3 +0,0 @@ -__webpack_require__.O.require = function (chunkId) { - return installedChunks[chunkId]; -}; diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap index 35ecc4c87b2b..50aadf8a14a6 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap @@ -97,9 +97,9 @@ Rspack x.x.x compiled successfully in X s `; exports[`statsOutput statsOutput/filename should print correct stats for 1`] = ` -asset 909.xxxx.js 8.88 KiB [emitted] (name: main) +asset 909.xxxx.js 8.81 KiB [emitted] (name: main) asset 521.xxxx.js 322 bytes [emitted] -runtime modules 7.28 KiB 11 modules +runtime modules 7.21 KiB 11 modules cacheable modules 70 bytes ./index.js 38 bytes [built] [code generated] ./dynamic.js 32 bytes [built] [code generated] @@ -150,18 +150,18 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s 1 chunks (Rspack x.x.x) compiled successfully in X s 2 chunks: - asset bundle2.js 10.3 KiB [emitted] (name: main) + asset bundle2.js 10.2 KiB [emitted] (name: main) asset 76.bundle2.js 497 bytes [emitted] (name: c) chunk (runtime: main) 76.bundle2.js (c) 74 bytes <{76}> <{909}> >{76}< [rendered] dependent modules 44 bytes [dependent] 2 modules ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle2.js (main) 145 bytes (javascript) 8.4 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle2.js (main) 145 bytes (javascript) 8.33 KiB (runtime) >{76}< [entry] [rendered] dependent modules 22 bytes [dependent] 1 module ./index.js 123 bytes [built] [code generated] 2 chunks (Rspack x.x.x) compiled successfully in X s 3 chunks: - asset bundle3.js 10.3 KiB [emitted] (name: main) + asset bundle3.js 10.2 KiB [emitted] (name: main) asset 76.bundle3.js 387 bytes [emitted] (name: c) asset 345.bundle3.js 186 bytes [emitted] chunk (runtime: main) 345.bundle3.js 44 bytes <{76}> [rendered] @@ -169,13 +169,13 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s ./e.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle3.js (c) 30 bytes <{909}> >{345}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle3.js (main) 145 bytes (javascript) 8.4 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle3.js (main) 145 bytes (javascript) 8.33 KiB (runtime) >{76}< [entry] [rendered] dependent modules 22 bytes [dependent] 1 module ./index.js 123 bytes [built] [code generated] 3 chunks (Rspack x.x.x) compiled successfully in X s 4 chunks: - asset bundle4.js 10.3 KiB [emitted] (name: main) + asset bundle4.js 10.2 KiB [emitted] (name: main) asset 76.bundle4.js 387 bytes [emitted] (name: c) asset 697.bundle4.js 130 bytes [emitted] asset 753.bundle4.js 130 bytes [emitted] @@ -185,7 +185,7 @@ exports[`statsOutput statsOutput/limit-chunk-count-plugin should print correct s ./d.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle4.js (c) 30 bytes <{909}> >{697}< >{753}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle4.js (main) 145 bytes (javascript) 8.4 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle4.js (main) 145 bytes (javascript) 8.33 KiB (runtime) >{76}< [entry] [rendered] dependent modules 22 bytes [dependent] 1 module ./index.js 123 bytes [built] [code generated] 4 chunks (Rspack x.x.x) compiled successfully in X s @@ -218,7 +218,7 @@ Rspack compiled with 1 error `; exports[`statsOutput statsOutput/named-chunk-group should print correct stats for 1`] = ` -Entrypoint main 8.87 KiB = main.js +Entrypoint main 8.8 KiB = main.js Chunk Group cimanyd 322 bytes = cimanyd.js `; @@ -234,48 +234,48 @@ Rspack compiled with 1 error `; exports[`statsOutput statsOutput/optimization-chunk-ids-natural should print correct stats for 1`] = ` -Entrypoint e1 10.4 KiB = e1.js -Entrypoint e2 10.3 KiB = e2.js +Entrypoint e1 10.3 KiB = e1.js +Entrypoint e2 10.2 KiB = e2.js chunk (runtime: e1) 0.js 24 bytes [rendered] chunk (runtime: e1) 1.js 52 bytes [rendered] chunk (runtime: e1, e2) 2.js 22 bytes [rendered] -chunk (runtime: e1) e1.js (e1) 74 bytes (javascript) 8.39 KiB (runtime) [entry] [rendered] -chunk (runtime: e2) e2.js (e2) 51 bytes (javascript) 8.39 KiB (runtime) [entry] [rendered] +chunk (runtime: e1) e1.js (e1) 74 bytes (javascript) 8.32 KiB (runtime) [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 51 bytes (javascript) 8.32 KiB (runtime) [entry] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk should print correct stats for 1`] = ` -Entrypoint e1 3.98 KiB = e1~runtime.js 3.59 KiB e1.js 391 bytes -Entrypoint e2 3.98 KiB = e2~runtime.js 3.59 KiB e2.js 391 bytes +Entrypoint e1 3.9 KiB = e1~runtime.js 3.52 KiB e1.js 391 bytes +Entrypoint e2 3.9 KiB = e2~runtime.js 3.52 KiB e2.js 391 bytes chunk (runtime: e1~runtime) e1.js (e1) 27 bytes [entry] [rendered] -chunk (runtime: e1~runtime) e1~runtime.js (e1~runtime) 2.5 KiB [initial] [rendered] +chunk (runtime: e1~runtime) e1~runtime.js (e1~runtime) 2.42 KiB [initial] [rendered] chunk (runtime: e2~runtime) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: e2~runtime) e2~runtime.js (e2~runtime) 2.5 KiB [initial] [rendered] +chunk (runtime: e2~runtime) e2~runtime.js (e2~runtime) 2.42 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk-multiple should print correct stats for 1`] = ` -Entrypoint e1 3.98 KiB = runtime~e1.js 3.59 KiB e1.js 391 bytes -Entrypoint e2 3.98 KiB = runtime~e2.js 3.59 KiB e2.js 391 bytes +Entrypoint e1 3.9 KiB = runtime~e1.js 3.52 KiB e1.js 391 bytes +Entrypoint e2 3.9 KiB = runtime~e2.js 3.52 KiB e2.js 391 bytes chunk (runtime: runtime~e1) e1.js (e1) 27 bytes [entry] [rendered] chunk (runtime: runtime~e2) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.5 KiB [initial] [rendered] -chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.5 KiB [initial] [rendered] +chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.42 KiB [initial] [rendered] +chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.42 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk-single should print correct stats for 1`] = ` -Entrypoint e1 3.97 KiB = runtime.js 3.59 KiB e1.js 391 bytes -Entrypoint e2 3.97 KiB = runtime.js 3.59 KiB e2.js 391 bytes +Entrypoint e1 3.9 KiB = runtime.js 3.52 KiB e1.js 391 bytes +Entrypoint e2 3.9 KiB = runtime.js 3.52 KiB e2.js 391 bytes chunk (runtime: runtime) e1.js (e1) 27 bytes [entry] [rendered] chunk (runtime: runtime) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: runtime) runtime.js (runtime) 2.49 KiB [initial] [rendered] +chunk (runtime: runtime) runtime.js (runtime) 2.42 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/optimization-runtime-chunk-true should print correct stats for 1`] = ` -Entrypoint e1 3.98 KiB = runtime~e1.js 3.59 KiB e1.js 391 bytes -Entrypoint e2 3.98 KiB = runtime~e2.js 3.59 KiB e2.js 391 bytes +Entrypoint e1 3.9 KiB = runtime~e1.js 3.52 KiB e1.js 391 bytes +Entrypoint e2 3.9 KiB = runtime~e2.js 3.52 KiB e2.js 391 bytes chunk (runtime: runtime~e1) e1.js (e1) 27 bytes [entry] [rendered] chunk (runtime: runtime~e2) e2.js (e2) 27 bytes [entry] [rendered] -chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.5 KiB [initial] [rendered] -chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.5 KiB [initial] [rendered] +chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.42 KiB [initial] [rendered] +chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.42 KiB [initial] [rendered] `; exports[`statsOutput statsOutput/parse-error should print correct stats for 1`] = ` @@ -302,7 +302,7 @@ asset main.js 303 KiB [emitted] (name: main) asset 697.js 130 bytes [emitted] asset 753.js 130 bytes [emitted] Entrypoint main 303 KiB = main.js -runtime modules 8.39 KiB 12 modules +runtime modules 8.32 KiB 12 modules cacheable modules 293 KiB ./index.js 49 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -318,7 +318,7 @@ asset main.js 303 KiB [emitted] [big] (name: main) asset 697.js 130 bytes [emitted] asset 753.js 130 bytes [emitted] Entrypoint main [big] 303 KiB = main.js -runtime modules 8.39 KiB 12 modules +runtime modules 8.32 KiB 12 modules cacheable modules 293 KiB ./index.js 48 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -328,11 +328,11 @@ cacheable modules 293 KiB ./e.js 22 bytes [built] [code generated] ERROR in × asset size limit: The following asset(s) exceed the recommended size limit (244.141 KiB). This can impact web performance.Assets: - │ main.js (303.492 KiB) + │ main.js (303.423 KiB) ERROR in × entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244.141 KiB). This can impact web performance.Entrypoints: - │ main (303.492 KiB) + │ main (303.423 KiB) │ main.js @@ -344,7 +344,7 @@ asset main.js 303 KiB [emitted] [big] (name: main) asset 697.js 130 bytes [emitted] asset 753.js 130 bytes [emitted] Entrypoint main [big] 303 KiB = main.js -runtime modules 8.39 KiB 12 modules +runtime modules 8.32 KiB 12 modules cacheable modules 293 KiB ./index.js 48 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -366,7 +366,7 @@ chunk (runtime: main) a2.js (a2) 1 bytes <{74}> [rendered] chunk (runtime: main) b.js (b) 203 bytes <{909}> >{438}< >{439}< >{826}< (prefetch: {826} {438}) (preload: {439}) [rendered] chunk (runtime: main) c.js (c) 134 bytes <{909}> >{380}< >{433}< (preload: {433} {380}) [rendered] chunk (runtime: main) b1.js (b1) 1 bytes <{751}> [rendered] -chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.5 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered] +chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.4 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered] `; exports[`statsOutput statsOutput/reasons should print correct stats for 1`] = ` diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt index bfa5cc54f225..c4fff2ebf501 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt @@ -1,3 +1,3 @@ ```html title=output.html -Rspack App +Rspack App ``` \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt b/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt index 4b48a32d1720..ddd2a4126a38 100644 --- a/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt @@ -8,7 +8,7 @@ - Bundle: chunk1_js.chunk.CURRENT_HASH.js - Manifest: [runtime of chunk2_js].LAST_HASH.hot-update.json, size: 65 - Manifest: main.LAST_HASH.hot-update.json, size: 41 -- Update: main.LAST_HASH.hot-update.js, size: 18249 +- Update: main.LAST_HASH.hot-update.js, size: 18148 ## Manifest @@ -81,9 +81,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -96,7 +94,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -123,13 +121,13 @@ if (installedChunkData !== 0) { var waitingUpdateResolves = {}; function loadUpdateChunk(chunkId, updatedModulesList) { currentUpdatedModulesList = updatedModulesList; - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { waitingUpdateResolves[chunkId] = resolve; // start update chunk loading var url = __webpack_require__.p + __webpack_require__.hu(chunkId); // create error before stack unwound to get useful stacktrace later var error = new Error(); - var loadingEnded = function (event) { + var loadingEnded = (event) => { if (waitingUpdateResolves[chunkId]) { waitingUpdateResolves[chunkId] = undefined; var errorType = @@ -153,7 +151,7 @@ function loadUpdateChunk(chunkId, updatedModulesList) { }); } -self["webpackHotUpdate"] = function (chunkId, moreModules, runtime) { +self["webpackHotUpdate"] = (chunkId, moreModules, runtime) => { for (var moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { currentUpdate[moduleId] = moreModules[moduleId]; @@ -615,11 +613,11 @@ __webpack_require__.hmrC.jsonp = function ( }; } }; -__webpack_require__.hmrM = function () { +__webpack_require__.hmrM = () => { if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then( - function (response) { + (response) => { if (response.status === 404) return; // no update available if (!response.ok) throw new Error( @@ -630,16 +628,12 @@ __webpack_require__.hmrM = function () { ); }; // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt b/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt index a5b274b7b2dd..d1673702be83 100644 --- a/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt +++ b/packages/rspack-test-tools/tests/hotCases/recover/recover-after-self-error/__snapshots__/web/3.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 1064 +- Update: main.LAST_HASH.hot-update.js, size: 1159 ## Manifest @@ -52,13 +52,15 @@ const id = module.id; },function(__webpack_require__) { // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = (exports, definition) => { - for(var key in definition) { - if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { - Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); - } - } -}; + + __webpack_require__.d = function (exports, definition) { + for (var key in definition) { + if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { + Object.defineProperty(exports, key, { configurable: true, enumerable: true, get: definition[key] }); + } + } + }; + })(); // webpack/runtime/get_full_hash (() => { diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js b/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js index 24ed3d4b0b0a..d7ecf330caa6 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js @@ -26,17 +26,17 @@ module.exports = { assets: Array [ Object { name: main.js, - size: 14017, + size: 13922, }, ], - assetsSize: 14017, + assetsSize: 13922, auxiliaryAssets: Array [ Object { name: main.js.map, - size: 676, + size: 667, }, ], - auxiliaryAssetsSize: 676, + auxiliaryAssetsSize: 667, childAssets: Object {}, children: Object { prefetch: Array [ @@ -215,17 +215,17 @@ module.exports = { assets: Array [ Object { name: main.js, - size: 14017, + size: 13922, }, ], - assetsSize: 14017, + assetsSize: 13922, auxiliaryAssets: Array [ Object { name: main.js.map, - size: 676, + size: 667, }, ], - auxiliaryAssetsSize: 676, + auxiliaryAssetsSize: 667, childAssets: Object {}, children: Object { prefetch: Array [ diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunks.js b/packages/rspack-test-tools/tests/statsAPICases/chunks.js index c1940d5c87a0..ed32e28024dd 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunks.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunks.js @@ -144,7 +144,7 @@ module.exports = { main.js, ], filteredModules: undefined, - hash: 2579eec3dea5af8d, + hash: 67718a28a7b45b16, id: 909, idHints: Array [], initial: true, @@ -235,7 +235,7 @@ module.exports = { size: 85, sizes: Object { javascript: 85, - runtime: 8795, + runtime: 8724, }, type: chunk, }, diff --git a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap index 50b30b085b30..b7aaf4b3c7c0 100644 --- a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap @@ -49,7 +49,7 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto > ./b ./index.js 2:0-47 dependent modules 80 bytes [dependent] 4 modules ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) disabled/a.js (a) 165 bytes (javascript) 7.14 KiB (runtime) [entry] [rendered] + chunk (runtime: a) disabled/a.js (a) 165 bytes (javascript) 7.01 KiB (runtime) [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) disabled/b.js (b) 116 bytes [entry] [rendered] @@ -58,7 +58,7 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto chunk (runtime: c) disabled/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 7.21 KiB (runtime) [entry] [rendered] + chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 7.08 KiB (runtime) [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) disabled/async-g.js (async-g) 65 bytes [rendered] @@ -95,7 +95,7 @@ default: > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] + chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.04 KiB (runtime) [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) default/b.js (b) 116 bytes [entry] [rendered] @@ -109,7 +109,7 @@ default: chunk (runtime: c) default/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) [entry] [rendered] + chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.09 KiB (runtime) [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) default/async-g.js (async-g) 45 bytes [rendered] @@ -130,7 +130,7 @@ vendors: > ./b ./index.js 2:0-47 dependent modules 80 bytes [dependent] 4 modules ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) vendors/a.js (a) 165 bytes (javascript) 7.14 KiB (runtime) [entry] [rendered] + chunk (runtime: a) vendors/a.js (a) 165 bytes (javascript) 7.01 KiB (runtime) [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) vendors/b.js (b) 116 bytes [entry] [rendered] @@ -139,7 +139,7 @@ vendors: chunk (runtime: c) vendors/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 7.21 KiB (runtime) [entry] [rendered] + chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 7.08 KiB (runtime) [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) vendors/async-g.js (async-g) 65 bytes [rendered] @@ -149,10 +149,10 @@ vendors: vendors (Rspack x.x.x) compiled successfully multiple-vendors: - Entrypoint main 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/main.js 4.88 KiB - Entrypoint a 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/a.js 4.88 KiB - Entrypoint b 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/b.js 4.88 KiB - Entrypoint c 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/c.js 4.88 KiB + Entrypoint main 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/main.js 4.8 KiB + Entrypoint a 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/a.js 4.8 KiB + Entrypoint b 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/b.js 4.8 KiB + Entrypoint c 10.8 KiB = multiple-vendors/libs.js 5.95 KiB multiple-vendors/c.js 4.8 KiB chunk (runtime: a, b, c, main) multiple-vendors/libs.js (libs) (id hint: libs) 709 bytes [initial] [rendered] split chunk (cache group: libs) > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 @@ -164,21 +164,21 @@ multiple-vendors: > ./ main dependent modules 562 bytes [dependent] 10 modules ./index.js 147 bytes [built] [code generated] - chunk (runtime: a) multiple-vendors/a.js (a) 3.26 KiB [entry] [rendered] + chunk (runtime: a) multiple-vendors/a.js (a) 3.19 KiB [entry] [rendered] > ./a a - chunk (runtime: b) multiple-vendors/b.js (b) 3.26 KiB [entry] [rendered] + chunk (runtime: b) multiple-vendors/b.js (b) 3.19 KiB [entry] [rendered] > ./b b - chunk (runtime: c) multiple-vendors/c.js (c) 3.26 KiB [entry] [rendered] + chunk (runtime: c) multiple-vendors/c.js (c) 3.19 KiB [entry] [rendered] > ./c c - chunk (runtime: main) multiple-vendors/main.js (main) 3.26 KiB [entry] [rendered] + chunk (runtime: main) multiple-vendors/main.js (main) 3.19 KiB [entry] [rendered] > ./ main multiple-vendors (Rspack x.x.x) compiled successfully all: - Entrypoint main 10.7 KiB = all/605.js 762 bytes all/main.js 9.92 KiB - Entrypoint a 10.4 KiB = all/272.js 497 bytes all/a.js 9.92 KiB - Entrypoint b 4.15 KiB = all/726.js 258 bytes all/b.js 3.9 KiB - Entrypoint c 4.15 KiB = all/29.js 257 bytes all/c.js 3.9 KiB + Entrypoint main 10.5 KiB = all/605.js 762 bytes all/main.js 9.77 KiB + Entrypoint a 10.3 KiB = all/272.js 497 bytes all/a.js 9.77 KiB + Entrypoint b 4.08 KiB = all/726.js 258 bytes all/b.js 3.83 KiB + Entrypoint c 4.08 KiB = all/29.js 257 bytes all/c.js 3.83 KiB chunk (runtime: main) all/199.js (id hint: vendors) 116 bytes [rendered] split chunk (cache group: vendors) > ./b ./index.js 2:0-47 ./b.js 116 bytes [built] [code generated] @@ -213,16 +213,16 @@ all: chunk (runtime: b) all/726.js (id hint: vendors) 116 bytes [initial] [rendered] split chunk (cache group: vendors) > ./b b ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) all/a.js (a) 8.15 KiB [entry] [rendered] + chunk (runtime: a) all/a.js (a) 8 KiB [entry] [rendered] > ./a a - chunk (runtime: b) all/b.js (b) 2.49 KiB [entry] [rendered] + chunk (runtime: b) all/b.js (b) 2.42 KiB [entry] [rendered] > ./b b - chunk (runtime: c) all/c.js (c) 2.49 KiB [entry] [rendered] + chunk (runtime: c) all/c.js (c) 2.42 KiB [entry] [rendered] > ./c c chunk (runtime: a, main) all/889.js (id hint: vendors) 45 bytes [rendered] split chunk (cache group: vendors) > ./g ./a.js 6:0-47 ./g.js 45 bytes [built] [code generated] - chunk (runtime: main) all/main.js (main) 8.15 KiB [entry] [rendered] + chunk (runtime: main) all/main.js (main) 8 KiB [entry] [rendered] > ./ main chunk (runtime: main) all/910.js (id hint: vendors) 185 bytes [rendered] split chunk (cache group: vendors) > ./a ./index.js 1:0-47 @@ -251,7 +251,7 @@ chunk (runtime: main) 751.bundle.js (b) 49 bytes <{76}> <{909}> >{76}< [rendered ./module-b.js 49 bytes [built] [code generated] chunk (runtime: main) 76.bundle.js (c) 98 bytes <{74}> <{751}> >{74}< >{751}< [rendered] ./module-c.js 98 bytes [built] [code generated] -chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 8.25 KiB (runtime) >{74}< >{751}< [entry] [rendered] +chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 8.12 KiB (runtime) >{74}< >{751}< [entry] [rendered] ./index.js 98 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; @@ -277,10 +277,10 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for commons-chunk-min-size-Infinity 1`] = ` -"asset entry-1.js 4.3 KiB [emitted] (name: entry-1) +"asset entry-1.js 4.23 KiB [emitted] (name: entry-1) asset vendor-1.js 242 bytes [emitted] (name: vendor-1) (id hint: vendor-1) -Entrypoint entry-1 4.54 KiB = vendor-1.js 242 bytes entry-1.js 4.3 KiB -runtime modules 2.49 KiB 3 modules +Entrypoint entry-1 4.47 KiB = vendor-1.js 242 bytes entry-1.js 4.23 KiB +runtime modules 2.42 KiB 3 modules modules by path ./modules/*.js 132 bytes ./modules/a.js 22 bytes [built] [code generated] ./modules/b.js 22 bytes [built] [code generated] @@ -358,7 +358,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for graph-correctness-entries 1`] = ` -"chunk (runtime: e1) e1.js (e1) 49 bytes (javascript) 8.27 KiB (runtime) >{74}< [entry] [rendered] +"chunk (runtime: e1) e1.js (e1) 49 bytes (javascript) 8.14 KiB (runtime) >{74}< [entry] [rendered] ./e1.js 49 bytes [built] [code generated] entry ./e1 chunk (runtime: e1, e2) a.js (a) 49 bytes <{605}> <{76}> >{751}< [rendered] @@ -372,14 +372,14 @@ chunk (runtime: e1, e2) c.js (c) 49 bytes <{751}> <{844}> >{74}< [rendered] ./module-c.js 49 bytes [built] [code generated] import() ./module-c ./e2.js import() ./module-c ./module-b.js -chunk (runtime: e2) e2.js (e2) 49 bytes (javascript) 8.27 KiB (runtime) >{76}< [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 49 bytes (javascript) 8.14 KiB (runtime) >{76}< [entry] [rendered] ./e2.js 49 bytes [built] [code generated] entry ./e2 Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for graph-correctness-modules 1`] = ` -"chunk (runtime: e1) e1.js (e1) 119 bytes (javascript) 8.54 KiB (runtime) >{74}< >{984}< [entry] [rendered] +"chunk (runtime: e1) e1.js (e1) 119 bytes (javascript) 8.42 KiB (runtime) >{74}< >{984}< [entry] [rendered] ./e1.js 70 bytes [built] [code generated] entry ./e1 ./module-x.js 49 bytes [dependent] [built] [code generated] @@ -397,7 +397,7 @@ chunk (runtime: e1, e2) c.js (c) 49 bytes <{751}> <{844}> >{74}< [rendered] ./module-c.js 49 bytes [built] [code generated] import() ./module-c ./e2.js import() ./module-c ./module-b.js -chunk (runtime: e2) e2.js (e2) 119 bytes (javascript) 8.54 KiB (runtime) >{76}< >{984}< [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 119 bytes (javascript) 8.42 KiB (runtime) >{76}< >{984}< [entry] [rendered] ./e2.js 70 bytes [built] [code generated] entry ./e2 ./module-x.js 49 bytes [dependent] [built] [code generated] @@ -436,7 +436,7 @@ chunk (runtime: main) id-equals-name_js0.js 21 bytes [rendered] ./id-equals-name.js 21 bytes [built] [code generated] chunk (runtime: main) id-equals-name_js_3.js 21 bytes [rendered] ./id-equals-name.js?3 21 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 639 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] +chunk (runtime: main) main.js (main) 639 bytes (javascript) 6.99 KiB (runtime) [entry] [rendered] ./index.js 639 bytes [built] [code generated] chunk (runtime: main) tree.js (tree) 137 bytes [rendered] dependent modules 98 bytes [dependent] 3 modules @@ -456,16 +456,16 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for immutable 1`] = ` -"asset 5da07eb45c1ef960.js 10.2 KiB [emitted] [immutable] (name: main) +"asset 51858b0b6ca76b68.js 10.1 KiB [emitted] [immutable] (name: main) asset 7342054f673663df.js 167 bytes [emitted] [immutable]" `; exports[`StatsTestCases should print correct stats for import-context-filter 1`] = ` -"asset entry.js 9.95 KiB [emitted] (name: entry) +"asset entry.js 9.82 KiB [emitted] (name: entry) asset 228.js 407 bytes [emitted] asset 271.js 407 bytes [emitted] asset 536.js 407 bytes [emitted] -runtime modules 7.12 KiB 9 modules +runtime modules 6.99 KiB 9 modules cacheable modules 724 bytes modules by path ./templates/*.js 114 bytes ./templates/bar.js 38 bytes [built] [code generated] @@ -477,10 +477,10 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-weak 1`] = ` -"asset entry.js 10 KiB [emitted] (name: entry) +"asset entry.js 9.89 KiB [emitted] (name: entry) asset 332.js 285 bytes [emitted] asset 313.js 130 bytes [emitted] -runtime modules 8.24 KiB 10 modules +runtime modules 8.11 KiB 10 modules cacheable modules 179 bytes ./entry.js 120 bytes [built] [code generated] ./modules/a.js 37 bytes [built] [code generated] @@ -489,10 +489,10 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-weak-parser-option 1`] = ` -"asset entry.js 10 KiB [emitted] (name: entry) +"asset entry.js 9.89 KiB [emitted] (name: entry) asset 332.js 285 bytes [emitted] asset 313.js 130 bytes [emitted] -runtime modules 8.24 KiB 10 modules +runtime modules 8.11 KiB 10 modules cacheable modules 153 bytes ./entry.js 94 bytes [built] [code generated] ./modules/a.js 37 bytes [built] [code generated] @@ -501,7 +501,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-with-invalid-options-comments 1`] = ` -"runtime modules 9.27 KiB 12 modules +"runtime modules 9.14 KiB 12 modules cacheable modules 559 bytes ./index.js 50 bytes [built] [code generated] ./chunk.js 401 bytes [built] [code generated] [2 warnings] @@ -540,20 +540,20 @@ Rspack x.x.x compiled with 2 warnings" `; exports[`StatsTestCases should print correct stats for issue-7577 1`] = ` -"asset a-runtime~main-bee03820f30f4a05.js 3.6 KiB [emitted] [immutable] (name: runtime~main) +"asset a-runtime~main-507111cdefb67f48.js 3.52 KiB [emitted] [immutable] (name: runtime~main) asset a-main-f9892dc0f961d982.js 387 bytes [emitted] [immutable] (name: main) asset a-all-a_js-cace9eea394248e7.js 128 bytes [emitted] [immutable] (id hint: all) -Entrypoint main 4.1 KiB = a-runtime~main-bee03820f30f4a05.js 3.6 KiB a-all-a_js-cace9eea394248e7.js 128 bytes a-main-f9892dc0f961d982.js 387 bytes -runtime modules 2.5 KiB 3 modules +Entrypoint main 4.03 KiB = a-runtime~main-507111cdefb67f48.js 3.52 KiB a-all-a_js-cace9eea394248e7.js 128 bytes a-main-f9892dc0f961d982.js 387 bytes +runtime modules 2.43 KiB 3 modules ./a.js 18 bytes [built] [code generated] Rspack x.x.x compiled successfully in X.23 -asset b-runtime~main-76389ef10c5c9516.js 4.25 KiB [emitted] [immutable] (name: runtime~main) +asset b-runtime~main-7d8187d08df3ca82.js 4.18 KiB [emitted] [immutable] (name: runtime~main) asset b-all-b_js-f689e3be6ed05e06.js 453 bytes [emitted] [immutable] (id hint: all) asset b-main-a97968a81f0fafdb.js 420 bytes [emitted] [immutable] (name: main) asset b-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 5.27 KiB = b-runtime~main-76389ef10c5c9516.js 4.25 KiB b-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes b-all-b_js-f689e3be6ed05e06.js 453 bytes b-main-a97968a81f0fafdb.js 420 bytes -runtime modules 3.04 KiB 5 modules +Entrypoint main 5.2 KiB = b-runtime~main-7d8187d08df3ca82.js 4.18 KiB b-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes b-all-b_js-f689e3be6ed05e06.js 453 bytes b-main-a97968a81f0fafdb.js 420 bytes +runtime modules 2.96 KiB 5 modules cacheable modules 40 bytes ./b.js 17 bytes [built] [code generated] ./node_modules/vendor.js 23 bytes [built] [code generated] @@ -562,11 +562,11 @@ Rspack x.x.x compiled successfully in X.23 assets by chunk 862 bytes (id hint: all) asset c-all-b_js-b683c5304b71900e.js 480 bytes [emitted] [immutable] (id hint: all) asset c-all-c_js-2c876c6ecab93d9b.js 382 bytes [emitted] [immutable] (id hint: all) -asset c-runtime~main-54907b49863c22c2.js 10.8 KiB [emitted] [immutable] (name: runtime~main) +asset c-runtime~main-85d5b8c60b8ea9fe.js 10.7 KiB [emitted] [immutable] (name: runtime~main) asset c-main-5df1191222ffdffb.js 588 bytes [emitted] [immutable] (name: main) asset c-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 11.8 KiB = c-runtime~main-54907b49863c22c2.js 10.8 KiB c-all-c_js-2c876c6ecab93d9b.js 382 bytes c-main-5df1191222ffdffb.js 588 bytes -runtime modules 9.39 KiB 13 modules +Entrypoint main 11.6 KiB = c-runtime~main-85d5b8c60b8ea9fe.js 10.7 KiB c-all-c_js-2c876c6ecab93d9b.js 382 bytes c-main-5df1191222ffdffb.js 588 bytes +runtime modules 9.25 KiB 13 modules cacheable modules 101 bytes ./c.js 61 bytes [built] [code generated] ./b.js 17 bytes [built] [code generated] @@ -597,7 +597,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1 chunks (Rspack x.x.x) compiled with 1 warning in X.23 2 chunks: - asset bundle2.js 10.4 KiB [emitted] (name: main) + asset bundle2.js 10.3 KiB [emitted] (name: main) asset 76.bundle2.js 553 bytes [emitted] (name: c) chunk (runtime: main) 76.bundle2.js (c) 96 bytes <{76}> <{909}> >{76}< [rendered] dependent modules 44 bytes [dependent] @@ -605,7 +605,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin ./e.js 22 bytes [dependent] [built] [code generated] ./a.js 22 bytes [built] [code generated] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle2.js (main) 261 bytes (javascript) 8.25 KiB (runtime) >{76}< [entry] [rendered] + chunk (runtime: main) bundle2.js (main) 261 bytes (javascript) 8.12 KiB (runtime) >{76}< [entry] [rendered] ./index.js 101 bytes [built] [code generated] [1 warning] Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] @@ -621,7 +621,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 2 chunks (Rspack x.x.x) compiled with 1 warning in X.23 3 chunks: - asset bundle3.js 10.4 KiB [emitted] (name: main) + asset bundle3.js 10.3 KiB [emitted] (name: main) asset 76.bundle3.js 387 bytes [emitted] (name: c) asset 588.bundle3.js 242 bytes [emitted] chunk (runtime: main) 588.bundle3.js 66 bytes <{76}> <{909}> [rendered] @@ -630,7 +630,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin ./e.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle3.js (c) 30 bytes <{909}> >{588}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle3.js (main) 261 bytes (javascript) 8.25 KiB (runtime) >{588}< >{76}< [entry] [rendered] + chunk (runtime: main) bundle3.js (main) 261 bytes (javascript) 8.12 KiB (runtime) >{588}< >{76}< [entry] [rendered] ./index.js 101 bytes [built] [code generated] [1 warning] Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] @@ -646,7 +646,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 3 chunks (Rspack x.x.x) compiled with 1 warning in X.23 4 chunks: - asset bundle4.js 10.4 KiB [emitted] (name: main) + asset bundle4.js 10.3 KiB [emitted] (name: main) asset 76.bundle4.js 387 bytes [emitted] (name: c) asset 345.bundle4.js 186 bytes [emitted] asset 272.bundle4.js 130 bytes [emitted] @@ -657,7 +657,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin ./e.js 22 bytes [built] [code generated] chunk (runtime: main) 76.bundle4.js (c) 30 bytes <{909}> >{345}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle4.js (main) 261 bytes (javascript) 8.25 KiB (runtime) >{272}< >{76}< [entry] [rendered] + chunk (runtime: main) bundle4.js (main) 261 bytes (javascript) 8.12 KiB (runtime) >{272}< >{76}< [entry] [rendered] ./index.js 101 bytes [built] [code generated] [1 warning] Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] @@ -726,23 +726,23 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for module-assets 1`] = ` -"assets by path *.js 8.88 KiB - asset main.js 8.44 KiB [emitted] (name: main) +"assets by path *.js 8.75 KiB + asset main.js 8.31 KiB [emitted] (name: main) asset b.js 226 bytes [emitted] (name: b) asset a.js 225 bytes [emitted] (name: a) assets by path *.png 42 KiB asset 1.png 21 KiB [emitted] [from: node_modules/a/1.png] asset 2.png 21 KiB [emitted] [from: node_modules/a/2.png] -Entrypoint main 8.44 KiB = main.js +Entrypoint main 8.31 KiB = main.js Chunk Group a 225 bytes = a.js Chunk Group b 226 bytes = b.js chunk (runtime: main) a.js (a) 36 bytes [rendered] ./node_modules/a/index.js 36 bytes [built] [code generated] chunk (runtime: main) b.js (b) 18 bytes [rendered] ./node_modules/b/index.js 18 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.87 KiB (runtime) [entry] [rendered] +chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.74 KiB (runtime) [entry] [rendered] ./index.js 82 bytes [built] [code generated] -runtime modules 6.87 KiB 8 modules +runtime modules 6.74 KiB 8 modules orphan modules 98 bytes [orphan] 2 modules modules with assets 136 bytes ./index.js 82 bytes [built] [code generated] @@ -752,9 +752,9 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for module-deduplication 1`] = ` -"asset e1.js 9.84 KiB [emitted] (name: e1) -asset e2.js 9.84 KiB [emitted] (name: e2) -asset e3.js 9.84 KiB [emitted] (name: e3) +"asset e1.js 9.71 KiB [emitted] (name: e1) +asset e2.js 9.71 KiB [emitted] (name: e2) +asset e3.js 9.71 KiB [emitted] (name: e3) asset 106.js 753 bytes [emitted] asset 511.js 753 bytes [emitted] asset 637.js 753 bytes [emitted] @@ -771,20 +771,20 @@ chunk (runtime: e3) 400.js 61 bytes [rendered] chunk (runtime: e1, e3) 511.js 81 bytes [rendered] ./async2.js 61 bytes [built] [code generated] ./f.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e1) e1.js (e1) 249 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] +chunk (runtime: e1) e1.js (e1) 249 bytes (javascript) 6.99 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] ./e1.js + 2 modules 209 bytes [code generated] chunk (runtime: e2, e3) 637.js 81 bytes [rendered] ./async1.js 61 bytes [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e3) e3.js (e3) 249 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] +chunk (runtime: e3) e3.js (e3) 249 bytes (javascript) 6.99 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e3.js + 2 modules 209 bytes [code generated] ./h.js 20 bytes [dependent] [built] [code generated] chunk (runtime: e2) 806.js 61 bytes [rendered] ./async2.js 61 bytes [built] [code generated] -chunk (runtime: e2) e2.js (e2) 249 bytes (javascript) 7.12 KiB (runtime) [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 249 bytes (javascript) 6.99 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e2.js + 2 modules 209 bytes [code generated] ./f.js 20 bytes [dependent] [built] [code generated] @@ -792,16 +792,16 @@ Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for module-deduplication-named 1`] = ` -"asset e1.js 9.7 KiB [emitted] (name: e1) -asset e2.js 9.7 KiB [emitted] (name: e2) -asset e3.js 9.7 KiB [emitted] (name: e3) +"asset e1.js 9.57 KiB [emitted] (name: e1) +asset e2.js 9.57 KiB [emitted] (name: e2) +asset e3.js 9.57 KiB [emitted] (name: e3) asset async1.js 865 bytes [emitted] (name: async1) asset async2.js 864 bytes [emitted] (name: async2) asset async3.js 864 bytes [emitted] (name: async3) chunk (runtime: e1, e2, e3) async3.js (async3) 135 bytes [rendered] ./async3.js 115 bytes [built] [code generated] ./h.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e1) e1.js (e1) 242 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] +chunk (runtime: e1) e1.js (e1) 242 bytes (javascript) 7.04 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] ./e1.js + 2 modules 202 bytes [code generated] @@ -811,11 +811,11 @@ chunk (runtime: e1, e2, e3) async2.js (async2) 135 bytes [rendered] chunk (runtime: e1, e2, e3) async1.js (async1) 135 bytes [rendered] ./async1.js 115 bytes [built] [code generated] ./d.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e3) e3.js (e3) 242 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] +chunk (runtime: e3) e3.js (e3) 242 bytes (javascript) 7.04 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e3.js + 2 modules 202 bytes [code generated] ./h.js 20 bytes [dependent] [built] [code generated] -chunk (runtime: e2) e2.js (e2) 242 bytes (javascript) 7.17 KiB (runtime) [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 242 bytes (javascript) 7.04 KiB (runtime) [entry] [rendered] ./b.js 20 bytes [dependent] [built] [code generated] ./e2.js + 2 modules 202 bytes [code generated] ./f.js 20 bytes [dependent] [built] [code generated] @@ -928,7 +928,7 @@ exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] = "Chunk Group async-a 1000 bytes = a-727.js 250 bytes a-async-a.js 751 bytes Chunk Group async-b 1000 bytes = a-727.js 250 bytes a-async-b.js 751 bytes Chunk Group async-c 1.21 KiB = a-vendors.js 586 bytes a-async-c.js 654 bytes -Chunk Group main 9.41 KiB = a-main.js +Chunk Group main 9.28 KiB = a-main.js chunk (runtime: main) a-async-c.js (async-c) 67 bytes [rendered] > ./c ./index.js 3:0-47 ./c.js 67 bytes [built] [code generated] @@ -946,12 +946,12 @@ chunk (runtime: main) a-727.js (id hint: ) 149 bytes [rendered] split chunk (cac > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 7.47 KiB (runtime) [entry] [rendered] +chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 7.34 KiB (runtime) [entry] [rendered] > ./ main ./index.js 146 bytes [built] [code generated] Rspack x.x.x compiled successfully -Entrypoint main 9.41 KiB = b-main.js +Entrypoint main 9.28 KiB = b-main.js Chunk Group async-a 1000 bytes = b-727.js 250 bytes b-async-a.js 751 bytes Chunk Group async-b 1000 bytes = b-727.js 250 bytes b-async-b.js 751 bytes Chunk Group async-c 1.21 KiB = b-vendors.js 586 bytes b-async-c.js 654 bytes @@ -972,17 +972,17 @@ chunk (runtime: main) b-727.js (id hint: ) 149 bytes [rendered] split chunk (cac > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 7.47 KiB (runtime) [entry] [rendered] +chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 7.34 KiB (runtime) [entry] [rendered] > ./ main ./index.js 146 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for named-chunks-plugin 1`] = ` -"asset entry.js 4.18 KiB [emitted] (name: entry) +"asset entry.js 4.11 KiB [emitted] (name: entry) asset vendor.js 211 bytes [emitted] (name: vendor) (id hint: vendor) -Entrypoint entry 4.39 KiB = vendor.js 211 bytes entry.js 4.18 KiB -runtime modules 2.49 KiB 3 modules +Entrypoint entry 4.32 KiB = vendor.js 211 bytes entry.js 4.11 KiB +runtime modules 2.42 KiB 3 modules cacheable modules 138 bytes ./entry.js 72 bytes [built] [code generated] ./modules/a.js 22 bytes [built] [code generated] @@ -992,7 +992,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for optimize-chunks 1`] = ` -"asset main.js 9.16 KiB {909} [emitted] (name: main) +"asset main.js 9.03 KiB {909} [emitted] (name: main) asset cir2 from cir1.js 355 bytes {334} [emitted] (name: cir2 from cir1) asset cir1.js 327 bytes {228} [emitted] (name: cir1) asset cir2.js 327 bytes {787} [emitted] (name: cir2) @@ -1024,7 +1024,7 @@ chunk {405} (runtime: main) ac in ab.js (ac in ab) 2 bytes <{909}> [rendered] chunk {787} (runtime: main) cir2.js (cir2) 81 bytes <{909}> >{228}< [rendered] > [10] ./index.js 14:0-54 ./circular2.js [193] 81 bytes {334} {787} [built] [code generated] -chunk {909} (runtime: main) main.js (main) 524 bytes (javascript) 6.69 KiB (runtime) >{228}< >{295}< >{37}< >{405}< >{787}< >{919}< [entry] [rendered] +chunk {909} (runtime: main) main.js (main) 524 bytes (javascript) 6.56 KiB (runtime) >{228}< >{295}< >{37}< >{405}< >{787}< >{919}< [entry] [rendered] > ./index main ./index.js [10] 523 bytes {909} [built] [code generated] ./modules/f.js [544] 1 bytes {909} [dependent] [built] [code generated] @@ -1039,9 +1039,9 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for output-module 1`] = ` -"asset main.mjs 7.84 KiB [emitted] [javascript module] (name: main) +"asset main.mjs 7.71 KiB [emitted] [javascript module] (name: main) asset 8.mjs 270 bytes [emitted] [javascript module] -runtime modules 6.13 KiB 8 modules +runtime modules 6 KiB 8 modules orphan modules 225 bytes [orphan] 2 modules cacheable modules 263 bytes ./index.js + 1 modules 225 bytes [code generated] @@ -1202,22 +1202,22 @@ Rspack x.x.x compiled with 3 errors in X s" `; exports[`StatsTestCases should print correct stats for prefetch 1`] = ` -"asset main.js 13.5 KiB {909} [emitted] (name: main) +"asset main.js 13.4 KiB {909} [emitted] (name: main) asset prefetched.js 554 bytes {674} [emitted] (name: prefetched) asset inner2.js 130 bytes {857} [emitted] (name: inner2) asset inner.js 102 bytes {481} [emitted] (name: inner) asset normal.js 102 bytes {615} [emitted] (name: normal) asset prefetched2.js 102 bytes {424} [emitted] (name: prefetched2) asset prefetched3.js 102 bytes {182} [emitted] (name: prefetched3) -Entrypoint main 13.5 KiB = main.js - prefetch: prefetched.js {674} (name: prefetched) +Entrypoint main 13.4 KiB = main.js + prefetch: prefetched.js {674} (name: prefetched), prefetched3.js {182} (name: prefetched3), prefetched2.js {424} (name: prefetched2) chunk {182} (runtime: main) prefetched3.js (prefetched3) 1 bytes <{909}> [rendered] chunk {424} (runtime: main) prefetched2.js (prefetched2) 1 bytes <{909}> [rendered] chunk {481} (runtime: main) inner.js (inner) 1 bytes <{674}> [rendered] chunk {615} (runtime: main) normal.js (normal) 1 bytes <{909}> [rendered] chunk {674} (runtime: main) prefetched.js (prefetched) 228 bytes <{909}> >{481}< >{857}< (prefetch: {857} {481}) [rendered] chunk {857} (runtime: main) inner2.js (inner2) 2 bytes <{674}> [rendered] -chunk {909} (runtime: main) main.js (main) 436 bytes (javascript) 10.6 KiB (runtime) >{182}< >{424}< >{615}< >{674}< (prefetch: {674}) [entry] [rendered]" +chunk {909} (runtime: main) main.js (main) 436 bytes (javascript) 10.5 KiB (runtime) >{182}< >{424}< >{615}< >{674}< (prefetch: {674} {182} {424}) [entry] [rendered]" `; exports[`StatsTestCases should print correct stats for prefetch-preload-mixed 1`] = ` @@ -1231,26 +1231,26 @@ chunk (runtime: main) a2.js (a2) 1 bytes <{74}> [rendered] chunk (runtime: main) b.js (b) 203 bytes <{909}> >{438}< >{439}< >{826}< (prefetch: {826} {438}) (preload: {439}) [rendered] chunk (runtime: main) c.js (c) 134 bytes <{909}> >{380}< >{433}< (preload: {433} {380}) [rendered] chunk (runtime: main) b1.js (b1) 1 bytes <{751}> [rendered] -chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.3 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered]" +chunk (runtime: main) main.js (main) 195 bytes (javascript) 11.2 KiB (runtime) >{74}< >{751}< >{76}< (prefetch: {74} {751} {76}) [entry] [rendered]" `; exports[`StatsTestCases should print correct stats for preload 1`] = ` -"asset main.js 12.2 KiB [emitted] (name: main) +"asset main.js 12.1 KiB [emitted] (name: main) asset preloaded.js 554 bytes [emitted] (name: preloaded) asset inner2.js 130 bytes [emitted] (name: inner2) asset inner.js 102 bytes [emitted] (name: inner) asset normal.js 102 bytes [emitted] (name: normal) asset preloaded2.js 101 bytes [emitted] (name: preloaded2) asset preloaded3.js 100 bytes [emitted] (name: preloaded3) -Entrypoint main 12.2 KiB = main.js - preload: preloaded.js {154} (name: preloaded) +Entrypoint main 12.1 KiB = main.js + preload: preloaded.js {154} (name: preloaded), preloaded3.js {551} (name: preloaded3), preloaded2.js {577} (name: preloaded2) chunk (runtime: main) preloaded.js (preloaded) 226 bytes (preload: {857} {481}) [rendered] chunk (runtime: main) inner.js (inner) 1 bytes [rendered] chunk (runtime: main) preloaded3.js (preloaded3) 1 bytes [rendered] chunk (runtime: main) preloaded2.js (preloaded2) 1 bytes [rendered] chunk (runtime: main) normal.js (normal) 1 bytes [rendered] chunk (runtime: main) inner2.js (inner2) 2 bytes [rendered] -chunk (runtime: main) main.js (main) 424 bytes (javascript) 9.53 KiB (runtime) (preload: {154}) [entry] [rendered]" +chunk (runtime: main) main.js (main) 424 bytes (javascript) 9.39 KiB (runtime) (preload: {154} {551} {577}) [entry] [rendered]" `; exports[`StatsTestCases should print correct stats for preset-errors-only 1`] = `""`; @@ -1320,61 +1320,61 @@ Rspack x.x.x compiled successfully" exports[`StatsTestCases should print correct stats for related-assets 1`] = ` "default: - assets by path *.br 13.8 KiB - asset default-main.js.br 11.8 KiB [emitted] - asset default-main.js.map.br 671 bytes [emitted] + assets by path *.br 13.6 KiB + asset default-main.js.br 11.7 KiB [emitted] + asset default-main.js.map.br 665 bytes [emitted] + 6 assets - assets by path *.gz 13.8 KiB - asset default-main.js.gz 11.8 KiB [emitted] - asset default-main.js.map.gz 671 bytes [emitted] + assets by path *.gz 13.6 KiB + asset default-main.js.gz 11.7 KiB [emitted] + asset default-main.js.map.gz 665 bytes [emitted] asset default-chunk_js.js.gz 611 bytes [emitted] + 5 assets - assets by path *.js 12.4 KiB - asset default-main.js 11.8 KiB [emitted] (name: main) + assets by path *.js 12.3 KiB + asset default-main.js 11.7 KiB [emitted] (name: main) asset default-chunk_js.js 611 bytes [emitted] assets by path *.css 142 bytes asset default-chunk_js.css 73 bytes [emitted] asset default-main.css 69 bytes [emitted] (name: main) relatedAssets: - assets by path *.br 13.9 KiB - asset relatedAssets-main.js.br 11.9 KiB [emitted] - asset relatedAssets-main.js.map.br 677 bytes [emitted] + assets by path *.br 13.7 KiB + asset relatedAssets-main.js.br 11.7 KiB [emitted] + asset relatedAssets-main.js.map.br 671 bytes [emitted] + 6 assets - assets by path *.gz 13.9 KiB - asset relatedAssets-main.js.gz 11.9 KiB [emitted] - asset relatedAssets-main.js.map.gz 677 bytes [emitted] + assets by path *.gz 13.7 KiB + asset relatedAssets-main.js.gz 11.7 KiB [emitted] + asset relatedAssets-main.js.map.gz 671 bytes [emitted] asset relatedAssets-chunk_js.js.gz 617 bytes [emitted] + 5 assets - assets by path *.js 12.5 KiB - asset relatedAssets-main.js 11.9 KiB [emitted] (name: main) + assets by path *.js 12.3 KiB + asset relatedAssets-main.js 11.7 KiB [emitted] (name: main) asset relatedAssets-chunk_js.js 617 bytes [emitted] assets by path *.css 154 bytes asset relatedAssets-chunk_js.css 79 bytes [emitted] asset relatedAssets-main.css 75 bytes [emitted] (name: main) exclude1: - hidden assets 27.7 KiB 16 assets - assets by status 12.6 KiB [emitted] - assets by path *.js 12.4 KiB - asset exclude1-main.js 11.9 KiB [emitted] (name: main) + hidden assets 27.3 KiB 16 assets + assets by status 12.4 KiB [emitted] + assets by path *.js 12.3 KiB + asset exclude1-main.js 11.7 KiB [emitted] (name: main) asset exclude1-chunk_js.js 612 bytes [emitted] assets by path *.css 144 bytes asset exclude1-chunk_js.css 74 bytes [emitted] asset exclude1-main.css 70 bytes [emitted] (name: main) exclude2: - assets by path *.br 13.9 KiB - asset exclude2-main.js.br 11.9 KiB [emitted] - asset exclude2-main.js.map.br 672 bytes [emitted] + assets by path *.br 13.7 KiB + asset exclude2-main.js.br 11.7 KiB [emitted] + asset exclude2-main.js.map.br 666 bytes [emitted] + 6 assets - assets by path *.gz 13.9 KiB - asset exclude2-main.js.gz 11.9 KiB [emitted] - asset exclude2-main.js.map.gz 672 bytes [emitted] + assets by path *.gz 13.7 KiB + asset exclude2-main.js.gz 11.7 KiB [emitted] + asset exclude2-main.js.map.gz 666 bytes [emitted] asset exclude2-chunk_js.js.gz 612 bytes [emitted] + 5 assets - assets by path *.js 12.4 KiB - asset exclude2-main.js 11.9 KiB [emitted] (name: main) + assets by path *.js 12.3 KiB + asset exclude2-main.js 11.7 KiB [emitted] (name: main) asset exclude2-chunk_js.js 612 bytes [emitted] assets by path *.css 144 bytes asset exclude2-chunk_js.css 74 bytes [emitted] @@ -1382,19 +1382,19 @@ exclude2: exclude3: hidden assets 2.89 KiB 10 assets - assets by status 37.4 KiB [emitted] - assets by path *.br 12.7 KiB - asset exclude3-main.js.br 11.9 KiB [emitted] - asset exclude3-main.js.map.br 672 bytes [emitted] + assets by status 36.8 KiB [emitted] + assets by path *.br 12.5 KiB + asset exclude3-main.js.br 11.7 KiB [emitted] + asset exclude3-main.js.map.br 666 bytes [emitted] asset exclude3-main.css.map.br 171 bytes [emitted] asset exclude3-main.css.br 70 bytes [emitted] - assets by path *.gz 12.7 KiB - asset exclude3-main.js.gz 11.9 KiB [emitted] - asset exclude3-main.js.map.gz 672 bytes [emitted] + assets by path *.gz 12.5 KiB + asset exclude3-main.js.gz 11.7 KiB [emitted] + asset exclude3-main.js.map.gz 666 bytes [emitted] asset exclude3-main.css.map.gz 171 bytes [emitted] asset exclude3-main.css.gz 70 bytes [emitted] - assets by chunk 11.9 KiB (name: main) - asset exclude3-main.js 11.9 KiB [emitted] (name: main) + assets by chunk 11.7 KiB (name: main) + asset exclude3-main.js 11.7 KiB [emitted] (name: main) asset exclude3-main.css 70 bytes [emitted] (name: main)" `; @@ -1435,34 +1435,34 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for runtime-chunk 1`] = ` -"Entrypoint e1 3.98 KiB = runtime~e1.js 3.59 KiB e1.js 391 bytes -Entrypoint e2 3.98 KiB = runtime~e2.js 3.59 KiB e2.js 391 bytes +"Entrypoint e1 3.9 KiB = runtime~e1.js 3.52 KiB e1.js 391 bytes +Entrypoint e2 3.9 KiB = runtime~e2.js 3.52 KiB e2.js 391 bytes Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for runtime-chunk-issue-7382 1`] = ` -"Entrypoint e1 4.27 KiB = runtime.js 3.59 KiB all.js 310 bytes e1.js 381 bytes -Entrypoint e2 4.27 KiB = runtime.js 3.59 KiB all.js 310 bytes e2.js 381 bytes +"Entrypoint e1 4.19 KiB = runtime.js 3.52 KiB all.js 310 bytes e1.js 381 bytes +Entrypoint e2 4.19 KiB = runtime.js 3.52 KiB all.js 310 bytes e2.js 381 bytes Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for runtime-chunk-single 1`] = ` -"Entrypoint e1 3.97 KiB = runtime.js 3.59 KiB e1.js 391 bytes -Entrypoint e2 3.97 KiB = runtime.js 3.59 KiB e2.js 391 bytes +"Entrypoint e1 3.9 KiB = runtime.js 3.52 KiB e1.js 391 bytes +Entrypoint e2 3.9 KiB = runtime.js 3.52 KiB e2.js 391 bytes Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for runtime-specific-used-exports 1`] = ` "production: - asset production-a.js 10.5 KiB [emitted] (name: a) - asset production-b.js 10.5 KiB [emitted] (name: b) + asset production-a.js 10.4 KiB [emitted] (name: a) + asset production-b.js 10.4 KiB [emitted] (name: b) asset production-dx_js.js 847 bytes [emitted] asset production-dw_js-_b3b00.js 838 bytes [emitted] asset production-dw_js-_b3b01.js 838 bytes [emitted] asset production-dy_js.js 831 bytes [emitted] asset production-dz_js.js 831 bytes [emitted] asset production-c.js 45 bytes [emitted] (name: c) - chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] + chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 7 KiB (runtime) [entry] [rendered] ./a.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1473,7 +1473,7 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp [only some exports used: x, y] ./reexport.js 37 bytes [dependent] [built] [code generated] [only some exports used: x, y] - chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] + chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 7 KiB (runtime) [entry] [rendered] ./b.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1507,7 +1507,7 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp ./dz.js 46 bytes [built] [code generated] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [only some exports used: identity, w, x, y, z] - runtime modules 14.3 KiB 18 modules + runtime modules 14 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [no exports used] @@ -1532,14 +1532,14 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp production (Rspack x.x.x) compiled successfully in X.23 development: - asset development-a.js 11.9 KiB [emitted] (name: a) - asset development-b.js 11.9 KiB [emitted] (name: b) + asset development-a.js 11.8 KiB [emitted] (name: a) + asset development-b.js 11.8 KiB [emitted] (name: b) asset development-dw_js.js 1.07 KiB [emitted] asset development-dx_js.js 1.07 KiB [emitted] asset development-dy_js.js 1.07 KiB [emitted] asset development-dz_js.js 1.07 KiB [emitted] asset development-c.js 419 bytes [emitted] (name: c) - chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] + chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 7 KiB (runtime) [entry] [rendered] ./a.js 261 bytes [built] [code generated] [used exports unknown] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1550,7 +1550,7 @@ development: [used exports unknown] ./reexport.js 37 bytes [dependent] [built] [code generated] [used exports unknown] - chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] + chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 7 KiB (runtime) [entry] [rendered] ./b.js 261 bytes [built] [code generated] [used exports unknown] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1584,7 +1584,7 @@ development: [used exports unknown] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [used exports unknown] - runtime modules 14.3 KiB 18 modules + runtime modules 14 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [used exports unknown] @@ -1613,14 +1613,14 @@ development: development (Rspack x.x.x) compiled successfully in X.23 global: - asset global-a.js 10.6 KiB [emitted] (name: a) - asset global-b.js 10.6 KiB [emitted] (name: b) + asset global-a.js 10.5 KiB [emitted] (name: a) + asset global-b.js 10.5 KiB [emitted] (name: b) asset global-dw_js.js 847 bytes [emitted] asset global-dx_js.js 847 bytes [emitted] asset global-dy_js.js 847 bytes [emitted] asset global-dz_js.js 847 bytes [emitted] asset global-c.js 45 bytes [emitted] (name: c) - chunk (runtime: a) global-a.js (a) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] + chunk (runtime: a) global-a.js (a) 605 bytes (javascript) 7 KiB (runtime) [entry] [rendered] ./a.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1631,7 +1631,7 @@ global: [only some exports used: x, y] ./reexport.js 37 bytes [dependent] [built] [code generated] [only some exports used: x, y] - chunk (runtime: b) global-b.js (b) 605 bytes (javascript) 7.13 KiB (runtime) [entry] [rendered] + chunk (runtime: b) global-b.js (b) 605 bytes (javascript) 7 KiB (runtime) [entry] [rendered] ./b.js 261 bytes [built] [code generated] [no exports used] ./dx-importer.js 63 bytes [dependent] [built] [code generated] @@ -1661,7 +1661,7 @@ global: ./dz.js 46 bytes [built] [code generated] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [only some exports used: identity, w, x, y, z] - runtime modules 14.3 KiB 18 modules + runtime modules 14 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [no exports used] @@ -1687,7 +1687,7 @@ global: `; exports[`StatsTestCases should print correct stats for scope-hoisting-multi 1`] = ` -"runtime modules 14.3 KiB 18 modules +"runtime modules 14.1 KiB 18 modules orphan modules 118 bytes [orphan] 4 modules cacheable modules 726 bytes ./first.js 236 bytes [built] [code generated] @@ -1699,7 +1699,7 @@ cacheable modules 726 bytes ./common_lazy_shared.js 25 bytes [built] [code generated] Rspack x.x.x compiled successfully in X.23 -runtime modules 14.3 KiB 18 modules +runtime modules 14.1 KiB 18 modules cacheable modules 1.05 KiB built modules 844 bytes [built] orphan modules 325 bytes [orphan] @@ -1724,9 +1724,9 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for side-effects-issue-7428 1`] = ` -"asset main.js 9.92 KiB [emitted] (name: main) +"asset main.js 9.79 KiB [emitted] (name: main) asset 0.js 563 bytes [emitted] -runtime modules 7.12 KiB 9 modules +runtime modules 6.99 KiB 9 modules cacheable modules 967 bytes modules by path ./components/src/ 501 bytes orphan modules 315 bytes [orphan] @@ -1813,8 +1813,8 @@ Rspack x.x.x compiled successfully in X.23" exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` "default: - Entrypoint main 9.34 KiB = default/main.js - Entrypoint a 8.9 KiB = default/a.js + Entrypoint main 9.21 KiB = default/main.js + Entrypoint a 8.77 KiB = default/a.js Entrypoint b 192 bytes = default/b.js Entrypoint c 192 bytes = default/c.js chunk (runtime: main) default/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -1844,7 +1844,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.17 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: a) default/a.js (a) 165 bytes (javascript) 7.04 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) default/b.js (b) 116 bytes [entry] [rendered] @@ -1858,7 +1858,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` chunk (runtime: c) default/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.09 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) default/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{74}> <{753}> ={581}= [rendered] @@ -1867,8 +1867,8 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` default (Rspack x.x.x) compiled successfully all-chunks: - Entrypoint main 9.35 KiB = all-chunks/main.js - Entrypoint a 8.91 KiB = all-chunks/a.js + Entrypoint main 9.22 KiB = all-chunks/main.js + Entrypoint a 8.78 KiB = all-chunks/a.js Entrypoint b 192 bytes = all-chunks/b.js Entrypoint c 192 bytes = all-chunks/c.js chunk (runtime: main) all-chunks/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -1898,7 +1898,7 @@ all-chunks: > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) all-chunks/a.js (a) 165 bytes (javascript) 7.17 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: a) all-chunks/a.js (a) 165 bytes (javascript) 7.04 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) all-chunks/b.js (b) 116 bytes [entry] [rendered] @@ -1912,7 +1912,7 @@ all-chunks: chunk (runtime: c) all-chunks/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) all-chunks/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) all-chunks/main.js (main) 147 bytes (javascript) 7.09 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) all-chunks/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{74}> <{753}> ={581}= [rendered] @@ -1921,10 +1921,10 @@ all-chunks: all-chunks (Rspack x.x.x) compiled successfully manual: - Entrypoint main 9.11 KiB = manual/main.js - Entrypoint a 11.4 KiB = manual/vendors.js 835 bytes manual/a.js 10.6 KiB - Entrypoint b 5.49 KiB = manual/vendors.js 835 bytes manual/b.js 4.68 KiB - Entrypoint c 5.49 KiB = manual/vendors.js 835 bytes manual/c.js 4.68 KiB + Entrypoint main 8.98 KiB = manual/main.js + Entrypoint a 11.2 KiB = manual/vendors.js 835 bytes manual/a.js 10.4 KiB + Entrypoint b 5.42 KiB = manual/vendors.js 835 bytes manual/b.js 4.61 KiB + Entrypoint c 5.42 KiB = manual/vendors.js 835 bytes manual/c.js 4.6 KiB chunk (runtime: main) manual/async-c.js (async-c) 156 bytes <{909}> ={192}= [rendered] > ./c ./index.js 3:0-47 dependent modules 40 bytes [dependent] 2 modules @@ -1956,25 +1956,25 @@ manual: > ./b ./index.js 2:0-47 dependent modules 40 bytes [dependent] 2 modules ./b.js 116 bytes [built] [code generated] - chunk (runtime: a) manual/a.js (a) 165 bytes (javascript) 8.15 KiB (runtime) ={192}= >{912}< [entry] [rendered] + chunk (runtime: a) manual/a.js (a) 165 bytes (javascript) 8 KiB (runtime) ={192}= >{912}< [entry] [rendered] > ./a a > x a > y a > z a ./a.js 165 bytes [built] [code generated] - chunk (runtime: b) manual/b.js (b) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: b) manual/b.js (b) 116 bytes (javascript) 2.7 KiB (runtime) ={192}= [entry] [rendered] > ./b b > x b > y b > z b ./b.js 116 bytes [built] [code generated] - chunk (runtime: c) manual/c.js (c) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: c) manual/c.js (c) 116 bytes (javascript) 2.69 KiB (runtime) ={192}= [entry] [rendered] > ./c c > x c > y c > z c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) manual/main.js (main) 147 bytes (javascript) 7.22 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] + chunk (runtime: main) manual/main.js (main) 147 bytes (javascript) 7.09 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) manual/async-g.js (async-g) 65 bytes <{192}> <{250}> <{74}> [rendered] @@ -1984,8 +1984,8 @@ manual: manual (Rspack x.x.x) compiled successfully name-too-long: - Entrypoint main 9.35 KiB = name-too-long/main.js - Entrypoint aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8.91 KiB = name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js + Entrypoint main 9.22 KiB = name-too-long/main.js + Entrypoint aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8.78 KiB = name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js Entrypoint bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 192 bytes = name-too-long/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.js Entrypoint cccccccccccccccccccccccccccccc 192 bytes = name-too-long/cccccccccccccccccccccccccccccc.js chunk (runtime: main) name-too-long/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -2026,20 +2026,20 @@ name-too-long: > ./b ./index.js 2:0-47 > ./c ./index.js 3:0-47 ./d.js 20 bytes [built] [code generated] - chunk (runtime: main) name-too-long/main.js (main) 147 bytes (javascript) 7.23 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) name-too-long/main.js (main) 147 bytes (javascript) 7.1 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, main) name-too-long/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{753}> <{959}> ={581}= [rendered] > ./g ./a.js 6:0-47 ./g.js 45 bytes [built] [code generated] - chunk (runtime: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 165 bytes (javascript) 7.18 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 165 bytes (javascript) 7.05 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ./a.js 165 bytes [built] [code generated] name-too-long (Rspack x.x.x) compiled successfully custom-chunks-filter: - Entrypoint main 9.36 KiB = custom-chunks-filter/main.js - Entrypoint a 8.92 KiB = custom-chunks-filter/a.js + Entrypoint main 9.23 KiB = custom-chunks-filter/main.js + Entrypoint a 8.79 KiB = custom-chunks-filter/a.js Entrypoint b 192 bytes = custom-chunks-filter/b.js Entrypoint c 192 bytes = custom-chunks-filter/c.js chunk (runtime: main) custom-chunks-filter/async-c.js (async-c) 116 bytes <{909}> ={416}= ={418}= ={581}= ={753}= [rendered] @@ -2069,7 +2069,7 @@ custom-chunks-filter: > ./c ./index.js 3:0-47 > ./g ./a.js 6:0-47 ./f.js 20 bytes [built] [code generated] - chunk (runtime: a) custom-chunks-filter/a.js (a) 165 bytes (javascript) 7.18 KiB (runtime) >{581}< >{912}< [entry] [rendered] + chunk (runtime: a) custom-chunks-filter/a.js (a) 165 bytes (javascript) 7.05 KiB (runtime) >{581}< >{912}< [entry] [rendered] > ./a a ./a.js 165 bytes [built] [code generated] chunk (runtime: b) custom-chunks-filter/b.js (b) 116 bytes [entry] [rendered] @@ -2083,7 +2083,7 @@ custom-chunks-filter: chunk (runtime: c) custom-chunks-filter/c.js (c) 116 bytes [entry] [rendered] > ./c c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) custom-chunks-filter/main.js (main) 147 bytes (javascript) 7.23 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] + chunk (runtime: main) custom-chunks-filter/main.js (main) 147 bytes (javascript) 7.1 KiB (runtime) >{172}< >{250}< >{262}< >{310}< >{416}< >{418}< >{581}< >{753}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) custom-chunks-filter/async-g.js (async-g) 45 bytes <{250}> <{310}> <{418}> <{74}> <{753}> ={581}= [rendered] @@ -2092,10 +2092,10 @@ custom-chunks-filter: custom-chunks-filter (Rspack x.x.x) compiled successfully custom-chunks-filter-in-cache-groups: - Entrypoint main 9.14 KiB = custom-chunks-filter-in-cache-groups/main.js - Entrypoint a 11 KiB = custom-chunks-filter-in-cache-groups/598.js 388 bytes custom-chunks-filter-in-cache-groups/a.js 10.6 KiB - Entrypoint b 5.49 KiB = custom-chunks-filter-in-cache-groups/vendors.js 835 bytes custom-chunks-filter-in-cache-groups/b.js 4.68 KiB - Entrypoint c 5.49 KiB = custom-chunks-filter-in-cache-groups/vendors.js 835 bytes custom-chunks-filter-in-cache-groups/c.js 4.68 KiB + Entrypoint main 9.01 KiB = custom-chunks-filter-in-cache-groups/main.js + Entrypoint a 10.8 KiB = custom-chunks-filter-in-cache-groups/598.js 388 bytes custom-chunks-filter-in-cache-groups/a.js 10.4 KiB + Entrypoint b 5.42 KiB = custom-chunks-filter-in-cache-groups/vendors.js 835 bytes custom-chunks-filter-in-cache-groups/b.js 4.61 KiB + Entrypoint c 5.42 KiB = custom-chunks-filter-in-cache-groups/vendors.js 835 bytes custom-chunks-filter-in-cache-groups/c.js 4.6 KiB chunk (runtime: main) custom-chunks-filter-in-cache-groups/async-c.js (async-c) 156 bytes <{909}> ={192}= [rendered] > ./c ./index.js 3:0-47 dependent modules 40 bytes [dependent] 2 modules @@ -2131,25 +2131,25 @@ custom-chunks-filter-in-cache-groups: ./node_modules/x.js 20 bytes [built] [code generated] ./node_modules/y.js 20 bytes [built] [code generated] ./node_modules/z.js 20 bytes [built] [code generated] - chunk (runtime: a) custom-chunks-filter-in-cache-groups/a.js (a) 165 bytes (javascript) 8.18 KiB (runtime) ={598}= >{912}< [entry] [rendered] + chunk (runtime: a) custom-chunks-filter-in-cache-groups/a.js (a) 165 bytes (javascript) 8.03 KiB (runtime) ={598}= >{912}< [entry] [rendered] > ./a a > x a > y a > z a ./a.js 165 bytes [built] [code generated] - chunk (runtime: b) custom-chunks-filter-in-cache-groups/b.js (b) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: b) custom-chunks-filter-in-cache-groups/b.js (b) 116 bytes (javascript) 2.7 KiB (runtime) ={192}= [entry] [rendered] > ./b b > x b > y b > z b ./b.js 116 bytes [built] [code generated] - chunk (runtime: c) custom-chunks-filter-in-cache-groups/c.js (c) 116 bytes (javascript) 2.77 KiB (runtime) ={192}= [entry] [rendered] + chunk (runtime: c) custom-chunks-filter-in-cache-groups/c.js (c) 116 bytes (javascript) 2.69 KiB (runtime) ={192}= [entry] [rendered] > ./c c > x c > y c > z c ./c.js 116 bytes [built] [code generated] - chunk (runtime: main) custom-chunks-filter-in-cache-groups/main.js (main) 147 bytes (javascript) 7.25 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] + chunk (runtime: main) custom-chunks-filter-in-cache-groups/main.js (main) 147 bytes (javascript) 7.12 KiB (runtime) >{172}< >{192}< >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] chunk (runtime: a, main) custom-chunks-filter-in-cache-groups/async-g.js (async-g) 65 bytes <{192}> <{250}> <{598}> <{74}> [rendered] @@ -2160,7 +2160,7 @@ custom-chunks-filter-in-cache-groups: `; exports[`StatsTestCases should print correct stats for split-chunks-automatic-name 1`] = ` -"Entrypoint main 9.42 KiB = main.js +"Entrypoint main 9.29 KiB = main.js chunk (runtime: main) async-a.js (async-a) (id hint: common) 136 bytes <{main}> ={common-d_js}= ={common-node_modules_x_js}= ={common-node_modules_y_js}= [rendered] > ./a ./index.js 1:0-47 ./a.js + 1 modules 136 bytes [code generated] @@ -2191,14 +2191,14 @@ chunk (runtime: main) common-node_modules_y_js.js (id hint: common) 20 bytes <{m chunk (runtime: main) common-node_modules_z_js.js (id hint: common) 20 bytes <{main}> ={async-c}= ={common-d_js}= ={common-f_js}= ={common-node_modules_x_js}= [rendered] split chunk (cache group: b) > ./c ./index.js 3:0-47 ./node_modules/z.js 20 bytes [built] [code generated] -chunk (runtime: main) main.js (main) (id hint: common) 147 bytes (javascript) 7.12 KiB (runtime) >{async-a}< >{async-b}< >{async-c}< >{common-d_js}< >{common-f_js}< >{common-node_modules_x_js}< >{common-node_modules_y_js}< >{common-node_modules_z_js}< [entry] [rendered] +chunk (runtime: main) main.js (main) (id hint: common) 147 bytes (javascript) 6.99 KiB (runtime) >{async-a}< >{async-b}< >{async-c}< >{common-d_js}< >{common-f_js}< >{common-node_modules_x_js}< >{common-node_modules_y_js}< >{common-node_modules_z_js}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] production (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-chunk-name 1`] = ` -"Entrypoint main 9.06 KiB = default/main.js +"Entrypoint main 8.93 KiB = default/main.js chunk (runtime: main) default/async-a.js (async-a) 20 bytes <{909}> [rendered] > a ./index.js 1:0-45 ./node_modules/a.js 20 bytes [built] [code generated] @@ -2209,14 +2209,14 @@ chunk (runtime: main) default/async-c-1.js (async-c-1) (id hint: vendors) 122 by > c ./index.js 3:0-47 > c ./index.js 4:0-47 ./node_modules/c.js 122 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 192 bytes (javascript) 7.19 KiB (runtime) >{250}< >{262}< >{589}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 192 bytes (javascript) 7.06 KiB (runtime) >{250}< >{262}< >{589}< [entry] [rendered] > ./ main ./index.js 192 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-combinations 1`] = ` -"Entrypoint main 9.53 KiB = main.js +"Entrypoint main 9.4 KiB = main.js chunk (runtime: main) async-c.js (async-c) 132 bytes <{909}> [rendered] > ./c ./index.js 3:0-47 dependent modules 87 bytes [dependent] 1 module @@ -2244,7 +2244,7 @@ chunk (runtime: main) async-d.js (async-d) 132 bytes <{909}> [rendered] > ./d ./index.js 4:0-47 dependent modules 87 bytes [dependent] 1 module ./d.js 45 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 343 bytes (javascript) 7.26 KiB (runtime) >{172}< >{198}< >{250}< >{262}< >{36}< >{407}< >{602}< >{912}< [entry] [rendered] +chunk (runtime: main) main.js (main) 343 bytes (javascript) 7.13 KiB (runtime) >{172}< >{198}< >{250}< >{262}< >{36}< >{407}< >{602}< >{912}< [entry] [rendered] > ./ main ./index.js 343 bytes [built] [code generated] chunk (runtime: main) async-g.js (async-g) 132 bytes <{909}> [rendered] @@ -2255,7 +2255,7 @@ Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-issue-6413 1`] = ` -"Entrypoint main 9.16 KiB = main.js +"Entrypoint main 9.03 KiB = main.js chunk (runtime: main) async-c.js (async-c) 36 bytes <{909}> ={306}= ={418}= [rendered] > ./c ./index.js 3:0-47 ./c.js 36 bytes [built] [code generated] @@ -2275,14 +2275,14 @@ chunk (runtime: main) 418.js (id hint: vendors) 20 bytes <{909}> ={172}= ={250}= > ./b ./index.js 2:0-47 > ./c ./index.js 3:0-47 ./node_modules/x.js 20 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 147 bytes (javascript) 7.19 KiB (runtime) >{172}< >{250}< >{262}< >{306}< >{418}< [entry] [rendered] +chunk (runtime: main) main.js (main) 147 bytes (javascript) 7.06 KiB (runtime) >{172}< >{250}< >{262}< >{306}< >{418}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] default (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-issue-6696 1`] = ` -"Entrypoint main 10.7 KiB = vendors.js 337 bytes main.js 10.4 KiB +"Entrypoint main 10.6 KiB = vendors.js 337 bytes main.js 10.3 KiB chunk (runtime: main) vendors.js (vendors) (id hint: vendors) 20 bytes ={909}= >{250}< >{262}< [initial] [rendered] split chunk (cache group: vendors) > ./ main ./node_modules/y.js 20 bytes [built] [code generated] @@ -2294,24 +2294,24 @@ chunk (runtime: main) async-b.js (async-b) 49 bytes <{192}> <{909}> [rendered] > ./b ./index.js 3:0-47 dependent modules 20 bytes [dependent] 1 module ./b.js 29 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 134 bytes (javascript) 8.17 KiB (runtime) ={192}= >{250}< >{262}< [entry] [rendered] +chunk (runtime: main) main.js (main) 134 bytes (javascript) 8.03 KiB (runtime) ={192}= >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 134 bytes [built] [code generated] default (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-issue-7401 1`] = ` -"Entrypoint a 4.82 KiB = 418.js 337 bytes a.js 4.49 KiB -Entrypoint b 8.72 KiB = b.js +"Entrypoint a 4.74 KiB = 418.js 337 bytes a.js 4.41 KiB +Entrypoint b 8.59 KiB = b.js Chunk Group c 705 bytes = 418.js 337 bytes c.js 368 bytes chunk (runtime: a, b) 418.js (id hint: vendors) 20 bytes <{751}> ={74}= ={76}= [initial] [rendered] split chunk (cache group: defaultVendors) > ./c ./b.js 1:0-41 > ./a a ./node_modules/x.js 20 bytes [built] [code generated] -chunk (runtime: a) a.js (a) 35 bytes (javascript) 2.77 KiB (runtime) ={418}= [entry] [rendered] +chunk (runtime: a) a.js (a) 35 bytes (javascript) 2.69 KiB (runtime) ={418}= [entry] [rendered] > ./a a ./a.js 35 bytes [built] [code generated] -chunk (runtime: b) b.js (b) 43 bytes (javascript) 7.15 KiB (runtime) >{418}< >{76}< [entry] [rendered] +chunk (runtime: b) b.js (b) 43 bytes (javascript) 7.02 KiB (runtime) >{418}< >{76}< [entry] [rendered] > ./b b ./b.js 43 bytes [built] [code generated] chunk (runtime: b) c.js (c) 35 bytes <{751}> ={418}= [rendered] @@ -2321,7 +2321,7 @@ default (Rspack x.x.x) compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-keep-remaining-size 1`] = ` -"Entrypoint main 9.26 KiB = default/main.js +"Entrypoint main 9.13 KiB = default/main.js chunk (runtime: main) default/async-c.js (async-c) 50 bytes <{909}> ={44}= [rendered] > ./c ./index.js 3:0-47 ./c.js 50 bytes [built] [code generated] @@ -2345,14 +2345,14 @@ chunk (runtime: main) default/async-d.js (async-d) 84 bytes <{909}> ={403}= [ren chunk (runtime: main) default/728.js (id hint: vendors) 126 bytes <{909}> ={250}= [rendered] split chunk (cache group: defaultVendors) > ./a ./index.js 1:0-47 ./node_modules/shared.js?1 126 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 196 bytes (javascript) 7.22 KiB (runtime) >{172}< >{250}< >{262}< >{403}< >{44}< >{602}< >{728}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 196 bytes (javascript) 7.09 KiB (runtime) >{172}< >{250}< >{262}< >{403}< >{44}< >{602}< >{728}< [entry] [rendered] > ./ main ./index.js 196 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-min-size-reduction 1`] = ` -"Entrypoint main 9.43 KiB = default/main.js +"Entrypoint main 9.3 KiB = default/main.js chunk (runtime: main) default/async-c.js (async-c) 50 bytes <{909}> ={44}= [rendered] > ./c ./index.js 3:0-47 ./c.js 50 bytes [built] [code generated] @@ -2377,14 +2377,14 @@ chunk (runtime: main) default/728.js (id hint: vendors) 126 bytes <{909}> ={250} > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./node_modules/shared.js?1 126 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 245 bytes (javascript) 7.24 KiB (runtime) >{172}< >{250}< >{262}< >{407}< >{44}< >{602}< >{728}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 245 bytes (javascript) 7.11 KiB (runtime) >{172}< >{250}< >{262}< >{407}< >{44}< >{602}< >{728}< [entry] [rendered] > ./ main ./index.js 245 bytes [built] [code generated] Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for split-chunks-prefer-bigger-splits 1`] = ` -"Entrypoint main 9.05 KiB = default/main.js +"Entrypoint main 8.92 KiB = default/main.js chunk (runtime: main) default/async-c.js (async-c) 70 bytes <{909}> ={457}= [rendered] > ./c ./index.js 3:0-47 ./c.js 70 bytes [built] [code generated] @@ -2401,7 +2401,7 @@ chunk (runtime: main) default/457.js (id hint: ) 150 bytes <{909}> ={172}= ={262 > ./c ./index.js 3:0-47 ./d.js 63 bytes [built] [code generated] ./f.js 87 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.21 KiB (runtime) >{172}< >{250}< >{262}< >{457}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.08 KiB (runtime) >{172}< >{250}< >{262}< >{457}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] Rspack x.x.x compiled successfully" @@ -2409,56 +2409,56 @@ Rspack x.x.x compiled successfully" exports[`StatsTestCases should print correct stats for split-chunks-runtime-specific 1`] = ` "used-exports: - asset used-exports-c.js 4.5 KiB [emitted] (name: c) - asset used-exports-b.js 4.5 KiB [emitted] (name: b) + asset used-exports-c.js 4.43 KiB [emitted] (name: c) + asset used-exports-b.js 4.43 KiB [emitted] (name: b) asset used-exports-572.js 355 bytes [emitted] asset used-exports-a.js 249 bytes [emitted] (name: a) Entrypoint a 249 bytes = used-exports-a.js - Entrypoint b 4.85 KiB = used-exports-572.js 355 bytes used-exports-b.js 4.5 KiB - Entrypoint c 4.85 KiB = used-exports-572.js 355 bytes used-exports-c.js 4.5 KiB + Entrypoint b 4.77 KiB = used-exports-572.js 355 bytes used-exports-b.js 4.43 KiB + Entrypoint c 4.78 KiB = used-exports-572.js 355 bytes used-exports-c.js 4.43 KiB chunk (runtime: b, c) used-exports-572.js (id hint: ) 72 bytes [initial] [rendered] split chunk (cache group: default) ./objects.js 72 bytes [built] [code generated] chunk (runtime: a) used-exports-a.js (a) 126 bytes [entry] [rendered] ./a.js + 1 modules 126 bytes [code generated] - chunk (runtime: b) used-exports-b.js (b) 54 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] + chunk (runtime: b) used-exports-b.js (b) 54 bytes (javascript) 2.7 KiB (runtime) [entry] [rendered] ./b.js 54 bytes [built] [code generated] - chunk (runtime: c) used-exports-c.js (c) 59 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] + chunk (runtime: c) used-exports-c.js (c) 59 bytes (javascript) 2.69 KiB (runtime) [entry] [rendered] ./c.js 59 bytes [built] [code generated] used-exports (Rspack x.x.x) compiled successfully in X.23 no-used-exports: - asset no-used-exports-c.js 4.58 KiB [emitted] (name: c) - asset no-used-exports-b.js 4.57 KiB [emitted] (name: b) - asset no-used-exports-a.js 4.57 KiB [emitted] (name: a) + asset no-used-exports-c.js 4.5 KiB [emitted] (name: c) + asset no-used-exports-b.js 4.5 KiB [emitted] (name: b) + asset no-used-exports-a.js 4.5 KiB [emitted] (name: a) asset no-used-exports-572.js 503 bytes [emitted] - Entrypoint a 5.06 KiB = no-used-exports-572.js 503 bytes no-used-exports-a.js 4.57 KiB - Entrypoint b 5.06 KiB = no-used-exports-572.js 503 bytes no-used-exports-b.js 4.57 KiB - Entrypoint c 5.07 KiB = no-used-exports-572.js 503 bytes no-used-exports-c.js 4.58 KiB + Entrypoint a 4.99 KiB = no-used-exports-572.js 503 bytes no-used-exports-a.js 4.5 KiB + Entrypoint b 4.99 KiB = no-used-exports-572.js 503 bytes no-used-exports-b.js 4.5 KiB + Entrypoint c 5 KiB = no-used-exports-572.js 503 bytes no-used-exports-c.js 4.5 KiB chunk (runtime: a, b, c) no-used-exports-572.js (id hint: ) 72 bytes [initial] [rendered] split chunk (cache group: default) ./objects.js 72 bytes [built] [code generated] - chunk (runtime: a) no-used-exports-a.js (a) 54 bytes (javascript) 2.79 KiB (runtime) [entry] [rendered] + chunk (runtime: a) no-used-exports-a.js (a) 54 bytes (javascript) 2.72 KiB (runtime) [entry] [rendered] ./a.js 54 bytes [built] [code generated] - chunk (runtime: b) no-used-exports-b.js (b) 54 bytes (javascript) 2.8 KiB (runtime) [entry] [rendered] + chunk (runtime: b) no-used-exports-b.js (b) 54 bytes (javascript) 2.72 KiB (runtime) [entry] [rendered] ./b.js 54 bytes [built] [code generated] - chunk (runtime: c) no-used-exports-c.js (c) 59 bytes (javascript) 2.79 KiB (runtime) [entry] [rendered] + chunk (runtime: c) no-used-exports-c.js (c) 59 bytes (javascript) 2.72 KiB (runtime) [entry] [rendered] ./c.js 59 bytes [built] [code generated] no-used-exports (Rspack x.x.x) compiled successfully in X.23 global: - asset global-c.js 4.5 KiB [emitted] (name: c) - asset global-b.js 4.5 KiB [emitted] (name: b) - asset global-a.js 4.5 KiB [emitted] (name: a) + asset global-c.js 4.43 KiB [emitted] (name: c) + asset global-b.js 4.43 KiB [emitted] (name: b) + asset global-a.js 4.43 KiB [emitted] (name: a) asset global-572.js 323 bytes [emitted] - Entrypoint a 4.81 KiB = global-572.js 323 bytes global-a.js 4.5 KiB - Entrypoint b 4.82 KiB = global-572.js 323 bytes global-b.js 4.5 KiB - Entrypoint c 4.82 KiB = global-572.js 323 bytes global-c.js 4.5 KiB + Entrypoint a 4.74 KiB = global-572.js 323 bytes global-a.js 4.43 KiB + Entrypoint b 4.74 KiB = global-572.js 323 bytes global-b.js 4.43 KiB + Entrypoint c 4.75 KiB = global-572.js 323 bytes global-c.js 4.43 KiB chunk (runtime: a, b, c) global-572.js (id hint: ) 72 bytes [initial] [rendered] split chunk (cache group: default) ./objects.js 72 bytes [built] [code generated] - chunk (runtime: a) global-a.js (a) 54 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] + chunk (runtime: a) global-a.js (a) 54 bytes (javascript) 2.69 KiB (runtime) [entry] [rendered] ./a.js 54 bytes [built] [code generated] - chunk (runtime: b) global-b.js (b) 54 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] + chunk (runtime: b) global-b.js (b) 54 bytes (javascript) 2.7 KiB (runtime) [entry] [rendered] ./b.js 54 bytes [built] [code generated] - chunk (runtime: c) global-c.js (c) 59 bytes (javascript) 2.77 KiB (runtime) [entry] [rendered] + chunk (runtime: c) global-c.js (c) 59 bytes (javascript) 2.69 KiB (runtime) [entry] [rendered] ./c.js 59 bytes [built] [code generated] global (Rspack x.x.x) compiled successfully in X.23" `; From f6fc2a4e8d8d37ece4b5978ac4d0231dfba3a952 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 10 Jan 2025 11:08:26 +0800 Subject: [PATCH 05/13] feat: runtime template with dojang --- crates/rspack_core/src/init_fragment.rs | 8 +- crates/rspack_core/src/runtime_template.rs | 19 +++-- .../runtime_module/module_chunk_loading.rs | 75 +++++++++++-------- ...nk_loading.js => module_chunk_loading.ejs} | 14 ++-- ... => module_chunk_loading_with_loading.ejs} | 10 +-- 5 files changed, 70 insertions(+), 56 deletions(-) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{module_chunk_loading.js => module_chunk_loading.ejs} (55%) rename crates/rspack_plugin_runtime/src/runtime_module/runtime/{module_chunk_loading_with_loading.js => module_chunk_loading_with_loading.ejs} (57%) diff --git a/crates/rspack_core/src/init_fragment.rs b/crates/rspack_core/src/init_fragment.rs index 41a80613c8ee..c65ec40caacc 100644 --- a/crates/rspack_core/src/init_fragment.rs +++ b/crates/rspack_core/src/init_fragment.rs @@ -157,7 +157,7 @@ fn first(fragments: Vec>>) -> Box pub trait InitFragmentRenderContext { fn add_runtime_requirements(&mut self, requirement: RuntimeGlobals); fn runtime_condition_expression(&mut self, runtime_condition: &RuntimeCondition) -> String; - fn returning_function(&self, return_value: &str, args: Option<&str>) -> String; + fn returning_function(&self, return_value: &str, args: &str) -> String; } pub trait InitFragment: IntoAny + DynHash + DynClone + Debug + Sync + Send { @@ -271,7 +271,7 @@ impl InitFragmentRenderContext for GenerateContext<'_> { ) } - fn returning_function(&self, return_value: &str, args: Option<&str>) -> String { + fn returning_function(&self, return_value: &str, args: &str) -> String { self.runtime_template.returning_function(return_value, args) } } @@ -287,7 +287,7 @@ impl InitFragmentRenderContext for ChunkRenderContext { unreachable!("should not call runtime condition expression in chunk render context") } - fn returning_function(&self, _return_value: &str, _args: Option<&str>) -> String { + fn returning_function(&self, _return_value: &str, _args: &str) -> String { unreachable!("should not call returning function in chunk render context") } } @@ -371,7 +371,7 @@ impl InitFragment for ESMExportInitFragment { Ok(format!( "{}: {}", prop, - context.returning_function(&s.1, None) + context.returning_function(&s.1, "") )) }) .collect::>>()? diff --git a/crates/rspack_core/src/runtime_template.rs b/crates/rspack_core/src/runtime_template.rs index ed62fbeaa3fc..6bb0c768edee 100644 --- a/crates/rspack_core/src/runtime_template.rs +++ b/crates/rspack_core/src/runtime_template.rs @@ -81,7 +81,6 @@ impl RuntimeTemplate { pub fn add_templates(&mut self, templates: Vec<(String, String)>) { for (key, template) in templates { if !self.dojang.templates.contains_key(&key) { - // println!("Adding template: {}", key); self .dojang .add_with_option(key.clone(), template) @@ -133,15 +132,19 @@ impl RuntimeTemplate { } } - pub fn returning_function(&self, return_value: &str, args: Option<&str>) -> String { + pub fn returning_function(&self, return_value: &str, args: &str) -> String { if self.environment.supports_arrow_function() { - format!("({}) => ({})", args.unwrap_or_default(), return_value) + format!("({}) => ({})", args, return_value) } else { - format!( - "function({}) {{ return {}; }}", - args.unwrap_or_default(), - return_value - ) + format!("function({}) {{ return {}; }}", args, return_value) + } + } + + pub fn basic_function(&self, args: &str, body: &str) -> String { + if self.environment.supports_arrow_function() { + format!("({}) => {{\n {} \n}}", args, body) + } else { + format!("function({}) {{\n {} \n}}", args, body) } } } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs index 67107356792c..1d6359c98d23 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs @@ -1,4 +1,3 @@ -use cow_utils::CowUtils; use rspack_collections::{DatabaseItem, Identifier}; use rspack_core::{ compile_boolean_matcher, impl_runtime_module, @@ -55,6 +54,19 @@ impl RuntimeModule for ModuleChunkLoadingRuntimeModule { self.id } + fn template(&self) -> Vec<(String, String)> { + vec![ + ( + self.id.to_string(), + include_str!("runtime/module_chunk_loading.ejs").to_string(), + ), + ( + format!("{}_with_loading", self.id), + include_str!("runtime/module_chunk_loading_with_loading.ejs").to_string(), + ), + ] + } + fn generate(&self, compilation: &Compilation) -> rspack_error::Result { let chunk = compilation .chunk_by_ukey @@ -101,48 +113,46 @@ impl RuntimeModule for ModuleChunkLoadingRuntimeModule { ))); if with_loading || with_external_install_chunk { - source.add(RawStringSource::from( - include_str!("runtime/module_chunk_loading.js") - .cow_replace( - "$WITH_ON_CHUNK_LOAD$", - match with_on_chunk_load { - true => "__webpack_require__.O();", - false => "", - }, - ) - .into_owned(), - )); + let raw_source = compilation.runtime_template.render( + &self.id, + Some(serde_json::json!({ + "WITH_ON_CHUNK_LOAD": match with_on_chunk_load { + true => "__webpack_require__.O();", + false => "", + }, + })), + )?; + + source.add(RawStringSource::from(raw_source)); } if with_loading { let body = if matches!(has_js_matcher, BooleanMatcher::Condition(false)) { "installedChunks[chunkId] = 0;".to_string() } else { - include_str!("runtime/module_chunk_loading_with_loading.js") - .cow_replace("$JS_MATCHER$", &has_js_matcher.render("chunkId")) - .cow_replace( - "$IMPORT_FUNCTION_NAME$", - &compilation.options.output.import_function_name, - ) - .cow_replace("$OUTPUT_DIR$", &root_output_dir) - .cow_replace( - "$MATCH_FALLBACK$", - if matches!(has_js_matcher, BooleanMatcher::Condition(true)) { + compilation.runtime_template.render( + &format!("{}_with_loading", self.id), + Some(serde_json::json!({ + "JS_MATCHER": &has_js_matcher.render("chunkId"), + "IMPORT_FUNCTION_NAME":&compilation.options.output.import_function_name, + "OUTPUT_DIR": &root_output_dir, + "MATCH_FALLBACK": if matches!(has_js_matcher, BooleanMatcher::Condition(true)) { "" } else { "else installedChunks[chunkId] = 0;\n" }, - ) - .into_owned() + })), + )? }; source.add(RawStringSource::from(format!( r#" - {}.j = function (chunkId, promises) {{ - {body} - }} + {}.j = {} "#, - RuntimeGlobals::ENSURE_CHUNK_HANDLERS + RuntimeGlobals::ENSURE_CHUNK_HANDLERS, + compilation + .runtime_template + .basic_function("chunkId, promises", &body), ))); } @@ -158,11 +168,12 @@ impl RuntimeModule for ModuleChunkLoadingRuntimeModule { if with_on_chunk_load { source.add(RawStringSource::from(format!( r#" - {}.j = function(chunkId) {{ - return installedChunks[chunkId] === 0; - }} + {}.j = {} "#, - RuntimeGlobals::ON_CHUNKS_LOADED + RuntimeGlobals::ON_CHUNKS_LOADED, + compilation + .runtime_template + .returning_function("installedChunks[chunkId] === 0", "chunkId"), ))); } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.ejs similarity index 55% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.ejs index 5c33e265a0fa..5fb44e3baceb 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.ejs @@ -1,4 +1,4 @@ -var installChunk = function (data) { +var installChunk = <%- basicFunction("data") %> { var ids = data.ids; var modules = data.modules; var runtime = data.runtime; @@ -6,17 +6,17 @@ var installChunk = function (data) { // then flag all "ids" as loaded and fire callback var moduleId, chunkId, i = 0; for (moduleId in modules) { - if (__webpack_require__.o(modules, moduleId)) { - __webpack_require__.m[moduleId] = modules[moduleId]; + if (<%- HAS_OWN_PROPERTY %>(modules, moduleId)) { + <%- MODULE_FACTORIES %>[moduleId] = modules[moduleId]; } } - if (runtime) runtime(__webpack_require__); + if (runtime) runtime(<%- REQUIRE %>); for (; i < ids.length; i++) { chunkId = ids[i]; - if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { + if (<%- HAS_OWN_PROPERTY %>(installedChunks, chunkId) && installedChunks[chunkId]) { installedChunks[chunkId][0](); } installedChunks[ids[i]] = 0; } - $WITH_ON_CHUNK_LOAD$ -}; \ No newline at end of file + <%- WITH_ON_CHUNK_LOAD %> +}; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_loading.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_loading.ejs similarity index 57% rename from crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_loading.js rename to crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_loading.ejs index 30156e929a05..044ba262f8b4 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_loading.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_loading.ejs @@ -1,21 +1,21 @@ // import() chunk loading for javascript -var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; +var installedChunkData = <%- HAS_OWN_PROPERTY %>(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; if (installedChunkData !== 0) { // 0 means "already installed".' // a Promise means "currently loading". if (installedChunkData) { promises.push(installedChunkData[1]); } else { - if ($JS_MATCHER$) { + if (<%- JS_MATCHER %>) { // setup Promise in chunk cache - var promise = $IMPORT_FUNCTION_NAME$("$OUTPUT_DIR$" + __webpack_require__.u(chunkId)).then(installChunk, function (e) { + var promise = <%- IMPORT_FUNCTION_NAME %>("<%- OUTPUT_DIR %>" + <%- GET_CHUNK_SCRIPT_FILENAME %>(chunkId)).then(installChunk, <%- basicFunction("e") %> { if (installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined; throw e; }); - var promise = Promise.race([promise, new Promise(function (resolve) { + var promise = Promise.race([promise, new Promise(<%- basicFunction("resolve") %> { installedChunkData = installedChunks[chunkId] = [resolve]; })]); promises.push(installedChunkData[1] = promise); } - $MATCH_FALLBACK$ + <%- MATCH_FALLBACK %> } } \ No newline at end of file From 24d548a3e55d5409e44d45876db8b67b5af35a24 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Mon, 13 Jan 2025 12:17:26 +0800 Subject: [PATCH 06/13] chore: update rspack_dojang version --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e13068b7431b..3b99ecac03cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4405,8 +4405,9 @@ dependencies = [ [[package]] name = "rspack_dojang" -version = "0.1.9" -source = "git+https://github.com/rspack-contrib/rspack-dojang.git?branch=feat%2Fpub-templates#05d338081cbf2adafcc7200674f40d42ad500dc9" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a1172695eaa000f610a46c6632d70ebbc7d812202ba64e83157e4a9e0b7269" dependencies = [ "html-escape", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 4c3d5c95bdee..bdf1ed69ec54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,7 +105,7 @@ swc_node_comments = { version = "=5.0.0" } pnp = { version = "0.9.0" } -rspack_dojang = { version = "0.1.9", git = "https://github.com/rspack-contrib/rspack-dojang.git", branch = "feat/pub-templates" } +rspack_dojang = { version = "0.1.10" } # all rspack workspace dependencies From c4f3f73803d3f2ff512506163dc1b314e358bb7a Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Mon, 13 Jan 2025 14:33:39 +0800 Subject: [PATCH 07/13] refactor: clean up unused code and improve template ID handling in runtime modules --- .../src/runtime_module/auto_public_path.rs | 39 ------------------- .../runtime_module/chunk_prefetch_startup.rs | 1 - .../src/runtime_module/get_chunk_filename.rs | 5 +-- .../import_scripts_chunk_loading.rs | 34 ++++++++++++---- 4 files changed, 28 insertions(+), 51 deletions(-) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs b/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs index e8d88c818080..227e856bff70 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/auto_public_path.rs @@ -106,43 +106,4 @@ fn auto_public_path_template( "ASSIGN": assign })), ) - - // let script_url_template = if output.script_type.eq("module") { - // format!( - // r#"var scriptUrl; - // if (typeof {import_meta_name}.url === "string") scriptUrl = {import_meta_name}.url - // "# - // ) - // .to_string() - // } else { - // format!( - // r#"var scriptUrl; - // if ({global}.importScripts) scriptUrl = {global}.location + ""; - // var document = {global}.document; - // if (!scriptUrl && document) {{ - // // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // // but an attacker could try to inject `` - // // and use `` - // if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - // if (!scriptUrl) {{ - // var scripts = document.getElementsByTagName("script"); - // if (scripts.length) {{ - // var i = scripts.length - 1; - // while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - // }} - // }} - // }} - // "# - // ) - // }; - // format!( - // r#" - // {script_url_template} - // // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - // if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - // scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - // {assign} - // "# - // ) } diff --git a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs index 6c6698041c86..b783cbc3856e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/chunk_prefetch_startup.rs @@ -91,7 +91,6 @@ impl RuntimeModule for ChunkPrefetchStartupRuntimeModule { } }; - // TODO: add params let source = compilation.runtime_template.render(&self.id, Some(serde_json::json!({ "GROUP_CHUNK_IDS": serde_json::to_string(&group_chunk_ids).expect("invalid json tostring"), "BODY": body, diff --git a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs index 898aff5bab5e..e057554a325d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs @@ -354,10 +354,7 @@ impl RuntimeModule for GetChunkFilenameRuntimeModule { let source = compilation.runtime_template.render(&self.id, Some(serde_json::json!({ "$GLOBAL$": self.global, - "STATIC_URLS": static_urls - .iter() - .map(|(filename, chunk_ids)| stringify_static_chunk_map(filename, chunk_ids)) - .join("\n"), + "STATIC_URLS": static_urls.iter().map(|(filename, chunk_ids)| stringify_static_chunk_map(filename, chunk_ids)).join("\n"), "DYNAMIC_URL":dynamic_url.unwrap_or_else(|| format!("\"\" + chunkId + \".{}\"", self.content_type)), })))?; diff --git a/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs index 954b717f0f0e..6376c3eb3e1e 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs @@ -56,6 +56,26 @@ impl ImportScriptsChunkLoadingRuntimeModule { }; Ok(RawStringSource::from(format!("{} = {};\n", RuntimeGlobals::BASE_URI, base_uri)).boxed()) } + + fn template_id(&self, id: TemplateId) -> String { + let base_id = self.id.as_str(); + + format!("{}_{}", base_id, id.as_str()) + } +} + +enum TemplateId { + WithHmr, + WithHmrManifest, +} + +impl TemplateId { + fn as_str(&self) -> &str { + match self { + Self::WithHmr => "with_hmr", + Self::WithHmrManifest => "with_hmr_manifest", + } + } } impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { @@ -70,11 +90,11 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { include_str!("runtime/import_scripts_chunk_loading.ejs").to_string(), ), ( - format!("{}_with_hmr", self.id), + self.template_id(TemplateId::WithHmr), include_str!("runtime/import_scripts_chunk_loading_with_hmr.ejs").to_string(), ), ( - format!("{}_with_hmr_manifest", self.id), + self.template_id(TemplateId::WithHmrManifest), include_str!("runtime/import_scripts_chunk_loading_with_hmr_manifest.ejs").to_string(), ), ] @@ -187,13 +207,13 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { ) }; - let render_source = compilation.runtime_template.render(&format!("{}_with_hmr", &self.id), Some(serde_json::json!({ + let source_with_hmr = compilation.runtime_template.render(&self.template_id(TemplateId::WithHmr), Some(serde_json::json!({ "URL": &url, "GLOBAL_OBJECT": &compilation.options.output.global_object.as_str(), "HOT_UPDATE_GLOBAL": &serde_json::to_string(&compilation.options.output.hot_update_global).expect("failed to serde_json::to_string(hot_update_global)"), })))?; - source.add(RawStringSource::from(render_source)); + source.add(RawStringSource::from(source_with_hmr)); source.add(RawStringSource::from(generate_javascript_hmr_runtime( "importScripts", ))); @@ -201,11 +221,11 @@ impl RuntimeModule for ImportScriptsChunkLoadingRuntimeModule { if with_hmr_manifest { // TODO: import_scripts_chunk_loading_with_hmr_manifest same as jsonp_chunk_loading_with_hmr_manifest - let render_source = compilation + let source_with_hmr_manifest = compilation .runtime_template - .render(&format!("{}_with_hmr_manifest", &self.id), None)?; + .render(&self.template_id(TemplateId::WithHmrManifest), None)?; - source.add(RawStringSource::from(render_source)); + source.add(RawStringSource::from(source_with_hmr_manifest)); } Ok(source.boxed()) From 003040a24cc8eba1cbfeadf9cd5ebcc8f1aa341f Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Mon, 13 Jan 2025 15:06:05 +0800 Subject: [PATCH 08/13] refactor: simplify string formatting and add linting for enum variant names --- crates/rspack_core/src/runtime_template.rs | 15 +++++++-------- .../src/runtime_module/jsonp_chunk_loading.rs | 1 + .../src/runtime_module/readfile_chunk_loading.rs | 1 + .../runtime_module/require_js_chunk_loading.rs | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/rspack_core/src/runtime_template.rs b/crates/rspack_core/src/runtime_template.rs index 6bb0c768edee..bb55e605c0b6 100644 --- a/crates/rspack_core/src/runtime_template.rs +++ b/crates/rspack_core/src/runtime_template.rs @@ -126,25 +126,24 @@ impl RuntimeTemplate { }) } else { Err(miette::Error::msg(format!( - "Runtime module: Template {} is not found", - key + "Runtime module: Template {key} is not found" ))) } } pub fn returning_function(&self, return_value: &str, args: &str) -> String { if self.environment.supports_arrow_function() { - format!("({}) => ({})", args, return_value) + format!("({args}) => ({return_value})") } else { - format!("function({}) {{ return {}; }}", args, return_value) + format!("function({args}) {{ return {return_value}; }}") } } pub fn basic_function(&self, args: &str, body: &str) -> String { if self.environment.supports_arrow_function() { - format!("({}) => {{\n {} \n}}", args, body) + format!("({args}) => {{\n {body} \n}}") } else { - format!("function({}) {{\n {} \n}}", args, body) + format!("function({args}) {{\n {body} \n}}") } } } @@ -228,7 +227,7 @@ fn array_variable(items: Operand, value: Operand) -> Operand { if item_name.is_empty() { String::default() } else { - format!("var {} = {}[{}];", item_name, value_name, idx) + format!("var {item_name} = {value_name}[{idx}];") } }) .join("\n"), @@ -242,7 +241,7 @@ fn array_variable(items: Operand, value: Operand) -> Operand { if item_name.is_empty() { String::default() } else { - format!("var {} = {}[{}];", item_name, value_name, idx) + format!("var {item_name} = {value_name}[{idx}];") } }) .join("\n"), diff --git a/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs index f855de7bf56c..e76ea0dcb20d 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs @@ -45,6 +45,7 @@ impl JsonpChunkLoadingRuntimeModule { } } +#[allow(clippy::enum_variant_names)] enum TemplateId { WithPrefetch, WithPreload, diff --git a/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs index 32268f7f0fe3..82c0f5b78808 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs @@ -65,6 +65,7 @@ impl ReadFileChunkLoadingRuntimeModule { } } +#[allow(clippy::enum_variant_names)] enum TemplateId { WithOnChunkLoad, WithLoading, diff --git a/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs b/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs index fcfab526026e..bb57cf239337 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs +++ b/crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs @@ -64,6 +64,7 @@ impl RequireChunkLoadingRuntimeModule { } } +#[allow(clippy::enum_variant_names)] enum TemplateId { WithLoading, WithOnChunkLoad, From 9ad81eb4fc3ef6e9f1e68409c8f4aa315487b4f3 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Thu, 16 Jan 2025 16:22:59 +0800 Subject: [PATCH 09/13] test: enhance runtime diff testing and update test snapshot --- .../rspack-test-tools/etc/test-tools.api.md | 4 +- packages/rspack-test-tools/src/case/diff.ts | 10 +- .../rspack-test-tools/src/processor/diff.ts | 24 +++- .../tests/RuntimeDiff.difftest.js | 6 + ...$.css => async.$a6fc40277b4ca390dc58$.css} | 0 ...7$.css => main.$a6fc40277b4ca390dc58$.css} | 0 .../chunkFilename-fullhash/expected/main.js | 108 +++++++-------- ....css => entryA.$ca6bb1b4e6164181e8b4$.css} | 0 ....css => entryB.$a183fbde182287ad0025$.css} | 0 ....css => 1.main.$70047dc38f07b464ca3c$.css} | 0 ....css => 2.main.$55fa56c1b924916c3e3d$.css} | 0 .../expected/main.js | 13 +- .../expected/common.js | 34 ++--- .../cases/dependOn/expected/common.js | 34 ++--- .../expected/main.js | 9 +- .../expected/main.mjs | 15 +-- .../es-named-export-as-is/expected/main.js | 15 +-- .../expected/main.mjs | 15 +-- .../cases/es-named-export/expected/main.js | 15 +-- .../expected/main.js | 15 +-- .../expected/main.js | 2 +- .../cases/export-only-locals/expected/main.js | 15 +-- .../cases/insert-function/expected/main.js | 104 +++++++-------- .../cases/insert-string/expected/main.js | 104 +++++++-------- .../cases/insert-undefined/expected/main.js | 104 +++++++-------- .../cases/issue-6649/expected/main.js | 116 ++++++++-------- .../multiple-compiler/expected/one-main.js | 2 +- .../multiple-compiler/expected/two-main.js | 2 +- .../cases/new-url/expected/main.js | 7 +- .../cases/no-runtime/expected/main.js | 88 ++++++------ .../cases/runtime/expected/runtime~main.js | 125 ++++++++---------- 31 files changed, 444 insertions(+), 542 deletions(-) rename tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/{async.$d026823092eb39bd50f7$.css => async.$a6fc40277b4ca390dc58$.css} (100%) rename tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/{main.$d026823092eb39bd50f7$.css => main.$a6fc40277b4ca390dc58$.css} (100%) rename tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/{entryA.$69c13c1bf095c299452e$.css => entryA.$ca6bb1b4e6164181e8b4$.css} (100%) rename tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/{entryB.$b65aa87be1605a017a12$.css => entryB.$a183fbde182287ad0025$.css} (100%) rename tests/plugin-test/css-extract/cases/contenthash/expected/{1.main.$a509ee0bcfc54dbee585$.css => 1.main.$70047dc38f07b464ca3c$.css} (100%) rename tests/plugin-test/css-extract/cases/contenthash/expected/{2.main.$4786469c8ec9cd61dffc$.css => 2.main.$55fa56c1b924916c3e3d$.css} (100%) diff --git a/packages/rspack-test-tools/etc/test-tools.api.md b/packages/rspack-test-tools/etc/test-tools.api.md index 2810d89b6428..325ad5d9b539 100644 --- a/packages/rspack-test-tools/etc/test-tools.api.md +++ b/packages/rspack-test-tools/etc/test-tools.api.md @@ -198,7 +198,7 @@ export function createDefaultsCase(name: string, src: string): void; export function createDiagnosticCase(name: string, src: string, dist: string): void; // @public (undocumented) -export function createDiffCase(name: string, src: string, dist: string): void; +export function createDiffCase(name: string, src: string, dist: string, enableAllEnvironment?: boolean): void; // @public (undocumented) export function createErrorCase(name: string, src: string, dist: string, testConfig: string): void; @@ -685,6 +685,8 @@ export interface IDiffProcessorOptions extends IFormatCodeOptions { // (undocumented) detail?: boolean; // (undocumented) + enableAllEnvironment?: boolean; + // (undocumented) errors?: boolean; // (undocumented) files?: string[]; diff --git a/packages/rspack-test-tools/src/case/diff.ts b/packages/rspack-test-tools/src/case/diff.ts index e127840e8412..e82955399af4 100644 --- a/packages/rspack-test-tools/src/case/diff.ts +++ b/packages/rspack-test-tools/src/case/diff.ts @@ -23,7 +23,12 @@ type TFileCompareResult = { runtimeModules: TModuleCompareResult[]; }; -export function createDiffCase(name: string, src: string, dist: string) { +export function createDiffCase( + name: string, + src: string, + dist: string, + enableAllEnvironment?: boolean +) { const caseConfigFile = path.join(src, "test.config.js"); if (!fs.existsSync(caseConfigFile)) { return; @@ -31,6 +36,9 @@ export function createDiffCase(name: string, src: string, dist: string) { const caseConfig: IDiffProcessorOptions = Object.assign( {}, DEFAULT_CASE_CONFIG, + { + enableAllEnvironment + }, require(caseConfigFile) ); diff --git a/packages/rspack-test-tools/src/processor/diff.ts b/packages/rspack-test-tools/src/processor/diff.ts index 4c993d9ad7a4..480000ffef05 100644 --- a/packages/rspack-test-tools/src/processor/diff.ts +++ b/packages/rspack-test-tools/src/processor/diff.ts @@ -27,6 +27,7 @@ export interface IDiffProcessorOptions extends IFormatCodeOptions { bootstrap?: boolean; detail?: boolean; errors?: boolean; + enableAllEnvironment?: boolean; replacements?: IFormatCodeReplacement[]; renameModule?: (file: string) => string; onCompareFile?: (file: string, result: TFileCompareResult) => void; @@ -45,6 +46,7 @@ export class DiffProcessor implements ITestProcessor { defaultOptions: context => this.getDefaultOptions( ECompilerType.Webpack, + options.enableAllEnvironment ?? false, context.getSource(), path.join(context.getDist(), ECompilerType.Webpack) ), @@ -58,6 +60,7 @@ export class DiffProcessor implements ITestProcessor { defaultOptions: context => this.getDefaultOptions( ECompilerType.Rspack, + options.enableAllEnvironment ?? false, context.getSource(), path.join(context.getDist(), ECompilerType.Rspack) ), @@ -132,6 +135,7 @@ export class DiffProcessor implements ITestProcessor { private getDefaultOptions( type: T, + enableAllEnvironment: boolean, src: string, dist: string ) { @@ -141,7 +145,25 @@ export class DiffProcessor implements ITestProcessor { output: { path: dist, filename: "bundle.js", - chunkFilename: "[name].chunk.js" + chunkFilename: "[name].chunk.js", + environment: enableAllEnvironment + ? { + arrowFunction: true, + asyncFunction: true, + bigIntLiteral: true, + const: true, + destructuring: true, + document: true, + dynamicImport: true, + dynamicImportInWorker: true, + forOf: true, + globalThis: true, + module: true, + nodePrefixForCoreModules: true, + optionalChaining: true, + templateLiteral: true + } + : undefined }, plugins: [ type === ECompilerType.Webpack && new WebpackDiffConfigPlugin(), diff --git a/packages/rspack-test-tools/tests/RuntimeDiff.difftest.js b/packages/rspack-test-tools/tests/RuntimeDiff.difftest.js index 4331e7be4696..92e9eb0c1fab 100644 --- a/packages/rspack-test-tools/tests/RuntimeDiff.difftest.js +++ b/packages/rspack-test-tools/tests/RuntimeDiff.difftest.js @@ -6,3 +6,9 @@ describeByWalk(__filename, (name, src, dist) => { }, { dist: path.resolve(__dirname, `./js/runtime-diff`) }); + +describeByWalk(__filename, (name, src, dist) => { + createDiffCase(name, src, dist, true); +}, { + dist: path.resolve(__dirname, `./js/runtime-diff-enviroment`), +}) diff --git a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$d026823092eb39bd50f7$.css b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$a6fc40277b4ca390dc58$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$d026823092eb39bd50f7$.css rename to tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$a6fc40277b4ca390dc58$.css diff --git a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$d026823092eb39bd50f7$.css b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$a6fc40277b4ca390dc58$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$d026823092eb39bd50f7$.css rename to tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$a6fc40277b4ca390dc58$.css diff --git a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js index 2f1c98306662..c07af1276d2e 100644 --- a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js +++ b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js @@ -42,9 +42,9 @@ __webpack_require__.m = __webpack_modules__; __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -55,30 +55,28 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".js" +} })(); // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".$" + __webpack_require__.h() + "$.css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".$" + __webpack_require__.h() + "$.css" +} })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "d026823092eb39bd50f7"; -}; +__webpack_require__.h = () => ("a6fc40277b4ca390dc58") })(); // webpack/runtime/global @@ -95,10 +93,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -166,7 +161,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -176,30 +171,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -317,9 +311,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -332,7 +324,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -356,16 +348,12 @@ if (installedChunkData !== 0) { } // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$69c13c1bf095c299452e$.css b/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$ca6bb1b4e6164181e8b4$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$69c13c1bf095c299452e$.css rename to tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$ca6bb1b4e6164181e8b4$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$b65aa87be1605a017a12$.css b/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$a183fbde182287ad0025$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$b65aa87be1605a017a12$.css rename to tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$a183fbde182287ad0025$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$a509ee0bcfc54dbee585$.css b/tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$70047dc38f07b464ca3c$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$a509ee0bcfc54dbee585$.css rename to tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$70047dc38f07b464ca3c$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$4786469c8ec9cd61dffc$.css b/tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$55fa56c1b924916c3e3d$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$4786469c8ec9cd61dffc$.css rename to tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$55fa56c1b924916c3e3d$.css diff --git a/tests/plugin-test/css-extract/cases/custom-loader-with-functional-exports/expected/main.js b/tests/plugin-test/css-extract/cases/custom-loader-with-functional-exports/expected/main.js index 25e807e8e446..8bed3520a830 100644 --- a/tests/plugin-test/css-extract/cases/custom-loader-with-functional-exports/expected/main.js +++ b/tests/plugin-test/css-extract/cases/custom-loader-with-functional-exports/expected/main.js @@ -4,8 +4,8 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - cnA: function() { return _1; }, - cnB: function() { return _2; } + cnA: () => (_1), + cnB: () => (_2) }); // extracted by css-extract-rspack-plugin var _1 = () => "class-name-a"; @@ -43,7 +43,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -53,15 +53,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/common.js b/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/common.js index a79fdde6b623..604770cd8f1b 100644 --- a/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/common.js +++ b/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/common.js @@ -45,15 +45,12 @@ __webpack_require__.m = __webpack_modules__; /************************************************************************/ // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -64,7 +61,7 @@ __webpack_require__.r = function(exports) { // webpack/runtime/on_chunk_loaded (() => { var deferred = []; -__webpack_require__.O = function (result, chunkIds, fn, priority) { +__webpack_require__.O = (result, chunkIds, fn, priority) => { if (chunkIds) { priority = priority || 0; for (var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) @@ -74,16 +71,12 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { } var notFulfilled = Infinity; for (var i = 0; i < deferred.length; i++) { - var chunkIds = deferred[i][0], - fn = deferred[i][1], - priority = deferred[i][2]; + var [chunkIds, fn, priority] = deferred[i]; var fulfilled = true; for (var j = 0; j < chunkIds.length; j++) { if ( (priority & (1 === 0) || notFulfilled >= priority) && - Object.keys(__webpack_require__.O).every(function (key) { - return __webpack_require__.O[key](chunkIds[j]); - }) + Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j]))) ) { chunkIds.splice(j--, 1); } else { @@ -108,20 +101,13 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { // undefined = chunk not loaded, null = chunk preloaded/prefetched // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded var installedChunks = {"common": 0,}; - __webpack_require__.O.j = function (chunkId) { - return installedChunks[chunkId] === 0; -}; -// install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; + __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);// install a JSONP callback for chunk loading +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/dependOn/expected/common.js b/tests/plugin-test/css-extract/cases/dependOn/expected/common.js index e3c6d8bf2541..f8c316c30533 100644 --- a/tests/plugin-test/css-extract/cases/dependOn/expected/common.js +++ b/tests/plugin-test/css-extract/cases/dependOn/expected/common.js @@ -39,15 +39,12 @@ __webpack_require__.m = __webpack_modules__; /************************************************************************/ // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -58,7 +55,7 @@ __webpack_require__.r = function(exports) { // webpack/runtime/on_chunk_loaded (() => { var deferred = []; -__webpack_require__.O = function (result, chunkIds, fn, priority) { +__webpack_require__.O = (result, chunkIds, fn, priority) => { if (chunkIds) { priority = priority || 0; for (var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) @@ -68,16 +65,12 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { } var notFulfilled = Infinity; for (var i = 0; i < deferred.length; i++) { - var chunkIds = deferred[i][0], - fn = deferred[i][1], - priority = deferred[i][2]; + var [chunkIds, fn, priority] = deferred[i]; var fulfilled = true; for (var j = 0; j < chunkIds.length; j++) { if ( (priority & (1 === 0) || notFulfilled >= priority) && - Object.keys(__webpack_require__.O).every(function (key) { - return __webpack_require__.O[key](chunkIds[j]); - }) + Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j]))) ) { chunkIds.splice(j--, 1); } else { @@ -102,20 +95,13 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { // undefined = chunk not loaded, null = chunk preloaded/prefetched // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded var installedChunks = {"common": 0,}; - __webpack_require__.O.j = function (chunkId) { - return installedChunks[chunkId] === 0; -}; -// install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; + __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);// install a JSONP callback for chunk loading +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/es-module-concatenation-modules/expected/main.js b/tests/plugin-test/css-extract/cases/es-module-concatenation-modules/expected/main.js index c968e317ca62..e42c45317a8e 100644 --- a/tests/plugin-test/css-extract/cases/es-module-concatenation-modules/expected/main.js +++ b/tests/plugin-test/css-extract/cases/es-module-concatenation-modules/expected/main.js @@ -6,7 +6,7 @@ var __webpack_require__ = {}; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -16,15 +16,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/es-named-export-as-is-output-module/expected/main.mjs b/tests/plugin-test/css-extract/cases/es-named-export-as-is-output-module/expected/main.mjs index dd69c43ae566..053a1bf3aff2 100644 --- a/tests/plugin-test/css-extract/cases/es-named-export-as-is-output-module/expected/main.mjs +++ b/tests/plugin-test/css-extract/cases/es-named-export-as-is-output-module/expected/main.mjs @@ -2,9 +2,9 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "a-class": function() { return _1; }, - b__class: function() { return _2; }, - cClass: function() { return _3; } + "a-class": () => (_1), + b__class: () => (_2), + cClass: () => (_3) }); // extracted by css-extract-rspack-plugin var _1 = "Xh041yLR4iCP4RGjge50"; @@ -43,7 +43,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -53,15 +53,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/es-named-export-as-is/expected/main.js b/tests/plugin-test/css-extract/cases/es-named-export-as-is/expected/main.js index 89198a1f8bbe..5cb395bcda90 100644 --- a/tests/plugin-test/css-extract/cases/es-named-export-as-is/expected/main.js +++ b/tests/plugin-test/css-extract/cases/es-named-export-as-is/expected/main.js @@ -4,9 +4,9 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "a-class": function() { return _1; }, - b__class: function() { return _2; }, - cClass: function() { return _3; } + "a-class": () => (_1), + b__class: () => (_2), + cClass: () => (_3) }); // extracted by css-extract-rspack-plugin var _1 = "Xh041yLR4iCP4RGjge50"; @@ -45,7 +45,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -55,15 +55,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/es-named-export-output-module/expected/main.mjs b/tests/plugin-test/css-extract/cases/es-named-export-output-module/expected/main.mjs index cb5557ba71f5..626bd42af062 100644 --- a/tests/plugin-test/css-extract/cases/es-named-export-output-module/expected/main.mjs +++ b/tests/plugin-test/css-extract/cases/es-named-export-output-module/expected/main.mjs @@ -2,9 +2,9 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "a-class": function() { return _1; }, - b__class: function() { return _2; }, - cClass: function() { return _3; } + "a-class": () => (_1), + b__class: () => (_2), + cClass: () => (_3) }); // extracted by css-extract-rspack-plugin var _1 = "foo__style__a-class"; @@ -43,7 +43,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -53,15 +53,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/es-named-export/expected/main.js b/tests/plugin-test/css-extract/cases/es-named-export/expected/main.js index 98680f2d6e23..674d97b621b2 100644 --- a/tests/plugin-test/css-extract/cases/es-named-export/expected/main.js +++ b/tests/plugin-test/css-extract/cases/es-named-export/expected/main.js @@ -4,9 +4,9 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "a-class": function() { return _1; }, - b__class: function() { return _2; }, - cClass: function() { return _3; } + "a-class": () => (_1), + b__class: () => (_2), + cClass: () => (_3) }); // extracted by css-extract-rspack-plugin var _1 = "foo__style__a-class"; @@ -45,7 +45,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -55,15 +55,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/export-only-locals-and-es-named-export/expected/main.js b/tests/plugin-test/css-extract/cases/export-only-locals-and-es-named-export/expected/main.js index bb57ea0cab8f..ba3e3597dbf1 100644 --- a/tests/plugin-test/css-extract/cases/export-only-locals-and-es-named-export/expected/main.js +++ b/tests/plugin-test/css-extract/cases/export-only-locals-and-es-named-export/expected/main.js @@ -4,9 +4,9 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - "a-class": function() { return _1; }, - b__class: function() { return _2; }, - cClass: function() { return _3; } + "a-class": () => (_1), + b__class: () => (_2), + cClass: () => (_3) }); // extracted by css-extract-rspack-plugin var _1 = "foo__style__a-class"; @@ -45,7 +45,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -55,15 +55,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/export-only-locals-commonjs/expected/main.js b/tests/plugin-test/css-extract/cases/export-only-locals-commonjs/expected/main.js index ef53b9233ccb..9de624b39f00 100644 --- a/tests/plugin-test/css-extract/cases/export-only-locals-commonjs/expected/main.js +++ b/tests/plugin-test/css-extract/cases/export-only-locals-commonjs/expected/main.js @@ -37,7 +37,7 @@ return module.exports; // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/export-only-locals/expected/main.js b/tests/plugin-test/css-extract/cases/export-only-locals/expected/main.js index 009a7a54796e..47847c5ca897 100644 --- a/tests/plugin-test/css-extract/cases/export-only-locals/expected/main.js +++ b/tests/plugin-test/css-extract/cases/export-only-locals/expected/main.js @@ -4,9 +4,9 @@ var __webpack_modules__ = ({ "./style.css": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - aClass: function() { return _1; }, - bClass: function() { return _2; }, - cClass: function() { return _3; } + aClass: () => (_1), + bClass: () => (_2), + cClass: () => (_3) }); // extracted by css-extract-rspack-plugin var _1 = "foo__style__a-class"; @@ -45,7 +45,7 @@ return module.exports; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -55,15 +55,12 @@ __webpack_require__.d = function(exports, definition) { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/insert-function/expected/main.js b/tests/plugin-test/css-extract/cases/insert-function/expected/main.js index 88d6288130ab..2ce22dff234c 100644 --- a/tests/plugin-test/css-extract/cases/insert-function/expected/main.js +++ b/tests/plugin-test/css-extract/cases/insert-function/expected/main.js @@ -33,9 +33,9 @@ __webpack_require__.m = __webpack_modules__; __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -46,24 +46,24 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".js" +} })(); // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".css" +} })(); // webpack/runtime/global (() => { @@ -79,10 +79,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -150,7 +147,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -160,30 +157,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -302,9 +298,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -317,7 +311,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -341,16 +335,12 @@ if (installedChunkData !== 0) { } // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/insert-string/expected/main.js b/tests/plugin-test/css-extract/cases/insert-string/expected/main.js index a150581e1783..aef910ef8efd 100644 --- a/tests/plugin-test/css-extract/cases/insert-string/expected/main.js +++ b/tests/plugin-test/css-extract/cases/insert-string/expected/main.js @@ -33,9 +33,9 @@ __webpack_require__.m = __webpack_modules__; __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -46,24 +46,24 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".js" +} })(); // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".css" +} })(); // webpack/runtime/global (() => { @@ -79,10 +79,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -150,7 +147,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -160,30 +157,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -298,9 +294,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -313,7 +307,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -337,16 +331,12 @@ if (installedChunkData !== 0) { } // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js b/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js index 471233a1fda4..3f25d4692629 100644 --- a/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js +++ b/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js @@ -33,9 +33,9 @@ __webpack_require__.m = __webpack_modules__; __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -46,24 +46,24 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".js" +} })(); // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".css" +} })(); // webpack/runtime/global (() => { @@ -79,10 +79,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -150,7 +147,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -160,30 +157,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -301,9 +297,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -316,7 +310,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -340,16 +334,12 @@ if (installedChunkData !== 0) { } // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js b/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js index 42c1642fe3dc..5131966e4f90 100644 --- a/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js +++ b/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js @@ -30,7 +30,7 @@ __webpack_require__.m = __webpack_modules__; /************************************************************************/ // webpack/runtime/create_fake_namespace_object (() => { -var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__ }; +var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__); var leafPrototypes; // create a fake namespace object // mode & 1: value is a module id, require it @@ -50,16 +50,16 @@ __webpack_require__.t = function(value, mode) { var def = {}; leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { - Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; } }); + Object.getOwnPropertyNames(current).forEach((key) => { def[key] = () => (value[key]) }); } - def['default'] = function() { return value }; + def['default'] = () => (value); __webpack_require__.d(ns, def); return ns; }; })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -72,9 +72,9 @@ __webpack_require__.d = function(exports, definition) { __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -85,30 +85,28 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".$" + {"\\css\\chunk": "b1b844425027e2012f17","\\js\\chunk": "033244835a8df445c8ec",}[chunkId] + "$.js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".$" + {"\\css\\chunk": "b1b844425027e2012f17","\\js\\chunk": "033244835a8df445c8ec",}[chunkId] + "$.js" +} })(); // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".$" + "045b86c2c3fee05a882a" + "$.css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".$" + "045b86c2c3fee05a882a" + "$.css" +} })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { - return "950959268269901ed8e8"; -}; +__webpack_require__.h = () => ("8e377d705856cad652ce") })(); // webpack/runtime/global @@ -125,10 +123,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -196,7 +191,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -206,30 +201,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -347,9 +341,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -362,7 +354,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -386,16 +378,12 @@ if (installedChunkData !== 0) { } // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/multiple-compiler/expected/one-main.js b/tests/plugin-test/css-extract/cases/multiple-compiler/expected/one-main.js index 5820c1f359c8..ab9a3374ce1e 100644 --- a/tests/plugin-test/css-extract/cases/multiple-compiler/expected/one-main.js +++ b/tests/plugin-test/css-extract/cases/multiple-compiler/expected/one-main.js @@ -37,7 +37,7 @@ return module.exports; // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/multiple-compiler/expected/two-main.js b/tests/plugin-test/css-extract/cases/multiple-compiler/expected/two-main.js index 5820c1f359c8..ab9a3374ce1e 100644 --- a/tests/plugin-test/css-extract/cases/multiple-compiler/expected/two-main.js +++ b/tests/plugin-test/css-extract/cases/multiple-compiler/expected/two-main.js @@ -37,7 +37,7 @@ return module.exports; // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/new-url/expected/main.js b/tests/plugin-test/css-extract/cases/new-url/expected/main.js index 193933133dc5..df0fe00ec956 100644 --- a/tests/plugin-test/css-extract/cases/new-url/expected/main.js +++ b/tests/plugin-test/css-extract/cases/new-url/expected/main.js @@ -39,15 +39,12 @@ __webpack_require__.m = __webpack_modules__; /************************************************************************/ // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } diff --git a/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js b/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js index e5719db7a739..b5548b729497 100644 --- a/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js +++ b/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js @@ -42,9 +42,9 @@ __webpack_require__.m = __webpack_modules__; __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -55,13 +55,13 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".js" +} })(); // webpack/runtime/global (() => { @@ -77,10 +77,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -148,7 +145,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -158,30 +155,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/jsonp_chunk_loading (() => { @@ -205,9 +201,7 @@ if (installedChunkData !== 0) { } else { if (true) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -220,7 +214,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -244,16 +238,12 @@ if (installedChunkData !== 0) { } // install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; diff --git a/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js b/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js index 6a90b5965a47..1fa06da23826 100644 --- a/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js +++ b/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js @@ -31,7 +31,7 @@ __webpack_require__.m = __webpack_modules__; /************************************************************************/ // webpack/runtime/create_fake_namespace_object (() => { -var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__ }; +var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__); var leafPrototypes; // create a fake namespace object // mode & 1: value is a module id, require it @@ -51,16 +51,16 @@ __webpack_require__.t = function(value, mode) { var def = {}; leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { - Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; } }); + Object.getOwnPropertyNames(current).forEach((key) => { def[key] = () => (value[key]) }); } - def['default'] = function() { return value }; + def['default'] = () => (value); __webpack_require__.d(ns, def); return ns; }; })(); // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -73,9 +73,9 @@ __webpack_require__.d = function(exports, definition) { __webpack_require__.f = {}; // This file contains only the entry chunk. // The chunk loading function for additional chunks -__webpack_require__.e = function (chunkId) { +__webpack_require__.e = (chunkId) => { return Promise.all( - Object.keys(__webpack_require__.f).reduce(function (promises, key) { + Object.keys(__webpack_require__.f).reduce((promises, key) => { __webpack_require__.f[key](chunkId, promises); return promises; }, []) @@ -86,24 +86,24 @@ __webpack_require__.e = function (chunkId) { // webpack/runtime/get javascript chunk filename (() => { // This function allow to reference chunks - __webpack_require__.u = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".js"; - }; - +__webpack_require__.u = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".js" +} })(); // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + + // return url for filenames based on template + return "" + chunkId + ".css" +} })(); // webpack/runtime/global (() => { @@ -119,10 +119,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/load_script (() => { @@ -190,7 +187,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -201,7 +198,7 @@ __webpack_require__.r = function(exports) { // webpack/runtime/on_chunk_loaded (() => { var deferred = []; -__webpack_require__.O = function (result, chunkIds, fn, priority) { +__webpack_require__.O = (result, chunkIds, fn, priority) => { if (chunkIds) { priority = priority || 0; for (var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) @@ -211,16 +208,12 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { } var notFulfilled = Infinity; for (var i = 0; i < deferred.length; i++) { - var chunkIds = deferred[i][0], - fn = deferred[i][1], - priority = deferred[i][2]; + var [chunkIds, fn, priority] = deferred[i]; var fulfilled = true; for (var j = 0; j < chunkIds.length; j++) { if ( (priority & (1 === 0) || notFulfilled >= priority) && - Object.keys(__webpack_require__.O).every(function (key) { - return __webpack_require__.O[key](chunkIds[j]); - }) + Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j]))) ) { chunkIds.splice(j--, 1); } else { @@ -240,30 +233,29 @@ __webpack_require__.O = function (result, chunkIds, fn, priority) { })(); // webpack/runtime/auto_public_path (() => { +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/jsonp_chunk_loading (() => { @@ -287,9 +279,7 @@ if (installedChunkData !== 0) { } else { if ("runtime~main" != chunkId) { // setup Promise in chunk cache - var promise = new Promise(function (resolve, reject) { - installedChunkData = installedChunks[chunkId] = [resolve, reject]; - }); + var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); promises.push((installedChunkData[2] = promise)); // start chunk loading @@ -302,7 +292,7 @@ if (installedChunkData !== 0) { if (installedChunkData !== 0) installedChunks[chunkId] = undefined; if (installedChunkData) { var errorType = - event && (event.type === 'load' ? 'missing' : event.type); + event && (event.type === 'load' ? 'missing' : event.type); var realSrc = event && event.target && event.target.src; error.message = 'Loading chunk ' + @@ -326,20 +316,13 @@ if (installedChunkData !== 0) { } } - __webpack_require__.O.j = function (chunkId) { - return installedChunks[chunkId] === 0; -}; -// install a JSONP callback for chunk loading -var webpackJsonpCallback = function (parentChunkLoadingFunction, data) { - var chunkIds = data[0]; - var moreModules = data[1]; - var runtime = data[2]; + __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);// install a JSONP callback for chunk loading +var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { + var [chunkIds, moreModules, runtime] = data; // add "moreModules" to the modules object, // then flag all "chunkIds" as loaded and fire callback - var moduleId, - chunkId, - i = 0; - if (chunkIds.some(function (id) { return installedChunks[id] !== 0 })) { + var moduleId, chunkId, i = 0; + if (chunkIds.some((id) => (installedChunks[id] !== 0))) { for (moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { __webpack_require__.m[moduleId] = moreModules[moduleId]; From 6a5adf24aca41874031a23b78768dcd713dff73f Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Thu, 16 Jan 2025 17:08:39 +0800 Subject: [PATCH 10/13] test: update hmr test code --- tests/plugin-test/css-extract/TestCases.test.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/plugin-test/css-extract/TestCases.test.js b/tests/plugin-test/css-extract/TestCases.test.js index 49de1ddd0c82..1c39e8940955 100644 --- a/tests/plugin-test/css-extract/TestCases.test.js +++ b/tests/plugin-test/css-extract/TestCases.test.js @@ -283,15 +283,13 @@ describe("TestCases", () => { res = res.replace(dateRegexp, ""); const matchAll = res.match( - /__webpack_require__\.h = function \(\) {\n.*return ("[\d\w].*");\n.*};/i + /__webpack_require__\.h = \(\) => \("([\d\w].*)"\);/i ); const replacer = new Array(matchAll[1].length); res = res.replace( - /__webpack_require__\.h = function \(\) {\n.*return ("[\d\w].*");\n.*};/i, - `__webpack_require__.h = function () { return "${replacer - .fill("x") - .join("")}" }` + /__webpack_require__\.h = \(\) => \("([\d\w].*)"\);/i, + `__webpack_require__.h = () => ("${replacer.fill("x").join("")}")` ); fs.writeFileSync( From 34720a9e28a57a3e51af441fb578b24e5602965b Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 17 Jan 2025 11:14:46 +0800 Subject: [PATCH 11/13] test: fix regex pattern in webpack require handler --- tests/plugin-test/css-extract/TestCases.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plugin-test/css-extract/TestCases.test.js b/tests/plugin-test/css-extract/TestCases.test.js index 1c39e8940955..21cedbe7d585 100644 --- a/tests/plugin-test/css-extract/TestCases.test.js +++ b/tests/plugin-test/css-extract/TestCases.test.js @@ -283,12 +283,12 @@ describe("TestCases", () => { res = res.replace(dateRegexp, ""); const matchAll = res.match( - /__webpack_require__\.h = \(\) => \("([\d\w].*)"\);/i + /__webpack_require__\.h = \(\) => \("([\d\w].*)"\)/i ); const replacer = new Array(matchAll[1].length); res = res.replace( - /__webpack_require__\.h = \(\) => \("([\d\w].*)"\);/i, + /__webpack_require__\.h = \(\) => \("([\d\w].*)"\)/i, `__webpack_require__.h = () => ("${replacer.fill("x").join("")}")` ); From 074d8bcfebc24b477422658783dc9b6ed59230fe Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 17 Jan 2025 14:34:21 +0800 Subject: [PATCH 12/13] test: update test snapshot and remove unnecessary newlines --- .../runtime/get_chunk_filename.ejs | 1 - .../__snapshots__/StatsOutput.test.js.snap | 4 +- .../variant/__snapshots__/output.snap.txt | 2 +- .../tests/statsAPICases/chunk-group.js | 16 ++-- .../tests/statsAPICases/chunks.js | 4 +- ...$.css => async.$f8a0be13a81c5cfa97d6$.css} | 0 ...8$.css => main.$f8a0be13a81c5cfa97d6$.css} | 0 .../chunkFilename-fullhash/expected/main.js | 4 +- .../expected/entry1.css | 1 + .../cases/hmr-locals/expected/main.js | 93 ++++++++----------- .../css-extract/cases/hmr/expected/main.js | 89 ++++++++---------- .../cases/insert-function/expected/main.js | 2 - .../cases/insert-string/expected/main.js | 2 - .../cases/insert-undefined/expected/main.js | 2 - .../cases/issue-6649/expected/main.js | 4 +- .../cases/no-runtime/expected/main.js | 1 - .../cases/runtime/expected/runtime~main.js | 2 - 17 files changed, 96 insertions(+), 131 deletions(-) rename tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/{async.$a6fc40277b4ca390dc58$.css => async.$f8a0be13a81c5cfa97d6$.css} (100%) rename tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/{main.$a6fc40277b4ca390dc58$.css => main.$f8a0be13a81c5cfa97d6$.css} (100%) diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs index 6e15578c2bb3..93a7d700aa0c 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/get_chunk_filename.ejs @@ -2,7 +2,6 @@ <%- $GLOBAL$ %> = <%- basicFunction("chunkId") %> { // return url for filenames not based on template <%- STATIC_URLS %> - // return url for filenames based on template return <%- DYNAMIC_URL %> } \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap index 50aadf8a14a6..30eb42ec3e9c 100644 --- a/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap +++ b/packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap @@ -328,11 +328,11 @@ cacheable modules 293 KiB ./e.js 22 bytes [built] [code generated] ERROR in × asset size limit: The following asset(s) exceed the recommended size limit (244.141 KiB). This can impact web performance.Assets: - │ main.js (303.423 KiB) + │ main.js (303.421 KiB) ERROR in × entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244.141 KiB). This can impact web performance.Entrypoints: - │ main (303.423 KiB) + │ main (303.421 KiB) │ main.js diff --git a/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt b/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt index c4fff2ebf501..e7b53a172b2a 100644 --- a/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt +++ b/packages/rspack-test-tools/tests/builtinCases/plugin-html/variant/__snapshots__/output.snap.txt @@ -1,3 +1,3 @@ ```html title=output.html -Rspack App +Rspack App ``` \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js b/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js index d7ecf330caa6..95b3fdd7491c 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunk-group.js @@ -26,17 +26,17 @@ module.exports = { assets: Array [ Object { name: main.js, - size: 13922, + size: 13920, }, ], - assetsSize: 13922, + assetsSize: 13920, auxiliaryAssets: Array [ Object { name: main.js.map, - size: 667, + size: 665, }, ], - auxiliaryAssetsSize: 667, + auxiliaryAssetsSize: 665, childAssets: Object {}, children: Object { prefetch: Array [ @@ -215,17 +215,17 @@ module.exports = { assets: Array [ Object { name: main.js, - size: 13922, + size: 13920, }, ], - assetsSize: 13922, + assetsSize: 13920, auxiliaryAssets: Array [ Object { name: main.js.map, - size: 667, + size: 665, }, ], - auxiliaryAssetsSize: 667, + auxiliaryAssetsSize: 665, childAssets: Object {}, children: Object { prefetch: Array [ diff --git a/packages/rspack-test-tools/tests/statsAPICases/chunks.js b/packages/rspack-test-tools/tests/statsAPICases/chunks.js index ed32e28024dd..9ea4297d9ed4 100644 --- a/packages/rspack-test-tools/tests/statsAPICases/chunks.js +++ b/packages/rspack-test-tools/tests/statsAPICases/chunks.js @@ -144,7 +144,7 @@ module.exports = { main.js, ], filteredModules: undefined, - hash: 67718a28a7b45b16, + hash: 48a38f1a4ad2911f, id: 909, idHints: Array [], initial: true, @@ -235,7 +235,7 @@ module.exports = { size: 85, sizes: Object { javascript: 85, - runtime: 8724, + runtime: 8722, }, type: chunk, }, diff --git a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$a6fc40277b4ca390dc58$.css b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$f8a0be13a81c5cfa97d6$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$a6fc40277b4ca390dc58$.css rename to tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/async.$f8a0be13a81c5cfa97d6$.css diff --git a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$a6fc40277b4ca390dc58$.css b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$f8a0be13a81c5cfa97d6$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$a6fc40277b4ca390dc58$.css rename to tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.$f8a0be13a81c5cfa97d6$.css diff --git a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js index c07af1276d2e..dc196b23b9cb 100644 --- a/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js +++ b/tests/plugin-test/css-extract/cases/chunkFilename-fullhash/expected/main.js @@ -58,7 +58,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".js" } @@ -69,14 +68,13 @@ __webpack_require__.u = (chunkId) => { __webpack_require__.miniCssF = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".$" + __webpack_require__.h() + "$.css" } })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = () => ("a6fc40277b4ca390dc58") +__webpack_require__.h = () => ("f8a0be13a81c5cfa97d6") })(); // webpack/runtime/global diff --git a/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/entry1.css b/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/entry1.css index df499507b850..c6856116b8cf 100644 --- a/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/entry1.css +++ b/tests/plugin-test/css-extract/cases/dependOn-multiple-files-per-entry/expected/entry1.css @@ -5,3 +5,4 @@ .styleB { background: blue; } + diff --git a/tests/plugin-test/css-extract/cases/hmr-locals/expected/main.js b/tests/plugin-test/css-extract/cases/hmr-locals/expected/main.js index e984b3b3e481..595f440d8baf 100644 --- a/tests/plugin-test/css-extract/cases/hmr-locals/expected/main.js +++ b/tests/plugin-test/css-extract/cases/hmr-locals/expected/main.js @@ -229,7 +229,7 @@ function cssReload(moduleId, options) { "./index.css": (function (module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { - x: function() { return _1; } + x: () => (_1) }); // extracted by css-extract-rspack-plugin var _1 = "VoofDB21D_QzDbRdwMiY"; @@ -311,7 +311,7 @@ __webpack_require__.i = []; /************************************************************************/ // webpack/runtime/define_property_getters (() => { -__webpack_require__.d = function(exports, definition) { +__webpack_require__.d = (exports, definition) => { for(var key in definition) { if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); @@ -322,32 +322,25 @@ __webpack_require__.d = function(exports, definition) { // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + // return url for filenames based on template + return "" + chunkId + ".css" +} })(); // webpack/runtime/get_chunk_update_filename (() => { -__webpack_require__.hu = function (chunkId) { - return '' + chunkId + '.' + __webpack_require__.h() + '.hot-update.js'; - }; - +__webpack_require__.hu = (chunkId) => ('' + chunkId + '.' + __webpack_require__.h() + '.hot-update.js') })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { return "xxxxxxxxxxxxxxxxxxxxxx" } +__webpack_require__.h = () => ("xxxxxxxxxxxxxxxxxxxx") })(); // webpack/runtime/get_main_filename/update manifest (() => { -__webpack_require__.hmrF = function () { - return "main." + __webpack_require__.h() + ".hot-update.json"; - }; - +__webpack_require__.hmrF = () => ("main." + __webpack_require__.h() + ".hot-update.json") })(); // webpack/runtime/global (() => { @@ -363,10 +356,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/hot_module_replacement (() => { @@ -800,7 +790,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -810,30 +800,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -956,13 +945,13 @@ __webpack_require__.hmrC.miniCss = function (chunkIds, removedChunks, removedMod var waitingUpdateResolves = {}; function loadUpdateChunk(chunkId, updatedModulesList) { currentUpdatedModulesList = updatedModulesList; - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { waitingUpdateResolves[chunkId] = resolve; // start update chunk loading var url = __webpack_require__.p + __webpack_require__.hu(chunkId); // create error before stack unwound to get useful stacktrace later var error = new Error(); - var loadingEnded = function (event) { + var loadingEnded = (event) => { if (waitingUpdateResolves[chunkId]) { waitingUpdateResolves[chunkId] = undefined; var errorType = @@ -986,7 +975,7 @@ function loadUpdateChunk(chunkId, updatedModulesList) { }); } -self["webpackHotUpdate"] = function (chunkId, moreModules, runtime) { +self["webpackHotUpdate"] = (chunkId, moreModules, runtime) => { for (var moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { currentUpdate[moduleId] = moreModules[moduleId]; @@ -1430,11 +1419,11 @@ __webpack_require__.hmrC.jsonp = function ( }; } }; -__webpack_require__.hmrM = function () { +__webpack_require__.hmrM = () => { if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then( - function (response) { + (response) => { if (response.status === 404) return; // no update available if (!response.ok) throw new Error( diff --git a/tests/plugin-test/css-extract/cases/hmr/expected/main.js b/tests/plugin-test/css-extract/cases/hmr/expected/main.js index 8a924f282b0d..45148393f535 100644 --- a/tests/plugin-test/css-extract/cases/hmr/expected/main.js +++ b/tests/plugin-test/css-extract/cases/hmr/expected/main.js @@ -307,32 +307,25 @@ __webpack_require__.i = []; // webpack/runtime/get mini-css chunk filename (() => { // This function allow to reference chunks - __webpack_require__.miniCssF = function (chunkId) { - // return url for filenames not based on template - - // return url for filenames based on template - return "" + chunkId + ".css"; - }; - +__webpack_require__.miniCssF = (chunkId) => { + // return url for filenames not based on template + + // return url for filenames based on template + return "" + chunkId + ".css" +} })(); // webpack/runtime/get_chunk_update_filename (() => { -__webpack_require__.hu = function (chunkId) { - return '' + chunkId + '.' + __webpack_require__.h() + '.hot-update.js'; - }; - +__webpack_require__.hu = (chunkId) => ('' + chunkId + '.' + __webpack_require__.h() + '.hot-update.js') })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = function () { return "xxxxxxxxxxxxxxxxxxxxxx" } +__webpack_require__.h = () => ("xxxxxxxxxxxxxxxxxxxx") })(); // webpack/runtime/get_main_filename/update manifest (() => { -__webpack_require__.hmrF = function () { - return "main." + __webpack_require__.h() + ".hot-update.json"; - }; - +__webpack_require__.hmrF = () => ("main." + __webpack_require__.h() + ".hot-update.json") })(); // webpack/runtime/global (() => { @@ -348,10 +341,7 @@ __webpack_require__.g = (function () { })(); // webpack/runtime/has_own_property (() => { -__webpack_require__.o = function (obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - +__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) })(); // webpack/runtime/hot_module_replacement (() => { @@ -785,7 +775,7 @@ __webpack_require__.l = function (url, done, key, chunkId) { // webpack/runtime/make_namespace_object (() => { // define __esModule on exports -__webpack_require__.r = function(exports) { +__webpack_require__.r = (exports) => { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } @@ -795,30 +785,29 @@ __webpack_require__.r = function(exports) { })(); // webpack/runtime/auto_public_path (() => { - - var scriptUrl; - if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; - var document = __webpack_require__.g.document; - if (!scriptUrl && document) { - // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, - // but an attacker could try to inject `` - // and use `` - if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; - if (!scriptUrl) { - var scripts = document.getElementsByTagName("script"); - if (scripts.length) { - var i = scripts.length - 1; - while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; - } - } - } - - // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", - // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', - if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); - scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); - __webpack_require__.p = scriptUrl - +var scriptUrl; + +if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; +var document = __webpack_require__.g.document; +if (!scriptUrl && document) {{ + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') scriptUrl = document.currentScript.src; + if (!scriptUrl) {{ + var scripts = document.getElementsByTagName("script"); + if (scripts.length) {{ + var i = scripts.length - 1; + while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; + }} + }} +}} + +// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration", +// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.', +if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); +scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); +__webpack_require__.p = scriptUrl })(); // webpack/runtime/css loading (() => { @@ -941,13 +930,13 @@ __webpack_require__.hmrC.miniCss = function (chunkIds, removedChunks, removedMod var waitingUpdateResolves = {}; function loadUpdateChunk(chunkId, updatedModulesList) { currentUpdatedModulesList = updatedModulesList; - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { waitingUpdateResolves[chunkId] = resolve; // start update chunk loading var url = __webpack_require__.p + __webpack_require__.hu(chunkId); // create error before stack unwound to get useful stacktrace later var error = new Error(); - var loadingEnded = function (event) { + var loadingEnded = (event) => { if (waitingUpdateResolves[chunkId]) { waitingUpdateResolves[chunkId] = undefined; var errorType = @@ -971,7 +960,7 @@ function loadUpdateChunk(chunkId, updatedModulesList) { }); } -self["webpackHotUpdate"] = function (chunkId, moreModules, runtime) { +self["webpackHotUpdate"] = (chunkId, moreModules, runtime) => { for (var moduleId in moreModules) { if (__webpack_require__.o(moreModules, moduleId)) { currentUpdate[moduleId] = moreModules[moduleId]; @@ -1415,11 +1404,11 @@ __webpack_require__.hmrC.jsonp = function ( }; } }; -__webpack_require__.hmrM = function () { +__webpack_require__.hmrM = () => { if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API"); return fetch(__webpack_require__.p + __webpack_require__.hmrF()).then( - function (response) { + (response) => { if (response.status === 404) return; // no update available if (!response.ok) throw new Error( diff --git a/tests/plugin-test/css-extract/cases/insert-function/expected/main.js b/tests/plugin-test/css-extract/cases/insert-function/expected/main.js index 2ce22dff234c..b158a5224f85 100644 --- a/tests/plugin-test/css-extract/cases/insert-function/expected/main.js +++ b/tests/plugin-test/css-extract/cases/insert-function/expected/main.js @@ -49,7 +49,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".js" } @@ -60,7 +59,6 @@ __webpack_require__.u = (chunkId) => { __webpack_require__.miniCssF = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".css" } diff --git a/tests/plugin-test/css-extract/cases/insert-string/expected/main.js b/tests/plugin-test/css-extract/cases/insert-string/expected/main.js index aef910ef8efd..7d9758eabf51 100644 --- a/tests/plugin-test/css-extract/cases/insert-string/expected/main.js +++ b/tests/plugin-test/css-extract/cases/insert-string/expected/main.js @@ -49,7 +49,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".js" } @@ -60,7 +59,6 @@ __webpack_require__.u = (chunkId) => { __webpack_require__.miniCssF = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".css" } diff --git a/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js b/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js index 3f25d4692629..3206bce82c2a 100644 --- a/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js +++ b/tests/plugin-test/css-extract/cases/insert-undefined/expected/main.js @@ -49,7 +49,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".js" } @@ -60,7 +59,6 @@ __webpack_require__.u = (chunkId) => { __webpack_require__.miniCssF = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".css" } diff --git a/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js b/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js index 5131966e4f90..512b6224c6de 100644 --- a/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js +++ b/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js @@ -88,7 +88,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".$" + {"\\css\\chunk": "b1b844425027e2012f17","\\js\\chunk": "033244835a8df445c8ec",}[chunkId] + "$.js" } @@ -99,14 +98,13 @@ __webpack_require__.u = (chunkId) => { __webpack_require__.miniCssF = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".$" + "045b86c2c3fee05a882a" + "$.css" } })(); // webpack/runtime/get_full_hash (() => { -__webpack_require__.h = () => ("8e377d705856cad652ce") +__webpack_require__.h = () => ("cc7ce048ef92de89ada1") })(); // webpack/runtime/global diff --git a/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js b/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js index b5548b729497..bcce81748701 100644 --- a/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js +++ b/tests/plugin-test/css-extract/cases/no-runtime/expected/main.js @@ -58,7 +58,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".js" } diff --git a/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js b/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js index 1fa06da23826..73554827de45 100644 --- a/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js +++ b/tests/plugin-test/css-extract/cases/runtime/expected/runtime~main.js @@ -89,7 +89,6 @@ __webpack_require__.e = (chunkId) => { __webpack_require__.u = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".js" } @@ -100,7 +99,6 @@ __webpack_require__.u = (chunkId) => { __webpack_require__.miniCssF = (chunkId) => { // return url for filenames not based on template - // return url for filenames based on template return "" + chunkId + ".css" } From aa058b5827698cebfa1d06dfae020e9089fa8851 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 17 Jan 2025 14:41:05 +0800 Subject: [PATCH 13/13] test: update snapshot for StatsTestCases to reflect changes in output --- .../StatsTestCases.basictest.js.snap | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap index b7aaf4b3c7c0..b6ba7d32d7c7 100644 --- a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap @@ -379,7 +379,7 @@ Rspack x.x.x compiled successfully" `; exports[`StatsTestCases should print correct stats for graph-correctness-modules 1`] = ` -"chunk (runtime: e1) e1.js (e1) 119 bytes (javascript) 8.42 KiB (runtime) >{74}< >{984}< [entry] [rendered] +"chunk (runtime: e1) e1.js (e1) 119 bytes (javascript) 8.41 KiB (runtime) >{74}< >{984}< [entry] [rendered] ./e1.js 70 bytes [built] [code generated] entry ./e1 ./module-x.js 49 bytes [dependent] [built] [code generated] @@ -397,7 +397,7 @@ chunk (runtime: e1, e2) c.js (c) 49 bytes <{751}> <{844}> >{74}< [rendered] ./module-c.js 49 bytes [built] [code generated] import() ./module-c ./e2.js import() ./module-c ./module-b.js -chunk (runtime: e2) e2.js (e2) 119 bytes (javascript) 8.42 KiB (runtime) >{76}< >{984}< [entry] [rendered] +chunk (runtime: e2) e2.js (e2) 119 bytes (javascript) 8.41 KiB (runtime) >{76}< >{984}< [entry] [rendered] ./e2.js 70 bytes [built] [code generated] entry ./e2 ./module-x.js 49 bytes [dependent] [built] [code generated] @@ -456,7 +456,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for immutable 1`] = ` -"asset 51858b0b6ca76b68.js 10.1 KiB [emitted] [immutable] (name: main) +"asset 453b233f2b0f63f6.js 10.1 KiB [emitted] [immutable] (name: main) asset 7342054f673663df.js 167 bytes [emitted] [immutable]" `; @@ -489,7 +489,7 @@ Rspack x.x.x compiled successfully in X.23" `; exports[`StatsTestCases should print correct stats for import-weak-parser-option 1`] = ` -"asset entry.js 9.89 KiB [emitted] (name: entry) +"asset entry.js 9.88 KiB [emitted] (name: entry) asset 332.js 285 bytes [emitted] asset 313.js 130 bytes [emitted] runtime modules 8.11 KiB 10 modules @@ -562,11 +562,11 @@ Rspack x.x.x compiled successfully in X.23 assets by chunk 862 bytes (id hint: all) asset c-all-b_js-b683c5304b71900e.js 480 bytes [emitted] [immutable] (id hint: all) asset c-all-c_js-2c876c6ecab93d9b.js 382 bytes [emitted] [immutable] (id hint: all) -asset c-runtime~main-85d5b8c60b8ea9fe.js 10.7 KiB [emitted] [immutable] (name: runtime~main) +asset c-runtime~main-e417307140e1f3b7.js 10.7 KiB [emitted] [immutable] (name: runtime~main) asset c-main-5df1191222ffdffb.js 588 bytes [emitted] [immutable] (name: main) asset c-vendors-node_modules_vendor_js-8e4df31a4698ceb4.js 173 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 11.6 KiB = c-runtime~main-85d5b8c60b8ea9fe.js 10.7 KiB c-all-c_js-2c876c6ecab93d9b.js 382 bytes c-main-5df1191222ffdffb.js 588 bytes -runtime modules 9.25 KiB 13 modules +Entrypoint main 11.6 KiB = c-runtime~main-e417307140e1f3b7.js 10.7 KiB c-all-c_js-2c876c6ecab93d9b.js 382 bytes c-main-5df1191222ffdffb.js 588 bytes +runtime modules 9.24 KiB 13 modules cacheable modules 101 bytes ./c.js 61 bytes [built] [code generated] ./b.js 17 bytes [built] [code generated] @@ -794,7 +794,7 @@ Rspack x.x.x compiled successfully" exports[`StatsTestCases should print correct stats for module-deduplication-named 1`] = ` "asset e1.js 9.57 KiB [emitted] (name: e1) asset e2.js 9.57 KiB [emitted] (name: e2) -asset e3.js 9.57 KiB [emitted] (name: e3) +asset e3.js 9.56 KiB [emitted] (name: e3) asset async1.js 865 bytes [emitted] (name: async1) asset async2.js 864 bytes [emitted] (name: async2) asset async3.js 864 bytes [emitted] (name: async3) @@ -1322,11 +1322,11 @@ exports[`StatsTestCases should print correct stats for related-assets 1`] = ` "default: assets by path *.br 13.6 KiB asset default-main.js.br 11.7 KiB [emitted] - asset default-main.js.map.br 665 bytes [emitted] + asset default-main.js.map.br 663 bytes [emitted] + 6 assets assets by path *.gz 13.6 KiB asset default-main.js.gz 11.7 KiB [emitted] - asset default-main.js.map.gz 665 bytes [emitted] + asset default-main.js.map.gz 663 bytes [emitted] asset default-chunk_js.js.gz 611 bytes [emitted] + 5 assets assets by path *.js 12.3 KiB @@ -1339,11 +1339,11 @@ exports[`StatsTestCases should print correct stats for related-assets 1`] = ` relatedAssets: assets by path *.br 13.7 KiB asset relatedAssets-main.js.br 11.7 KiB [emitted] - asset relatedAssets-main.js.map.br 671 bytes [emitted] + asset relatedAssets-main.js.map.br 669 bytes [emitted] + 6 assets assets by path *.gz 13.7 KiB asset relatedAssets-main.js.gz 11.7 KiB [emitted] - asset relatedAssets-main.js.map.gz 671 bytes [emitted] + asset relatedAssets-main.js.map.gz 669 bytes [emitted] asset relatedAssets-chunk_js.js.gz 617 bytes [emitted] + 5 assets assets by path *.js 12.3 KiB @@ -1366,11 +1366,11 @@ exclude1: exclude2: assets by path *.br 13.7 KiB asset exclude2-main.js.br 11.7 KiB [emitted] - asset exclude2-main.js.map.br 666 bytes [emitted] + asset exclude2-main.js.map.br 664 bytes [emitted] + 6 assets assets by path *.gz 13.7 KiB asset exclude2-main.js.gz 11.7 KiB [emitted] - asset exclude2-main.js.map.gz 666 bytes [emitted] + asset exclude2-main.js.map.gz 664 bytes [emitted] asset exclude2-chunk_js.js.gz 612 bytes [emitted] + 5 assets assets by path *.js 12.3 KiB @@ -1385,12 +1385,12 @@ exclude3: assets by status 36.8 KiB [emitted] assets by path *.br 12.5 KiB asset exclude3-main.js.br 11.7 KiB [emitted] - asset exclude3-main.js.map.br 666 bytes [emitted] + asset exclude3-main.js.map.br 664 bytes [emitted] asset exclude3-main.css.map.br 171 bytes [emitted] asset exclude3-main.css.br 70 bytes [emitted] assets by path *.gz 12.5 KiB asset exclude3-main.js.gz 11.7 KiB [emitted] - asset exclude3-main.js.map.gz 666 bytes [emitted] + asset exclude3-main.js.map.gz 664 bytes [emitted] asset exclude3-main.css.map.gz 171 bytes [emitted] asset exclude3-main.css.gz 70 bytes [emitted] assets by chunk 11.7 KiB (name: main) @@ -1867,7 +1867,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` default (Rspack x.x.x) compiled successfully all-chunks: - Entrypoint main 9.22 KiB = all-chunks/main.js + Entrypoint main 9.21 KiB = all-chunks/main.js Entrypoint a 8.78 KiB = all-chunks/a.js Entrypoint b 192 bytes = all-chunks/b.js Entrypoint c 192 bytes = all-chunks/c.js @@ -2038,7 +2038,7 @@ name-too-long: name-too-long (Rspack x.x.x) compiled successfully custom-chunks-filter: - Entrypoint main 9.23 KiB = custom-chunks-filter/main.js + Entrypoint main 9.22 KiB = custom-chunks-filter/main.js Entrypoint a 8.79 KiB = custom-chunks-filter/a.js Entrypoint b 192 bytes = custom-chunks-filter/b.js Entrypoint c 192 bytes = custom-chunks-filter/c.js @@ -2294,7 +2294,7 @@ chunk (runtime: main) async-b.js (async-b) 49 bytes <{192}> <{909}> [rendered] > ./b ./index.js 3:0-47 dependent modules 20 bytes [dependent] 1 module ./b.js 29 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 134 bytes (javascript) 8.03 KiB (runtime) ={192}= >{250}< >{262}< [entry] [rendered] +chunk (runtime: main) main.js (main) 134 bytes (javascript) 8.02 KiB (runtime) ={192}= >{250}< >{262}< [entry] [rendered] > ./ main ./index.js 134 bytes [built] [code generated] default (Rspack x.x.x) compiled successfully" @@ -2401,7 +2401,7 @@ chunk (runtime: main) default/457.js (id hint: ) 150 bytes <{909}> ={172}= ={262 > ./c ./index.js 3:0-47 ./d.js 63 bytes [built] [code generated] ./f.js 87 bytes [built] [code generated] -chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.08 KiB (runtime) >{172}< >{250}< >{262}< >{457}< [entry] [rendered] +chunk (runtime: main) default/main.js (main) 147 bytes (javascript) 7.07 KiB (runtime) >{172}< >{250}< >{262}< >{457}< [entry] [rendered] > ./ main ./index.js 147 bytes [built] [code generated] Rspack x.x.x compiled successfully"