Skip to content

Commit 29a9d38

Browse files
jordy25519wphan
andauthored
Chore/esbuild (#316)
* increase swift maker heartbeat window * esbuild it * fix * optimize --------- Co-authored-by: wphan <[email protected]>
1 parent 1f1e2ef commit 29a9d38

File tree

5 files changed

+247
-39
lines changed

5 files changed

+247
-39
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*/**/node_modules
2+
*/**/lib
3+
*/**/dist
4+
.git/
5+
.husky/

Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
FROM public.ecr.aws/bitnami/node:20.18.1
2-
RUN apt-get install git
3-
ENV NODE_ENV=production
4-
RUN npm install -g typescript
5-
RUN npm install -g ts-node
1+
FROM node:20.18.1 AS builder
2+
RUN npm install -g husky
3+
4+
COPY package.json yarn.lock ./
65

76
WORKDIR /app
87

98
COPY . .
109
RUN yarn install
11-
RUN yarn build
12-
RUN yarn install --production
10+
RUN node esbuild.config.js
11+
12+
FROM node:20.18.1-alpine
13+
# 'bigint-buffer' native lib for performance
14+
RUN apk add python3 make g++ --virtual .build &&\
15+
npm install -C /lib bigint-buffer &&\
16+
apk del .build
17+
COPY --from=builder /app/lib/ ./lib/
1318

1419
EXPOSE 9464
1520

16-
CMD [ "yarn", "start:all" ]
21+
CMD ["node", "./lib/index.js"]

esbuild.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const esbuild = require('esbuild');
2+
const glob = require('tiny-glob');
3+
4+
const commonConfig = {
5+
bundle: true,
6+
platform: 'node',
7+
target: 'es2020',
8+
sourcemap: false,
9+
// minify: true, makes messy debug/error output
10+
treeShaking: true,
11+
legalComments: 'none',
12+
mainFields: ['module', 'main'],
13+
metafile: true,
14+
format: 'cjs',
15+
external: [
16+
'bigint-buffer'
17+
]
18+
};
19+
20+
(async () => {
21+
let entryPoints = await glob("./src/*.ts", { filesOnly: true });
22+
await esbuild.build({
23+
...commonConfig,
24+
entryPoints,
25+
outdir: 'lib',
26+
});
27+
})().catch(() => process.exit(1));

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,19 @@
4444
"@typescript-eslint/eslint-plugin": "5.62.0",
4545
"@typescript-eslint/parser": "4.33.0",
4646
"chai": "4.3.10",
47+
"esbuild": "0.24.0",
4748
"eslint": "7.32.0",
4849
"eslint-config-prettier": "8.10.0",
4950
"eslint-plugin-prettier": "3.4.1",
5051
"husky": "7.0.4",
5152
"mocha": "10.2.0",
5253
"prettier": "3.0.1",
54+
"tiny-glob": "0.2.9",
5355
"ts-node": "10.9.1"
5456
},
5557
"scripts": {
5658
"prepare": "husky install",
57-
"build": "yarn clean && tsc",
59+
"build": "yarn clean && node esbuild.config.js",
5860
"clean": "rm -rf lib",
5961
"start": "node lib/index.js",
6062
"dev": "NODE_OPTIONS=--max-old-space-size=8192 ts-node src/index.ts",

0 commit comments

Comments
 (0)