@module-federation/rspack 0.0.0-feat-support-bridge-react-router-v7-20251015102312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/LICENSE +21 -0
- package/dist/RemoteEntryPlugin.cjs.js +70 -0
- package/dist/RemoteEntryPlugin.cjs.js.map +1 -0
- package/dist/RemoteEntryPlugin.esm.mjs +67 -0
- package/dist/RemoteEntryPlugin.esm.mjs.map +1 -0
- package/dist/index.cjs.js +13 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.d.ts +1 -0
- package/dist/index.esm.mjs +8 -0
- package/dist/index.esm.mjs.map +1 -0
- package/dist/plugin.cjs.js +253 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.esm.d.ts +1 -0
- package/dist/plugin.esm.mjs +249 -0
- package/dist/plugin.esm.mjs.map +1 -0
- package/dist/remote-entry-plugin.cjs.js +10 -0
- package/dist/remote-entry-plugin.cjs.js.map +1 -0
- package/dist/remote-entry-plugin.d.ts +1 -0
- package/dist/remote-entry-plugin.esm.d.ts +1 -0
- package/dist/remote-entry-plugin.esm.mjs +4 -0
- package/dist/remote-entry-plugin.esm.mjs.map +1 -0
- package/dist/src/ModuleFederationPlugin.d.ts +16 -0
- package/dist/src/RemoteEntryPlugin.d.ts +9 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/logger.d.ts +3 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present hanric(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# `@module-federation/rspack` Documentation
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present hanric(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pBtoa = require('btoa');
|
|
4
|
+
var managers = require('@module-federation/managers');
|
|
5
|
+
var sdk = require('@module-federation/sdk');
|
|
6
|
+
|
|
7
|
+
const isLoggerFactory = (candidate) => typeof candidate === 'function';
|
|
8
|
+
const createBundlerLogger = isLoggerFactory(sdk.createInfrastructureLogger)
|
|
9
|
+
? (prefix) => sdk.createInfrastructureLogger(prefix)
|
|
10
|
+
: sdk.createLogger;
|
|
11
|
+
const logger = createBundlerLogger('[ Module Federation Rspack Plugin ]');
|
|
12
|
+
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const charMap = {
|
|
15
|
+
'<': '\\u003C',
|
|
16
|
+
'>': '\\u003E',
|
|
17
|
+
'/': '\\u002F',
|
|
18
|
+
'\\': '\\\\',
|
|
19
|
+
'\b': '\\b',
|
|
20
|
+
'\f': '\\f',
|
|
21
|
+
'\n': '\\n',
|
|
22
|
+
'\r': '\\r',
|
|
23
|
+
'\t': '\\t',
|
|
24
|
+
'\0': '\\0',
|
|
25
|
+
'\u2028': '\\u2028',
|
|
26
|
+
'\u2029': '\\u2029',
|
|
27
|
+
};
|
|
28
|
+
function escapeUnsafeChars(str) {
|
|
29
|
+
return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g, (x) => charMap[x]);
|
|
30
|
+
}
|
|
31
|
+
class RemoteEntryPlugin {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
this.name = 'VmokRemoteEntryPlugin';
|
|
34
|
+
this._options = options;
|
|
35
|
+
}
|
|
36
|
+
static addPublicPathEntry(compiler, getPublicPath, name) {
|
|
37
|
+
let code;
|
|
38
|
+
const sanitizedPublicPath = escapeUnsafeChars(getPublicPath);
|
|
39
|
+
if (!getPublicPath.startsWith('function')) {
|
|
40
|
+
code = `${compiler.webpack.RuntimeGlobals.publicPath} = new Function(${JSON.stringify(sanitizedPublicPath)})()`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
code = `(${sanitizedPublicPath}())`;
|
|
44
|
+
}
|
|
45
|
+
const base64Code = pBtoa(code);
|
|
46
|
+
const dataUrl = `data:text/javascript;base64,${base64Code}`;
|
|
47
|
+
compiler.hooks.afterPlugins.tap('VmokRemoteEntryPlugin', () => {
|
|
48
|
+
new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {
|
|
49
|
+
name: name,
|
|
50
|
+
}).apply(compiler);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
apply(compiler) {
|
|
54
|
+
const { name, getPublicPath } = this._options;
|
|
55
|
+
if (!getPublicPath || !name) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const containerManager = new managers.ContainerManager();
|
|
59
|
+
containerManager.init(this._options);
|
|
60
|
+
if (!containerManager.enable) {
|
|
61
|
+
logger.warn("Detect you don't set exposes, 'getPublicPath' will not have effect.");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
RemoteEntryPlugin.addPublicPathEntry(compiler, getPublicPath, name);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.RemoteEntryPlugin = RemoteEntryPlugin;
|
|
69
|
+
exports.logger = logger;
|
|
70
|
+
//# sourceMappingURL=RemoteEntryPlugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteEntryPlugin.cjs.js","sources":["../../src/logger.ts","../../src/RemoteEntryPlugin.ts"],"sourcesContent":[null,null],"names":["createInfrastructureLogger","createLogger","ContainerManager"],"mappings":";;;;;;AAQA,MAAM,eAAe,GAAG,CAAC,SAAkB,KACzC,OAAO,SAAS,KAAK,UAAU;AAEjC,MAAM,mBAAmB,GAAkB,eAAe,CACxDA,8BAA0B;MAExB,CAAC,MAAM,KAAKA,8BAA0B,CAAC,MAAM;MAC7CC,gBAAY;AAEhB,MAAM,MAAM,GAAG,mBAAmB,CAAC,qCAAqC;;ACXxE;AAEA,MAAM,OAAO,GAA2B;AACtC,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,QAAQ,EAAE,SAAS;AACnB,IAAA,QAAQ,EAAE,SAAS;CACpB;AAED,SAAS,iBAAiB,CAAC,GAAW,EAAA;AACpC,IAAA,OAAO,GAAG,CAAC,OAAO,CAAC,iCAAiC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1E;MAEa,iBAAiB,CAAA;AAI5B,IAAA,WAAA,CAAY,OAA6D,EAAA;QAHhE,IAAI,CAAA,IAAA,GAAG,uBAAuB;AAIrC,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;AAGzB,IAAA,OAAO,kBAAkB,CACvB,QAAkB,EAClB,aAAqB,EACrB,IAAY,EAAA;AAEZ,QAAA,IAAI,IAAI;AACR,QAAA,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,aAAa,CAAC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-federation/managers';
|
|
3
|
+
import { createInfrastructureLogger, createLogger } from '@module-federation/sdk';
|
|
4
|
+
|
|
5
|
+
const isLoggerFactory = (candidate) => typeof candidate === 'function';
|
|
6
|
+
const createBundlerLogger = isLoggerFactory(createInfrastructureLogger)
|
|
7
|
+
? (prefix) => createInfrastructureLogger(prefix)
|
|
8
|
+
: createLogger;
|
|
9
|
+
const logger = createBundlerLogger('[ Module Federation Rspack Plugin ]');
|
|
10
|
+
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
const charMap = {
|
|
13
|
+
'<': '\\u003C',
|
|
14
|
+
'>': '\\u003E',
|
|
15
|
+
'/': '\\u002F',
|
|
16
|
+
'\\': '\\\\',
|
|
17
|
+
'\b': '\\b',
|
|
18
|
+
'\f': '\\f',
|
|
19
|
+
'\n': '\\n',
|
|
20
|
+
'\r': '\\r',
|
|
21
|
+
'\t': '\\t',
|
|
22
|
+
'\0': '\\0',
|
|
23
|
+
'\u2028': '\\u2028',
|
|
24
|
+
'\u2029': '\\u2029',
|
|
25
|
+
};
|
|
26
|
+
function escapeUnsafeChars(str) {
|
|
27
|
+
return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g, (x) => charMap[x]);
|
|
28
|
+
}
|
|
29
|
+
class RemoteEntryPlugin {
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.name = 'VmokRemoteEntryPlugin';
|
|
32
|
+
this._options = options;
|
|
33
|
+
}
|
|
34
|
+
static addPublicPathEntry(compiler, getPublicPath, name) {
|
|
35
|
+
let code;
|
|
36
|
+
const sanitizedPublicPath = escapeUnsafeChars(getPublicPath);
|
|
37
|
+
if (!getPublicPath.startsWith('function')) {
|
|
38
|
+
code = `${compiler.webpack.RuntimeGlobals.publicPath} = new Function(${JSON.stringify(sanitizedPublicPath)})()`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
code = `(${sanitizedPublicPath}())`;
|
|
42
|
+
}
|
|
43
|
+
const base64Code = pBtoa(code);
|
|
44
|
+
const dataUrl = `data:text/javascript;base64,${base64Code}`;
|
|
45
|
+
compiler.hooks.afterPlugins.tap('VmokRemoteEntryPlugin', () => {
|
|
46
|
+
new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {
|
|
47
|
+
name: name,
|
|
48
|
+
}).apply(compiler);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
apply(compiler) {
|
|
52
|
+
const { name, getPublicPath } = this._options;
|
|
53
|
+
if (!getPublicPath || !name) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const containerManager = new ContainerManager();
|
|
57
|
+
containerManager.init(this._options);
|
|
58
|
+
if (!containerManager.enable) {
|
|
59
|
+
logger.warn("Detect you don't set exposes, 'getPublicPath' will not have effect.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
RemoteEntryPlugin.addPublicPathEntry(compiler, getPublicPath, name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { RemoteEntryPlugin as R, logger as l };
|
|
67
|
+
//# sourceMappingURL=RemoteEntryPlugin.esm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteEntryPlugin.esm.mjs","sources":["../../src/logger.ts","../../src/RemoteEntryPlugin.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;AAQA,MAAM,eAAe,GAAG,CAAC,SAAkB,KACzC,OAAO,SAAS,KAAK,UAAU;AAEjC,MAAM,mBAAmB,GAAkB,eAAe,CACxD,0BAA0B;MAExB,CAAC,MAAM,KAAK,0BAA0B,CAAC,MAAM;MAC7C,YAAY;AAEhB,MAAM,MAAM,GAAG,mBAAmB,CAAC,qCAAqC;;ACXxE;AAEA,MAAM,OAAO,GAA2B;AACtC,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,KAAK;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BAAA,IAAI,EAAE,IAAI;AACX,aAAA,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;AACpB,SAAC,CAAC;;AAGJ,IAAA,KAAK,CAAC,QAAkB,EAAA;QACtB,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,QAAQ;AAC7C,QAAA,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,EAAE;YAC3B;;AAEF,QAAA,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE;AAC/C,QAAA,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AACpC,QAAA,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE;AAC5B,YAAA,MAAM,CAAC,IAAI,CACT,qEAAqE,CACtE;YACD;;QAEF,iBAAiB,CAAC,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC;;AAEtE;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var plugin = require('./plugin.cjs.js');
|
|
4
|
+
var core = require('@rspack/core');
|
|
5
|
+
|
|
6
|
+
const ContainerPlugin = core.container.ContainerPlugin;
|
|
7
|
+
const ContainerReferencePlugin = core.container.ContainerReferencePlugin;
|
|
8
|
+
|
|
9
|
+
exports.ModuleFederationPlugin = plugin.ModuleFederationPlugin;
|
|
10
|
+
exports.PLUGIN_NAME = plugin.PLUGIN_NAME;
|
|
11
|
+
exports.ContainerPlugin = ContainerPlugin;
|
|
12
|
+
exports.ContainerReferencePlugin = ContainerReferencePlugin;
|
|
13
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/index.ts"],"sourcesContent":[null],"names":["container"],"mappings":";;;;;AAEa,MAAA,eAAe,GAAGA,cAAS,CAAC;AAC5B,MAAA,wBAAwB,GAAGA,cAAS,CAAC;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ModuleFederationPlugin, PLUGIN_NAME } from './plugin.esm.mjs';
|
|
2
|
+
import { container } from '@rspack/core';
|
|
3
|
+
|
|
4
|
+
const ContainerPlugin = container.ContainerPlugin;
|
|
5
|
+
const ContainerReferencePlugin = container.ContainerReferencePlugin;
|
|
6
|
+
|
|
7
|
+
export { ContainerPlugin, ContainerReferencePlugin };
|
|
8
|
+
//# sourceMappingURL=index.esm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.mjs","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAEa,MAAA,eAAe,GAAG,SAAS,CAAC;AAC5B,MAAA,wBAAwB,GAAG,SAAS,CAAC;;;;"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sdk = require('@module-federation/sdk');
|
|
4
|
+
var manifest = require('@module-federation/manifest');
|
|
5
|
+
var managers = require('@module-federation/managers');
|
|
6
|
+
var dtsPlugin = require('@module-federation/dts-plugin');
|
|
7
|
+
var ReactBridgePlugin = require('@module-federation/bridge-react-webpack-plugin');
|
|
8
|
+
var path = require('node:path');
|
|
9
|
+
var fs = require('node:fs');
|
|
10
|
+
var remoteEntryPlugin = require('./RemoteEntryPlugin.cjs.js');
|
|
11
|
+
|
|
12
|
+
const RuntimeToolsPath = require.resolve('@module-federation/runtime-tools');
|
|
13
|
+
const PLUGIN_NAME = 'RspackModuleFederationPlugin';
|
|
14
|
+
class ModuleFederationPlugin {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.name = PLUGIN_NAME;
|
|
17
|
+
this._options = options;
|
|
18
|
+
}
|
|
19
|
+
_patchBundlerConfig(compiler) {
|
|
20
|
+
const { name, experiments } = this._options;
|
|
21
|
+
const definePluginOptions = {};
|
|
22
|
+
if (name) {
|
|
23
|
+
definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(sdk.composeKeyWithSeparator(name, managers.utils.getBuildVersion()));
|
|
24
|
+
}
|
|
25
|
+
// Add FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN
|
|
26
|
+
const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;
|
|
27
|
+
definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =
|
|
28
|
+
disableSnapshot;
|
|
29
|
+
// Determine ENV_TARGET: only if manually specified in experiments.optimization.target
|
|
30
|
+
if (experiments?.optimization &&
|
|
31
|
+
typeof experiments.optimization === 'object' &&
|
|
32
|
+
experiments.optimization !== null &&
|
|
33
|
+
'target' in experiments.optimization) {
|
|
34
|
+
const manualTarget = experiments.optimization.target;
|
|
35
|
+
// Ensure the target is one of the expected values before setting
|
|
36
|
+
if (manualTarget === 'web' || manualTarget === 'node') {
|
|
37
|
+
definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// No inference for ENV_TARGET. If not manually set and valid, it's not defined.
|
|
41
|
+
new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);
|
|
42
|
+
}
|
|
43
|
+
_checkSingleton(compiler) {
|
|
44
|
+
let count = 0;
|
|
45
|
+
compiler.options.plugins.forEach((p) => {
|
|
46
|
+
if (typeof p !== 'object' || !p) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (p['name'] === this.name) {
|
|
50
|
+
count++;
|
|
51
|
+
if (count > 1) {
|
|
52
|
+
throw new Error(`Detect duplicate register ${this.name},please ensure ${this.name} is singleton!`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
apply(compiler) {
|
|
58
|
+
sdk.bindLoggerToCompiler(remoteEntryPlugin.logger, compiler, PLUGIN_NAME);
|
|
59
|
+
const { _options: options } = this;
|
|
60
|
+
if (!options.name) {
|
|
61
|
+
throw new Error('[ ModuleFederationPlugin ]: name is required');
|
|
62
|
+
}
|
|
63
|
+
this._checkSingleton(compiler);
|
|
64
|
+
this._patchBundlerConfig(compiler);
|
|
65
|
+
const containerManager = new managers.ContainerManager();
|
|
66
|
+
containerManager.init(options);
|
|
67
|
+
if (containerManager.enable) {
|
|
68
|
+
this._patchChunkSplit(compiler, options.name);
|
|
69
|
+
}
|
|
70
|
+
// must before ModuleFederationPlugin
|
|
71
|
+
new remoteEntryPlugin.RemoteEntryPlugin(options).apply(compiler);
|
|
72
|
+
if (options.experiments?.provideExternalRuntime) {
|
|
73
|
+
if (options.exposes) {
|
|
74
|
+
throw new Error('You can only set provideExternalRuntime: true in pure consumer which not expose modules.');
|
|
75
|
+
}
|
|
76
|
+
const runtimePlugins = options.runtimePlugins || [];
|
|
77
|
+
options.runtimePlugins = runtimePlugins.concat(require.resolve('@module-federation/inject-external-runtime-core-plugin'));
|
|
78
|
+
}
|
|
79
|
+
if (options.experiments?.externalRuntime === true) {
|
|
80
|
+
const Externals = compiler.webpack.ExternalsPlugin;
|
|
81
|
+
new Externals(compiler.options.externalsType || 'global', {
|
|
82
|
+
'@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',
|
|
83
|
+
}).apply(compiler);
|
|
84
|
+
}
|
|
85
|
+
options.implementation = options.implementation || RuntimeToolsPath;
|
|
86
|
+
let disableManifest = options.manifest === false;
|
|
87
|
+
let disableDts = options.dts === false;
|
|
88
|
+
if (!disableDts) {
|
|
89
|
+
const dtsPlugin$1 = new dtsPlugin.DtsPlugin(options);
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
dtsPlugin$1.apply(compiler);
|
|
92
|
+
dtsPlugin$1.addRuntimePlugins();
|
|
93
|
+
}
|
|
94
|
+
if (!disableManifest && options.exposes) {
|
|
95
|
+
try {
|
|
96
|
+
options.exposes = containerManager.containerPluginExposesOptions;
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
if (err instanceof Error) {
|
|
100
|
+
err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;
|
|
101
|
+
}
|
|
102
|
+
remoteEntryPlugin.logger.warn(err);
|
|
103
|
+
disableManifest = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
new compiler.webpack.container.ModuleFederationPlugin(options).apply(compiler);
|
|
107
|
+
const runtimeESMPath = require.resolve('@module-federation/runtime/dist/index.esm.js', { paths: [options.implementation] });
|
|
108
|
+
compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', () => {
|
|
109
|
+
compiler.options.resolve.alias = {
|
|
110
|
+
...compiler.options.resolve.alias,
|
|
111
|
+
'@module-federation/runtime$': runtimeESMPath,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
if (!disableManifest) {
|
|
115
|
+
this._statsPlugin = new manifest.StatsPlugin(options, {
|
|
116
|
+
pluginVersion: "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
117
|
+
bundler: 'rspack',
|
|
118
|
+
});
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
this._statsPlugin.apply(compiler);
|
|
121
|
+
}
|
|
122
|
+
const checkBridgeReactInstalled = () => {
|
|
123
|
+
try {
|
|
124
|
+
const userPackageJsonPath = path.resolve(compiler.context, 'package.json');
|
|
125
|
+
if (fs.existsSync(userPackageJsonPath)) {
|
|
126
|
+
const userPackageJson = JSON.parse(fs.readFileSync(userPackageJsonPath, 'utf-8'));
|
|
127
|
+
const userDependencies = {
|
|
128
|
+
...userPackageJson.dependencies,
|
|
129
|
+
...userPackageJson.devDependencies,
|
|
130
|
+
};
|
|
131
|
+
return !!userDependencies['@module-federation/bridge-react'];
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const hasBridgeReact = checkBridgeReactInstalled();
|
|
140
|
+
// react bridge plugin
|
|
141
|
+
const shouldEnableBridgePlugin = () => {
|
|
142
|
+
// Priority 1: Explicit enableBridgeRouter configuration
|
|
143
|
+
if (options?.bridge?.enableBridgeRouter === true) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
// Priority 2: Explicit disable via enableBridgeRouter:false or disableAlias:true
|
|
147
|
+
if (options?.bridge?.enableBridgeRouter === false ||
|
|
148
|
+
options?.bridge?.disableAlias === true) {
|
|
149
|
+
if (options?.bridge?.disableAlias === true) {
|
|
150
|
+
remoteEntryPlugin.logger.warn('⚠️ [ModuleFederationPlugin] The `disableAlias` option is deprecated and will be removed in a future version.\n' +
|
|
151
|
+
' Please use `enableBridgeRouter: false` instead:\n' +
|
|
152
|
+
' {\n' +
|
|
153
|
+
' bridge: {\n' +
|
|
154
|
+
' enableBridgeRouter: false // Use this instead of disableAlias: true\n' +
|
|
155
|
+
' }\n' +
|
|
156
|
+
' }');
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
// Priority 3: Automatic detection based on bridge-react installation
|
|
161
|
+
if (hasBridgeReact) {
|
|
162
|
+
remoteEntryPlugin.logger.info('💡 [ModuleFederationPlugin] Detected @module-federation/bridge-react in your dependencies.\n' +
|
|
163
|
+
' For better control and to avoid future breaking changes, please explicitly set:\n' +
|
|
164
|
+
' {\n' +
|
|
165
|
+
' bridge: {\n' +
|
|
166
|
+
' enableBridgeRouter: true // Explicitly enable bridge router\n' +
|
|
167
|
+
' }\n' +
|
|
168
|
+
' }');
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
};
|
|
173
|
+
if (shouldEnableBridgePlugin()) {
|
|
174
|
+
new ReactBridgePlugin({
|
|
175
|
+
moduleFederationOptions: this._options,
|
|
176
|
+
}).apply(compiler);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_patchChunkSplit(compiler, name) {
|
|
180
|
+
const { splitChunks } = compiler.options.optimization;
|
|
181
|
+
const patchChunkSplit = (cacheGroup) => {
|
|
182
|
+
switch (typeof cacheGroup) {
|
|
183
|
+
case 'boolean':
|
|
184
|
+
case 'string':
|
|
185
|
+
case 'function':
|
|
186
|
+
break;
|
|
187
|
+
// cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
|
|
188
|
+
case 'object': {
|
|
189
|
+
if (cacheGroup instanceof RegExp) {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
if (!cacheGroup.chunks) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
if (typeof cacheGroup.chunks === 'function') {
|
|
196
|
+
const prevChunks = cacheGroup.chunks;
|
|
197
|
+
cacheGroup.chunks = (chunk) => {
|
|
198
|
+
if (chunk.name &&
|
|
199
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return prevChunks(chunk);
|
|
203
|
+
};
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
if (cacheGroup.chunks === 'all') {
|
|
207
|
+
cacheGroup.chunks = (chunk) => {
|
|
208
|
+
if (chunk.name &&
|
|
209
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
};
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
if (cacheGroup.chunks === 'initial') {
|
|
217
|
+
cacheGroup.chunks = (chunk) => {
|
|
218
|
+
if (chunk.name &&
|
|
219
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
return chunk.isOnlyInitial();
|
|
223
|
+
};
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
if (!splitChunks) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// 修改 splitChunk.chunks
|
|
234
|
+
patchChunkSplit(splitChunks);
|
|
235
|
+
const { cacheGroups } = splitChunks;
|
|
236
|
+
if (!cacheGroups) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
// 修改 splitChunk.cacheGroups[key].chunks
|
|
240
|
+
Object.keys(cacheGroups).forEach((cacheGroupKey) => {
|
|
241
|
+
patchChunkSplit(cacheGroups[cacheGroupKey]);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
get statsResourceInfo() {
|
|
245
|
+
return this._statsPlugin?.resourceInfo;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const GetPublicPathPlugin = remoteEntryPlugin.RemoteEntryPlugin;
|
|
249
|
+
|
|
250
|
+
exports.GetPublicPathPlugin = GetPublicPathPlugin;
|
|
251
|
+
exports.ModuleFederationPlugin = ModuleFederationPlugin;
|
|
252
|
+
exports.PLUGIN_NAME = PLUGIN_NAME;
|
|
253
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["../../src/ModuleFederationPlugin.ts"],"sourcesContent":[null],"names":["composeKeyWithSeparator","utils","bindLoggerToCompiler","logger","ContainerManager","RemoteEntryPlugin","dtsPlugin","DtsPlugin","StatsPlugin"],"mappings":";;;;;;;;;;;AA+BA,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC;AAErE,MAAM,WAAW,GAAG;MACd,sBAAsB,CAAA;AAKjC,IAAA,WAAA,CAAY,OAA6D,EAAA;QAJhE,IAAI,CAAA,IAAA,GAAG,WAAW;AAKzB,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;AAGjB,IAAA,mBAAmB,CAAC,QAAkB,EAAA;QAC5C,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,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;;AAEzC;AAEM,MAAM,mBAAmB,GAAGE;;;;;;"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/ModuleFederationPlugin";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/ModuleFederationPlugin";
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { composeKeyWithSeparator, bindLoggerToCompiler } from '@module-federation/sdk';
|
|
2
|
+
import { StatsPlugin } from '@module-federation/manifest';
|
|
3
|
+
import { utils, ContainerManager } from '@module-federation/managers';
|
|
4
|
+
import { DtsPlugin } from '@module-federation/dts-plugin';
|
|
5
|
+
import ReactBridgePlugin from '@module-federation/bridge-react-webpack-plugin';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { R as RemoteEntryPlugin, l as logger } from './RemoteEntryPlugin.esm.mjs';
|
|
9
|
+
|
|
10
|
+
const RuntimeToolsPath = require.resolve('@module-federation/runtime-tools');
|
|
11
|
+
const PLUGIN_NAME = 'RspackModuleFederationPlugin';
|
|
12
|
+
class ModuleFederationPlugin {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.name = PLUGIN_NAME;
|
|
15
|
+
this._options = options;
|
|
16
|
+
}
|
|
17
|
+
_patchBundlerConfig(compiler) {
|
|
18
|
+
const { name, experiments } = this._options;
|
|
19
|
+
const definePluginOptions = {};
|
|
20
|
+
if (name) {
|
|
21
|
+
definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(composeKeyWithSeparator(name, utils.getBuildVersion()));
|
|
22
|
+
}
|
|
23
|
+
// Add FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN
|
|
24
|
+
const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;
|
|
25
|
+
definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =
|
|
26
|
+
disableSnapshot;
|
|
27
|
+
// Determine ENV_TARGET: only if manually specified in experiments.optimization.target
|
|
28
|
+
if (experiments?.optimization &&
|
|
29
|
+
typeof experiments.optimization === 'object' &&
|
|
30
|
+
experiments.optimization !== null &&
|
|
31
|
+
'target' in experiments.optimization) {
|
|
32
|
+
const manualTarget = experiments.optimization.target;
|
|
33
|
+
// Ensure the target is one of the expected values before setting
|
|
34
|
+
if (manualTarget === 'web' || manualTarget === 'node') {
|
|
35
|
+
definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// No inference for ENV_TARGET. If not manually set and valid, it's not defined.
|
|
39
|
+
new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);
|
|
40
|
+
}
|
|
41
|
+
_checkSingleton(compiler) {
|
|
42
|
+
let count = 0;
|
|
43
|
+
compiler.options.plugins.forEach((p) => {
|
|
44
|
+
if (typeof p !== 'object' || !p) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (p['name'] === this.name) {
|
|
48
|
+
count++;
|
|
49
|
+
if (count > 1) {
|
|
50
|
+
throw new Error(`Detect duplicate register ${this.name},please ensure ${this.name} is singleton!`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
apply(compiler) {
|
|
56
|
+
bindLoggerToCompiler(logger, compiler, PLUGIN_NAME);
|
|
57
|
+
const { _options: options } = this;
|
|
58
|
+
if (!options.name) {
|
|
59
|
+
throw new Error('[ ModuleFederationPlugin ]: name is required');
|
|
60
|
+
}
|
|
61
|
+
this._checkSingleton(compiler);
|
|
62
|
+
this._patchBundlerConfig(compiler);
|
|
63
|
+
const containerManager = new ContainerManager();
|
|
64
|
+
containerManager.init(options);
|
|
65
|
+
if (containerManager.enable) {
|
|
66
|
+
this._patchChunkSplit(compiler, options.name);
|
|
67
|
+
}
|
|
68
|
+
// must before ModuleFederationPlugin
|
|
69
|
+
new RemoteEntryPlugin(options).apply(compiler);
|
|
70
|
+
if (options.experiments?.provideExternalRuntime) {
|
|
71
|
+
if (options.exposes) {
|
|
72
|
+
throw new Error('You can only set provideExternalRuntime: true in pure consumer which not expose modules.');
|
|
73
|
+
}
|
|
74
|
+
const runtimePlugins = options.runtimePlugins || [];
|
|
75
|
+
options.runtimePlugins = runtimePlugins.concat(require.resolve('@module-federation/inject-external-runtime-core-plugin'));
|
|
76
|
+
}
|
|
77
|
+
if (options.experiments?.externalRuntime === true) {
|
|
78
|
+
const Externals = compiler.webpack.ExternalsPlugin;
|
|
79
|
+
new Externals(compiler.options.externalsType || 'global', {
|
|
80
|
+
'@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',
|
|
81
|
+
}).apply(compiler);
|
|
82
|
+
}
|
|
83
|
+
options.implementation = options.implementation || RuntimeToolsPath;
|
|
84
|
+
let disableManifest = options.manifest === false;
|
|
85
|
+
let disableDts = options.dts === false;
|
|
86
|
+
if (!disableDts) {
|
|
87
|
+
const dtsPlugin = new DtsPlugin(options);
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
dtsPlugin.apply(compiler);
|
|
90
|
+
dtsPlugin.addRuntimePlugins();
|
|
91
|
+
}
|
|
92
|
+
if (!disableManifest && options.exposes) {
|
|
93
|
+
try {
|
|
94
|
+
options.exposes = containerManager.containerPluginExposesOptions;
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
if (err instanceof Error) {
|
|
98
|
+
err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;
|
|
99
|
+
}
|
|
100
|
+
logger.warn(err);
|
|
101
|
+
disableManifest = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
new compiler.webpack.container.ModuleFederationPlugin(options).apply(compiler);
|
|
105
|
+
const runtimeESMPath = require.resolve('@module-federation/runtime/dist/index.esm.js', { paths: [options.implementation] });
|
|
106
|
+
compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', () => {
|
|
107
|
+
compiler.options.resolve.alias = {
|
|
108
|
+
...compiler.options.resolve.alias,
|
|
109
|
+
'@module-federation/runtime$': runtimeESMPath,
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
if (!disableManifest) {
|
|
113
|
+
this._statsPlugin = new StatsPlugin(options, {
|
|
114
|
+
pluginVersion: "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
115
|
+
bundler: 'rspack',
|
|
116
|
+
});
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
this._statsPlugin.apply(compiler);
|
|
119
|
+
}
|
|
120
|
+
const checkBridgeReactInstalled = () => {
|
|
121
|
+
try {
|
|
122
|
+
const userPackageJsonPath = path.resolve(compiler.context, 'package.json');
|
|
123
|
+
if (fs.existsSync(userPackageJsonPath)) {
|
|
124
|
+
const userPackageJson = JSON.parse(fs.readFileSync(userPackageJsonPath, 'utf-8'));
|
|
125
|
+
const userDependencies = {
|
|
126
|
+
...userPackageJson.dependencies,
|
|
127
|
+
...userPackageJson.devDependencies,
|
|
128
|
+
};
|
|
129
|
+
return !!userDependencies['@module-federation/bridge-react'];
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const hasBridgeReact = checkBridgeReactInstalled();
|
|
138
|
+
// react bridge plugin
|
|
139
|
+
const shouldEnableBridgePlugin = () => {
|
|
140
|
+
// Priority 1: Explicit enableBridgeRouter configuration
|
|
141
|
+
if (options?.bridge?.enableBridgeRouter === true) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
// Priority 2: Explicit disable via enableBridgeRouter:false or disableAlias:true
|
|
145
|
+
if (options?.bridge?.enableBridgeRouter === false ||
|
|
146
|
+
options?.bridge?.disableAlias === true) {
|
|
147
|
+
if (options?.bridge?.disableAlias === true) {
|
|
148
|
+
logger.warn('⚠️ [ModuleFederationPlugin] The `disableAlias` option is deprecated and will be removed in a future version.\n' +
|
|
149
|
+
' Please use `enableBridgeRouter: false` instead:\n' +
|
|
150
|
+
' {\n' +
|
|
151
|
+
' bridge: {\n' +
|
|
152
|
+
' enableBridgeRouter: false // Use this instead of disableAlias: true\n' +
|
|
153
|
+
' }\n' +
|
|
154
|
+
' }');
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
// Priority 3: Automatic detection based on bridge-react installation
|
|
159
|
+
if (hasBridgeReact) {
|
|
160
|
+
logger.info('💡 [ModuleFederationPlugin] Detected @module-federation/bridge-react in your dependencies.\n' +
|
|
161
|
+
' For better control and to avoid future breaking changes, please explicitly set:\n' +
|
|
162
|
+
' {\n' +
|
|
163
|
+
' bridge: {\n' +
|
|
164
|
+
' enableBridgeRouter: true // Explicitly enable bridge router\n' +
|
|
165
|
+
' }\n' +
|
|
166
|
+
' }');
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
};
|
|
171
|
+
if (shouldEnableBridgePlugin()) {
|
|
172
|
+
new ReactBridgePlugin({
|
|
173
|
+
moduleFederationOptions: this._options,
|
|
174
|
+
}).apply(compiler);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_patchChunkSplit(compiler, name) {
|
|
178
|
+
const { splitChunks } = compiler.options.optimization;
|
|
179
|
+
const patchChunkSplit = (cacheGroup) => {
|
|
180
|
+
switch (typeof cacheGroup) {
|
|
181
|
+
case 'boolean':
|
|
182
|
+
case 'string':
|
|
183
|
+
case 'function':
|
|
184
|
+
break;
|
|
185
|
+
// cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
|
|
186
|
+
case 'object': {
|
|
187
|
+
if (cacheGroup instanceof RegExp) {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (!cacheGroup.chunks) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
if (typeof cacheGroup.chunks === 'function') {
|
|
194
|
+
const prevChunks = cacheGroup.chunks;
|
|
195
|
+
cacheGroup.chunks = (chunk) => {
|
|
196
|
+
if (chunk.name &&
|
|
197
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return prevChunks(chunk);
|
|
201
|
+
};
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
if (cacheGroup.chunks === 'all') {
|
|
205
|
+
cacheGroup.chunks = (chunk) => {
|
|
206
|
+
if (chunk.name &&
|
|
207
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
};
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
if (cacheGroup.chunks === 'initial') {
|
|
215
|
+
cacheGroup.chunks = (chunk) => {
|
|
216
|
+
if (chunk.name &&
|
|
217
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return chunk.isOnlyInitial();
|
|
221
|
+
};
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
if (!splitChunks) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
// 修改 splitChunk.chunks
|
|
232
|
+
patchChunkSplit(splitChunks);
|
|
233
|
+
const { cacheGroups } = splitChunks;
|
|
234
|
+
if (!cacheGroups) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
// 修改 splitChunk.cacheGroups[key].chunks
|
|
238
|
+
Object.keys(cacheGroups).forEach((cacheGroupKey) => {
|
|
239
|
+
patchChunkSplit(cacheGroups[cacheGroupKey]);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
get statsResourceInfo() {
|
|
243
|
+
return this._statsPlugin?.resourceInfo;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const GetPublicPathPlugin = RemoteEntryPlugin;
|
|
247
|
+
|
|
248
|
+
export { GetPublicPathPlugin, ModuleFederationPlugin, PLUGIN_NAME };
|
|
249
|
+
//# sourceMappingURL=plugin.esm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.esm.mjs","sources":["../../src/ModuleFederationPlugin.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AA+BA,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC;AAErE,MAAM,WAAW,GAAG;MACd,sBAAsB,CAAA;AAKjC,IAAA,WAAA,CAAY,OAA6D,EAAA;QAJhE,IAAI,CAAA,IAAA,GAAG,WAAW;AAKzB,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;AAGjB,IAAA,mBAAmB,CAAC,QAAkB,EAAA;QAC5C,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,QAAQ;QAC3C,MAAM,mBAAmB,GAAqC,EAAE;QAChE,IAAI,IAAI,EAAE;AACR,YAAA,mBAAmB,CAAC,6BAA6B,CAAC,GAAG,IAAI,CAAC,SAAS,CACjE,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CACvD;;;QAGH,MAAM,eAAe,GAAG,WAAW,EAAE,YAAY,EAAE,eAAe,IAAI,KAAK;QAC3E,mBAAmB,CAAC,wCAAwC,CAAC;AAC3D,YAAA,eAAe;;QAGjB,IACE,WAAW,EAAE,YAAY;AACzB,YAAA,OAAO,WAAW,CAAC,YAAY,KAAK,QAAQ;YAC5C,WAAW,CAAC,YAAY,KAAK,IAAI;AACjC,YAAA,QAAQ,IAAI,WAAW,CAAC,YAAY,EACpC;AACA,YAAA,MAAM,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC,MAGjC;;YAEb,IAAI,YAAY,KAAK,KAAK,IAAI,YAAY,KAAK,MAAM,EAAE;gBACrD,mBAAmB,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,SAA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AAK,IAAI,GAAG,UAAU,CAAC,EACzD;AACA,gCAAA,OAAO,KAAK;;AAEd,4BAAA,OAAO,KAAK,CAAC,aAAa,EAAE;AAC9B,yBAAC;wBACD;;oBAEF;;;AAKN,SAAC;QAED,IAAI,CAAC,WAAW,EAAE;YAChB;;;QAGF,eAAe,CAAC,WAAW,CAAC;AAE5B,QAAA,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW;QAEnC,IAAI,CAAC,WAAW,EAAE;YAChB;;;QAIF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,KAAI;AACjD,YAAA,eAAe,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;AAC7C,SAAC,CAAC;;AAGJ,IAAA,IAAI,iBAAiB,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,YAAY,EAAE,YAAY;;AAEzC;AAEM,MAAM,mBAAmB,GAAG;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('btoa');
|
|
4
|
+
require('@module-federation/managers');
|
|
5
|
+
var remoteEntryPlugin = require('./RemoteEntryPlugin.cjs.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.RemoteEntryPlugin = remoteEntryPlugin.RemoteEntryPlugin;
|
|
10
|
+
//# sourceMappingURL=remote-entry-plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-entry-plugin.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/RemoteEntryPlugin";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/RemoteEntryPlugin";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-entry-plugin.esm.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
|
+
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
import { RemoteEntryPlugin } from './RemoteEntryPlugin';
|
|
4
|
+
export declare const PLUGIN_NAME = "RspackModuleFederationPlugin";
|
|
5
|
+
export declare class ModuleFederationPlugin implements RspackPluginInstance {
|
|
6
|
+
readonly name = "RspackModuleFederationPlugin";
|
|
7
|
+
private _options;
|
|
8
|
+
private _statsPlugin?;
|
|
9
|
+
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
|
|
10
|
+
private _patchBundlerConfig;
|
|
11
|
+
private _checkSingleton;
|
|
12
|
+
apply(compiler: Compiler): void;
|
|
13
|
+
private _patchChunkSplit;
|
|
14
|
+
get statsResourceInfo(): Partial<import("@module-federation/manifest").ResourceInfo> | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare const GetPublicPathPlugin: typeof RemoteEntryPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
export declare class RemoteEntryPlugin implements RspackPluginInstance {
|
|
4
|
+
readonly name = "VmokRemoteEntryPlugin";
|
|
5
|
+
_options: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
|
+
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
|
|
7
|
+
static addPublicPathEntry(compiler: Compiler, getPublicPath: string, name: string): void;
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ModuleFederationPlugin, PLUGIN_NAME } from './ModuleFederationPlugin';
|
|
2
|
+
export declare const ContainerPlugin: typeof import("@rspack/core/dist/container/ContainerPlugin").ContainerPlugin;
|
|
3
|
+
export declare const ContainerReferencePlugin: typeof import("@rspack/core/dist/container/ContainerReferencePlugin").ContainerReferencePlugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@module-federation/rspack",
|
|
3
|
+
"version": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Module Federation",
|
|
7
|
+
"Rspack"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/module-federation/core.git",
|
|
19
|
+
"directory": "packages/rspack"
|
|
20
|
+
},
|
|
21
|
+
"author": "hanric <hanric.zhang@gmail.com>",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"main": "./dist/index.cjs.js",
|
|
24
|
+
"module": "./dist/index.esm.mjs",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"btoa": "1.2.1",
|
|
28
|
+
"@module-federation/bridge-react-webpack-plugin": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
29
|
+
"@module-federation/dts-plugin": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
30
|
+
"@module-federation/manifest": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
31
|
+
"@module-federation/managers": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
32
|
+
"@module-federation/inject-external-runtime-core-plugin": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
33
|
+
"@module-federation/runtime-tools": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
|
|
34
|
+
"@module-federation/sdk": "0.0.0-feat-support-bridge-react-router-v7-20251015102312"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@rspack/core": "^1.0.2"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"import": "./dist/index.esm.mjs",
|
|
43
|
+
"require": "./dist/index.cjs.js"
|
|
44
|
+
},
|
|
45
|
+
"./plugin": {
|
|
46
|
+
"types": "./dist/plugin.d.ts",
|
|
47
|
+
"import": "./dist/plugin.esm.mjs",
|
|
48
|
+
"require": "./dist/plugin.cjs.js"
|
|
49
|
+
},
|
|
50
|
+
"./remote-entry-plugin": {
|
|
51
|
+
"types": "./dist/remote-entry-plugin.d.ts",
|
|
52
|
+
"import": "./dist/remote-entry-plugin.esm.mjs",
|
|
53
|
+
"require": "./dist/remote-entry-plugin.cjs.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"typesVersions": {
|
|
57
|
+
"*": {
|
|
58
|
+
".": [
|
|
59
|
+
"./dist/index.d.ts"
|
|
60
|
+
],
|
|
61
|
+
"plugin": [
|
|
62
|
+
"./dist/plugin.d.ts"
|
|
63
|
+
],
|
|
64
|
+
"remote-entry-plugin": [
|
|
65
|
+
"./dist/remote-entry-plugin.d.ts"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"typescript": "^4.9.0 || ^5.0.0",
|
|
71
|
+
"vue-tsc": ">=1.0.24",
|
|
72
|
+
"@rspack/core": ">=0.7"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"typescript": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"vue-tsc": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|