Skip to content

Commit b71f15a

Browse files
committed
Cleanup
1 parent 56fe382 commit b71f15a

File tree

5 files changed

+3
-334
lines changed

5 files changed

+3
-334
lines changed

.swcrc

Lines changed: 0 additions & 29 deletions
This file was deleted.

tsup/assets.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import type { Options } from '.';
22

3-
// import { globalExternals } from "@fal-works/esbuild-plugin-global-externals";
4-
// import GlobalsPlugin from "esbuild-plugin-globals";
5-
import { defineConfig } from 'tsup';
6-
// const { externalGlobalPlugin } = require("esbuild-plugin-external-global");
73
import esbuildPluginExternalGlobal from 'esbuild-plugin-external-global';
8-
import { DIR_DST } from './constants';
94

105

116
export default function buildAssetConfig(): Options {
@@ -20,31 +15,12 @@ export default function buildAssetConfig(): Options {
2015
options.banner = {
2116
js: `const jQuery = $;` // jQuery UI Tabbable requires this
2217
};
23-
// options.external = [
24-
// 'jquery'
25-
// ]
2618
},
2719
esbuildPlugins: [
28-
// GlobalsPlugin({
29-
// // 'jquery': 'jQuery',
30-
// 'jquery': '$'
31-
// }),
32-
// globalExternals({
33-
// 'jquery': 'window.$'
34-
// // 'jquery': 'jQuery'
35-
// })
3620
esbuildPluginExternalGlobal.externalGlobalPlugin({
37-
// 'react': 'window.React',
38-
// 'react-dom': 'window.ReactDOM',
39-
// 'jQuery': 'window.$' // It seems jquery is available as $ in the global scope
4021
'jquery': 'window.$'
4122
})
4223
],
43-
// external: [
44-
// // This will leave require('jquery') as is in the bundle
45-
// // causes: Uncaught ReferenceError: require is not defined
46-
// 'jquery'
47-
// ],
4824
format: [
4925
'cjs'
5026
],
@@ -60,7 +36,6 @@ export default function buildAssetConfig(): Options {
6036
outDir: 'build/resources/main/assets',
6137
platform: 'browser',
6238
silent: ['QUIET', 'WARN'].includes(process.env.LOG_LEVEL_FROM_GRADLE||''),
63-
// splitting: false,
6439
sourcemap: process.env.NODE_ENV === 'development',
6540
tsconfig: 'src/main/resources/assets/tsconfig.json',
6641
};

tsup/server.ts

Lines changed: 2 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import type { Options } from '.';
22

3-
// import { polyfillNode } from 'esbuild-plugin-polyfill-node';
43
import { globSync } from 'glob';
5-
// import { print } from 'q-i';
64
import {
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

1511
export 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
/^\/lib\/xp\//,
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',

tsup/test.ts

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,33 @@
11
import type { Options } from '.';
22

3-
// import { polyfillNode } from 'esbuild-plugin-polyfill-node';
4-
// import { print } from 'q-i';
53
import { DIR_SRC_TEST } from './constants';
64
import {addRecursive} from './addRecursive';
75

86

97
export default function buildServerConfig(): Options {
108
const entry: string[] = [];
119
addRecursive(DIR_SRC_TEST, entry);
12-
// print(entry);
1310

1411
return {
1512
bundle: true,
1613
dts: false, // d.ts files are use useless at runtime
1714
entry,
18-
// env: {
19-
// BROWSER_SYNC_PORT: '3000',
20-
// },
2115
esbuildOptions(options, context) {
22-
// options.alias = {
23-
// 'alias': './src/main/resources/lib/filename.js'
24-
// };
25-
26-
// Some node modules might need globalThis
27-
// options.banner = {
28-
// js: `const globalThis = (1, eval)('this');` // buffer polyfill needs this
29-
// };
30-
31-
// If you have libs with chunks, use this to avoid collisions
3216
options.chunkNames = '_chunks/[name]-[hash]';
3317

3418
options.mainFields = ['module', 'main'];
3519

3620
options.outbase = DIR_SRC_TEST;
3721
},
38-
esbuildPlugins: [
39-
// Some node modules might need parts of Node polyfilled:
40-
// polyfillNode({
41-
// globals: {
42-
// buffer: false,
43-
// process: false
44-
// },
45-
// polyfills: {
46-
// _stream_duplex: false,
47-
// _stream_passthrough: false,
48-
// _stream_readable: false,
49-
// _stream_transform: false,
50-
// _stream_writable: false,
51-
// assert: false,
52-
// 'assert/strict': false,
53-
// async_hooks: false,
54-
// buffer: false,
55-
// child_process: false,
56-
// cluster: false,
57-
// console: false,
58-
// constants: false,
59-
// crypto: false,
60-
// dgram: false,
61-
// diagnostics_channel: false,
62-
// dns: false,
63-
// domain: false,
64-
// events: false,
65-
// fs: false,
66-
// 'fs/promises': false,
67-
// http: false,
68-
// http2: false,
69-
// https: false,
70-
// module: false,
71-
// net: false,
72-
// os: false,
73-
// path: false,
74-
// perf_hooks: false,
75-
// process: false, //"empty",
76-
// punycode: false,
77-
// querystring: false,
78-
// readline: false,
79-
// repl: false,
80-
// stream: false,
81-
// string_decoder: false,
82-
// sys: false,
83-
// timers: false,
84-
// 'timers/promises': false,
85-
// tls: false,
86-
// tty: false,
87-
// url: false,
88-
// util: false, // true,
89-
// v8: false,
90-
// vm: false,
91-
// wasi: false,
92-
// worker_threads: false,
93-
// zlib: false,
94-
// }
95-
// }) // ReferenceError: "navigator" is not defined
96-
],
22+
esbuildPlugins: [],
9723
external: [
9824
/^\//,
9925
],
10026
format: 'cjs',
10127
inject: [
102-
// Injects makes it possible to use some functionality in any file :)
103-
// However it also makes every file larger, unless splitting: true
104-
// If for some reason you cannot use code splitting, it is better
105-
// to import a polyfill only in the entries that needs it.
106-
// Code-js polyfills share code, so together they don't add the sum of all the polyfills.
107-
// For example injecting both number/is-finite and is-integer only adds 60K, not 108K
108-
109-
// Here are some things Nashorn doesn't support, comment them in to inject them:
110-
// 'node_modules/core-js/stable/array/flat.js', // 69K (18K) minified
111-
// 'node_modules/core-js/stable/array/includes.js', // 60K (15K)
112-
// 'node_modules/core-js/stable/math/trunc.js', // 53K (14K)
113-
// 'node_modules/core-js/stable/number/is-finite.js', // 54K (14K)
114-
// 'node_modules/core-js/stable/number/is-integer.js', // 54K (14K)
115-
// 'node_modules/core-js/stable/parse-float.js', // 59K (15K)
116-
// 'node_modules/core-js/stable/reflect/index.js', // 88K (22K)
117-
// 'node_modules/core-js/stable/string/pad-start.js',
118-
119-
// TIP: I used this command to find sizes
120-
// 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
12128
],
12229
minify: false, // Minifying server files makes debugging harder
12330

124-
// TIP: Command to check if there are any bad requires left behind
125-
// grep -r 'require("' build/resources/main | grep -v 'require("/'|grep -v chunk
12631
noExternal: [],
12732

12833
platform: 'neutral',

0 commit comments

Comments
 (0)