Skip to content

Commit d2fa807

Browse files
committed
feat: migrate to ESM and update dependencies
* Bump to Node 18.16.0 * Migrate to ESM instead of CJS * Bump all dependencies * Migrate to yarn berry * Add more fonts to the docker images BREAKING CHANGE: migrate to ESM
1 parent 07ae53e commit d2fa807

File tree

20 files changed

+9769
-5309
lines changed

20 files changed

+9769
-5309
lines changed

.circleci/config.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
executors:
44
node-standalone:
55
docker:
6-
- image: cimg/node:18.3.0
6+
- image: cimg/node:18.16.0
77

88
jobs:
99
deps-install:
@@ -12,19 +12,20 @@ jobs:
1212
- checkout
1313
- restore_cache:
1414
keys:
15-
- yarn-cache-node18-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
16-
- yarn-cache-node18-{{ checksum "package.json" }}
17-
- yarn-cache-node18
15+
- yarn2-cache-node18-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
16+
- yarn2-cache-node18-{{ checksum "package.json" }}
17+
- yarn2-cache-node18
1818
- run:
1919
name: Install depdencies
20-
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
20+
command: yarn install --immutable
2121
- save_cache:
22-
key: yarn-cache-node18-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
22+
key: yarn2-cache-node18-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
2323
paths:
24-
- ~/.cache/yarn
24+
- ~/project/.yarn/cache
2525
- persist_to_workspace:
2626
root: ~/project
2727
paths:
28+
- .yarn
2829
- node_modules
2930

3031
validate-project:

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
/build
22
/node_modules
3+
4+
# yarn
5+
.pnp.*
6+
.yarn/*
7+
!.yarn/patches
8+
!.yarn/plugins
9+
!.yarn/releases
10+
!.yarn/sdks
11+
!.yarn/versions

.eslintrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"root": true,
33
"parser": "@typescript-eslint/parser",
44
"parserOptions": {
5-
"ecmaVersion": 2019,
5+
"ecmaVersion": 2022,
66
"sourceType": "module",
77
"warnOnUnsupportedTypeScriptVersion": true
88
},
@@ -63,5 +63,9 @@
6363
"no-useless-constructor": "off",
6464
"@typescript-eslint/no-useless-constructor": "warn"
6565
},
66-
"settings": { "import/resolver": { "node": { "extensions": [".mjs", ".csj", ".js", ".ts", ".ts", ".json"] } } }
66+
"settings": {
67+
"import/resolver": {
68+
"typescript": {}
69+
}
70+
}
6771
}

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Use Node.js
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: '18.3.0'
27+
node-version: '18.16.0'
2828

2929
- name: Install dependencies
3030
run: yarn --frozen-lockfile
@@ -81,9 +81,6 @@ jobs:
8181
- name: Build chromium image
8282
run: docker build . --file docker/chromium/Dockerfile --platform linux/arm64 --tag $IMAGE_CHROMIUM
8383

84-
- name: Log into registry
85-
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u $DOCKER_LOGIN --password-stdin
86-
8784
- name: Push chromium image
8885
run: |
8986
IMAGE_ID=appvantage/$IMAGE_NAME

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
/build
22
/node_modules
3+
4+
# yarn
5+
.pnp.*
6+
.yarn/*
7+
!.yarn/patches
8+
!.yarn/plugins
9+
!.yarn/releases
10+
!.yarn/sdks
11+
!.yarn/versions

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 546 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-3.5.1.cjs

Lines changed: 873 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
nodeLinker: node-modules
2+
3+
plugins:
4+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
5+
spec: "@yarnpkg/plugin-interactive-tools"
6+
7+
yarnPath: .yarn/releases/yarn-3.5.1.cjs
File renamed without changes.

docker/chrome/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18.3.0-bullseye-slim as build
1+
FROM node:18.16.0-bullseye-slim as build
22

33
RUN apt-get update \
44
&& apt-get install -y --no-install-recommends curl \
@@ -9,9 +9,10 @@ WORKDIR /usr/local/app
99
ENV NODE_ENV=development
1010
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
1111

12-
COPY yarn.lock package.json ./
12+
COPY .yarn ./.yarn
13+
COPY yarn.lock package.json .yarnrc.yml ./
1314

14-
RUN yarn install --frozen-lockfile
15+
RUN yarn install --immutable
1516

1617
COPY tsconfig.json ./
1718
COPY src ./src
@@ -22,12 +23,12 @@ ENV NODE_ENV=production
2223

2324
# install dependencies with frozen lockfile
2425
# then clean with node prune
25-
RUN yarn install --frozen-lockfile --production
26+
RUN yarn install --immutable
2627

2728
# install node prune
2829
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
2930

30-
FROM node:18.3.0-bullseye-slim
31+
FROM node:18.16.0-bullseye-slim
3132

3233
RUN apt-get update \
3334
&& apt-get install -y wget gnupg ca-certificates procps libxss1 \
@@ -41,7 +42,7 @@ RUN apt-get update \
4142
# but that seems too easy to get out of date.
4243
&& apt-get install -y google-chrome-stable \
4344
# Font installation, support chinese font characters for now
44-
&& apt-get install -y fonts-wqy-zenhei \
45+
&& apt-get install -y fonts-wqy-zenhei fonts-indic fonts-noto fonts-noto-cjk \
4546
&& rm -rf /var/lib/apt/lists/*
4647

4748
WORKDIR /usr/local/app
@@ -51,6 +52,8 @@ ENV NODE_ENV=production
5152
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
5253

5354
COPY --from=build /usr/local/app/node_modules ./node_modules
55+
COPY --from=build /usr/local/app/.yarn ./.yarn
5456
COPY --from=build /usr/local/app/build ./
57+
COPY yarn.lock package.json .yarnrc.yml ./
5558

5659
CMD node index.js

0 commit comments

Comments
 (0)