File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ Handlebars.registerHelper('json', function (context) {
1515} ) ;
1616
1717export async function bundler ( config : BundlerConfig ) : Promise < string > {
18- // Get current file's directory path in ESM
1918 const __filename = fileURLToPath ( import . meta. url ) ;
2019 const __dirname = path . dirname ( __filename ) ;
2120
@@ -37,11 +36,27 @@ export async function bundler(config: BundlerConfig): Promise<string> {
3736 const compiledTemplate = Handlebars . compile ( template ) ;
3837 const compiledCode = compiledTemplate ( config ) ;
3938
40- // Bundle with esbuild
41- const result = await esbuild . transform ( compiledCode , {
42- minify : true ,
39+ // Bundle with esbuild using stdin
40+ const result = await esbuild . build ( {
41+ stdin : {
42+ contents : compiledCode ,
43+ loader : 'js' ,
44+ resolveDir : path . resolve ( __dirname , '..' ) ,
45+ } ,
46+ bundle : true ,
47+ write : false ,
4348 format : 'iife' ,
49+ minify : true ,
50+ treeShaking : true ,
51+ platform : 'node' , // TODO: Add browser support
52+ target : 'es2015' ,
53+ splitting : false ,
54+ metafile : true , // Helps with tree-shaking analysis
55+ mainFields : [ 'module' ] , // Prefer ESM versions for better tree-shaking
4456 } ) ;
4557
46- return result . code ;
58+ // Optionally log bundle analysis
59+ console . log ( await esbuild . analyzeMetafile ( result . metafile ) ) ;
60+
61+ return result . outputFiles [ 0 ] . text ;
4762}
Original file line number Diff line number Diff line change 1- import { elb } from '@elbwalker/utils/web';
2- import { debounce } from '@elbwalker/utils';
1+ // Import specific utilities from their exact paths
2+ import { elb, debounce } from '@elbwalker/utils';
33
44console.log('Project configuration:', {
55 name: '{{ name }} ',
You can’t perform that action at this time.
0 commit comments