@module-federation/sdk 0.6.0 → 0.6.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.
package/dist/index.cjs.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var polyfills = require('./polyfills.cjs.js');
6
+
5
7
  const FederationModuleManifest = 'federation-manifest.json';
6
8
  const MANIFEST_EXT = '.json';
7
9
  const BROWSER_LOG_KEY = 'FEDERATION_DEBUG';
@@ -61,13 +63,6 @@ const getProcessEnv = function() {
61
63
  return typeof process !== 'undefined' && process.env ? process.env : {};
62
64
  };
63
65
 
64
- function safeToString(info) {
65
- try {
66
- return JSON.stringify(info, null, 2);
67
- } catch (e) {
68
- return '';
69
- }
70
- }
71
66
  const DEBUG_LOG = '[ FEDERATION DEBUG ]';
72
67
  function safeGetLocalStorageItem() {
73
68
  try {
@@ -247,16 +242,12 @@ const error = (msg)=>{
247
242
  const warn = (msg)=>{
248
243
  console.warn(`${LOG_CATEGORY}: ${msg}`);
249
244
  };
250
-
251
- function _extends() {
252
- _extends = Object.assign || function assign(target) {
253
- for(var i = 1; i < arguments.length; i++){
254
- var source = arguments[i];
255
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
256
- }
257
- return target;
258
- };
259
- return _extends.apply(this, arguments);
245
+ function safeToString(info) {
246
+ try {
247
+ return JSON.stringify(info, null, 2);
248
+ } catch (e) {
249
+ return '';
250
+ }
260
251
  }
261
252
 
262
253
  const simpleJoinRemoteEntry = (rPath, rName)=>{
@@ -362,23 +353,23 @@ function generateSnapshotFromManifest(manifest, options = {}) {
362
353
  };
363
354
  if ((_manifest_metaData = manifest.metaData) == null ? void 0 : _manifest_metaData.prefetchInterface) {
364
355
  const prefetchInterface = manifest.metaData.prefetchInterface;
365
- basicRemoteSnapshot = _extends({}, basicRemoteSnapshot, {
356
+ basicRemoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
366
357
  prefetchInterface
367
358
  });
368
359
  }
369
360
  if ((_manifest_metaData1 = manifest.metaData) == null ? void 0 : _manifest_metaData1.prefetchEntry) {
370
361
  const { path, name, type } = manifest.metaData.prefetchEntry;
371
- basicRemoteSnapshot = _extends({}, basicRemoteSnapshot, {
362
+ basicRemoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
372
363
  prefetchEntry: simpleJoinRemoteEntry(path, name),
373
364
  prefetchEntryType: type
374
365
  });
375
366
  }
376
367
  if ('publicPath' in manifest.metaData) {
377
- remoteSnapshot = _extends({}, basicRemoteSnapshot, {
368
+ remoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
378
369
  publicPath: getPublicPath()
379
370
  });
380
371
  } else {
381
- remoteSnapshot = _extends({}, basicRemoteSnapshot, {
372
+ remoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
382
373
  getPublicPath: getPublicPath()
383
374
  });
384
375
  }
@@ -463,7 +454,7 @@ function createScript(info) {
463
454
  });
464
455
  }
465
456
  }
466
- const onScriptComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
457
+ const onScriptComplete = async (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
467
458
  event)=>{
468
459
  var _info_cb;
469
460
  clearTimeout(timeoutId);
@@ -477,12 +468,17 @@ function createScript(info) {
477
468
  (script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
478
469
  }
479
470
  });
480
- if (prev) {
471
+ if (prev && typeof prev === 'function') {
481
472
  var _info_cb1;
482
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
483
- const res = prev(event);
473
+ const result = prev(event);
474
+ if (result instanceof Promise) {
475
+ var _info_cb2;
476
+ const res = await result;
477
+ info == null ? void 0 : (_info_cb2 = info.cb) == null ? void 0 : _info_cb2.call(info);
478
+ return res;
479
+ }
484
480
  info == null ? void 0 : (_info_cb1 = info.cb) == null ? void 0 : _info_cb1.call(info);
485
- return res;
481
+ return result;
486
482
  }
487
483
  }
488
484
  info == null ? void 0 : (_info_cb = info.cb) == null ? void 0 : _info_cb.call(info);
@@ -566,7 +562,7 @@ function loadScript(url, info) {
566
562
  const { script, needAttach } = createScript({
567
563
  url,
568
564
  cb: resolve,
569
- attrs: _extends({
565
+ attrs: polyfills._extends({
570
566
  fetchpriority: 'high'
571
567
  }, attrs),
572
568
  createScriptHook,
@@ -702,7 +698,7 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
702
698
  return defaultOptions;
703
699
  }
704
700
  if (options && typeof options === 'object') {
705
- return _extends({}, defaultOptions, options);
701
+ return polyfills._extends({}, defaultOptions, options);
706
702
  }
707
703
  throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
708
704
  };
@@ -749,6 +745,7 @@ exports.logger = logger;
749
745
  exports.moduleFederationPlugin = ModuleFederationPlugin;
750
746
  exports.normalizeOptions = normalizeOptions;
751
747
  exports.parseEntry = parseEntry;
748
+ exports.safeToString = safeToString;
752
749
  exports.safeWrapper = safeWrapper;
753
750
  exports.sharePlugin = SharePlugin;
754
751
  exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry;
package/dist/index.esm.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { _ as _extends } from './polyfills.esm.js';
2
+
1
3
  const FederationModuleManifest = 'federation-manifest.json';
2
4
  const MANIFEST_EXT = '.json';
3
5
  const BROWSER_LOG_KEY = 'FEDERATION_DEBUG';
@@ -57,13 +59,6 @@ const getProcessEnv = function() {
57
59
  return typeof process !== 'undefined' && process.env ? process.env : {};
58
60
  };
59
61
 
60
- function safeToString(info) {
61
- try {
62
- return JSON.stringify(info, null, 2);
63
- } catch (e) {
64
- return '';
65
- }
66
- }
67
62
  const DEBUG_LOG = '[ FEDERATION DEBUG ]';
68
63
  function safeGetLocalStorageItem() {
69
64
  try {
@@ -243,16 +238,12 @@ const error = (msg)=>{
243
238
  const warn = (msg)=>{
244
239
  console.warn(`${LOG_CATEGORY}: ${msg}`);
245
240
  };
246
-
247
- function _extends() {
248
- _extends = Object.assign || function assign(target) {
249
- for(var i = 1; i < arguments.length; i++){
250
- var source = arguments[i];
251
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
252
- }
253
- return target;
254
- };
255
- return _extends.apply(this, arguments);
241
+ function safeToString(info) {
242
+ try {
243
+ return JSON.stringify(info, null, 2);
244
+ } catch (e) {
245
+ return '';
246
+ }
256
247
  }
257
248
 
258
249
  const simpleJoinRemoteEntry = (rPath, rName)=>{
@@ -459,7 +450,7 @@ function createScript(info) {
459
450
  });
460
451
  }
461
452
  }
462
- const onScriptComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
453
+ const onScriptComplete = async (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
463
454
  event)=>{
464
455
  var _info_cb;
465
456
  clearTimeout(timeoutId);
@@ -473,12 +464,17 @@ function createScript(info) {
473
464
  (script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
474
465
  }
475
466
  });
476
- if (prev) {
467
+ if (prev && typeof prev === 'function') {
477
468
  var _info_cb1;
478
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
479
- const res = prev(event);
469
+ const result = prev(event);
470
+ if (result instanceof Promise) {
471
+ var _info_cb2;
472
+ const res = await result;
473
+ info == null ? void 0 : (_info_cb2 = info.cb) == null ? void 0 : _info_cb2.call(info);
474
+ return res;
475
+ }
480
476
  info == null ? void 0 : (_info_cb1 = info.cb) == null ? void 0 : _info_cb1.call(info);
481
- return res;
477
+ return result;
482
478
  }
483
479
  }
484
480
  info == null ? void 0 : (_info_cb = info.cb) == null ? void 0 : _info_cb.call(info);
@@ -704,4 +700,4 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
704
700
  };
705
701
  }
706
702
 
707
- export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn };
703
+ export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeToString, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ function _extends() {
4
+ _extends = Object.assign || function assign(target) {
5
+ for(var i = 1; i < arguments.length; i++){
6
+ var source = arguments[i];
7
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
8
+ }
9
+ return target;
10
+ };
11
+ return _extends.apply(this, arguments);
12
+ }
13
+
14
+ exports._extends = _extends;
@@ -0,0 +1,12 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function assign(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
6
+ }
7
+ return target;
8
+ };
9
+ return _extends.apply(this, arguments);
10
+ }
11
+
12
+ export { _extends as _ };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
3
3
  */
4
- export type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'script' | 'node-commonjs';
4
+ export type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'module-import' | 'script' | 'node-commonjs';
5
5
  /**
6
6
  * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
7
7
  */
@@ -175,6 +175,9 @@ export interface ModuleFederationPluginOptions {
175
175
  dts?: boolean | PluginDtsOptions;
176
176
  async?: boolean | AsyncBoundaryOptions;
177
177
  virtualRuntimeEntry?: boolean;
178
+ experiments?: {
179
+ federationRuntime?: false | 'hoisted';
180
+ };
178
181
  }
179
182
  /**
180
183
  * Modules that should be exposed by this container. Property names are used as public paths.
@@ -14,4 +14,5 @@ declare const getResourceUrl: (module: ModuleInfo, sourceUrl: string) => string;
14
14
  declare const assert: (condition: any, msg: string) => asserts condition;
15
15
  declare const error: (msg: string | Error | unknown) => never;
16
16
  declare const warn: (msg: Parameters<typeof console.warn>[0]) => void;
17
- export { parseEntry, logger, decodeName, encodeName, composeKeyWithSeparator, generateExposeFilename, generateShareFilename, getResourceUrl, assert, error, warn, };
17
+ declare function safeToString(info: any): string;
18
+ export { parseEntry, logger, decodeName, encodeName, composeKeyWithSeparator, generateExposeFilename, generateShareFilename, getResourceUrl, assert, error, warn, safeToString, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [