@webmate-studio/builder 0.2.17 → 0.2.19

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 +9 -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.19",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
package/src/bundler.js CHANGED
@@ -42,6 +42,7 @@ export async function bundleIsland(islandPath, outputPath, options = {}) {
42
42
  target,
43
43
  outfile: outputPath,
44
44
  platform: 'browser',
45
+ charset: 'utf8', // Force UTF-8 output to prevent base64 corruption (esbuild bug #1501)
45
46
  // Loaders for different file types
46
47
  // NOTE: All image formats are handled by custom plugin above (image-base64-dataurl)
47
48
  // to generate proper data:image/...;base64,... URLs for CSS compatibility
@@ -90,18 +91,20 @@ export async function bundleIsland(islandPath, outputPath, options = {}) {
90
91
  webp: 'image/webp'
91
92
  };
92
93
 
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
94
+ // Read file as binary buffer
95
95
  const buffer = await fs.readFile(args.path);
96
+ // Convert to base64 string (pure ASCII, safe for JavaScript)
96
97
  const base64 = buffer.toString('base64');
97
98
  const mimeType = mimeTypes[ext] || 'application/octet-stream';
99
+
100
+ // Build the complete data URL
98
101
  const dataUrl = `data:${mimeType};base64,${base64}`;
99
102
 
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
103
+ // Return as a raw JavaScript module with template literal to preserve exact bytes
104
+ // Using template literal ensures no escaping or encoding happens
102
105
  return {
103
- contents: dataUrl,
104
- loader: 'text'
106
+ contents: `export default \`${dataUrl}\`;`,
107
+ loader: 'js'
105
108
  };
106
109
  });
107
110
  }