@module-federation/sdk 0.0.0-next-20240808084345 → 0.0.0-next-20240812084439

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
@@ -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
- const createScriptRes = info.createScriptHook(info.url, info.attrs);
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;
514
516
  if (info.createLinkHook) {
515
- const createLinkRes = info.createLinkHook(info.url);
517
+ createLinkRes = info.createLinkHook(info.url);
516
518
  if (createLinkRes instanceof HTMLLinkElement) {
517
519
  link = createLinkRes;
518
520
  }
519
521
  }
520
522
  const attrs = info.attrs;
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
- const createScriptRes = info.createScriptHook(info.url, info.attrs);
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;
510
512
  if (info.createLinkHook) {
511
- const createLinkRes = info.createLinkHook(info.url);
513
+ createLinkRes = info.createLinkHook(info.url);
512
514
  if (createLinkRes instanceof HTMLLinkElement) {
513
515
  link = createLinkRes;
514
516
  }
515
517
  }
516
518
  const attrs = info.attrs;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.0.0-next-20240808084345",
3
+ "version": "0.0.0-next-20240812084439",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [