11import { build , type BuildOptions , context } from 'esbuild' ;
2- import { nodeExternalsPlugin } from 'esbuild-node-externals' ;
32
43const isProd = Boolean ( process . env . NODE_ENV === 'production' ) ;
54const watch = Boolean ( process . env . ESBUILD_WATCH ) ;
@@ -9,20 +8,34 @@ const config: BuildOptions = {
98 bundle : true ,
109 platform : 'node' ,
1110 minify : isProd ,
12- target : 'node18 ' ,
11+ target : 'node20 ' ,
1312 sourcemap : true ,
1413 format : 'cjs' ,
1514 tsconfig : 'tsconfig.json' ,
1615 plugins : [
17- // Exclude node_modules from the bundle since they will be packaged with the cli
18- nodeExternalsPlugin ( ) ,
16+ // taken from https://github.com/tjx666/awesome-vscode-extension-boilerplate/blob/main/scripts/esbuild.ts
17+ {
18+ name : 'umd2esm' ,
19+ setup ( build ) {
20+ build . onResolve ( { filter : / ^ ( v s c o d e - .* | e s t r e e - w a l k e r | j s o n c - p a r s e r ) / } , args => {
21+ const pathUmdMay = require . resolve ( args . path , {
22+ paths : [ args . resolveDir ] ,
23+ } ) ;
24+ // Call twice the replace is to solve the problem of the path in Windows
25+ const pathEsm = pathUmdMay
26+ . replace ( '/umd/' , '/esm/' )
27+ . replace ( '\\umd\\' , '\\esm\\' ) ;
28+ return { path : pathEsm } ;
29+ } ) ;
30+ } ,
31+ } ,
1932 ] ,
2033 define : {
2134 'process.env.DEFAULT_APP_NAME' : JSON . stringify ( isProd ? 'Insomnia' : 'insomnia-app' ) ,
2235 'process.env.VERSION' : JSON . stringify ( isProd ? version : 'dev' ) ,
2336 '__DEV__' : JSON . stringify ( ! isProd ) ,
2437 } ,
25- external : [ '@getinsomnia/node-libcurl' , 'mocha' ] ,
38+ external : [ '@getinsomnia/node-libcurl' , 'insomnia-send-request' , 'fsevents' , ' mocha'] ,
2639 entryPoints : [ './src/index.ts' ] ,
2740} ;
2841
0 commit comments