Skip to content

Commit a516e39

Browse files
author
ScriptedAlchemy
committed
fix(rstest): apply review fixes to the federation plugin
- default off MF dts/manifest/dev machinery in test builds (explicit user values win) and warn when forcing asyncStartup, library.name, or experiments.optimization.target over explicit user config - use api.context.callerName to warn outside rstest and default the target to browser under the rstest-browser runner (explicit target wins) - export FEDERATION_PLUGIN_NAME as the stable public plugin name - register modifyEnvironmentConfig with order 'post' so the externals bypass stays ahead of other plugins regardless of registration order - sniff federation remotes from duck-typed plugins and cover scoped string remotes (@scope/remote@url) with a regression test
1 parent 940fac8 commit a516e39

9 files changed

Lines changed: 495 additions & 451 deletions

File tree

packages/rstest/src/externals-bypass.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { Rspack } from '@rsbuild/core';
22

33
import { NODE_RUNTIME_PLUGIN } from './runtime-plugin';
44

5+
const DATA_JAVASCRIPT_REQUEST = /!=!data:text\/javascript(?:;|,)/i;
6+
57
const isFederationRemoteRequest = (
68
request: string,
79
remoteNames: Set<string>,
@@ -11,11 +13,16 @@ const isFederationRemoteRequest = (
1113
}
1214

1315
for (const remoteName of remoteNames) {
14-
if (
15-
request === remoteName ||
16-
request.startsWith(`${remoteName}/`) ||
17-
request.startsWith(`${remoteName}@`)
18-
) {
16+
if (request === remoteName) {
17+
return true;
18+
}
19+
20+
if (!request.startsWith(remoteName)) {
21+
continue;
22+
}
23+
24+
const separator = request[remoteName.length];
25+
if (separator === '/' || separator === '@') {
1926
return true;
2027
}
2128
}
@@ -27,7 +34,7 @@ export const shouldKeepBundledForFederation = (
2734
request: string,
2835
remoteNames?: Set<string>,
2936
): boolean => {
30-
if (/!=!data:text\/javascript(?:;|,)/i.test(request)) {
37+
if (DATA_JAVASCRIPT_REQUEST.test(request)) {
3138
return true;
3239
}
3340

0 commit comments

Comments
 (0)