@module-federation/rspack 0.1.12 → 0.1.14

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/index.cjs.js CHANGED
@@ -3,14 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var sdk = require('@module-federation/sdk');
6
- var managers = require('@module-federation/managers');
7
6
  var manifest = require('@module-federation/manifest');
7
+ var managers = require('@module-federation/managers');
8
8
  var dtsPlugin = require('@module-federation/dts-plugin');
9
9
 
10
- function getIdentifier(name) {
11
- return "".concat(name).concat(sdk.SEPARATOR).concat(managers.utils.getBuildVersion());
12
- }
13
-
14
10
  function _class_call_check(instance, Constructor) {
15
11
  if (!(instance instanceof Constructor)) {
16
12
  throw new TypeError("Cannot call a class as a function");
@@ -93,11 +89,11 @@ function _type_of(obj) {
93
89
  "@swc/helpers - typeof";
94
90
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
95
91
  }
96
- var RuntimeToolsPath = require.resolve("@module-federation/runtime-tools");
92
+ var RuntimeToolsPath = require.resolve('@module-federation/runtime-tools');
97
93
  var ModuleFederationPlugin = /*#__PURE__*/ function() {
98
94
  function ModuleFederationPlugin(options) {
99
95
  _class_call_check(this, ModuleFederationPlugin);
100
- _define_property(this, "name", "RspackModuleFederationPlugin");
96
+ _define_property(this, "name", 'RspackModuleFederationPlugin');
101
97
  _define_property(this, "_options", void 0);
102
98
  this._options = options;
103
99
  }
@@ -106,9 +102,11 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
106
102
  key: "_patchBundlerConfig",
107
103
  value: function _patchBundlerConfig(compiler) {
108
104
  var name = this._options.name;
109
- new compiler.webpack.DefinePlugin({
110
- FEDERATION_BUILD_IDENTIFIER: JSON.stringify(getIdentifier(name))
111
- }).apply(compiler);
105
+ if (name) {
106
+ new compiler.webpack.DefinePlugin({
107
+ FEDERATION_BUILD_IDENTIFIER: JSON.stringify(sdk.composeKeyWithSeparator(name, managers.utils.getBuildVersion()))
108
+ }).apply(compiler);
109
+ }
112
110
  }
113
111
  },
114
112
  {
@@ -131,7 +129,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
131
129
  value: function apply(compiler) {
132
130
  var _this = this, options = _this._options;
133
131
  if (!options.name) {
134
- throw new Error("[ ModuleFederationPlugin ]: name is required");
132
+ throw new Error('[ ModuleFederationPlugin ]: name is required');
135
133
  }
136
134
  this._checkSingleton(compiler);
137
135
  this._patchBundlerConfig(compiler);
@@ -154,20 +152,20 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
154
152
  }
155
153
  }
156
154
  new compiler.webpack.container.ModuleFederationPlugin(options).apply(compiler);
157
- var runtimeESMPath = require.resolve("@module-federation/runtime/dist/index.esm.js", {
155
+ var runtimeESMPath = require.resolve('@module-federation/runtime/dist/index.esm.js', {
158
156
  paths: [
159
157
  options.implementation
160
158
  ]
161
159
  });
162
- compiler.hooks.afterPlugins.tap("PatchAliasWebpackPlugin", function() {
160
+ compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', function() {
163
161
  compiler.options.resolve.alias = _object_spread_props(_object_spread({}, compiler.options.resolve.alias), {
164
- "@module-federation/runtime$": runtimeESMPath
162
+ '@module-federation/runtime$': runtimeESMPath
165
163
  });
166
164
  });
167
165
  if (!disableManifest) {
168
166
  new manifest.StatsPlugin(options, {
169
- pluginVersion: "0.1.12",
170
- bundler: "rspack"
167
+ pluginVersion: "0.1.14",
168
+ bundler: 'rspack'
171
169
  }).apply(compiler);
172
170
  }
173
171
  }
@@ -178,12 +176,12 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
178
176
  var splitChunks = compiler.options.optimization.splitChunks;
179
177
  var patchChunkSplit = function(cacheGroup) {
180
178
  switch(typeof cacheGroup === "undefined" ? "undefined" : _type_of(cacheGroup)){
181
- case "boolean":
182
- case "string":
183
- case "function":
179
+ case 'boolean':
180
+ case 'string':
181
+ case 'function':
184
182
  break;
185
183
  // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
186
- case "object":
184
+ case 'object':
187
185
  {
188
186
  if (_instanceof(cacheGroup, RegExp)) {
189
187
  break;
@@ -191,23 +189,23 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
191
189
  if (!cacheGroup.chunks) {
192
190
  break;
193
191
  }
194
- if (typeof cacheGroup.chunks === "function") {
192
+ if (typeof cacheGroup.chunks === 'function') {
195
193
  var prevChunks = cacheGroup.chunks;
196
194
  cacheGroup.chunks = function(chunk) {
197
- if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) {
195
+ if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
198
196
  return false;
199
197
  }
200
198
  return prevChunks(chunk);
201
199
  };
202
200
  break;
203
201
  }
204
- if (cacheGroup.chunks === "all") {
205
- cacheGroup.chunks = new RegExp("^(?!.*(".concat(name, "|").concat(name, "_partial)).*$"), "g");
202
+ if (cacheGroup.chunks === 'all') {
203
+ cacheGroup.chunks = new RegExp("^(?!.*(".concat(name, "|").concat(name, "_partial)).*$"), 'g');
206
204
  break;
207
205
  }
208
- if (cacheGroup.chunks === "initial") {
206
+ if (cacheGroup.chunks === 'initial') {
209
207
  cacheGroup.chunks = function(chunk) {
210
- if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) {
208
+ if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
211
209
  return false;
212
210
  }
213
211
  return chunk.isOnlyInitial();
package/dist/index.esm.js CHANGED
@@ -1,12 +1,8 @@
1
- import { SEPARATOR } from '@module-federation/sdk';
2
- import { utils, ContainerManager } from '@module-federation/managers';
1
+ import { composeKeyWithSeparator } from '@module-federation/sdk';
3
2
  import { StatsPlugin } from '@module-federation/manifest';
3
+ import { utils, ContainerManager } from '@module-federation/managers';
4
4
  import { DtsPlugin } from '@module-federation/dts-plugin';
5
5
 
6
- function getIdentifier(name) {
7
- return "".concat(name).concat(SEPARATOR).concat(utils.getBuildVersion());
8
- }
9
-
10
6
  function _class_call_check(instance, Constructor) {
11
7
  if (!(instance instanceof Constructor)) {
12
8
  throw new TypeError("Cannot call a class as a function");
@@ -89,11 +85,11 @@ function _type_of(obj) {
89
85
  "@swc/helpers - typeof";
90
86
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
91
87
  }
92
- var RuntimeToolsPath = require.resolve("@module-federation/runtime-tools");
88
+ var RuntimeToolsPath = require.resolve('@module-federation/runtime-tools');
93
89
  var ModuleFederationPlugin = /*#__PURE__*/ function() {
94
90
  function ModuleFederationPlugin(options) {
95
91
  _class_call_check(this, ModuleFederationPlugin);
96
- _define_property(this, "name", "RspackModuleFederationPlugin");
92
+ _define_property(this, "name", 'RspackModuleFederationPlugin');
97
93
  _define_property(this, "_options", void 0);
98
94
  this._options = options;
99
95
  }
@@ -102,9 +98,11 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
102
98
  key: "_patchBundlerConfig",
103
99
  value: function _patchBundlerConfig(compiler) {
104
100
  var name = this._options.name;
105
- new compiler.webpack.DefinePlugin({
106
- FEDERATION_BUILD_IDENTIFIER: JSON.stringify(getIdentifier(name))
107
- }).apply(compiler);
101
+ if (name) {
102
+ new compiler.webpack.DefinePlugin({
103
+ FEDERATION_BUILD_IDENTIFIER: JSON.stringify(composeKeyWithSeparator(name, utils.getBuildVersion()))
104
+ }).apply(compiler);
105
+ }
108
106
  }
109
107
  },
110
108
  {
@@ -127,7 +125,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
127
125
  value: function apply(compiler) {
128
126
  var _this = this, options = _this._options;
129
127
  if (!options.name) {
130
- throw new Error("[ ModuleFederationPlugin ]: name is required");
128
+ throw new Error('[ ModuleFederationPlugin ]: name is required');
131
129
  }
132
130
  this._checkSingleton(compiler);
133
131
  this._patchBundlerConfig(compiler);
@@ -150,20 +148,20 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
150
148
  }
151
149
  }
152
150
  new compiler.webpack.container.ModuleFederationPlugin(options).apply(compiler);
153
- var runtimeESMPath = require.resolve("@module-federation/runtime/dist/index.esm.js", {
151
+ var runtimeESMPath = require.resolve('@module-federation/runtime/dist/index.esm.js', {
154
152
  paths: [
155
153
  options.implementation
156
154
  ]
157
155
  });
158
- compiler.hooks.afterPlugins.tap("PatchAliasWebpackPlugin", function() {
156
+ compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', function() {
159
157
  compiler.options.resolve.alias = _object_spread_props(_object_spread({}, compiler.options.resolve.alias), {
160
- "@module-federation/runtime$": runtimeESMPath
158
+ '@module-federation/runtime$': runtimeESMPath
161
159
  });
162
160
  });
163
161
  if (!disableManifest) {
164
162
  new StatsPlugin(options, {
165
- pluginVersion: "0.1.12",
166
- bundler: "rspack"
163
+ pluginVersion: "0.1.14",
164
+ bundler: 'rspack'
167
165
  }).apply(compiler);
168
166
  }
169
167
  }
@@ -174,12 +172,12 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
174
172
  var splitChunks = compiler.options.optimization.splitChunks;
175
173
  var patchChunkSplit = function(cacheGroup) {
176
174
  switch(typeof cacheGroup === "undefined" ? "undefined" : _type_of(cacheGroup)){
177
- case "boolean":
178
- case "string":
179
- case "function":
175
+ case 'boolean':
176
+ case 'string':
177
+ case 'function':
180
178
  break;
181
179
  // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
182
- case "object":
180
+ case 'object':
183
181
  {
184
182
  if (_instanceof(cacheGroup, RegExp)) {
185
183
  break;
@@ -187,23 +185,23 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
187
185
  if (!cacheGroup.chunks) {
188
186
  break;
189
187
  }
190
- if (typeof cacheGroup.chunks === "function") {
188
+ if (typeof cacheGroup.chunks === 'function') {
191
189
  var prevChunks = cacheGroup.chunks;
192
190
  cacheGroup.chunks = function(chunk) {
193
- if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) {
191
+ if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
194
192
  return false;
195
193
  }
196
194
  return prevChunks(chunk);
197
195
  };
198
196
  break;
199
197
  }
200
- if (cacheGroup.chunks === "all") {
201
- cacheGroup.chunks = new RegExp("^(?!.*(".concat(name, "|").concat(name, "_partial)).*$"), "g");
198
+ if (cacheGroup.chunks === 'all') {
199
+ cacheGroup.chunks = new RegExp("^(?!.*(".concat(name, "|").concat(name, "_partial)).*$"), 'g');
202
200
  break;
203
201
  }
204
- if (cacheGroup.chunks === "initial") {
202
+ if (cacheGroup.chunks === 'initial') {
205
203
  cacheGroup.chunks = function(chunk) {
206
- if (chunk.name && (chunk.name === name || chunk.name === name + "_partial")) {
204
+ if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
207
205
  return false;
208
206
  }
209
207
  return chunk.isOnlyInitial();
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/rspack",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Module Federation",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/rspack",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Module Federation",
@@ -19,11 +19,11 @@
19
19
  "module": "./dist/index.esm.js",
20
20
  "types": "./dist/index.cjs.d.ts",
21
21
  "dependencies": {
22
- "@module-federation/sdk": "0.1.12",
23
- "@module-federation/runtime-tools": "0.1.12",
24
- "@module-federation/manifest": "0.1.12",
25
- "@module-federation/managers": "0.1.12",
26
- "@module-federation/dts-plugin": "0.1.12"
22
+ "@module-federation/sdk": "0.1.14",
23
+ "@module-federation/runtime-tools": "0.1.14",
24
+ "@module-federation/manifest": "0.1.14",
25
+ "@module-federation/managers": "0.1.14",
26
+ "@module-federation/dts-plugin": "0.1.14"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@rspack/core": "0.5.0"
@@ -1 +0,0 @@
1
- export declare function getIdentifier(name: string): string;