@webmate-studio/builder 0.2.17 → 0.2.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bundler.js +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmate-studio/builder",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
package/src/bundler.js CHANGED
@@ -90,18 +90,20 @@ export async function bundleIsland(islandPath, outputPath, options = {}) {
90
90
  webp: 'image/webp'
91
91
  };
92
92
 
93
- // IMPORTANT: Read file as Buffer, convert to base64 BEFORE returning to esbuild
94
- // If we return raw buffer bytes, esbuild will treat them as UTF-8 text
93
+ // Read file as binary buffer
95
94
  const buffer = await fs.readFile(args.path);
95
+ // Convert to base64 string (pure ASCII, safe for JavaScript)
96
96
  const base64 = buffer.toString('base64');
97
97
  const mimeType = mimeTypes[ext] || 'application/octet-stream';
98
+
99
+ // Build the complete data URL
98
100
  const dataUrl = `data:${mimeType};base64,${base64}`;
99
101
 
100
- // Return as text (loader: 'text') with the full data URL as a string literal
101
- // This prevents esbuild from trying to interpret binary data
102
+ // Return as a raw JavaScript module with template literal to preserve exact bytes
103
+ // Using template literal ensures no escaping or encoding happens
102
104
  return {
103
- contents: dataUrl,
104
- loader: 'text'
105
+ contents: `export default \`${dataUrl}\`;`,
106
+ loader: 'js'
105
107
  };
106
108
  });
107
109
  }