@blocklet/pages-kit 0.4.131 → 0.4.132
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.
|
@@ -68,7 +68,7 @@ function injectGlobalComponents() {
|
|
|
68
68
|
if (win[builtin_1.BuiltinModulesGlobalVariableName]) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const enableShim = !!
|
|
71
|
+
const enableShim = !!win?.esmsInitOptions?.shimMode && win.importShim;
|
|
72
72
|
if (!enableShim && win.importShim?.addImportMap) {
|
|
73
73
|
win.importShim.addImportMap = () => {
|
|
74
74
|
// avoid addImportMap error
|
|
@@ -252,17 +252,21 @@ export default ${hasDefaultExport ? 'moduleSource.default' : 'moduleSource'};
|
|
|
252
252
|
}
|
|
253
253
|
// 添加 resolve 配置
|
|
254
254
|
const importMap = { imports };
|
|
255
|
-
if (enableShim) {
|
|
256
|
-
window.importShim.addImportMap(importMap);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
// fallback to create script tag
|
|
260
|
-
const script = document.createElement('script');
|
|
261
|
-
script.type = 'importmap';
|
|
262
|
-
script.textContent = JSON.stringify(importMap, null, 2);
|
|
263
|
-
document.head.appendChild(script);
|
|
264
|
-
}
|
|
265
255
|
win.importMap = importMap;
|
|
256
|
+
if (enableShim && !!window?.esmsInitOptions?.shimMode) {
|
|
257
|
+
try {
|
|
258
|
+
win.importShim.addImportMap(importMap);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
// ignore error
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// fallback to create script tag
|
|
266
|
+
const script = document.createElement('script');
|
|
267
|
+
script.type = 'importmap';
|
|
268
|
+
script.textContent = JSON.stringify(importMap, null, 2);
|
|
269
|
+
document.head.appendChild(script);
|
|
266
270
|
};
|
|
267
271
|
setupImportMap();
|
|
268
272
|
}
|