vite-plugin-cross-origin-storage 1.3.12 → 1.3.14
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.js +2 -2
- package/dist/loader.js +8 -4
- package/loader.js +8 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1667,6 +1667,7 @@ function cosPlugin(options = {}) {
|
|
|
1667
1667
|
const allChunks = Object.values(bundle).filter(
|
|
1668
1668
|
(c) => c.type === "chunk"
|
|
1669
1669
|
);
|
|
1670
|
+
const base = config.base.endsWith("/") ? config.base : config.base + "/";
|
|
1670
1671
|
const managedChunkNames = new Set(Object.keys(managedChunks));
|
|
1671
1672
|
const managedChunkInfo = {};
|
|
1672
1673
|
for (const fileName in managedChunks) {
|
|
@@ -1690,7 +1691,7 @@ function cosPlugin(options = {}) {
|
|
|
1690
1691
|
/[.*+?^${}()|[\]\\]/g,
|
|
1691
1692
|
"\\$&"
|
|
1692
1693
|
);
|
|
1693
|
-
const bareSpecifier = depFileName
|
|
1694
|
+
const bareSpecifier = `${base}${depFileName}`;
|
|
1694
1695
|
const staticPattern = `(import|export)\\b\\s*((?:(?!\\bimport\\b|\\bexport\\b)[\\s\\S])*?\\bfrom\\b\\s*)?['"]${escapedRelPath}['"]\\s*;?`;
|
|
1695
1696
|
const staticRegex = new RegExp(staticPattern, "g");
|
|
1696
1697
|
targetChunk.code = targetChunk.code.replace(
|
|
@@ -1709,7 +1710,6 @@ function cosPlugin(options = {}) {
|
|
|
1709
1710
|
}
|
|
1710
1711
|
}
|
|
1711
1712
|
const manifest = {};
|
|
1712
|
-
const base = config.base.endsWith("/") ? config.base : config.base + "/";
|
|
1713
1713
|
for (const fileName in managedChunkInfo) {
|
|
1714
1714
|
const { chunk, globalVar } = managedChunkInfo[fileName];
|
|
1715
1715
|
const finalHash = crypto.createHash("sha256").update(chunk.code).digest("hex");
|
package/dist/loader.js
CHANGED
|
@@ -106,10 +106,14 @@
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if (url) {
|
|
109
|
-
//
|
|
110
|
-
// This
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
// Use a Data URL shim to decouple the import graph.
|
|
110
|
+
// This ensures that the circular dependency between React and React-DOM
|
|
111
|
+
// doesn't cause a lockout/deadlock during the module graph instantiation.
|
|
112
|
+
const shim = `export * from "${url}";${chunk.hasDefault ? `export { default } from "${url}";` : ''}`;
|
|
113
|
+
const shimUrl = `data:text/javascript;base64,${btoa(shim)}`;
|
|
114
|
+
|
|
115
|
+
importMap.imports[chunk.fileName] = shimUrl;
|
|
116
|
+
importMap.imports[chunk.file] = shimUrl;
|
|
113
117
|
|
|
114
118
|
// Also set global if anyone still needs it (legacy)
|
|
115
119
|
if (chunk.globalVar) {
|
package/loader.js
CHANGED
|
@@ -106,10 +106,14 @@
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if (url) {
|
|
109
|
-
//
|
|
110
|
-
// This
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
// Use a Data URL shim to decouple the import graph.
|
|
110
|
+
// This ensures that the circular dependency between React and React-DOM
|
|
111
|
+
// doesn't cause a lockout/deadlock during the module graph instantiation.
|
|
112
|
+
const shim = `export * from "${url}";${chunk.hasDefault ? `export { default } from "${url}";` : ''}`;
|
|
113
|
+
const shimUrl = `data:text/javascript;base64,${btoa(shim)}`;
|
|
114
|
+
|
|
115
|
+
importMap.imports[chunk.fileName] = shimUrl;
|
|
116
|
+
importMap.imports[chunk.file] = shimUrl;
|
|
113
117
|
|
|
114
118
|
// Also set global if anyone still needs it (legacy)
|
|
115
119
|
if (chunk.globalVar) {
|