@module-federation/rspack 0.12.0 → 0.13.0
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/dist/plugin.cjs.js
CHANGED
|
@@ -138,9 +138,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
|
|
|
138
138
|
this._patchChunkSplit(compiler, options.name);
|
|
139
139
|
}
|
|
140
140
|
// must before ModuleFederationPlugin
|
|
141
|
-
|
|
142
|
-
new remoteEntryPlugin.RemoteEntryPlugin(options.name, options.getPublicPath).apply(compiler);
|
|
143
|
-
}
|
|
141
|
+
new remoteEntryPlugin.RemoteEntryPlugin(options).apply(compiler);
|
|
144
142
|
if ((_options_experiments = options.experiments) === null || _options_experiments === void 0 ? void 0 : _options_experiments.provideExternalRuntime) {
|
|
145
143
|
if (options.exposes) {
|
|
146
144
|
throw new Error('You can only set provideExternalRuntime: true in pure consumer which not expose modules.');
|
|
@@ -185,7 +183,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
|
|
|
185
183
|
});
|
|
186
184
|
if (!disableManifest) {
|
|
187
185
|
this._statsPlugin = new manifest.StatsPlugin(options, {
|
|
188
|
-
pluginVersion: "0.
|
|
186
|
+
pluginVersion: "0.13.0",
|
|
189
187
|
bundler: 'rspack'
|
|
190
188
|
});
|
|
191
189
|
// @ts-ignore
|
package/dist/plugin.esm.mjs
CHANGED
|
@@ -136,9 +136,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
|
|
|
136
136
|
this._patchChunkSplit(compiler, options.name);
|
|
137
137
|
}
|
|
138
138
|
// must before ModuleFederationPlugin
|
|
139
|
-
|
|
140
|
-
new RemoteEntryPlugin(options.name, options.getPublicPath).apply(compiler);
|
|
141
|
-
}
|
|
139
|
+
new RemoteEntryPlugin(options).apply(compiler);
|
|
142
140
|
if ((_options_experiments = options.experiments) === null || _options_experiments === void 0 ? void 0 : _options_experiments.provideExternalRuntime) {
|
|
143
141
|
if (options.exposes) {
|
|
144
142
|
throw new Error('You can only set provideExternalRuntime: true in pure consumer which not expose modules.');
|
|
@@ -183,7 +181,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
|
|
|
183
181
|
});
|
|
184
182
|
if (!disableManifest) {
|
|
185
183
|
this._statsPlugin = new StatsPlugin(options, {
|
|
186
|
-
pluginVersion: "0.
|
|
184
|
+
pluginVersion: "0.13.0",
|
|
187
185
|
bundler: 'rspack'
|
|
188
186
|
});
|
|
189
187
|
// @ts-ignore
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pBtoa = require('btoa');
|
|
4
|
+
var managers = require('@module-federation/managers');
|
|
5
|
+
var sdk = require('@module-federation/sdk');
|
|
6
|
+
|
|
7
|
+
var logger = sdk.createLogger('[ Module Federation Rspack Plugin ]');
|
|
4
8
|
|
|
5
9
|
function _class_call_check(instance, Constructor) {
|
|
6
10
|
if (!(instance instanceof Constructor)) {
|
|
@@ -33,6 +37,7 @@ function _define_property(obj, key, value) {
|
|
|
33
37
|
}
|
|
34
38
|
return obj;
|
|
35
39
|
}
|
|
40
|
+
// @ts-ignore
|
|
36
41
|
var charMap = {
|
|
37
42
|
'<': '\\u003C',
|
|
38
43
|
'>': '\\u003E',
|
|
@@ -53,22 +58,29 @@ function escapeUnsafeChars(str) {
|
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
var RemoteEntryPlugin = /*#__PURE__*/ function() {
|
|
56
|
-
function RemoteEntryPlugin(
|
|
61
|
+
function RemoteEntryPlugin(options) {
|
|
57
62
|
_class_call_check(this, RemoteEntryPlugin);
|
|
58
63
|
_define_property(this, "name", 'VmokRemoteEntryPlugin');
|
|
59
|
-
_define_property(this, "
|
|
60
|
-
|
|
61
|
-
this._name = name;
|
|
62
|
-
this._getPublicPath = getPublicPath;
|
|
64
|
+
_define_property(this, "_options", void 0);
|
|
65
|
+
this._options = options;
|
|
63
66
|
}
|
|
64
67
|
_create_class(RemoteEntryPlugin, [
|
|
65
68
|
{
|
|
66
69
|
key: "apply",
|
|
67
70
|
value: function apply(compiler) {
|
|
68
|
-
var
|
|
71
|
+
var _this__options = this._options, name = _this__options.name, getPublicPath = _this__options.getPublicPath;
|
|
72
|
+
if (!getPublicPath || !name) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
var containerManager = new managers.ContainerManager();
|
|
76
|
+
containerManager.init(this._options);
|
|
77
|
+
if (!containerManager.enable) {
|
|
78
|
+
logger.warn("Detect you don't set exposes, 'getPublicPath' will not have effect.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
69
81
|
var code;
|
|
70
|
-
var sanitizedPublicPath = escapeUnsafeChars(
|
|
71
|
-
if (!
|
|
82
|
+
var sanitizedPublicPath = escapeUnsafeChars(getPublicPath);
|
|
83
|
+
if (!getPublicPath.startsWith('function')) {
|
|
72
84
|
code = "".concat(compiler.webpack.RuntimeGlobals.publicPath, " = new Function(").concat(JSON.stringify(sanitizedPublicPath), ")()");
|
|
73
85
|
} else {
|
|
74
86
|
code = "(".concat(sanitizedPublicPath, "())");
|
|
@@ -77,7 +89,7 @@ var RemoteEntryPlugin = /*#__PURE__*/ function() {
|
|
|
77
89
|
var dataUrl = "data:text/javascript;base64,".concat(base64Code);
|
|
78
90
|
compiler.hooks.afterPlugins.tap('VmokRemoteEntryPlugin', function() {
|
|
79
91
|
new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {
|
|
80
|
-
name:
|
|
92
|
+
name: name
|
|
81
93
|
}).apply(compiler);
|
|
82
94
|
});
|
|
83
95
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import pBtoa from 'btoa';
|
|
2
|
+
import { ContainerManager } from '@module-federation/managers';
|
|
3
|
+
import { createLogger } from '@module-federation/sdk';
|
|
4
|
+
|
|
5
|
+
var logger = createLogger('[ Module Federation Rspack Plugin ]');
|
|
2
6
|
|
|
3
7
|
function _class_call_check(instance, Constructor) {
|
|
4
8
|
if (!(instance instanceof Constructor)) {
|
|
@@ -31,6 +35,7 @@ function _define_property(obj, key, value) {
|
|
|
31
35
|
}
|
|
32
36
|
return obj;
|
|
33
37
|
}
|
|
38
|
+
// @ts-ignore
|
|
34
39
|
var charMap = {
|
|
35
40
|
'<': '\\u003C',
|
|
36
41
|
'>': '\\u003E',
|
|
@@ -51,22 +56,29 @@ function escapeUnsafeChars(str) {
|
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
58
|
var RemoteEntryPlugin = /*#__PURE__*/ function() {
|
|
54
|
-
function RemoteEntryPlugin(
|
|
59
|
+
function RemoteEntryPlugin(options) {
|
|
55
60
|
_class_call_check(this, RemoteEntryPlugin);
|
|
56
61
|
_define_property(this, "name", 'VmokRemoteEntryPlugin');
|
|
57
|
-
_define_property(this, "
|
|
58
|
-
|
|
59
|
-
this._name = name;
|
|
60
|
-
this._getPublicPath = getPublicPath;
|
|
62
|
+
_define_property(this, "_options", void 0);
|
|
63
|
+
this._options = options;
|
|
61
64
|
}
|
|
62
65
|
_create_class(RemoteEntryPlugin, [
|
|
63
66
|
{
|
|
64
67
|
key: "apply",
|
|
65
68
|
value: function apply(compiler) {
|
|
66
|
-
var
|
|
69
|
+
var _this__options = this._options, name = _this__options.name, getPublicPath = _this__options.getPublicPath;
|
|
70
|
+
if (!getPublicPath || !name) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
var containerManager = new ContainerManager();
|
|
74
|
+
containerManager.init(this._options);
|
|
75
|
+
if (!containerManager.enable) {
|
|
76
|
+
logger.warn("Detect you don't set exposes, 'getPublicPath' will not have effect.");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
67
79
|
var code;
|
|
68
|
-
var sanitizedPublicPath = escapeUnsafeChars(
|
|
69
|
-
if (!
|
|
80
|
+
var sanitizedPublicPath = escapeUnsafeChars(getPublicPath);
|
|
81
|
+
if (!getPublicPath.startsWith('function')) {
|
|
70
82
|
code = "".concat(compiler.webpack.RuntimeGlobals.publicPath, " = new Function(").concat(JSON.stringify(sanitizedPublicPath), ")()");
|
|
71
83
|
} else {
|
|
72
84
|
code = "(".concat(sanitizedPublicPath, "())");
|
|
@@ -75,7 +87,7 @@ var RemoteEntryPlugin = /*#__PURE__*/ function() {
|
|
|
75
87
|
var dataUrl = "data:text/javascript;base64,".concat(base64Code);
|
|
76
88
|
compiler.hooks.afterPlugins.tap('VmokRemoteEntryPlugin', function() {
|
|
77
89
|
new compiler.webpack.EntryPlugin(compiler.context, dataUrl, {
|
|
78
|
-
name:
|
|
90
|
+
name: name
|
|
79
91
|
}).apply(compiler);
|
|
80
92
|
});
|
|
81
93
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
3
|
export declare class RemoteEntryPlugin implements RspackPluginInstance {
|
|
3
4
|
readonly name = "VmokRemoteEntryPlugin";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(name: string, getPublicPath: string);
|
|
5
|
+
_options: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
|
+
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
|
|
7
7
|
apply(compiler: Compiler): void;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/rspack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Module Federation",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"types": "./dist/index.cjs.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"btoa": "1.2.1",
|
|
28
|
-
"@module-federation/bridge-react-webpack-plugin": "0.
|
|
29
|
-
"@module-federation/dts-plugin": "0.
|
|
30
|
-
"@module-federation/managers": "0.
|
|
31
|
-
"@module-federation/manifest": "0.
|
|
32
|
-
"@module-federation/runtime-tools": "0.
|
|
33
|
-
"@module-federation/inject-external-runtime-core-plugin": "0.
|
|
34
|
-
"@module-federation/sdk": "0.
|
|
28
|
+
"@module-federation/bridge-react-webpack-plugin": "0.13.0",
|
|
29
|
+
"@module-federation/dts-plugin": "0.13.0",
|
|
30
|
+
"@module-federation/managers": "0.13.0",
|
|
31
|
+
"@module-federation/manifest": "0.13.0",
|
|
32
|
+
"@module-federation/runtime-tools": "0.13.0",
|
|
33
|
+
"@module-federation/inject-external-runtime-core-plugin": "0.13.0",
|
|
34
|
+
"@module-federation/sdk": "0.13.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@rspack/core": "^1.0.2"
|