@@ -26,7 +26,10 @@ const commonOptions = {
2626 target : 'es2021' ,
2727 sourcemap : true ,
2828 treeShaking : true ,
29+ splitting : true ,
30+ chunkNames : 'chunks/[name]-[hash]' ,
2931 logLevel : 'warning' ,
32+ outExtension : { '.js' : '.mjs' } ,
3033} ;
3134
3235/** @type {esbuild.BuildOptions } */
@@ -103,7 +106,8 @@ if (config.addon) {
103106 bundleConfig = {
104107 ...bundleConfig ,
105108 entryPoints : [ `addons/addon-${ config . addon } /src/${ getAddonEntryPoint ( config . addon ) } .ts` ] ,
106- outfile : `addons/addon-${ config . addon } /lib/addon-${ config . addon } .mjs` ,
109+ outdir : `addons/addon-${ config . addon } /lib` ,
110+ entryNames : `addon-${ config . addon } ` ,
107111 } ;
108112 outConfig = {
109113 ...outConfig ,
@@ -128,11 +132,12 @@ if (config.addon) {
128132 bundleConfig = {
129133 ...bundleConfig ,
130134 entryPoints : [ `demo/client/client.ts` ] ,
131- outfile : 'demo/dist/client-bundle.js' ,
135+ outdir : 'demo/dist' ,
136+ entryNames : 'client-bundle' ,
132137 external : [ 'util' , 'os' , 'fs' , 'path' , 'stream' , 'Terminal' ] ,
133138 alias : {
134139 // Library ESM imports
135- "@xterm/xterm" : "." ,
140+ "@xterm/xterm" : "./lib/xterm.mjs " ,
136141 "@xterm/addon-attach" : "./addons/addon-attach/lib/addon-attach.mjs" ,
137142 "@xterm/addon-clipboard" : "./addons/addon-clipboard/lib/addon-clipboard.mjs" ,
138143 "@xterm/addon-fit" : "./addons/addon-fit/lib/addon-fit.mjs" ,
@@ -164,14 +169,19 @@ if (config.addon) {
164169 format : 'cjs' ,
165170 platform : 'node' ,
166171 external : [ 'node-pty' ] ,
172+ // Splitting is not compatible with cjs format
173+ splitting : false ,
174+ // Override the .mjs extension from commonOptions
175+ outExtension : { } ,
167176 }
168177 skipOut = true ;
169178 skipOutTest = true ;
170179} else if ( config . isHeadless ) {
171180 bundleConfig = {
172181 ...bundleConfig ,
173182 entryPoints : [ `src/headless/public/Terminal.ts` ] ,
174- outfile : `headless/lib-headless/xterm-headless.mjs`
183+ outdir : `headless/lib-headless` ,
184+ entryNames : 'xterm-headless' ,
175185 } ;
176186 outConfig = {
177187 ...outConfig ,
@@ -183,7 +193,8 @@ if (config.addon) {
183193 bundleConfig = {
184194 ...bundleConfig ,
185195 entryPoints : [ `src/browser/public/Terminal.ts` ] ,
186- outfile : `lib/xterm.mjs`
196+ outdir : `lib` ,
197+ entryNames : 'xterm' ,
187198 } ;
188199 outConfig = {
189200 ...outConfig ,
0 commit comments