11import type { Options } from '.' ;
22
3- // import { polyfillNode } from 'esbuild-plugin-polyfill-node';
43import { globSync } from 'glob' ;
5- // import { print } from 'q-i';
64import {
75 DIR_SRC ,
86 DIR_SRC_ASSETS ,
97 DIR_SRC_STATIC
108} from './constants' ;
11- // import {addControllersInFolder} from './addControllersInFolder';
12- // import {addRecursive} from './addRecursive';
139
1410
1511export default function buildServerConfig ( ) : Options {
@@ -19,93 +15,16 @@ export default function buildServerConfig(): Options {
1915 globSync ( `${ DIR_SRC_STATIC } /**/*.ts` )
2016 )
2117 } ) ;
22- // const entry: string[] = [];
23- // addRecursive(`${DIR_SRC}/lib`, entry)
24- // addControllersInFolder(`${DIR_SRC}/admin/tools`, entry);
25- // addControllersInFolder(`${DIR_SRC}/services`, entry);
26- // print(entry);
2718
2819 return {
2920 bundle : true , // Needed for @enonic /lib-admin-ui
3021 dts : false , // d.ts files are use useless at runtime
3122 entry,
32- // env: {
33- // BROWSER_SYNC_PORT: '3000',
34- // },
3523 esbuildOptions ( options , context ) {
36- // options.alias = {
37- // 'alias': './src/main/resources/lib/filename.js'
38- // };
39-
40- // Some node modules might need globalThis
41- // options.banner = {
42- // js: `const globalThis = (1, eval)('this');` // buffer polyfill needs this
43- // };
44-
45- // If you have libs with chunks, use this to avoid collisions
4624 options . chunkNames = '_chunks/[name]-[hash]' ;
47-
4825 options . mainFields = [ 'module' , 'main' ] ;
4926 } ,
50- esbuildPlugins : [
51- // Some node modules might need parts of Node polyfilled:
52- // polyfillNode({
53- // globals: {
54- // buffer: false,
55- // process: false
56- // },
57- // polyfills: {
58- // _stream_duplex: false,
59- // _stream_passthrough: false,
60- // _stream_readable: false,
61- // _stream_transform: false,
62- // _stream_writable: false,
63- // assert: false,
64- // 'assert/strict': false,
65- // async_hooks: false,
66- // buffer: false,
67- // child_process: false,
68- // cluster: false,
69- // console: false,
70- // constants: false,
71- // crypto: false,
72- // dgram: false,
73- // diagnostics_channel: false,
74- // dns: false,
75- // domain: false,
76- // events: false,
77- // fs: false,
78- // 'fs/promises': false,
79- // http: false,
80- // http2: false,
81- // https: false,
82- // module: false,
83- // net: false,
84- // os: false,
85- // path: false,
86- // perf_hooks: false,
87- // process: false, //"empty",
88- // punycode: false,
89- // querystring: false,
90- // readline: false,
91- // repl: false,
92- // stream: false,
93- // string_decoder: false,
94- // sys: false,
95- // timers: false,
96- // 'timers/promises': false,
97- // tls: false,
98- // tty: false,
99- // url: false,
100- // util: false, // true,
101- // v8: false,
102- // vm: false,
103- // wasi: false,
104- // worker_threads: false,
105- // zlib: false,
106- // }
107- // }) // ReferenceError: "navigator" is not defined
108- ] ,
27+ esbuildPlugins : [ ] ,
10928 external : [
11029 '/lib/cache' ,
11130 '/lib/enonic/static' ,
@@ -123,27 +42,7 @@ export default function buildServerConfig(): Options {
12342 / ^ \/ l i b \/ x p \/ / ,
12443 ] ,
12544 format : 'cjs' ,
126- inject : [
127- // Injects makes it possible to use some functionality in any file :)
128- // However it also makes every file larger, unless splitting: true
129- // If for some reason you cannot use code splitting, it is better
130- // to import a polyfill only in the entries that needs it.
131- // Code-js polyfills share code, so together they don't add the sum of all the polyfills.
132- // For example injecting both number/is-finite and is-integer only adds 60K, not 108K
133-
134- // Here are some things Nashorn doesn't support, comment them in to inject them:
135- // 'node_modules/core-js/stable/array/flat.js', // 69K (18K) minified
136- // 'node_modules/core-js/stable/array/includes.js', // 60K (15K)
137- // 'node_modules/core-js/stable/math/trunc.js', // 53K (14K)
138- // 'node_modules/core-js/stable/number/is-finite.js', // 54K (14K)
139- // 'node_modules/core-js/stable/number/is-integer.js', // 54K (14K)
140- // 'node_modules/core-js/stable/parse-float.js', // 59K (15K)
141- // 'node_modules/core-js/stable/reflect/index.js', // 88K (22K)
142- // 'node_modules/core-js/stable/string/pad-start.js',
143-
144- // TIP: I used this command to find sizes
145- // npm --silent run clean && npm --silent run build:server; ls -lh build/resources/main/empty.js; npm --silent run clean && npm --silent run build:server -- --minify; ls -lh build/resources/main/empty.js
146- ] ,
45+ inject : [ ] ,
14746 minify : false , // Minifying server files makes debugging harder
14847
14948 // TIP: Command to check if there are any bad requires left behind
@@ -155,7 +54,6 @@ export default function buildServerConfig(): Options {
15554 shims : false , // https://tsup.egoist.dev/#inject-cjs-and-esm-shims
15655
15756 splitting : false , // In order for tests to work
158- // splitting: true,
15957
16058 sourcemap : false ,
16159 target : 'es5' ,
0 commit comments