@module-federation/sdk 0.3.4 → 0.4.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 +7 -5
- package/dist/index.esm.js +7 -5
- package/dist/package.json +1 -1
- package/dist/src/dom.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -435,8 +435,9 @@ function createScript(info) {
|
|
|
435
435
|
script = document.createElement('script');
|
|
436
436
|
script.type = 'text/javascript';
|
|
437
437
|
script.src = info.url;
|
|
438
|
+
let createScriptRes = undefined;
|
|
438
439
|
if (info.createScriptHook) {
|
|
439
|
-
|
|
440
|
+
createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
440
441
|
if (createScriptRes instanceof HTMLScriptElement) {
|
|
441
442
|
script = createScriptRes;
|
|
442
443
|
} else if (typeof createScriptRes === 'object') {
|
|
@@ -445,7 +446,7 @@ function createScript(info) {
|
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
448
|
const attrs = info.attrs;
|
|
448
|
-
if (attrs) {
|
|
449
|
+
if (attrs && !createScriptRes) {
|
|
449
450
|
Object.keys(attrs).forEach((name)=>{
|
|
450
451
|
if (script) {
|
|
451
452
|
if (name === 'async' || name === 'defer') {
|
|
@@ -511,14 +512,15 @@ function createLink(info) {
|
|
|
511
512
|
if (!link) {
|
|
512
513
|
link = document.createElement('link');
|
|
513
514
|
link.setAttribute('href', info.url);
|
|
515
|
+
let createLinkRes = undefined;
|
|
516
|
+
const attrs = info.attrs;
|
|
514
517
|
if (info.createLinkHook) {
|
|
515
|
-
|
|
518
|
+
createLinkRes = info.createLinkHook(info.url, attrs);
|
|
516
519
|
if (createLinkRes instanceof HTMLLinkElement) {
|
|
517
520
|
link = createLinkRes;
|
|
518
521
|
}
|
|
519
522
|
}
|
|
520
|
-
|
|
521
|
-
if (attrs) {
|
|
523
|
+
if (attrs && !createLinkRes) {
|
|
522
524
|
Object.keys(attrs).forEach((name)=>{
|
|
523
525
|
if (link && !link.getAttribute(name)) {
|
|
524
526
|
link.setAttribute(name, attrs[name]);
|
package/dist/index.esm.js
CHANGED
|
@@ -431,8 +431,9 @@ function createScript(info) {
|
|
|
431
431
|
script = document.createElement('script');
|
|
432
432
|
script.type = 'text/javascript';
|
|
433
433
|
script.src = info.url;
|
|
434
|
+
let createScriptRes = undefined;
|
|
434
435
|
if (info.createScriptHook) {
|
|
435
|
-
|
|
436
|
+
createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
436
437
|
if (createScriptRes instanceof HTMLScriptElement) {
|
|
437
438
|
script = createScriptRes;
|
|
438
439
|
} else if (typeof createScriptRes === 'object') {
|
|
@@ -441,7 +442,7 @@ function createScript(info) {
|
|
|
441
442
|
}
|
|
442
443
|
}
|
|
443
444
|
const attrs = info.attrs;
|
|
444
|
-
if (attrs) {
|
|
445
|
+
if (attrs && !createScriptRes) {
|
|
445
446
|
Object.keys(attrs).forEach((name)=>{
|
|
446
447
|
if (script) {
|
|
447
448
|
if (name === 'async' || name === 'defer') {
|
|
@@ -507,14 +508,15 @@ function createLink(info) {
|
|
|
507
508
|
if (!link) {
|
|
508
509
|
link = document.createElement('link');
|
|
509
510
|
link.setAttribute('href', info.url);
|
|
511
|
+
let createLinkRes = undefined;
|
|
512
|
+
const attrs = info.attrs;
|
|
510
513
|
if (info.createLinkHook) {
|
|
511
|
-
|
|
514
|
+
createLinkRes = info.createLinkHook(info.url, attrs);
|
|
512
515
|
if (createLinkRes instanceof HTMLLinkElement) {
|
|
513
516
|
link = createLinkRes;
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
|
-
|
|
517
|
-
if (attrs) {
|
|
519
|
+
if (attrs && !createLinkRes) {
|
|
518
520
|
Object.keys(attrs).forEach((name)=>{
|
|
519
521
|
if (link && !link.getAttribute(name)) {
|
|
520
522
|
link.setAttribute(name, attrs[name]);
|
package/dist/package.json
CHANGED
package/dist/src/dom.d.ts
CHANGED
|
@@ -19,12 +19,12 @@ export declare function createLink(info: {
|
|
|
19
19
|
cb: (value: void | PromiseLike<void>) => void;
|
|
20
20
|
attrs: Record<string, string>;
|
|
21
21
|
needDeleteLink?: boolean;
|
|
22
|
-
createLinkHook?: (url: string) => HTMLLinkElement | void;
|
|
22
|
+
createLinkHook?: (url: string, attrs?: Record<string, any>) => HTMLLinkElement | void;
|
|
23
23
|
}): {
|
|
24
24
|
link: HTMLLinkElement;
|
|
25
25
|
needAttach: boolean;
|
|
26
26
|
};
|
|
27
27
|
export declare function loadScript(url: string, info: {
|
|
28
28
|
attrs?: Record<string, any>;
|
|
29
|
-
createScriptHook?: (url: string, attrs?: Record<string, any>
|
|
29
|
+
createScriptHook?: (url: string, attrs?: Record<string, any>) => CreateScriptHookReturn;
|
|
30
30
|
}): Promise<void>;
|