Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
2c2543c
chore(sdk): migrate to rslib bundleless
ScriptedAlchemy Feb 2, 2026
aba7b69
chore(webpack-bundler-runtime): migrate to rslib bundleless
ScriptedAlchemy Feb 2, 2026
fcabd8d
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 4, 2026
7dcea95
Merge remote-tracking branch 'origin/main' into rslib/webpack-bundler…
ScriptedAlchemy Feb 4, 2026
d0753a9
Merge branch 'main' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 5, 2026
bbef4e6
Merge remote-tracking branch 'origin/main' into rslib/webpack-bundler…
ScriptedAlchemy Feb 5, 2026
46b7d78
Merge branch 'rslib/webpack-bundler-runtime' of github.com:module-fed…
ScriptedAlchemy Feb 5, 2026
36cf2dc
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 5, 2026
d196edf
fix(enhanced): resolve webpack bundler runtime esm entry
ScriptedAlchemy Feb 5, 2026
ffa31b9
fix(enhanced): resolve webpack bundler runtime esm entry
ScriptedAlchemy Feb 5, 2026
54e19b9
fix(runtime-core): avoid static sdk loadScriptNode export usage
ScriptedAlchemy Feb 6, 2026
25130d2
fix(enhanced,error-codes): resolve runtime paths and browser url fall…
ScriptedAlchemy Feb 6, 2026
d956a53
fix(runtime): add cjs helper interop and browser url fallback
ScriptedAlchemy Feb 6, 2026
c51392a
fix(sdk): add browser fallback for node url module
ScriptedAlchemy Feb 6, 2026
ed6805e
fix(runtime): add cjs helper interop and browser url fallback
ScriptedAlchemy Feb 6, 2026
3c05e1b
fix(sdk): add browser fallback for node url module
ScriptedAlchemy Feb 6, 2026
dd29fb2
fix(enhanced,error-codes): resolve runtime paths and browser url fall…
ScriptedAlchemy Feb 6, 2026
380ced4
fix(sdk): explicitly re-export utils at package root
ScriptedAlchemy Feb 6, 2026
0990896
fix(webpack-bundler-runtime): disable cjs import.meta url shim
ScriptedAlchemy Feb 6, 2026
e0d6d97
fix(webpack-bundler-runtime): disable cjs import.meta url shim
ScriptedAlchemy Feb 6, 2026
ed4adee
fix(runtime-tools): normalize webpack bundler runtime cjs interop
ScriptedAlchemy Feb 6, 2026
5dd27cf
fix(runtime-tools): normalize webpack bundler runtime cjs interop
ScriptedAlchemy Feb 6, 2026
b44f08a
fix(runtime-tools): avoid browser url polyfill resolution
ScriptedAlchemy Feb 6, 2026
9e8bd9e
fix(runtime-tools): avoid browser url polyfill resolution
ScriptedAlchemy Feb 6, 2026
94c4f51
test(chrome-devtools): stabilize proxy e2e against internal snapshot …
ScriptedAlchemy Feb 6, 2026
92bb824
test(chrome-devtools): stabilize proxy e2e against internal snapshot …
ScriptedAlchemy Feb 6, 2026
087bd71
test(chrome-devtools): wait for manifest requests before proxy assert…
ScriptedAlchemy Feb 6, 2026
c3564a7
test(chrome-devtools): wait for manifest requests before proxy assert…
ScriptedAlchemy Feb 6, 2026
267e0bd
test(chrome-devtools): remove flaky baseline proxy assertion
ScriptedAlchemy Feb 6, 2026
7d93f98
test(chrome-devtools): remove flaky baseline proxy assertion
ScriptedAlchemy Feb 6, 2026
709394f
fix(chrome-devtools): accept query params in proxy manifest checks
ScriptedAlchemy Feb 6, 2026
7f835ac
fix(chrome-devtools): stabilize proxy e2e via matchedVersion
ScriptedAlchemy Feb 6, 2026
4da543b
fix(module-federation): disable npm workspaces in actionlint
ScriptedAlchemy Feb 6, 2026
1f045d4
fix(module-federation): run actionlint outside monorepo root
ScriptedAlchemy Feb 6, 2026
42facbb
fix(module-federation): run actionlint via official container
ScriptedAlchemy Feb 6, 2026
225c614
fix(core): restore esm runtime resolution and devtools proxy test
ScriptedAlchemy Feb 6, 2026
56250c2
fix(enhanced): resolve runtime entries across rslib output layouts
ScriptedAlchemy Feb 6, 2026
f4b8ede
fix(chrome-devtools): drop flaky initial proxy assertion
ScriptedAlchemy Feb 6, 2026
7216517
fix(inject-external-runtime-core-plugin): import runtime core directly
ScriptedAlchemy Feb 6, 2026
974c8a1
fix(inject-external-runtime-core-plugin): avoid lockfile drift in ci
ScriptedAlchemy Feb 6, 2026
193712a
fix(inject-external-runtime-core-plugin): load runtime core from esm …
ScriptedAlchemy Feb 6, 2026
fc59e55
fix(core): stabilize devtools proxy and runtime-core import
ScriptedAlchemy Feb 6, 2026
98eb82d
Merge branch 'main' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 6, 2026
b29b184
fix(core): run actionlint in container
ScriptedAlchemy Feb 6, 2026
cbd1f5f
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 6, 2026
ad48be1
Merge remote-tracking branch 'origin/main' into rslib/webpack-bundler…
ScriptedAlchemy Feb 7, 2026
f5ef4a4
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 7, 2026
f11afc7
fix(core): use direct actionlint binary install instead of raven-actions
ScriptedAlchemy Feb 7, 2026
1844fa9
fix(core): use direct actionlint binary install instead of raven-actions
ScriptedAlchemy Feb 7, 2026
e3953d2
fix(manifest-webpack-host): disable react refresh in demo e2e
ScriptedAlchemy Feb 7, 2026
aa8ea63
chore(runtime-tools): migrate to rslib bundleless
ScriptedAlchemy Feb 2, 2026
b3e4ecc
fix(enhanced): resolve webpack bundler runtime esm entry
ScriptedAlchemy Feb 5, 2026
5c7aa89
fix(runtime): add cjs helper interop and browser url fallback
ScriptedAlchemy Feb 6, 2026
d2254b6
fix(sdk): add browser fallback for node url module
ScriptedAlchemy Feb 6, 2026
27ef74d
fix(enhanced,error-codes): resolve runtime paths and browser url fall…
ScriptedAlchemy Feb 6, 2026
2d73c2b
fix(webpack-bundler-runtime): disable cjs import.meta url shim
ScriptedAlchemy Feb 6, 2026
6a6b5c3
fix(runtime-tools): normalize webpack bundler runtime cjs interop
ScriptedAlchemy Feb 6, 2026
bfc973a
fix(runtime-tools): avoid browser url polyfill resolution
ScriptedAlchemy Feb 6, 2026
619369e
test(chrome-devtools): stabilize proxy e2e against internal snapshot …
ScriptedAlchemy Feb 6, 2026
37284eb
test(chrome-devtools): wait for manifest requests before proxy assert…
ScriptedAlchemy Feb 6, 2026
71f9758
test(chrome-devtools): remove flaky baseline proxy assertion
ScriptedAlchemy Feb 6, 2026
0454442
fix(chrome-devtools): accept query params in proxy manifest checks
ScriptedAlchemy Feb 6, 2026
2f5960c
fix(chrome-devtools): stabilize proxy e2e via matchedVersion
ScriptedAlchemy Feb 6, 2026
c13d0c0
fix(module-federation): disable npm workspaces in actionlint
ScriptedAlchemy Feb 6, 2026
58c10af
fix(module-federation): run actionlint outside monorepo root
ScriptedAlchemy Feb 6, 2026
501eab4
fix(module-federation): run actionlint via official container
ScriptedAlchemy Feb 6, 2026
4901bed
fix(core): restore esm runtime resolution and devtools proxy test
ScriptedAlchemy Feb 6, 2026
0a775a9
fix(enhanced): resolve runtime entries across rslib output layouts
ScriptedAlchemy Feb 6, 2026
2cf11e5
fix(chrome-devtools): drop flaky initial proxy assertion
ScriptedAlchemy Feb 6, 2026
3d1bc04
fix(inject-external-runtime-core-plugin): import runtime core directly
ScriptedAlchemy Feb 6, 2026
b0c612a
fix(inject-external-runtime-core-plugin): avoid lockfile drift in ci
ScriptedAlchemy Feb 6, 2026
8b6835c
fix(inject-external-runtime-core-plugin): load runtime core from esm …
ScriptedAlchemy Feb 6, 2026
f9887dd
fix(core): stabilize devtools proxy and runtime-core import
ScriptedAlchemy Feb 6, 2026
261d126
fix(core): harden devtools proxy and runtime-core guard
ScriptedAlchemy Feb 6, 2026
914fcc3
fix(chrome-devtools): remove flaky matched-version assert
ScriptedAlchemy Feb 6, 2026
ca4ff51
fix(core): use direct actionlint binary install instead of raven-actions
ScriptedAlchemy Feb 7, 2026
af1900f
CI pipeline issues (#4384)
ScriptedAlchemy Feb 8, 2026
9ee06cd
fix(inject-external-runtime-core-plugin): avoid default import of run…
ScriptedAlchemy Feb 8, 2026
7cbb861
Merge remote-tracking branch 'origin/main' into HEAD
ScriptedAlchemy Feb 8, 2026
ca4cb45
Merge remote-tracking branch 'origin/main' into HEAD
ScriptedAlchemy Feb 8, 2026
495a029
Merge branch 'main' into rslib/runtime-tools
ScriptedAlchemy Feb 8, 2026
a7784f8
fix(inject-external-runtime-core-plugin): import runtime-core esm file
ScriptedAlchemy Feb 9, 2026
bc4d23c
Merge branch 'main' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 9, 2026
9a49071
Merge branch 'rslib/webpack-bundler-runtime' of github.com:module-fed…
ScriptedAlchemy Feb 9, 2026
2d134dd
Merge branch 'main' into rslib/sdk
ScriptedAlchemy Feb 9, 2026
d309b48
Merge branch 'rslib/sdk' of github.com:module-federation/core into rs…
ScriptedAlchemy Feb 9, 2026
6a1fd63
Merge remote-tracking branch 'origin/main' into rslib/runtime-tools
ScriptedAlchemy Feb 9, 2026
a977cdb
Merge remote-tracking branch 'origin/main' into rslib/webpack-bundler…
ScriptedAlchemy Feb 9, 2026
cf1bf56
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 9, 2026
37f73e6
Merge remote-tracking branch 'origin/main' into rslib/runtime-tools
ScriptedAlchemy Feb 9, 2026
e3ea194
fix(enhanced): reduce fallback build races
ScriptedAlchemy Feb 9, 2026
3ff8646
fix(runtime-tools): avoid false-fail on treeshake CI skip
ScriptedAlchemy Feb 9, 2026
7042513
fix(runtime-tools): align CI gating and runtime compatibility
ScriptedAlchemy Feb 10, 2026
2387512
fix(sdk): align runtime compatibility defaults
ScriptedAlchemy Feb 10, 2026
48cc641
fix(webpack-bundler-runtime): align runtime compatibility defaults
ScriptedAlchemy Feb 10, 2026
7772e4b
fix(runtime-tools): restore browser url alias for web bundles
ScriptedAlchemy Feb 10, 2026
3b245f4
fix(webpack-bundler-runtime): restore browser url alias
ScriptedAlchemy Feb 10, 2026
617edf5
fix(webpack-bundler-runtime): keep default-only entry export shape
ScriptedAlchemy Feb 10, 2026
6f12385
fix(webpack-bundler-runtime): restore cjs interop named exports
ScriptedAlchemy Feb 10, 2026
c370ca6
fix(webpack-bundler-runtime): route require/main to stable js entry
ScriptedAlchemy Feb 10, 2026
fe505ca
Merge remote-tracking branch 'origin/main' into rslib/webpack-bundler…
ScriptedAlchemy Feb 12, 2026
911175e
chore(core): add changeset coverage for pr #4358
ScriptedAlchemy Feb 12, 2026
14172b1
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 12, 2026
2e722ba
chore(core): add changeset coverage for pr #4356
ScriptedAlchemy Feb 12, 2026
889f703
Merge remote-tracking branch 'origin/main' into rslib/runtime-tools
ScriptedAlchemy Feb 12, 2026
edc5ba7
chore(core): add changeset coverage for pr #4355
ScriptedAlchemy Feb 12, 2026
60710c9
chore(core): add contextual changeset for rslib runtime migration
ScriptedAlchemy Feb 12, 2026
5d00fae
chore(sdk): add contextual changeset for rslib migration
ScriptedAlchemy Feb 12, 2026
d6bdbe3
chore(runtime-tools): add contextual changeset for rslib migration
ScriptedAlchemy Feb 12, 2026
79d9481
Merge remote-tracking branch 'origin/main' into rslib/webpack-bundler…
ScriptedAlchemy Feb 14, 2026
b21999b
Merge remote-tracking branch 'origin/main' into rslib/runtime-tools
ScriptedAlchemy Feb 14, 2026
bf20eab
Merge remote-tracking branch 'origin/main' into rslib/sdk
ScriptedAlchemy Feb 14, 2026
6923a54
Merge branch 'main' into rslib/runtime-tools
ScriptedAlchemy Feb 14, 2026
7e94f49
Merge branch 'main' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 14, 2026
69201d9
Merge branch 'main' into rslib/sdk
ScriptedAlchemy Feb 14, 2026
9b1ef87
fix(inject-external-runtime-core-plugin): fix runtimeCore import conf…
ScriptedAlchemy Feb 15, 2026
1723141
fix(enhanced): resolve runtime dist index.js output names
ScriptedAlchemy Feb 15, 2026
bfd91b6
chore(runtime-core): align share export helper import paths
ScriptedAlchemy Feb 15, 2026
ecd9ee2
chore(runtime-core): align share export helper import paths
ScriptedAlchemy Feb 15, 2026
b7f936d
chore(runtime-core): align share export helper import paths
ScriptedAlchemy Feb 15, 2026
5ab6330
Merge branch 'rslib/runtime' into rslib/sdk
ScriptedAlchemy Feb 15, 2026
a21b555
chore(3009-webpack-provider): remove react refresh disable workaround
ScriptedAlchemy Feb 15, 2026
12972c3
Merge branch 'rslib/sdk' into rslib/runtime-tools
ScriptedAlchemy Feb 15, 2026
3c39c53
Merge branch 'rslib/runtime-tools' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 15, 2026
c8a9fc4
Merge branch 'rslib/runtime' into rslib/sdk
ScriptedAlchemy Feb 15, 2026
61dffd3
chore(sdk): add rslib publint plugin
ScriptedAlchemy Feb 15, 2026
1227a58
Merge branch 'rslib/sdk' into rslib/runtime-tools
ScriptedAlchemy Feb 15, 2026
fc8137e
chore(runtime-tools): add rslib publint plugin
ScriptedAlchemy Feb 15, 2026
fc9f036
Merge branch 'rslib/runtime-tools' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 15, 2026
424dfdc
chore(webpack-bundler-runtime): add rslib publint plugin
ScriptedAlchemy Feb 15, 2026
9392b11
Merge branch 'rslib/runtime' into rslib/sdk
ScriptedAlchemy Feb 15, 2026
17cd045
Merge branch 'rslib/sdk' into rslib/runtime-tools
ScriptedAlchemy Feb 15, 2026
8b57455
Merge branch 'rslib/runtime-tools' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 15, 2026
012fb00
fix(node): type beforeInit args in runtime plugin
ScriptedAlchemy Feb 15, 2026
ad59b45
Merge branch 'rslib/runtime' into rslib/sdk
ScriptedAlchemy Feb 16, 2026
7270391
Merge branch 'rslib/sdk' into rslib/runtime-tools
ScriptedAlchemy Feb 16, 2026
e4a5fc9
Merge branch 'rslib/runtime-tools' into rslib/webpack-bundler-runtime
ScriptedAlchemy Feb 16, 2026
8d1fecd
fix(node): type runtime plugin beforeInit args
ScriptedAlchemy Feb 16, 2026
28d9c26
Merge remote-tracking branch 'origin/rslib/webpack-bundler-runtime' i…
ScriptedAlchemy Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/loud-elephants-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@module-federation/enhanced': patch
'@module-federation/inject-external-runtime-core-plugin': patch
'@module-federation/webpack-bundler-runtime': patch
---

Migrate webpack-bundler-runtime packaging to rslib bundleless outputs and align related enhanced/runtime plugin integration metadata.
6 changes: 6 additions & 0 deletions .changeset/tall-seals-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@module-federation/inject-external-runtime-core-plugin': patch
'@module-federation/runtime-tools': patch
---

Migrate runtime-tools to rslib bundleless output and align external runtime-core plugin integration for the new build layout.
6 changes: 6 additions & 0 deletions .changeset/wet-carpets-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@module-federation/runtime-core': patch
'@module-federation/sdk': patch
---

Migrate SDK packaging to rslib bundleless and update runtime-core SDK imports to safely resolve optional `loadScriptNode` exports in Node paths.
7 changes: 1 addition & 6 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@ jobs:
shell: bash

- name: Run actionlint
uses: raven-actions/actionlint@v2
env:
NODE_PATH: ${{ runner.temp }}/node_modules
with:
matcher: true
working-directory: ${{ runner.temp }}
run: ./actionlint -color
30 changes: 30 additions & 0 deletions apps/manifest-demo/webpack-host/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,36 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => {
p._options.library = undefined;
}
});

