@module-federation/sdk 0.6.16 → 0.7.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/index.cjs.js CHANGED
@@ -600,11 +600,9 @@ const loadNodeFetch = async ()=>{
600
600
  const fetchModule = await importNodeModule('node-fetch');
601
601
  return fetchModule.default || fetchModule;
602
602
  };
603
- const lazyLoaderHookFetch = async (input, init)=>{
604
- // @ts-ignore
605
- const loaderHooks = __webpack_require__.federation.instance.loaderHook;
603
+ const lazyLoaderHookFetch = async (input, init, loaderHook)=>{
606
604
  const hook = (url, init)=>{
607
- return loaderHooks.lifecycle.fetch.emit(url, init);
605
+ return loaderHook.lifecycle.fetch.emit(url, init);
608
606
  };
609
607
  const res = await hook(input, init || {});
610
608
  if (!res || !(res instanceof Response)) {
@@ -613,9 +611,9 @@ const lazyLoaderHookFetch = async (input, init)=>{
613
611
  }
614
612
  return res;
615
613
  };
616
- function createScriptNode(url, cb, attrs, createScriptHook) {
617
- if (createScriptHook) {
618
- const hookResult = createScriptHook(url);
614
+ function createScriptNode(url, cb, attrs, loaderHook) {
615
+ if (loaderHook == null ? void 0 : loaderHook.createScriptHook) {
616
+ const hookResult = loaderHook.createScriptHook(url);
619
617
  if (hookResult && typeof hookResult === 'object' && 'url' in hookResult) {
620
618
  url = hookResult.url;
621
619
  }
@@ -629,17 +627,8 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
629
627
  return;
630
628
  }
631
629
  const getFetch = async ()=>{
632
- //@ts-ignore
633
- if (typeof __webpack_require__ !== 'undefined') {
634
- try {
635
- //@ts-ignore
636
- const loaderHooks = __webpack_require__.federation.instance.loaderHook;
637
- if (loaderHooks.lifecycle.fetch) {
638
- return lazyLoaderHookFetch;
639
- }
640
- } catch (e) {
641
- console.warn('federation.instance.loaderHook.lifecycle.fetch failed:', e);
642
- }
630
+ if (loaderHook == null ? void 0 : loaderHook.fetch) {
631
+ return (input, init)=>lazyLoaderHookFetch(input, init, loaderHook);
643
632
  }
644
633
  return typeof fetch === 'undefined' ? loadNodeFetch() : fetch;
645
634
  };
@@ -706,7 +695,7 @@ function loadScriptNode(url, info) {
706
695
  const entryExports = globalThis[remoteEntryKey] = scriptContext;
707
696
  resolve(entryExports);
708
697
  }
709
- }, info.attrs, info.createScriptHook);
698
+ }, info.attrs, info.loaderHook);
710
699
  });
711
700
  }
712
701
  async function loadModule(url, options) {
@@ -1,5 +1,5 @@
1
1
  import { createLogger as createLogger$1 } from 'isomorphic-rslog';
2
- import { _ as _extends } from './polyfills.esm.js';
2
+ import { _ as _extends } from './polyfills.esm.mjs';
3
3
 
4
4
  const FederationModuleManifest = 'federation-manifest.json';
5
5
  const MANIFEST_EXT = '.json';
@@ -598,11 +598,9 @@ const loadNodeFetch = async ()=>{
598
598
  const fetchModule = await importNodeModule('node-fetch');
599
599
  return fetchModule.default || fetchModule;
600
600
  };
601
- const lazyLoaderHookFetch = async (input, init)=>{
602
- // @ts-ignore
603
- const loaderHooks = __webpack_require__.federation.instance.loaderHook;
601
+ const lazyLoaderHookFetch = async (input, init, loaderHook)=>{
604
602
  const hook = (url, init)=>{
605
- return loaderHooks.lifecycle.fetch.emit(url, init);
603
+ return loaderHook.lifecycle.fetch.emit(url, init);
606
604
  };
607
605
  const res = await hook(input, init || {});
608
606
  if (!res || !(res instanceof Response)) {
@@ -611,9 +609,9 @@ const lazyLoaderHookFetch = async (input, init)=>{
611
609
  }
612
610
  return res;
613
611
  };
614
- function createScriptNode(url, cb, attrs, createScriptHook) {
615
- if (createScriptHook) {
616
- const hookResult = createScriptHook(url);
612
+ function createScriptNode(url, cb, attrs, loaderHook) {
613
+ if (loaderHook == null ? void 0 : loaderHook.createScriptHook) {
614
+ const hookResult = loaderHook.createScriptHook(url);
617
615
  if (hookResult && typeof hookResult === 'object' && 'url' in hookResult) {
618
616
  url = hookResult.url;
619
617
  }
@@ -627,17 +625,8 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
627
625
  return;
628
626
  }
629
627
  const getFetch = async ()=>{
630
- //@ts-ignore
631
- if (typeof __webpack_require__ !== 'undefined') {
632
- try {
633
- //@ts-ignore
634
- const loaderHooks = __webpack_require__.federation.instance.loaderHook;
635
- if (loaderHooks.lifecycle.fetch) {
636
- return lazyLoaderHookFetch;
637
- }
638
- } catch (e) {
639
- console.warn('federation.instance.loaderHook.lifecycle.fetch failed:', e);
640
- }
628
+ if (loaderHook == null ? void 0 : loaderHook.fetch) {
629
+ return (input, init)=>lazyLoaderHookFetch(input, init, loaderHook);
641
630
  }
642
631
  return typeof fetch === 'undefined' ? loadNodeFetch() : fetch;
643
632
  };
@@ -704,7 +693,7 @@ function loadScriptNode(url, info) {
704
693
  const entryExports = globalThis[remoteEntryKey] = scriptContext;
705
694
  resolve(entryExports);
706
695
  }
707
- }, info.attrs, info.createScriptHook);
696
+ }, info.attrs, info.loaderHook);
708
697
  });
709
698
  }
