@module-federation/sdk 0.2.4 → 0.2.6
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 -3
- package/dist/index.esm.js +7 -3
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -555,7 +555,6 @@ function loadScript(url, info) {
|
|
|
555
555
|
url,
|
|
556
556
|
cb: resolve,
|
|
557
557
|
attrs: _extends({
|
|
558
|
-
crossorigin: 'anonymous',
|
|
559
558
|
fetchpriority: 'high'
|
|
560
559
|
}, attrs),
|
|
561
560
|
createScriptHook,
|
|
@@ -570,7 +569,7 @@ function importNodeModule(name) {
|
|
|
570
569
|
throw new Error('import specifier is required');
|
|
571
570
|
}
|
|
572
571
|
const importModule = new Function('name', `return import(name)`);
|
|
573
|
-
return importModule(name).then((res)=>res
|
|
572
|
+
return importModule(name).then((res)=>res).catch((error)=>{
|
|
574
573
|
console.error(`Error importing module ${name}:`, error);
|
|
575
574
|
throw error;
|
|
576
575
|
});
|
|
@@ -624,6 +623,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
624
623
|
};
|
|
625
624
|
const handleScriptFetch = async (f, urlObj)=>{
|
|
626
625
|
try {
|
|
626
|
+
var _vm_constants;
|
|
627
627
|
const res = await f(urlObj.href);
|
|
628
628
|
const data = await res.text();
|
|
629
629
|
const [path, vm] = await Promise.all([
|
|
@@ -638,7 +638,11 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
638
638
|
};
|
|
639
639
|
const urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
|
|
640
640
|
const filename = path.basename(urlObj.pathname);
|
|
641
|
-
|
|
641
|
+
var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;
|
|
642
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
|
|
643
|
+
filename,
|
|
644
|
+
importModuleDynamically: (_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER = (_vm_constants = vm.constants) == null ? void 0 : _vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER) != null ? _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER : importNodeModule
|
|
645
|
+
});
|
|
642
646
|
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
|
|
643
647
|
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
644
648
|
if (attrs && exportedInterface && attrs['globalName']) {
|
package/dist/index.esm.js
CHANGED
|
@@ -551,7 +551,6 @@ function loadScript(url, info) {
|
|
|
551
551
|
url,
|
|
552
552
|
cb: resolve,
|
|
553
553
|
attrs: _extends({
|
|
554
|
-
crossorigin: 'anonymous',
|
|
555
554
|
fetchpriority: 'high'
|
|
556
555
|
}, attrs),
|
|
557
556
|
createScriptHook,
|
|
@@ -566,7 +565,7 @@ function importNodeModule(name) {
|
|
|
566
565
|
throw new Error('import specifier is required');
|
|
567
566
|
}
|
|
568
567
|
const importModule = new Function('name', `return import(name)`);
|
|
569
|
-
return importModule(name).then((res)=>res
|
|
568
|
+
return importModule(name).then((res)=>res).catch((error)=>{
|
|
570
569
|
console.error(`Error importing module ${name}:`, error);
|
|
571
570
|
throw error;
|
|
572
571
|
});
|
|
@@ -620,6 +619,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
620
619
|
};
|
|
621
620
|
const handleScriptFetch = async (f, urlObj)=>{
|
|
622
621
|
try {
|
|
622
|
+
var _vm_constants;
|
|
623
623
|
const res = await f(urlObj.href);
|
|
624
624
|
const data = await res.text();
|
|
625
625
|
const [path, vm] = await Promise.all([
|
|
@@ -634,7 +634,11 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
634
634
|
};
|
|
635
635
|
const urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
|
|
636
636
|
const filename = path.basename(urlObj.pathname);
|
|
637
|
-
|
|
637
|
+
var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;
|
|
638
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
|
|
639
|
+
filename,
|
|
640
|
+
importModuleDynamically: (_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER = (_vm_constants = vm.constants) == null ? void 0 : _vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER) != null ? _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER : importNodeModule
|
|
641
|
+
});
|
|
638
642
|
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
|
|
639
643
|
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
640
644
|
if (attrs && exportedInterface && attrs['globalName']) {
|
package/dist/package.json
CHANGED