@webmate-studio/builder 0.2.7 → 0.2.9
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 +16 -21
- package/src/index.js +2 -1
package/package.json
CHANGED
package/src/bundler.js
CHANGED
|
@@ -3,9 +3,6 @@ import esbuildSvelte from 'esbuild-svelte';
|
|
|
3
3
|
import fs from 'fs/promises';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import pc from 'picocolors';
|
|
6
|
-
import { createRequire } from 'module';
|
|
7
|
-
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* Bundle island JavaScript files with esbuild
|
|
@@ -36,15 +33,6 @@ export async function bundleIsland(islandPath, outputPath, options = {}) {
|
|
|
36
33
|
// Only use JSX for .jsx files (React/Preact), not for .js files (Lit/Alpine/Vue/Vanilla)
|
|
37
34
|
const useJsxLoader = islandPath.endsWith('.jsx');
|
|
38
35
|
|
|
39
|
-
// Try to resolve Svelte package path
|
|
40
|
-
let sveltePackagePath;
|
|
41
|
-
try {
|
|
42
|
-
sveltePackagePath = path.dirname(require.resolve('svelte/package.json'));
|
|
43
|
-
} catch (e) {
|
|
44
|
-
// Svelte not found in builder's node_modules, might be in workspace
|
|
45
|
-
sveltePackagePath = null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
36
|
const result = await esbuild.build({
|
|
49
37
|
entryPoints: [islandPath],
|
|
50
38
|
bundle: true,
|
|
@@ -54,26 +42,33 @@ export async function bundleIsland(islandPath, outputPath, options = {}) {
|
|
|
54
42
|
target,
|
|
55
43
|
outfile: outputPath,
|
|
56
44
|
platform: 'browser',
|
|
57
|
-
//
|
|
45
|
+
// Loaders for different file types
|
|
58
46
|
loader: useJsxLoader ? {
|
|
59
47
|
'.jsx': 'jsx',
|
|
60
48
|
'.ts': 'tsx',
|
|
61
|
-
'.tsx': 'tsx'
|
|
49
|
+
'.tsx': 'tsx',
|
|
50
|
+
'.jpg': 'dataurl',
|
|
51
|
+
'.jpeg': 'dataurl',
|
|
52
|
+
'.png': 'dataurl',
|
|
53
|
+
'.gif': 'dataurl',
|
|
54
|
+
'.svg': 'dataurl',
|
|
55
|
+
'.webp': 'dataurl'
|
|
62
56
|
} : {
|
|
63
57
|
'.ts': 'tsx',
|
|
64
|
-
'.tsx': 'tsx'
|
|
58
|
+
'.tsx': 'tsx',
|
|
59
|
+
'.jpg': 'dataurl',
|
|
60
|
+
'.jpeg': 'dataurl',
|
|
61
|
+
'.png': 'dataurl',
|
|
62
|
+
'.gif': 'dataurl',
|
|
63
|
+
'.svg': 'dataurl',
|
|
64
|
+
'.webp': 'dataurl'
|
|
65
65
|
},
|
|
66
66
|
// Use automatic JSX runtime (React 17+) only for JSX files
|
|
67
67
|
jsx: useJsxLoader ? 'automatic' : undefined,
|
|
68
68
|
// JSX import source (Preact uses preact, React uses react)
|
|
69
69
|
jsxImportSource: useJsxLoader ? 'preact' : undefined,
|
|
70
70
|
// Alias vue to the full build (with template compiler)
|
|
71
|
-
|
|
72
|
-
alias: sveltePackagePath ? {
|
|
73
|
-
'vue': 'vue/dist/vue.esm-bundler.js',
|
|
74
|
-
'svelte': path.join(sveltePackagePath, 'src/runtime/index.js'),
|
|
75
|
-
'svelte/internal': path.join(sveltePackagePath, 'src/runtime/internal/index.js')
|
|
76
|
-
} : {
|
|
71
|
+
alias: {
|
|
77
72
|
'vue': 'vue/dist/vue.esm-bundler.js'
|
|
78
73
|
},
|
|
79
74
|
// Define Vue feature flags
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { build } from './build.js';
|
|
2
2
|
import { generateComponentCSS, generateTailwindCSS, extractTailwindClasses } from './tailwind-generator.js';
|
|
3
3
|
import { cleanComponentHTML } from './html-cleaner.js';
|
|
4
|
+
import { bundleIsland, bundleComponentIslands } from './bundler.js';
|
|
4
5
|
|
|
5
|
-
export { build, generateComponentCSS, generateTailwindCSS, extractTailwindClasses, cleanComponentHTML };
|
|
6
|
+
export { build, generateComponentCSS, generateTailwindCSS, extractTailwindClasses, cleanComponentHTML, bundleIsland, bundleComponentIslands };
|