@webmate-studio/builder 0.2.26 → 0.2.28
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/build-service.js +17 -4
- package/package.json +1 -1
package/build-service.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import http from 'http';
|
|
9
9
|
import { generateComponentCSS } from './src/tailwind-generator.js';
|
|
10
10
|
import { bundleIsland } from './src/bundler.js';
|
|
11
|
+
import { cleanComponentHTML } from './src/html-cleaner.js';
|
|
11
12
|
import { mkdtemp, writeFile, rm, mkdir } from 'fs/promises';
|
|
12
13
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
13
14
|
import { join } from 'path';
|
|
@@ -196,22 +197,33 @@ async function buildComponent(payload) {
|
|
|
196
197
|
// Read bundled content
|
|
197
198
|
const bundledContent = readFileSync(outputPath, 'utf8');
|
|
198
199
|
|
|
200
|
+
// Use output filename (.js) not input filename (.svelte)
|
|
201
|
+
const outputFilename = island.file.replace(/\.(jsx?|tsx?|svelte|vue)$/, '.js');
|
|
202
|
+
|
|
199
203
|
bundledIslands.push({
|
|
200
|
-
file:
|
|
204
|
+
file: outputFilename, // Use .js extension!
|
|
201
205
|
content: bundledContent,
|
|
202
206
|
size: result.size,
|
|
203
207
|
originalSize: island.content.length
|
|
204
208
|
});
|
|
205
209
|
|
|
206
|
-
console.log(`[Build Service] ✓ ${island.file} → ${(result.size / 1024).toFixed(2)}kb`);
|
|
210
|
+
console.log(`[Build Service] ✓ ${island.file} → ${outputFilename} (${(result.size / 1024).toFixed(2)}kb)`);
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
213
|
|
|
214
|
+
// Transform HTML: Convert <IslandName /> to <island-name> Custom Elements
|
|
215
|
+
let transformedHtml = html;
|
|
216
|
+
if (html && islands.length > 0) {
|
|
217
|
+
const islandNames = islands.map(i => i.file.replace(/\.(jsx?|tsx?|svelte|vue)$/, ''));
|
|
218
|
+
transformedHtml = cleanComponentHTML(html, islandNames);
|
|
219
|
+
console.log(`[Build Service] ✓ Transformed HTML: ${islandNames.length} island(s) → Custom Elements`);
|
|
220
|
+
}
|
|
221
|
+
|
|
210
222
|
// Generate CSS
|
|
211
223
|
let css = '';
|
|
212
|
-
if (
|
|
224
|
+
if (transformedHtml) {
|
|
213
225
|
console.log('[Build Service] Generating CSS...');
|
|
214
|
-
const cssResult = await generateComponentCSS(
|
|
226
|
+
const cssResult = await generateComponentCSS(transformedHtml, {
|
|
215
227
|
designTokens: null,
|
|
216
228
|
minify: true
|
|
217
229
|
});
|
|
@@ -223,6 +235,7 @@ async function buildComponent(payload) {
|
|
|
223
235
|
success: true,
|
|
224
236
|
bundledIslands,
|
|
225
237
|
css,
|
|
238
|
+
html: transformedHtml, // Return transformed HTML
|
|
226
239
|
stats: {
|
|
227
240
|
islands: bundledIslands.length,
|
|
228
241
|
totalSize: bundledIslands.reduce((sum, i) => sum + i.size, 0) + css.length
|