@module-federation/runtime 0.1.2 → 0.1.3
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/README.md +42 -0
- package/dist/index.cjs.js +9 -3
- package/dist/index.esm.js +9 -4
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +1 -1
- package/dist/share.esm.js +1 -1
- package/dist/src/core.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -325,6 +325,48 @@ registerRemotes([
|
|
|
325
325
|
]);
|
|
326
326
|
```
|
|
327
327
|
|
|
328
|
+
### registerPlugins
|
|
329
|
+
|
|
330
|
+
- Type: `registerPlugins(plugins: Array<FederationRuntimePlugin>): void`
|
|
331
|
+
- Used to register remotes after init .
|
|
332
|
+
|
|
333
|
+
- Type
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
import type { FederationRuntimePlugin } from '@module-federation/runtime';
|
|
337
|
+
|
|
338
|
+
function registerPlugins(plugins: Array<FederationRuntimePlugin>) {}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
- Details:
|
|
342
|
+
Allows plugins to be registered dynamically or lazily. Lazy plugins will be called after normal runtime plugins.
|
|
343
|
+
Similar function as registerRemote, but for runtime plugins.
|
|
344
|
+
* Example
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
import { init, registerPlugins } from '@module-federation/runtime';
|
|
348
|
+
|
|
349
|
+
init({
|
|
350
|
+
name: '@demo/register-new-remotes',
|
|
351
|
+
remotes: [
|
|
352
|
+
{
|
|
353
|
+
name: '@demo/sub1',
|
|
354
|
+
entry: 'http://localhost:2001/mf-manifest.json',
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
plugins: [
|
|
358
|
+
//normal/eager runtime plugins
|
|
359
|
+
]
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
import('./runtime-plugin').then(plugin => {
|
|
363
|
+
registerPlugins([
|
|
364
|
+
//more plugins loaded lazyily or dynamically
|
|
365
|
+
plugin
|
|
366
|
+
]);
|
|
367
|
+
})
|
|
368
|
+
```
|
|
369
|
+
|
|
328
370
|
## hooks
|
|
329
371
|
|
|
330
372
|
Lifecycle hooks for FederationHost interaction.
|
package/dist/index.cjs.js
CHANGED
|
@@ -69,7 +69,7 @@ function matchRemote(remotes, nameOrAlias) {
|
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function registerPlugins(plugins, hookInstances) {
|
|
72
|
+
function registerPlugins$1(plugins, hookInstances) {
|
|
73
73
|
const globalPlugins = share.getGlobalHostPlugins();
|
|
74
74
|
// Incorporate global plugins
|
|
75
75
|
if (globalPlugins.length > 0) {
|
|
@@ -1527,7 +1527,7 @@ class FederationHost {
|
|
|
1527
1527
|
return optionsRes;
|
|
1528
1528
|
}
|
|
1529
1529
|
registerPlugins(plugins) {
|
|
1530
|
-
registerPlugins(plugins, [
|
|
1530
|
+
registerPlugins$1(plugins, [
|
|
1531
1531
|
this.hooks,
|
|
1532
1532
|
this.snapshotHandler.hooks,
|
|
1533
1533
|
this.loaderHook
|
|
@@ -1658,7 +1658,7 @@ class FederationHost {
|
|
|
1658
1658
|
// not used yet
|
|
1659
1659
|
afterPreloadRemote: new AsyncHook()
|
|
1660
1660
|
});
|
|
1661
|
-
this.version = "0.1.
|
|
1661
|
+
this.version = "0.1.3";
|
|
1662
1662
|
this.moduleCache = new Map();
|
|
1663
1663
|
this.loaderHook = new PluginSystem({
|
|
1664
1664
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -1738,6 +1738,11 @@ function registerRemotes(...args) {
|
|
|
1738
1738
|
// eslint-disable-next-line prefer-spread
|
|
1739
1739
|
return FederationInstance.registerRemotes.apply(FederationInstance, args);
|
|
1740
1740
|
}
|
|
1741
|
+
function registerPlugins(...args) {
|
|
1742
|
+
share.assert(FederationInstance, 'Please call init first');
|
|
1743
|
+
// eslint-disable-next-line prefer-spread
|
|
1744
|
+
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
1745
|
+
}
|
|
1741
1746
|
// Inject for debug
|
|
1742
1747
|
share.setGlobalFederationConstructor(FederationHost);
|
|
1743
1748
|
|
|
@@ -1758,4 +1763,5 @@ exports.loadRemote = loadRemote;
|
|
|
1758
1763
|
exports.loadShare = loadShare;
|
|
1759
1764
|
exports.loadShareSync = loadShareSync;
|
|
1760
1765
|
exports.preloadRemote = preloadRemote;
|
|
1766
|
+
exports.registerPlugins = registerPlugins;
|
|
1761
1767
|
exports.registerRemotes = registerRemotes;
|
package/dist/index.esm.js
CHANGED
|
@@ -67,7 +67,7 @@ function matchRemote(remotes, nameOrAlias) {
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function registerPlugins(plugins, hookInstances) {
|
|
70
|
+
function registerPlugins$1(plugins, hookInstances) {
|
|
71
71
|
const globalPlugins = getGlobalHostPlugins();
|
|
72
72
|
// Incorporate global plugins
|
|
73
73
|
if (globalPlugins.length > 0) {
|
|
@@ -1525,7 +1525,7 @@ class FederationHost {
|
|
|
1525
1525
|
return optionsRes;
|
|
1526
1526
|
}
|
|
1527
1527
|
registerPlugins(plugins) {
|
|
1528
|
-
registerPlugins(plugins, [
|
|
1528
|
+
registerPlugins$1(plugins, [
|
|
1529
1529
|
this.hooks,
|
|
1530
1530
|
this.snapshotHandler.hooks,
|
|
1531
1531
|
this.loaderHook
|
|
@@ -1656,7 +1656,7 @@ class FederationHost {
|
|
|
1656
1656
|
// not used yet
|
|
1657
1657
|
afterPreloadRemote: new AsyncHook()
|
|
1658
1658
|
});
|
|
1659
|
-
this.version = "0.1.
|
|
1659
|
+
this.version = "0.1.3";
|
|
1660
1660
|
this.moduleCache = new Map();
|
|
1661
1661
|
this.loaderHook = new PluginSystem({
|
|
1662
1662
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -1736,7 +1736,12 @@ function registerRemotes(...args) {
|
|
|
1736
1736
|
// eslint-disable-next-line prefer-spread
|
|
1737
1737
|
return FederationInstance.registerRemotes.apply(FederationInstance, args);
|
|
1738
1738
|
}
|
|
1739
|
+
function registerPlugins(...args) {
|
|
1740
|
+
assert(FederationInstance, 'Please call init first');
|
|
1741
|
+
// eslint-disable-next-line prefer-spread
|
|
1742
|
+
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
1743
|
+
}
|
|
1739
1744
|
// Inject for debug
|
|
1740
1745
|
setGlobalFederationConstructor(FederationHost);
|
|
1741
1746
|
|
|
1742
|
-
export { FederationHost, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes };
|
|
1747
|
+
export { FederationHost, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -185,7 +185,7 @@ function getGlobalFederationConstructor() {
|
|
|
185
185
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
186
186
|
if (isDebug) {
|
|
187
187
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
188
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
188
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.3";
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/share.esm.js
CHANGED
|
@@ -183,7 +183,7 @@ function getGlobalFederationConstructor() {
|
|
|
183
183
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
184
184
|
if (isDebug) {
|
|
185
185
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
186
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
186
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.3";
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/src/core.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ export declare class FederationHost {
|
|
|
153
153
|
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
|
|
154
154
|
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string]): void;
|
|
155
155
|
private formatOptions;
|
|
156
|
-
|
|
156
|
+
registerPlugins(plugins: UserOptions['plugins']): void;
|
|
157
157
|
private setShared;
|
|
158
158
|
private removeRemote;
|
|
159
159
|
private registerRemote;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export declare function loadShare(...args: Parameters<FederationHost['loadShare'
|
|
|
12
12
|
export declare function loadShareSync(...args: Parameters<FederationHost['loadShareSync']>): ReturnType<FederationHost['loadShareSync']>;
|
|
13
13
|
export declare function preloadRemote(...args: Parameters<FederationHost['preloadRemote']>): ReturnType<FederationHost['preloadRemote']>;
|
|
14
14
|
export declare function registerRemotes(...args: Parameters<FederationHost['registerRemotes']>): ReturnType<FederationHost['registerRemotes']>;
|
|
15
|
+
export declare function registerPlugins(...args: Parameters<FederationHost['registerPlugins']>): ReturnType<FederationHost['registerRemotes']>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@module-federation/sdk": "0.1.
|
|
48
|
+
"@module-federation/sdk": "0.1.3"
|
|
49
49
|
}
|
|
50
50
|
}
|