@module-federation/rspack 0.13.0 → 0.14.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.
@@ -99,12 +99,26 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
99
99
  {
100
100
  key: "_patchBundlerConfig",
101
101
  value: function _patchBundlerConfig(compiler) {
102
- var name = this._options.name;
102
+ var _experiments_optimization;
103
+ var _this__options = this._options, name = _this__options.name, experiments = _this__options.experiments;
104
+ var definePluginOptions = {};
103
105
  if (name) {
104
- new compiler.webpack.DefinePlugin({
105
- FEDERATION_BUILD_IDENTIFIER: JSON.stringify(sdk.composeKeyWithSeparator(name, managers.utils.getBuildVersion()))
106
- }).apply(compiler);
106
+ definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(sdk.composeKeyWithSeparator(name, managers.utils.getBuildVersion()));
107
+ }
108
+ var _experiments_optimization_disableSnapshot;
109
+ // Add FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN
110
+ var disableSnapshot = (_experiments_optimization_disableSnapshot = experiments === null || experiments === void 0 ? void 0 : (_experiments_optimization = experiments.optimization) === null || _experiments_optimization === void 0 ? void 0 : _experiments_optimization.disableSnapshot) !== null && _experiments_optimization_disableSnapshot !== void 0 ? _experiments_optimization_disableSnapshot : false;
111
+ definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] = disableSnapshot;
112
+ // Determine ENV_TARGET: only if manually specified in experiments.optimization.target
113
+ if ((experiments === null || experiments === void 0 ? void 0 : experiments.optimization) && _type_of(experiments.optimization) === 'object' && experiments.optimization !== null && 'target' in experiments.optimization) {
114
+ var manualTarget = experiments.optimization.target;
115
+ // Ensure the target is one of the expected values before setting
116
+ if (manualTarget === 'web' || manualTarget === 'node') {
117
+ definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);
118
+ }
107
119
  }
120
+ // No inference for ENV_TARGET. If not manually set and valid, it's not defined.
121
+ new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);
108
122
  }
109
123
  },
110
124
  {
@@ -113,7 +127,10 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
113
127
  var _this = this;
114
128
  var count = 0;
115
129
  compiler.options.plugins.forEach(function(p) {
116
- if (p.name === _this.name) {
130
+ if ((typeof p === "undefined" ? "undefined" : _type_of(p)) !== 'object' || !p) {
131
+ return;
132
+ }
133
+ if (p['name'] === _this.name) {
117
134
  count++;
118
135
  if (count > 1) {
119
136
  throw new Error("Detect duplicate register ".concat(_this.name, ",please ensure ").concat(_this.name, " is singleton!"));
@@ -156,8 +173,10 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
156
173
  var disableManifest = options.manifest === false;
157
174
  var disableDts = options.dts === false;
158
175
  if (!disableDts) {
176
+ var dtsPlugin$1 = new dtsPlugin.DtsPlugin(options);
159
177
  // @ts-ignore
160
- new dtsPlugin.DtsPlugin(options).apply(compiler);
178
+ dtsPlugin$1.apply(compiler);
179
+ dtsPlugin$1.addRuntimePlugins();
161
180
  }
162
181
  if (!disableManifest && options.exposes) {
163
182
  try {
@@ -183,7 +202,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
183
202
  });
184
203
  if (!disableManifest) {
185
204
  this._statsPlugin = new manifest.StatsPlugin(options, {
186
- pluginVersion: "0.13.0",
205
+ pluginVersion: "0.14.0",
187
206
  bundler: 'rspack'
188
207
  });
189
208
  // @ts-ignore
@@ -97,12 +97,26 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
97
97
  {
98
98
  key: "_patchBundlerConfig",
99
99
  value: function _patchBundlerConfig(compiler) {
100
- var name = this._options.name;
100
+ var _experiments_optimization;
101
+ var _this__options = this._options, name = _this__options.name, experiments = _this__options.experiments;
102
+ var definePluginOptions = {};
101
103
  if (name) {
102
- new compiler.webpack.DefinePlugin({
103
- FEDERATION_BUILD_IDENTIFIER: JSON.stringify(composeKeyWithSeparator(name, utils.getBuildVersion()))
104
- }).apply(compiler);
104
+ definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(composeKeyWithSeparator(name, utils.getBuildVersion()));
105
+ }
106
+ var _experiments_optimization_disableSnapshot;
107
+ // Add FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN
108
+ var disableSnapshot = (_experiments_optimization_disableSnapshot = experiments === null || experiments === void 0 ? void 0 : (_experiments_optimization = experiments.optimization) === null || _experiments_optimization === void 0 ? void 0 : _experiments_optimization.disableSnapshot) !== null && _experiments_optimization_disableSnapshot !== void 0 ? _experiments_optimization_disableSnapshot : false;
109
+ definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] = disableSnapshot;
110
+ // Determine ENV_TARGET: only if manually specified in experiments.optimization.target
111
+ if ((experiments === null || experiments === void 0 ? void 0 : experiments.optimization) && _type_of(experiments.optimization) === 'object' && experiments.optimization !== null && 'target' in experiments.optimization) {
112
+ var manualTarget = experiments.optimization.target;
113
+ // Ensure the target is one of the expected values before setting
114
+ if (manualTarget === 'web' || manualTarget === 'node') {
115
+ definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);
116
+ }
105
117
  }
118
+ // No inference for ENV_TARGET. If not manually set and valid, it's not defined.
119
+ new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);
106
120
  }
107
121
  },
108
122
  {
@@ -111,7 +125,10 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
111
125
  var _this = this;
112
126
  var count = 0;
113
127
  compiler.options.plugins.forEach(function(p) {
114
- if (p.name === _this.name) {
128
+ if ((typeof p === "undefined" ? "undefined" : _type_of(p)) !== 'object' || !p) {
129
+ return;
130
+ }
131
+ if (p['name'] === _this.name) {
115
132
  count++;
116
133
  if (count > 1) {
117
134
  throw new Error("Detect duplicate register ".concat(_this.name, ",please ensure ").concat(_this.name, " is singleton!"));
@@ -154,8 +171,10 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
154
171
  var disableManifest = options.manifest === false;
155
172
  var disableDts = options.dts === false;
156
173
  if (!disableDts) {
174
+ var dtsPlugin = new DtsPlugin(options);
157
175
  // @ts-ignore
158
- new DtsPlugin(options).apply(compiler);
176
+ dtsPlugin.apply(compiler);
177
+ dtsPlugin.addRuntimePlugins();
159
178
  }
160
179
  if (!disableManifest && options.exposes) {
161
180
  try {
@@ -181,7 +200,7 @@ var ModuleFederationPlugin = /*#__PURE__*/ function() {
181
200
  });
182
201
  if (!disableManifest) {
183
202
  this._statsPlugin = new StatsPlugin(options, {
184
- pluginVersion: "0.13.0",
203
+ pluginVersion: "0.14.0",
185
204
  bundler: 'rspack'
186
205
  });
187
206
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/rspack",
3
- "version": "0.13.0",
3
+ "version": "0.14.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.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"
28
+ "@module-federation/bridge-react-webpack-plugin": "0.14.0",
29
+ "@module-federation/dts-plugin": "0.14.0",
30
+ "@module-federation/managers": "0.14.0",
31
+ "@module-federation/manifest": "0.14.0",
32
+ "@module-federation/runtime-tools": "0.14.0",
33
+ "@module-federation/inject-external-runtime-core-plugin": "0.14.0",
34
+ "@module-federation/sdk": "0.14.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rspack/core": "^1.0.2"