710
699
  async function loadModule(url, options) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.6.16",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
@@ -22,12 +22,12 @@
22
22
  "exports": {
23
23
  ".": {
24
24
  "types": "./dist/index.cjs.d.ts",
25
- "import": "./dist/index.esm.js",
25
+ "import": "./dist/index.esm.mjs",
26
26
  "require": "./dist/index.cjs.js"
27
27
  },
28
28
  "./normalize-webpack-path": {
29
29
  "types": "./dist/normalize-webpack-path.cjs.d.ts",
30
- "import": "./dist/normalize-webpack-path.esm.js",
30
+ "import": "./dist/normalize-webpack-path.esm.mjs",
31
31
  "require": "./dist/normalize-webpack-path.cjs.js"
32
32
  }
33
33
  },
@@ -1,6 +1,11 @@
1
- import { CreateScriptHookNode } from './types';
2
- export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: CreateScriptHookNode): void;
1
+ import { CreateScriptHookNode, FetchHook } from './types';
2
+ export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, loaderHook?: {
3
+ createScriptHook?: CreateScriptHookNode;
4
+ fetch?: FetchHook;
5
+ }): void;
3
6
  export declare function loadScriptNode(url: string, info: {
4
7
  attrs?: Record<string, any>;
5
- createScriptHook?: CreateScriptHookNode;
8
+ loaderHook?: {
9
+ createScriptHook?: CreateScriptHookNode;
10
+ };
6
11
  }): Promise<void>;
@@ -9,3 +9,4 @@ export type CreateScriptHookReturn = CreateScriptHookReturnNode | CreateScriptHo
9
9
  export type CreateScriptHookNode = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnNode;
10
10
  export type CreateScriptHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnDom;
11
11
  export type CreateScriptHook = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
12
+ export type FetchHook = (args: [string, RequestInit]) => Promise<Response> | void | false;
@@ -183,6 +183,14 @@ export interface ModuleFederationPluginOptions {
183
183
  experiments?: {
184
184
  federationRuntime?: false | 'hoisted';
185
185
  };
186
+ bridge?: {
187
+ /**
188
+ * Disables the default alias setting in the bridge.
189
+ * When true, users must manually handle basename through root component props.
190
+ * @default false
191
+ */
192
+ disableAlias?: boolean;
193
+ };
186
194
  }
187
195
  /**
188
196
  * Modules that should be exposed by this container. Property names are used as public paths.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.6.16",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
@@ -17,17 +17,17 @@
17
17
  "author": "zhanghang <hanric.zhang@gmail.com>",
18
18
  "sideEffects": false,
19
19
  "main": "./dist/index.cjs.js",
20
- "module": "./dist/index.esm.js",
20
+ "module": "./dist/index.esm.mjs",
21
21
  "types": "./dist/index.cjs.d.ts",
22
22
  "exports": {
23
23
  ".": {
24
24
  "types": "./dist/index.cjs.d.ts",
25
- "import": "./dist/index.esm.js",
25
+ "import": "./dist/index.esm.mjs",
26
26
  "require": "./dist/index.cjs.js"
27
27
  },
28
28
  "./normalize-webpack-path": {
29
29
  "types": "./dist/normalize-webpack-path.cjs.d.ts",
30
- "import": "./dist/normalize-webpack-path.esm.js",
30
+ "import": "./dist/normalize-webpack-path.esm.mjs",
31
31
  "require": "./dist/normalize-webpack-path.cjs.js"
32
32
  }
33
33
  },
File without changes