From f07aee443dde948b092c98d93e60c56b405b7ca7 Mon Sep 17 00:00:00 2001 From: 2heal1 Date: Mon, 6 Jan 2025 10:58:01 +0800 Subject: [PATCH] chore: update usage --- apps/router-demo/router-remote4-2004/rsbuild.config.ts | 2 +- packages/rspack/package.json | 1 - packages/rspack/src/RemoteEntryPlugin.ts | 5 ++--- pnpm-lock.yaml | 3 --- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/router-demo/router-remote4-2004/rsbuild.config.ts b/apps/router-demo/router-remote4-2004/rsbuild.config.ts index ed6ae4ff1e..6adce577df 100644 --- a/apps/router-demo/router-remote4-2004/rsbuild.config.ts +++ b/apps/router-demo/router-remote4-2004/rsbuild.config.ts @@ -29,7 +29,7 @@ export default defineConfig({ }, shared: ['react', 'react-dom'], // getPublicPath: `return 'http://localhost:2004/'`, - getPublicPath: `function(){return 'http://localhost:2004/'}`, + getPublicPath: `function(originalPublicPath){console.log(originalPublicPath);__webpack_require__.p = 'http://localhost:2004/'}`, }), ], }); diff --git a/packages/rspack/package.json b/packages/rspack/package.json index d68efb3b37..11915c2332 100644 --- a/packages/rspack/package.json +++ b/packages/rspack/package.json @@ -34,7 +34,6 @@ "@module-federation/sdk": "workspace:*" }, "devDependencies": { - "@types/btoa": "1.2.5", "@rspack/core": "^1.0.2" }, "exports": { diff --git a/packages/rspack/src/RemoteEntryPlugin.ts b/packages/rspack/src/RemoteEntryPlugin.ts index 03ebbc5436..984da4918d 100644 --- a/packages/rspack/src/RemoteEntryPlugin.ts +++ b/packages/rspack/src/RemoteEntryPlugin.ts @@ -1,4 +1,5 @@ import type { Compiler, RspackPluginInstance } from '@rspack/core'; +// @ts-ignore import pBtoa from 'btoa'; const charMap: Record = { @@ -39,9 +40,7 @@ export class RemoteEntryPlugin implements RspackPluginInstance { compiler.webpack.RuntimeGlobals.publicPath } = new Function(${JSON.stringify(sanitizedPublicPath)})()`; } else { - code = `${ - compiler.webpack.RuntimeGlobals.publicPath - } = (${sanitizedPublicPath})()`; + code = `(${sanitizedPublicPath}(${compiler.webpack.RuntimeGlobals.publicPath}))`; } const base64Code = pBtoa(code); const dataUrl = `data:text/javascript;base64,${base64Code}`; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8dc0c44af2..60811f9669 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2554,9 +2554,6 @@ importers: '@rspack/core': specifier: ^1.0.2 version: 1.0.8(@swc/helpers@0.5.13) - '@types/btoa': - specifier: 1.2.5 - version: 1.2.5 packages/runtime: dependencies: