From 8c1e92a1eb8b096be7eb8c23630fe6abf1c95b83 Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Thu, 12 Feb 2026 00:32:18 +0800 Subject: [PATCH] fix(pack): script external loadScript --- crates/pack-core/js/src/umd/runtime-base.ts | 30 +++++++++++++ .../pack-core/js/src/umd/runtime-types.d.ts | 2 + .../async-script-externals/config.json | 13 ++++++ .../async-script-externals/input/index.ts | 6 +++ .../output/_externals____2fc6bb03.js | 25 +++++++++++ .../output/_externals____2fc6bb03.js.map | 5 +++ .../output/_root-of-the-server___fa01a871.js | 25 +++++++++++ .../_root-of-the-server___fa01a871.js.map | 6 +++ .../async-script-externals/output/main.js | 5 +++ .../async-script-externals/output/main.js.map | 5 +++ .../output/_root-of-the-server___3b647096.js | 44 +++++++++++-------- .../_root-of-the-server___3b647096.js.map | 2 +- .../script/output/_externals____2fc6bb03.js | 22 ++++++---- .../snapshot/public_path/basic/output/main.js | 21 +++++++++ .../public_path/basic/output/main.js.map | 6 +-- .../public_path/runtime/output/main.js | 21 +++++++++ .../public_path/runtime/output/main.js.map | 6 +-- .../runtime/app_build_runtime/output/main.js | 21 +++++++++ .../app_build_runtime/output/main.js.map | 6 +-- .../runtime/app_dev_runtime/output/main.js | 21 +++++++++ .../app_dev_runtime/output/main.js.map | 8 ++-- .../export_entry_exports/output/main.js | 21 +++++++++ .../export_entry_exports/output/main.js.map | 6 +-- .../library_build_runtime/output/main.js | 21 +++++++++ .../library_build_runtime/output/main.js.map | 10 ++--- next.js | 2 +- 26 files changed, 310 insertions(+), 50 deletions(-) create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/config.json create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/input/index.ts create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/output/_externals____2fc6bb03.js create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/output/_externals____2fc6bb03.js.map create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/output/_root-of-the-server___fa01a871.js create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/output/_root-of-the-server___fa01a871.js.map create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/output/main.js create mode 100644 crates/pack-tests/tests/snapshot/externals/async-script-externals/output/main.js.map diff --git a/crates/pack-core/js/src/umd/runtime-base.ts b/crates/pack-core/js/src/umd/runtime-base.ts index b72e3435f3..1fce94255c 100644 --- a/crates/pack-core/js/src/umd/runtime-base.ts +++ b/crates/pack-core/js/src/umd/runtime-base.ts @@ -133,6 +133,36 @@ function loadChunkByUrl( } browserContextPrototype.L = loadChunkByUrl; +const loadedScripts = new Map>(); + +/** + * Load an external script by creating a