@webmate-studio/builder 0.2.30 → 0.2.31
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 +7 -1
- package/package.json +1 -1
- package/src/bundler.js +13 -4
package/build-service.js
CHANGED
|
@@ -73,11 +73,17 @@ function injectSvelteOptions(filename, content, componentMetadata) {
|
|
|
73
73
|
// SwiperTest.svelte → swiper-test
|
|
74
74
|
// MyAwesomeComponent.svelte → my-awesome-component
|
|
75
75
|
const componentName = filename.replace('.svelte', '');
|
|
76
|
-
|
|
76
|
+
let tagName = componentName
|
|
77
77
|
.replace(/([A-Z])/g, '-$1') // Insert hyphen before capital letters
|
|
78
78
|
.toLowerCase()
|
|
79
79
|
.replace(/^-/, ''); // Remove leading hyphen
|
|
80
80
|
|
|
81
|
+
// Svelte requires custom element names to be hyphenated
|
|
82
|
+
// If there's no hyphen, add a prefix to make it valid
|
|
83
|
+
if (!tagName.includes('-')) {
|
|
84
|
+
tagName = 'wm-' + tagName; // e.g., "button" → "wm-button"
|
|
85
|
+
}
|
|
86
|
+
|
|
81
87
|
// Generate props definition from component.json
|
|
82
88
|
const props = {};
|
|
83
89
|
if (componentMetadata.props) {
|
package/package.json
CHANGED
package/src/bundler.js
CHANGED
|
@@ -202,9 +202,16 @@ export async function bundleComponentIslands(componentDir, outputDir) {
|
|
|
202
202
|
return { islands: [], success: true };
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
// Find all
|
|
205
|
+
// Find all island files (JS, JSX, Svelte, Vue, etc.)
|
|
206
206
|
const files = await fs.readdir(islandsDir);
|
|
207
|
-
const islandFiles = files.filter((f) =>
|
|
207
|
+
const islandFiles = files.filter((f) =>
|
|
208
|
+
f.endsWith('.js') ||
|
|
209
|
+
f.endsWith('.jsx') ||
|
|
210
|
+
f.endsWith('.svelte') ||
|
|
211
|
+
f.endsWith('.vue') ||
|
|
212
|
+
f.endsWith('.ts') ||
|
|
213
|
+
f.endsWith('.tsx')
|
|
214
|
+
);
|
|
208
215
|
|
|
209
216
|
if (islandFiles.length === 0) {
|
|
210
217
|
return { islands: [], success: true };
|
|
@@ -217,7 +224,9 @@ export async function bundleComponentIslands(componentDir, outputDir) {
|
|
|
217
224
|
|
|
218
225
|
for (const islandFile of islandFiles) {
|
|
219
226
|
const inputPath = path.join(islandsDir, islandFile);
|
|
220
|
-
|
|
227
|
+
// Output file is always .js regardless of input extension (.svelte, .jsx, etc.)
|
|
228
|
+
const outputFile = islandFile.replace(/\.(svelte|jsx|vue|tsx?)$/, '.js');
|
|
229
|
+
const outputPath = path.join(outputDir, outputFile);
|
|
221
230
|
|
|
222
231
|
console.log(pc.dim(` Bundling ${islandFile}...`));
|
|
223
232
|
|
|
@@ -233,7 +242,7 @@ export async function bundleComponentIslands(componentDir, outputDir) {
|
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
results.push({
|
|
236
|
-
file:
|
|
245
|
+
file: outputFile, // Use output filename (.js) instead of input filename
|
|
237
246
|
...result
|
|
238
247
|
});
|
|
239
248
|
}
|