// React Refresh (Fast Refresh) injects runtime hooks into every processed JS module.
// Our workspace packages ship pre-bundled CJS outputs that contain nested webpack runtimes
// (for example `packages/sdk/dist/index.cjs`). When those files are instrumented, the injected
// code can crash at runtime with:
// "Cannot set properties of undefined (setting 'runtime')"
// This breaks Cypress e2e that load the manifest host (port 3013).
//
// We don't rely on Fast Refresh for this demo host, so drop both the webpack plugin and the
// `react-refresh/babel` transform to keep e2e stable.
config.plugins = (config.plugins || []).filter((p) => {
const name = p?.constructor?.name;
return !name || !name.includes('ReactRefresh');
});

const babelLoader = (config.module?.rules || []).find(
(rule) =>
rule &&
typeof rule !== 'string' &&
rule.loader?.toString().includes('babel-loader'),
);
if (babelLoader && typeof babelLoader !== 'string') {
babelLoader.options = babelLoader.options || {};
const plugins = babelLoader.options.plugins || [];
babelLoader.options.plugins = plugins.filter((plugin) => {
const id = Array.isArray(plugin) ? plugin[0] : plugin;
return !(typeof id === 'string' && id.includes('react-refresh/babel'));
});
}

if (config.devServer) {
config.devServer.client.overlay = false;
config.devServer.devMiddleware.writeToDisk = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const RuntimePath = resolveModule(
[
'@module-federation/runtime/dist/index.esm.js',
'@module-federation/runtime',
'@module-federation/runtime/dist/index.js',
'@module-federation/runtime/dist/index.cjs.cjs',
],
{
Expand Down Expand Up @@ -397,6 +398,7 @@ class FederationRuntimePlugin {
[
'@module-federation/runtime/dist/index.esm.js',
'@module-federation/runtime',
'@module-federation/runtime/dist/index.js',
'@module-federation/runtime/dist/index.cjs.cjs',
],
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,35 +246,58 @@ export default class IndependentSharedPlugin {
if (!shareConfig.treeShaking) {
return;
}
const shareRequests = shareRequestsMap[shareName].requests;
await Promise.all(
shareRequests.map(async ([request, version]) => {
const sharedConfig = sharedOptions.find(
([name]) => name === shareName,
)?.[1];
const [shareFileName, globalName, sharedVersion] =
await this.createIndependentCompiler(parentCompiler, {
shareRequestsMap,
currentShare: {
shareName,
version,
request,
independentShareFileName: sharedConfig?.treeShaking?.filename,
},
});
if (typeof shareFileName === 'string') {
this.buildAssets[shareName] ||= [];
this.buildAssets[shareName].push([
path.join(
resolveOutputDir(outputDir, shareName),
shareFileName,
),
sharedVersion,
globalName,
]);
}
}),

const shareRequests = shareRequestsMap[shareName]?.requests || [];
if (!shareRequests.length) {
return;
}

// De-dupe identical (request, version) pairs. Duplicate requests can
// happen when a package is both directly imported and also imported by
// another shared package.
const seen = new Set<string>();
const uniqueShareRequests: [string, string][] = [];
for (const [request, version] of shareRequests) {
const key = `${version}@@${request}`;
if (seen.has(key)) continue;
seen.add(key);
uniqueShareRequests.push([request, version]);
}

// Ensure we don't keep stale outputs for this share across builds.
// Each request/version compilation emits into `${version}/...` under this
// directory, so we clean once per shareName, and keep per-compiler
// `output.clean` disabled to avoid inter-compiler races.
const fullShareOutputDir = path.resolve(
parentCompiler.outputPath,
resolveOutputDir(outputDir, shareName),
);
try {
fs.rmSync(fullShareOutputDir, { recursive: true, force: true });
} catch {
// ignore
}

for (const [request, version] of uniqueShareRequests) {
const [shareFileName, globalName, sharedVersion] =
await this.createIndependentCompiler(parentCompiler, {
shareRequestsMap,
currentShare: {
shareName,
version,
request,
independentShareFileName: shareConfig?.treeShaking?.filename,
},
});
if (typeof shareFileName === 'string') {
this.buildAssets[shareName] ||= [];
this.buildAssets[shareName].push([
path.join(resolveOutputDir(outputDir, shareName), shareFileName),
sharedVersion,
globalName,
]);
}
}
}),
);

Expand Down Expand Up @@ -379,7 +402,11 @@ export default class IndependentSharedPlugin {
// 输出配置
output: {
path: fullOutputDir,
clean: true,
// For the initial "collector" compilation we want a clean directory.
// For per-share compilations, avoid cleaning the whole output directory
// on every compiler run to prevent deleting outputs produced by other
// (possibly concurrent) share builds.
clean: !extraOptions,
publicPath: parentConfig.output?.publicPath || 'auto',
},

Expand Down
6 changes: 5 additions & 1 deletion packages/node/src/runtimePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type {
ModuleFederationRuntimePlugin,
ModuleFederation,
} from '@module-federation/runtime';

type BeforeInitArgs = Parameters<
Parameters<ModuleFederation['hooks']['lifecycle']['beforeInit']['on']>[0]
>[0];
type WebpackRequire = {
(id: string): any;
u: (chunkId: string) => string;
Expand Down Expand Up @@ -377,7 +381,7 @@ export const setupWebpackRequirePatching = (
export default function (): ModuleFederationRuntimePlugin {
return {
name: 'node-federation-plugin',
beforeInit(args) {
beforeInit(args: BeforeInitArgs) {
// Patch webpack chunk loading handlers
(() => {
// Create the chunk tracking object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"main": "./dist/index.cjs.cjs",
"module": "./dist/index.esm.js",
"types": "./dist/index.cjs.d.ts",
"browser": {
"url": false
},
"exports": {
".": {
"types": "./dist/index.cjs.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import runtimeCoreDefault, * as runtimeCoreNamespace from '@module-federation/runtime-tools/runtime-core';
import * as runtimeCore from '@module-federation/runtime-tools/dist/runtime-core.js';

import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime-tools/runtime-core';
const runtimeCore =
(runtimeCoreDefault as typeof runtimeCoreNamespace | undefined) ??
runtimeCoreNamespace;
declare global {
var __VERSION__: string;
var _FEDERATION_RUNTIME_CORE: typeof runtimeCore;
Expand All @@ -18,16 +15,16 @@ function injectExternalRuntimeCorePlugin(): ModuleFederationRuntimePlugin {
name: 'inject-external-runtime-core-plugin',
version: __VERSION__,
beforeInit(args) {
const globalRef = (
runtimeCore as typeof runtimeCore & {
Global?: typeof runtimeCore.Global;
}
).Global;
if (!globalRef || typeof globalRef !== 'object') {
return args;
}
const name = args.options.name;
const version = __VERSION__;

// Use the real host global rather than runtimeCore.Global, since Global can be
// missing (tree-shaken/re-export-only) or be a sandboxed view in some MF setups.
const globalRef = globalThis as typeof globalThis & {
_FEDERATION_RUNTIME_CORE?: typeof runtimeCore;
_FEDERATION_RUNTIME_CORE_FROM?: { version: string; name: string };
};

if (
globalRef._FEDERATION_RUNTIME_CORE &&
globalRef._FEDERATION_RUNTIME_CORE_FROM &&
Expand Down
23 changes: 13 additions & 10 deletions packages/runtime-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"version": "2.0.1",
"type": "module",
"author": "zhanghang <hanric.zhang@gmail.com>",
"main": "./dist/index.cjs.cjs",
"module": "./dist/index.esm.js",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"browser": {
"url": false
},
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -23,41 +26,41 @@
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.esm.js"
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs.cjs"
"default": "./dist/index.cjs"
}
},
"./runtime": {
"import": {
"types": "./dist/runtime.d.ts",
"default": "./dist/runtime.esm.js"
"default": "./dist/runtime.js"
},
"require": {
"types": "./dist/runtime.d.ts",
"default": "./dist/runtime.cjs.cjs"
"default": "./dist/runtime.cjs"
}
},
"./runtime-core": {
"import": {
"types": "./dist/runtime-core.d.ts",
"default": "./dist/runtime-core.esm.js"
"default": "./dist/runtime-core.js"
},
"require": {
"types": "./dist/runtime-core.d.ts",
"default": "./dist/runtime-core.cjs.cjs"
"default": "./dist/runtime-core.cjs"
}
},
"./webpack-bundler-runtime": {
"import": {
"types": "./dist/webpack-bundler-runtime.d.ts",
"default": "./dist/webpack-bundler-runtime.esm.js"
"default": "./dist/webpack-bundler-runtime.js"
},
"require": {
"types": "./dist/webpack-bundler-runtime.d.ts",
"default": "./dist/webpack-bundler-runtime.cjs.cjs"
"default": "./dist/webpack-bundler-runtime.cjs"
}
},
"./*": "./*"
Expand Down
20 changes: 3 additions & 17 deletions packages/runtime-tools/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,11 @@
"tags": ["type:pkg"],
"targets": {
"build": {
"executor": "@nx/rollup:rollup",
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/packages/runtime-tools/dist"],
"options": {
"parallel": false,
"outputPath": "packages/runtime-tools/dist",
"main": "packages/runtime-tools/src/index.ts",
"additionalEntryPoints": [
"packages/runtime-tools/src/runtime.ts",
"packages/runtime-tools/src/webpack-bundler-runtime.ts"
],
"tsConfig": "packages/runtime-tools/tsconfig.lib.json",
"assets": [],
"project": "packages/runtime-tools/package.json",
"compiler": "tsc",
"rollupConfig": "packages/runtime-tools/rollup.config.cjs",
"format": ["cjs", "esm"],
"external": ["@module-federation/*"],
"generatePackageJson": false,
"useLegacyTypescriptPlugin": false
"command": "rslib build",
"cwd": "packages/runtime-tools"
},
"dependsOn": [
{
Expand Down
49 changes: 49 additions & 0 deletions packages/runtime-tools/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { defineConfig } from '@rslib/core';
import { pluginPublint } from 'rsbuild-plugin-publint';

export default defineConfig({
plugins: [pluginPublint()],
lib: [
{
format: 'esm',
syntax: 'es2021',
bundle: false,
outBase: 'src',
dts: {
bundle: false,
distPath: './dist',
},
},
{
format: 'cjs',
syntax: 'es2021',
bundle: false,
outBase: 'src',
dts: false,
},
],
source: {
entry: {
index: [
'./src/**/*.{ts,tsx,js,jsx}',
'!./src/**/*.spec.*',
'!./src/**/*.test.*',
],
},
tsconfigPath: './tsconfig.lib.json',
},
output: {
target: 'node',
minify: false,
distPath: {
root: './dist',
},
externals: [/@module-federation\//],
copy: [
{
from: './LICENSE',
to: '.',
},
],
},
});
Loading
Loading