This repository has been archived by the owner on Jan 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.cjs
71 lines (59 loc) · 2.31 KB
/
esbuild.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const watchMode = process.env.WATCH_MODE;
const devMode = watchMode;
const packageDependencies = {
...require('./packages/utils/package.json').dependencies,
...require('./packages/ctrader/package.json').dependencies,
...require('./packages/metatrader/package.json').dependencies,
...require('./packages/binance/package.json').dependencies,
...require('./packages/swap/package.json').dependencies,
...require('./packages/coin/package.json').dependencies,
...require('./packages/core/package.json').dependencies,
// new
...require('./packages-share/core/package.json').dependencies,
...require('./packages-backend/core-backend/package.json').dependencies,
...require('./packages-backend/queue/package.json').dependencies,
...require('./packages-backend/slack/package.json').dependencies,
...require('./packages-backend/discord/package.json').dependencies,
...require('./packages-backend/expo/package.json').dependencies,
...require('./packages-backend/notif/package.json').dependencies,
...require('./packages-backend/firebase/package.json').dependencies,
...require('./packages-backend/mongo/package.json').dependencies,
...require('./packages-backend/redis/package.json').dependencies,
...require('./packages-backend/cache-first/package.json').dependencies,
...require('./packages-backend/ctrader-api/package.json').dependencies,
...require('./packages-backend/metatrader-api/package.json').dependencies,
...require('./packages-backend/meta-api/package.json').dependencies,
...require('./packages-backend/trade/package.json').dependencies,
};
const baseOptions = {
entryPoints: ['index.ts'],
outdir: 'dist',
loader: { '.js': 'js', '.ts': 'ts' },
bundle: true,
splitting: true,
minify: !devMode,
sourcemap: !devMode,
target: ['esnext'],
platform: 'node',
format: 'esm',
};
const build = async (dependencies, buildOptions) => {
const externalDependencies = Object.keys({
...packageDependencies,
...dependencies,
});
const options = {
...baseOptions,
...buildOptions,
external: externalDependencies,
};
if (watchMode) {
const ctx = await esbuild.context(options);
await ctx.watch();
} else {
await esbuild.build(options);
}
};
module.exports = build;