@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.
- package/package.json +1 -1
- package/src/bundler.js +9 -6
package/package.json
CHANGED
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
|
-
//
|
|
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
|
|
101
|
-
//
|
|
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: '
|
|
106
|
+
contents: `export default \`${dataUrl}\`;`,
|
|
107
|
+
loader: 'js'
|
|
105
108
|
};
|
|
106
109
|
});
|
|
107
110
|
}
|