vite-plugin-cross-origin-storage 1.3.20 → 1.3.22

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 CHANGED
@@ -1691,7 +1691,7 @@ function cosPlugin(options = {}) {
1691
1691
  /[.*+?^${}()|[\]\\]/g,
1692
1692
  "\\$&"
1693
1693
  );
1694
- const bareSpecifier = `./${depFileName}`;
1694
+ const bareSpecifier = `cos-chunk:${depFileName}`;
1695
1695
  const staticPattern = `(import|export)\\b\\s*((?:(?!\\bimport\\b|\\bexport\\b)[\\s\\S])*?\\bfrom\\b\\s*)?['"]${escapedRelPath}['"]\\s*;?`;
1696
1696
  const staticRegex = new RegExp(staticPattern, "g");
1697
1697
  targetChunk.code = targetChunk.code.replace(
package/dist/loader.js CHANGED
@@ -81,8 +81,8 @@
81
81
  const loadPromises = chunksToLoad.map(async (chunk) => {
82
82
  const dataUrl = await getChunkDataUrl(chunk);
83
83
  if (dataUrl) {
84
- // Map the relative path (as used in the plugin's bare specifier rewrite) to the data URL
85
- importMap.imports[`./${chunk.fileName}`] = dataUrl;
84
+ // Use a bare specifier prefix to avoid hierarchical resolution issues
85
+ importMap.imports[`cos-chunk:${chunk.fileName}`] = dataUrl;
86
86
  }
87
87
  });
88
88
 
@@ -97,9 +97,11 @@
97
97
  console.log('COS Loader: Import Map injected');
98
98
 
99
99
  // Import the main entry.
100
- // The main entry itself is also managed and rewritten to use bare specifiers.
101
- const entryFileName = mainEntry.fileName;
102
- await import(`./${entryFileName}`);
100
+ // If the entry itself were managed, we would use cos-chunk: prefix here too.
101
+ // For now, it's loaded via its absolute path from the server,
102
+ // and its internal imports (rewritten by the plugin) will use cos-chunk:
103
+ const entryUrl = mainEntry.file;
104
+ await import(entryUrl);
103
105
 
104
106
  } catch (err) {
105
107
  console.error('COS Loader: Failed to start app', err);
package/loader.js CHANGED
@@ -81,8 +81,8 @@
81
81
  const loadPromises = chunksToLoad.map(async (chunk) => {
82
82
  const dataUrl = await getChunkDataUrl(chunk);
83
83
  if (dataUrl) {
84
- // Map the relative path (as used in the plugin's bare specifier rewrite) to the data URL
85
- importMap.imports[`./${chunk.fileName}`] = dataUrl;
84
+ // Use a bare specifier prefix to avoid hierarchical resolution issues
85
+ importMap.imports[`cos-chunk:${chunk.fileName}`] = dataUrl;
86
86
  }
87
87
  });
88
88
 
@@ -97,9 +97,11 @@
97
97
  console.log('COS Loader: Import Map injected');
98
98
 
99
99
  // Import the main entry.
100
- // The main entry itself is also managed and rewritten to use bare specifiers.
101
- const entryFileName = mainEntry.fileName;
102
- await import(`./${entryFileName}`);
100
+ // If the entry itself were managed, we would use cos-chunk: prefix here too.
101
+ // For now, it's loaded via its absolute path from the server,
102
+ // and its internal imports (rewritten by the plugin) will use cos-chunk:
103
+ const entryUrl = mainEntry.file;
104
+ await import(entryUrl);
103
105
 
104
106
  } catch (err) {
105
107
  console.error('COS Loader: Failed to start app', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-cross-origin-storage",
3
- "version": "1.3.20",
3
+ "version": "1.3.22",
4
4
  "description": "Vite plugin to load chunks from Cross-Origin Storage",
5
5
  "keywords": [
6
6
  "vite",