From 35e0d38ae88669f8d5b1039d6717af5e42eb135a Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Thu, 4 Jun 2026 13:28:29 +0800 Subject: [PATCH] fix: resolve remote rspack browser split chunk imports --- src/lib/bundle/core.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/bundle/core.ts b/src/lib/bundle/core.ts index 8b1f3fa..541d25e 100644 --- a/src/lib/bundle/core.ts +++ b/src/lib/bundle/core.ts @@ -160,6 +160,19 @@ function replaceRequiredImportSource( ); } +function replaceRemoteRspackRelativeImportSources(source: string, version: string) { + return source.replace( + /\b(from\s*|import\s*)["'](\.\/[^"']+\.(?:mjs|js))["'];?/g, + (match, prefix: string, specifier: string) => { + try { + return `${prefix}${JSON.stringify(getRspackBrowserFileUrl(version, `dist/${specifier.slice(2)}`))};`; + } catch { + return match; + } + }, + ); +} + function hasImportSource(source: string, specifier: string) { return new RegExp(`from\\s*["']${escapeRegExp(specifier)}["'];?`).test(source); } @@ -301,6 +314,7 @@ async function getRspackBrowserEntryUrls(version: string): Promise