@module-federation/webpack-bundler-runtime 0.18.0 → 0.18.1

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.
@@ -124,8 +124,22 @@ function consumes(options) {
124
124
  const onFactory = (factory)=>{
125
125
  installedModules[id] = 0;
126
126
  webpackRequire.m[id] = (module)=>{
127
+ var _shareInfo_shareConfig;
127
128
  delete webpackRequire.c[id];
128
- module.exports = factory();
129
+ const result = factory();
130
+ // Add layer property from shareConfig if available
131
+ const { shareInfo } = moduleToHandlerMapping[id];
132
+ if ((shareInfo == null ? void 0 : (_shareInfo_shareConfig = shareInfo.shareConfig) == null ? void 0 : _shareInfo_shareConfig.layer) && result && typeof result === 'object') {
133
+ try {
134
+ // Only set layer if it's not already defined or if it's undefined
135
+ if (!result.hasOwnProperty('layer') || result.layer === undefined) {
136
+ result.layer = shareInfo.shareConfig.layer;
137
+ }
138
+ } catch (e) {
139
+ // Ignore if layer property is read-only
140
+ }
141
+ }
142
+ module.exports = result;
129
143
  };
130
144
  };
131
145
  const onError = (error)=>{
@@ -252,6 +266,7 @@ function installInitialConsumes(options) {
252
266
  const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options;
253
267
  initialConsumes.forEach((id)=>{
254
268
  webpackRequire.m[id] = (module)=>{
269
+ var _shareInfo_shareConfig;
255
270
  // Handle scenario when module is used synchronously
256
271
  installedModules[id] = 0;
257
272
  delete webpackRequire.c[id];
@@ -263,7 +278,20 @@ function installInitialConsumes(options) {
263
278
  if (typeof factory !== 'function') {
264
279
  throw new Error(`Shared module is not available for eager consumption: ${id}`);
265
280
  }
266
- module.exports = factory();
281
+ const result = factory();
282
+ // Add layer property from shareConfig if available
283
+ const { shareInfo } = moduleToHandlerMapping[id];
284
+ if ((shareInfo == null ? void 0 : (_shareInfo_shareConfig = shareInfo.shareConfig) == null ? void 0 : _shareInfo_shareConfig.layer) && result && typeof result === 'object') {
285
+ try {
286
+ // Only set layer if it's not already defined or if it's undefined
287
+ if (!result.hasOwnProperty('layer') || result.layer === undefined) {
288
+ result.layer = shareInfo.shareConfig.layer;
289
+ }
290
+ } catch (e) {
291
+ // Ignore if layer property is read-only
292
+ }
293
+ }
294
+ module.exports = result;
267
295
  };
268
296
  });
269
297
  }
package/dist/index.esm.js CHANGED
@@ -109,8 +109,22 @@ function consumes(options) {
109
109
  const onFactory = (factory)=>{
110
110
  installedModules[id] = 0;
111
111
  webpackRequire.m[id] = (module)=>{
112
+ var _shareInfo_shareConfig;
112
113
  delete webpackRequire.c[id];
113
- module.exports = factory();
114
+ const result = factory();
115
+ // Add layer property from shareConfig if available
116
+ const { shareInfo } = moduleToHandlerMapping[id];
117
+ if ((shareInfo == null ? void 0 : (_shareInfo_shareConfig = shareInfo.shareConfig) == null ? void 0 : _shareInfo_shareConfig.layer) && result && typeof result === 'object') {
118
+ try {
119
+ // Only set layer if it's not already defined or if it's undefined
120
+ if (!result.hasOwnProperty('layer') || result.layer === undefined) {
121
+ result.layer = shareInfo.shareConfig.layer;
122
+ }
123
+ } catch (e) {
124
+ // Ignore if layer property is read-only
125
+ }
126
+ }
127
+ module.exports = result;
114
128
  };
115
129
  };
116
130
  const onError = (error)=>{
@@ -237,6 +251,7 @@ function installInitialConsumes(options) {
237
251
  const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options;
238
252
  initialConsumes.forEach((id)=>{
239
253
  webpackRequire.m[id] = (module)=>{
254
+ var _shareInfo_shareConfig;
240
255
  // Handle scenario when module is used synchronously
241
256
  installedModules[id] = 0;
242
257
  delete webpackRequire.c[id];
@@ -248,7 +263,20 @@ function installInitialConsumes(options) {
248
263
  if (typeof factory !== 'function') {
249
264
  throw new Error(`Shared module is not available for eager consumption: ${id}`);
250
265
  }
251
- module.exports = factory();
266
+ const result = factory();
267
+ // Add layer property from shareConfig if available
268
+ const { shareInfo } = moduleToHandlerMapping[id];
269
+ if ((shareInfo == null ? void 0 : (_shareInfo_shareConfig = shareInfo.shareConfig) == null ? void 0 : _shareInfo_shareConfig.layer) && result && typeof result === 'object') {
270
+ try {
271
+ // Only set layer if it's not already defined or if it's undefined
272
+ if (!result.hasOwnProperty('layer') || result.layer === undefined) {
273
+ result.layer = shareInfo.shareConfig.layer;
274
+ }
275
+ } catch (e) {
276
+ // Ignore if layer property is read-only
277
+ }
278
+ }
279
+ module.exports = result;
252
280
  };
253
281
  });
254
282
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "@module-federation/webpack-bundler-runtime",
4
- "version": "0.18.0",
4
+ "version": "0.18.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Module Federation Runtime for webpack",
@@ -26,8 +26,8 @@
26
26
  "module": "./dist/index.esm.js",
27
27
  "types": "./dist/index.d.ts",
28
28
  "dependencies": {
29
- "@module-federation/runtime": "0.18.0",
30
- "@module-federation/sdk": "0.18.0"
29
+ "@module-federation/runtime": "0.18.1",
30
+ "@module-federation/sdk": "0.18.1"
31
31
  },
32
32
  "exports": {
33
33
  ".": {
@@ -63,6 +63,6 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
- "@module-federation/runtime": "0.18.0"
66
+ "@module-federation/runtime": "0.18.1"
67
67
  }
68
68
  }