@@ -7,6 +7,7 @@ const OUTPUT_DIR = join(process.cwd(), "dist");
77
88await fse . emptyDir ( OUTPUT_DIR ) ;
99
10+ // Bin output
1011await esbuild . build ( {
1112 entryPoints : [ join ( SOURCE_DIR , "bin" , "index.ts" ) , join ( SOURCE_DIR , "index.ts" ) ] ,
1213 bundle : true ,
@@ -47,3 +48,85 @@ await esbuild.build({
4748 ".json" : "json" ,
4849 } ,
4950} ) ;
51+
52+ // Client output
53+ await esbuild . build ( {
54+ entryPoints : [ join ( SOURCE_DIR , "client" , "public-exports.ts" ) ] ,
55+ bundle : true ,
56+ outfile : join ( OUTPUT_DIR , "client" , "index.js" ) ,
57+ target : "ESNext" ,
58+ format : "esm" ,
59+
60+ keepNames : true ,
61+ minify : true ,
62+ metafile : false ,
63+
64+ chunkNames : "_chunks/[name]-[hash]" ,
65+ assetNames : "_assets/[name]-[hash]" ,
66+
67+ mainFields : [ "module" , "main" ] , // Prefer ESM versions
68+ conditions : [ "import" , "module" , "require" ] , // Module resolution conditions
69+
70+ treeShaking : true ,
71+ packages : "external" ,
72+
73+ jsx : "automatic" ,
74+ jsxImportSource : "preact" ,
75+
76+ platform : "node" ,
77+
78+ alias : {
79+ "@" : SOURCE_DIR ,
80+ "react" : "preact/compat" ,
81+ "react-dom" : "preact/compat" ,
82+ } ,
83+
84+ loader : {
85+ ".js" : "jsx" ,
86+ ".jsx" : "jsx" ,
87+ ".ts" : "tsx" ,
88+ ".tsx" : "tsx" ,
89+ ".json" : "json" ,
90+ } ,
91+ } ) ;
92+
93+ // Server output
94+ await esbuild . build ( {
95+ entryPoints : [ join ( SOURCE_DIR , "server" , "public-exports.ts" ) ] ,
96+ bundle : true ,
97+ outfile : join ( OUTPUT_DIR , "server" , "index.js" ) ,
98+ target : "ESNext" ,
99+ format : "esm" ,
100+
101+ keepNames : true ,
102+ minify : true ,
103+ metafile : false ,
104+
105+ chunkNames : "_chunks/[name]-[hash]" ,
106+ assetNames : "_assets/[name]-[hash]" ,
107+
108+ mainFields : [ "module" , "main" ] , // Prefer ESM versions
109+ conditions : [ "import" , "module" , "require" ] , // Module resolution conditions
110+
111+ treeShaking : true ,
112+ packages : "external" ,
113+
114+ jsx : "automatic" ,
115+ jsxImportSource : "preact" ,
116+
117+ platform : "node" ,
118+
119+ alias : {
120+ "@" : SOURCE_DIR ,
121+ "react" : "preact/compat" ,
122+ "react-dom" : "preact/compat" ,
123+ } ,
124+
125+ loader : {
126+ ".js" : "jsx" ,
127+ ".jsx" : "jsx" ,
128+ ".ts" : "tsx" ,
129+ ".tsx" : "tsx" ,
130+ ".json" : "json" ,
131+ } ,
132+ } ) ;
0 commit comments