@webmate-studio/builder 0.2.26 → 0.2.27
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 +12 -2
- 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';
|
|
@@ -207,11 +208,19 @@ async function buildComponent(payload) {
|
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
// Transform HTML: Convert <IslandName /> to <island-name> Custom Elements
|
|
212
|
+
let transformedHtml = html;
|
|
213
|
+
if (html && islands.length > 0) {
|
|
214
|
+
const islandNames = islands.map(i => i.file.replace(/\.(jsx?|tsx?|svelte|vue)$/, ''));
|
|
215
|
+
transformedHtml = cleanComponentHTML(html, islandNames);
|
|
216
|
+
console.log(`[Build Service] ✓ Transformed HTML: ${islandNames.length} island(s) → Custom Elements`);
|
|
217
|
+
}
|
|
218
|
+
|
|
210
219
|
// Generate CSS
|
|
211
220
|
let css = '';
|
|
212
|
-
if (
|
|
221
|
+
if (transformedHtml) {
|
|
213
222
|
console.log('[Build Service] Generating CSS...');
|
|
214
|
-
const cssResult = await generateComponentCSS(
|
|
223
|
+
const cssResult = await generateComponentCSS(transformedHtml, {
|
|
215
224
|
designTokens: null,
|
|
216
225
|
minify: true
|
|
217
226
|
});
|
|
@@ -223,6 +232,7 @@ async function buildComponent(payload) {
|
|
|
223
232
|
success: true,
|
|
224
233
|
bundledIslands,
|
|
225
234
|
css,
|
|
235
|
+
html: transformedHtml, // Return transformed HTML
|
|
226
236
|
stats: {
|
|
227
237
|
islands: bundledIslands.length,
|
|
228
238
|
totalSize: bundledIslands.reduce((sum, i) => sum + i.size, 0) + css.length
|