@module-federation/runtime 0.1.18 → 0.1.19
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 +90 -33
- package/dist/index.esm.js +91 -34
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +1 -1
- package/dist/share.esm.js +1 -1
- package/dist/src/utils/preload.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -563,7 +563,8 @@ function normalizePreloadExposes(exposes) {
|
|
|
563
563
|
return expose;
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
|
-
function preloadAssets(remoteInfo, host, assets
|
|
566
|
+
function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
|
|
567
|
+
useLinkPreload = true) {
|
|
567
568
|
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
568
569
|
if (host.options.inBrowser) {
|
|
569
570
|
entryAssets.forEach((asset)=>{
|
|
@@ -615,40 +616,96 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
615
616
|
});
|
|
616
617
|
}
|
|
617
618
|
});
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
619
|
+
if (useLinkPreload) {
|
|
620
|
+
cssAssets.forEach((cssUrl)=>{
|
|
621
|
+
const { link: cssEl, needAttach } = sdk.createLink({
|
|
622
|
+
url: cssUrl,
|
|
623
|
+
cb: ()=>{},
|
|
624
|
+
attrs: {
|
|
625
|
+
rel: 'preload',
|
|
626
|
+
as: 'style',
|
|
627
|
+
crossorigin: 'anonymous'
|
|
628
|
+
},
|
|
629
|
+
createLinkHook: (url)=>{
|
|
630
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
631
|
+
url
|
|
632
|
+
});
|
|
633
|
+
if (res instanceof HTMLLinkElement) {
|
|
634
|
+
return res;
|
|
635
|
+
}
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
626
638
|
});
|
|
627
|
-
|
|
628
|
-
return res;
|
|
629
|
-
}
|
|
630
|
-
return;
|
|
639
|
+
needAttach && document.head.appendChild(cssEl);
|
|
631
640
|
});
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
641
|
+
} else {
|
|
642
|
+
cssAssets.forEach((cssUrl)=>{
|
|
643
|
+
const { link: cssEl, needAttach } = sdk.createLink({
|
|
644
|
+
url: cssUrl,
|
|
645
|
+
cb: ()=>{},
|
|
646
|
+
attrs: {
|
|
647
|
+
rel: 'stylesheet',
|
|
648
|
+
type: 'text/css'
|
|
649
|
+
},
|
|
650
|
+
createLinkHook: (url)=>{
|
|
651
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
652
|
+
url
|
|
653
|
+
});
|
|
654
|
+
if (res instanceof HTMLLinkElement) {
|
|
655
|
+
return res;
|
|
656
|
+
}
|
|
657
|
+
return;
|
|
658
|
+
},
|
|
659
|
+
needDeleteLink: false
|
|
643
660
|
});
|
|
644
|
-
|
|
645
|
-
return res;
|
|
646
|
-
}
|
|
647
|
-
return;
|
|
661
|
+
needAttach && document.head.appendChild(cssEl);
|
|
648
662
|
});
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
663
|
+
}
|
|
664
|
+
if (useLinkPreload) {
|
|
665
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
666
|
+
const { link: linkEl, needAttach } = sdk.createLink({
|
|
667
|
+
url: jsUrl,
|
|
668
|
+
cb: ()=>{},
|
|
669
|
+
attrs: {
|
|
670
|
+
rel: 'preload',
|
|
671
|
+
as: 'script',
|
|
672
|
+
crossorigin: 'anonymous'
|
|
673
|
+
},
|
|
674
|
+
createLinkHook: (url)=>{
|
|
675
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
676
|
+
url
|
|
677
|
+
});
|
|
678
|
+
if (res instanceof HTMLLinkElement) {
|
|
679
|
+
return res;
|
|
680
|
+
}
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
needAttach && document.head.appendChild(linkEl);
|
|
685
|
+
});
|
|
686
|
+
} else {
|
|
687
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
688
|
+
const { script: scriptEl, needAttach } = sdk.createScript({
|
|
689
|
+
url: jsUrl,
|
|
690
|
+
cb: ()=>{},
|
|
691
|
+
attrs: {
|
|
692
|
+
crossorigin: 'anonymous',
|
|
693
|
+
fetchpriority: 'high'
|
|
694
|
+
},
|
|
695
|
+
createScriptHook: (url)=>{
|
|
696
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
697
|
+
url
|
|
698
|
+
});
|
|
699
|
+
if (res instanceof HTMLScriptElement) {
|
|
700
|
+
return res;
|
|
701
|
+
}
|
|
702
|
+
return;
|
|
703
|
+
},
|
|
704
|
+
needDeleteScript: true
|
|
705
|
+
});
|
|
706
|
+
needAttach && document.head.appendChild(scriptEl);
|
|
707
|
+
});
|
|
708
|
+
}
|
|
652
709
|
}
|
|
653
710
|
}
|
|
654
711
|
|
|
@@ -711,7 +768,7 @@ function snapshotPlugin() {
|
|
|
711
768
|
globalSnapshot
|
|
712
769
|
});
|
|
713
770
|
if (assets) {
|
|
714
|
-
preloadAssets(remoteInfo, origin, assets);
|
|
771
|
+
preloadAssets(remoteInfo, origin, assets, false);
|
|
715
772
|
}
|
|
716
773
|
return _extends$4({}, args, {
|
|
717
774
|
remoteSnapshot
|
|
@@ -1913,7 +1970,7 @@ class FederationHost {
|
|
|
1913
1970
|
// maybe will change, temporarily for internal use only
|
|
1914
1971
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1915
1972
|
});
|
|
1916
|
-
this.version = "0.1.
|
|
1973
|
+
this.version = "0.1.19";
|
|
1917
1974
|
this.moduleCache = new Map();
|
|
1918
1975
|
this.loaderHook = new PluginSystem({
|
|
1919
1976
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as getGlobalHostPlugins, a as globalLoading, D as DEFAULT_REMOTE_TYPE, b as DEFAULT_SCOPE, c as getRemoteEntryExports, d as assert, s as safeToString, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as isBrowserEnv, m as getInfoWithoutType, n as getPreloaded, o as setPreloaded, p as getRegisteredShare, q as arrayOptions, r as getGlobalSnapshotInfoByModuleInfo, t as addGlobalSnapshot, u as setGlobalSnapshotInfoByModuleInfo, v as getGlobalSnapshot, G as Global, x as formatShareConfigs, y as getTargetSharedOptions, z as getGlobalShareScope, A as addUniqueItem, B as getBuilderId, C as setGlobalFederationConstructor, E as getGlobalFederationInstance, F as getGlobalFederationConstructor, H as setGlobalFederationInstance } from './share.esm.js';
|
|
2
2
|
export { I as registerGlobalPlugins } from './share.esm.js';
|
|
3
|
-
import { loadScriptNode, loadScript, composeKeyWithSeparator, createLink, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1, isBrowserEnv as isBrowserEnv$1 } from '@module-federation/sdk';
|
|
3
|
+
import { loadScriptNode, loadScript, composeKeyWithSeparator, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1, isBrowserEnv as isBrowserEnv$1 } from '@module-federation/sdk';
|
|
4
4
|
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
5
5
|
|
|
6
6
|
// Function to match a remote with its name and expose
|
|
@@ -561,7 +561,8 @@ function normalizePreloadExposes(exposes) {
|
|
|
561
561
|
return expose;
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
|
-
function preloadAssets(remoteInfo, host, assets
|
|
564
|
+
function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
|
|
565
|
+
useLinkPreload = true) {
|
|
565
566
|
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
566
567
|
if (host.options.inBrowser) {
|
|
567
568
|
entryAssets.forEach((asset)=>{
|
|
@@ -613,40 +614,96 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
613
614
|
});
|
|
614
615
|
}
|
|
615
616
|
});
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
if (useLinkPreload) {
|
|
618
|
+
cssAssets.forEach((cssUrl)=>{
|
|
619
|
+
const { link: cssEl, needAttach } = createLink({
|
|
620
|
+
url: cssUrl,
|
|
621
|
+
cb: ()=>{},
|
|
622
|
+
attrs: {
|
|
623
|
+
rel: 'preload',
|
|
624
|
+
as: 'style',
|
|
625
|
+
crossorigin: 'anonymous'
|
|
626
|
+
},
|
|
627
|
+
createLinkHook: (url)=>{
|
|
628
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
629
|
+
url
|
|
630
|
+
});
|
|
631
|
+
if (res instanceof HTMLLinkElement) {
|
|
632
|
+
return res;
|
|
633
|
+
}
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
624
636
|
});
|
|
625
|
-
|
|
626
|
-
return res;
|
|
627
|
-
}
|
|
628
|
-
return;
|
|
637
|
+
needAttach && document.head.appendChild(cssEl);
|
|
629
638
|
});
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
639
|
+
} else {
|
|
640
|
+
cssAssets.forEach((cssUrl)=>{
|
|
641
|
+
const { link: cssEl, needAttach } = createLink({
|
|
642
|
+
url: cssUrl,
|
|
643
|
+
cb: ()=>{},
|
|
644
|
+
attrs: {
|
|
645
|
+
rel: 'stylesheet',
|
|
646
|
+
type: 'text/css'
|
|
647
|
+
},
|
|
648
|
+
createLinkHook: (url)=>{
|
|
649
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
650
|
+
url
|
|
651
|
+
});
|
|
652
|
+
if (res instanceof HTMLLinkElement) {
|
|
653
|
+
return res;
|
|
654
|
+
}
|
|
655
|
+
return;
|
|
656
|
+
},
|
|
657
|
+
needDeleteLink: false
|
|
641
658
|
});
|
|
642
|
-
|
|
643
|
-
return res;
|
|
644
|
-
}
|
|
645
|
-
return;
|
|
659
|
+
needAttach && document.head.appendChild(cssEl);
|
|
646
660
|
});
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
661
|
+
}
|
|
662
|
+
if (useLinkPreload) {
|
|
663
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
664
|
+
const { link: linkEl, needAttach } = createLink({
|
|
665
|
+
url: jsUrl,
|
|
666
|
+
cb: ()=>{},
|
|
667
|
+
attrs: {
|
|
668
|
+
rel: 'preload',
|
|
669
|
+
as: 'script',
|
|
670
|
+
crossorigin: 'anonymous'
|
|
671
|
+
},
|
|
672
|
+
createLinkHook: (url)=>{
|
|
673
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
674
|
+
url
|
|
675
|
+
});
|
|
676
|
+
if (res instanceof HTMLLinkElement) {
|
|
677
|
+
return res;
|
|
678
|
+
}
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
needAttach && document.head.appendChild(linkEl);
|
|
683
|
+
});
|
|
684
|
+
} else {
|
|
685
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
686
|
+
const { script: scriptEl, needAttach } = createScript({
|
|
687
|
+
url: jsUrl,
|
|
688
|
+
cb: ()=>{},
|
|
689
|
+
attrs: {
|
|
690
|
+
crossorigin: 'anonymous',
|
|
691
|
+
fetchpriority: 'high'
|
|
692
|
+
},
|
|
693
|
+
createScriptHook: (url)=>{
|
|
694
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
695
|
+
url
|
|
696
|
+
});
|
|
697
|
+
if (res instanceof HTMLScriptElement) {
|
|
698
|
+
return res;
|
|
699
|
+
}
|
|
700
|
+
return;
|
|
701
|
+
},
|
|
702
|
+
needDeleteScript: true
|
|
703
|
+
});
|
|
704
|
+
needAttach && document.head.appendChild(scriptEl);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
650
707
|
}
|
|
651
708
|
}
|
|
652
709
|
|
|
@@ -709,7 +766,7 @@ function snapshotPlugin() {
|
|
|
709
766
|
globalSnapshot
|
|
710
767
|
});
|
|
711
768
|
if (assets) {
|
|
712
|
-
preloadAssets(remoteInfo, origin, assets);
|
|
769
|
+
preloadAssets(remoteInfo, origin, assets, false);
|
|
713
770
|
}
|
|
714
771
|
return _extends$4({}, args, {
|
|
715
772
|
remoteSnapshot
|
|
@@ -1911,7 +1968,7 @@ class FederationHost {
|
|
|
1911
1968
|
// maybe will change, temporarily for internal use only
|
|
1912
1969
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1913
1970
|
});
|
|
1914
|
-
this.version = "0.1.
|
|
1971
|
+
this.version = "0.1.19";
|
|
1915
1972
|
this.moduleCache = new Map();
|
|
1916
1973
|
this.loaderHook = new PluginSystem({
|
|
1917
1974
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -190,7 +190,7 @@ function getGlobalFederationConstructor() {
|
|
|
190
190
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
191
191
|
if (isDebug) {
|
|
192
192
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
193
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
193
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.19";
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/share.esm.js
CHANGED
|
@@ -188,7 +188,7 @@ function getGlobalFederationConstructor() {
|
|
|
188
188
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
189
189
|
if (isDebug) {
|
|
190
190
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
191
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
191
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.19";
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -3,4 +3,4 @@ import { FederationHost } from '../core';
|
|
|
3
3
|
export declare function defaultPreloadArgs(preloadConfig: PreloadRemoteArgs | depsPreloadArg): PreloadConfig;
|
|
4
4
|
export declare function formatPreloadArgs(remotes: Array<Remote>, preloadArgs: Array<PreloadRemoteArgs>): PreloadOptions;
|
|
5
5
|
export declare function normalizePreloadExposes(exposes?: string[]): string[];
|
|
6
|
-
export declare function preloadAssets(remoteInfo: RemoteInfo, host: FederationHost, assets: PreloadAssets): void;
|
|
6
|
+
export declare function preloadAssets(remoteInfo: RemoteInfo, host: FederationHost, assets: PreloadAssets, useLinkPreload?: boolean): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
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.19"
|
|
49
49
|
}
|
|
50
50
|
}
|