From 7abf7b660bf7d9fe49d7e97a1cbd203b10e0302a Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:15:46 +0800 Subject: [PATCH 1/8] upgrade vite to 5.4.9 and fix build issue --- package.json | 2 +- tsconfig.json | 1 + vite.config.ts | 8 +++----- yarn.lock | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index c2347aa..3fa677f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "eslint-config-next": "^14.2.15", "happy-dom": "^15.7.4", "typescript": "^5.6.2", - "vite": "^5.4.8", + "vite": "^5.4.9", "vitest": "^2.1.3" }, "browserslist": [ diff --git a/tsconfig.json b/tsconfig.json index db12314..683044f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,6 +37,7 @@ "**/*.tsx", ".next/types/**/*.ts" ], + "types": ["vitest/globals"], "exclude": [ "node_modules" ] diff --git a/vite.config.ts b/vite.config.ts index f445e04..3f1072f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,9 @@ -// vite.config.ts -import { defineConfig } from 'vite'; -import react from '@vitejs/plugin-react'; +// vitest.config.ts +import { defineConfig } from 'vitest/config'; export default defineConfig({ - plugins: [react()], test: { globals: true, - environment: 'node', // Set a default environment + environment: 'node', }, }); diff --git a/yarn.lock b/yarn.lock index 3ac4ef9..ce082ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5176,7 +5176,7 @@ __metadata: react-dom: "npm:^18.3.1" regenerator-runtime: "npm:^0.14.1" typescript: "npm:^5.6.2" - vite: "npm:^5.4.8" + vite: "npm:^5.4.9" vitest: "npm:^2.1.3" winston: "npm:^3.15.0" languageName: unknown @@ -5497,7 +5497,7 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.0.0, vite@npm:^5.4.8": +"vite@npm:^5.0.0": version: 5.4.8 resolution: "vite@npm:5.4.8" dependencies: @@ -5540,6 +5540,49 @@ __metadata: languageName: node linkType: hard +"vite@npm:^5.4.9": + version: 5.4.9 + resolution: "vite@npm:5.4.9" + dependencies: + esbuild: "npm:^0.21.3" + fsevents: "npm:~2.3.3" + postcss: "npm:^8.4.43" + rollup: "npm:^4.20.0" + peerDependencies: + "@types/node": ^18.0.0 || >=20.0.0 + less: "*" + lightningcss: ^1.21.0 + sass: "*" + sass-embedded: "*" + stylus: "*" + sugarss: "*" + terser: ^5.4.0 + dependenciesMeta: + fsevents: + optional: true + peerDependenciesMeta: + "@types/node": + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + bin: + vite: bin/vite.js + checksum: 10c0/e9c59f2c639047e37c79bbbb151c7a55a3dc27932957cf4cf0447ee0bdcc1ddfd9b1fb3ba0465371c01ba3616d62561327855794c2d652213c3a10a32e6d369d + languageName: node + linkType: hard + "vitest@npm:^2.1.3": version: 2.1.3 resolution: "vitest@npm:2.1.3" From 7410199e9d72ae4f68faaf61c5b35dc510d11f80 Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:21:12 +0800 Subject: [PATCH 2/8] add caching for github action --- .github/workflows/yarn-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/yarn-test.yml b/.github/workflows/yarn-test.yml index f5ee588..99cff0a 100644 --- a/.github/workflows/yarn-test.yml +++ b/.github/workflows/yarn-test.yml @@ -27,6 +27,8 @@ jobs: with: node-version: ${{ matrix.node-version }} check-latest: true + cache: 'yarn' + cache-dependency-path: 'yarn.lock' - name: Enable Corepack run: corepack enable # Enable Corepack to manage Yarn versions From 461e202d80c9024f78b1cc3fce5331d3d63b7f18 Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:25:10 +0800 Subject: [PATCH 3/8] fix yarn cache issue --- .github/workflows/yarn-test.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/yarn-test.yml b/.github/workflows/yarn-test.yml index 99cff0a..8542cae 100644 --- a/.github/workflows/yarn-test.yml +++ b/.github/workflows/yarn-test.yml @@ -27,8 +27,6 @@ jobs: with: node-version: ${{ matrix.node-version }} check-latest: true - cache: 'yarn' - cache-dependency-path: 'yarn.lock' - name: Enable Corepack run: corepack enable # Enable Corepack to manage Yarn versions @@ -36,6 +34,19 @@ jobs: - name: Set Yarn to version 2 run: yarn set version berry # Set Yarn to v2 (Berry) + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Cache Yarn dependencies + uses: actions/cache@v4 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install dependencies run: yarn install From 263c6371d62c1dd30b69e8a50ef4643eec0dd615 Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:36:16 +0800 Subject: [PATCH 4/8] add caching option --- .github/workflows/yarn-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/yarn-test.yml b/.github/workflows/yarn-test.yml index 8542cae..d85549c 100644 --- a/.github/workflows/yarn-test.yml +++ b/.github/workflows/yarn-test.yml @@ -27,6 +27,7 @@ jobs: with: node-version: ${{ matrix.node-version }} check-latest: true + cache: 'yarn' - name: Enable Corepack run: corepack enable # Enable Corepack to manage Yarn versions @@ -48,7 +49,7 @@ jobs: ${{ runner.os }}-yarn- - name: Install dependencies - run: yarn install + run: yarn install --immutable - name: Build project run: yarn build From 412b19377b3349bc977e1975391e5312bd7b34b8 Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:40:25 +0800 Subject: [PATCH 5/8] remove packageManager option in package.json --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 3fa677f..9eb105e 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,5 @@ "resolutions": { "glob": "^11", "rimraf": "^4" - }, - "packageManager": "yarn@4.5.0" + } } From 2105176d7ff6eaa4560b3bfbb4bf83ff32c70039 Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:43:18 +0800 Subject: [PATCH 6/8] use set up node.js for caching --- .github/workflows/yarn-test.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/yarn-test.yml b/.github/workflows/yarn-test.yml index d85549c..9e14a34 100644 --- a/.github/workflows/yarn-test.yml +++ b/.github/workflows/yarn-test.yml @@ -35,19 +35,6 @@ jobs: - name: Set Yarn to version 2 run: yarn set version berry # Set Yarn to v2 (Berry) - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - - name: Cache Yarn dependencies - uses: actions/cache@v4 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install dependencies run: yarn install --immutable From 80117d13e39380b2af3554f907c16919477fc02c Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:51:08 +0800 Subject: [PATCH 7/8] improve github action caching --- .github/workflows/yarn-test.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/yarn-test.yml b/.github/workflows/yarn-test.yml index 9e14a34..20ce589 100644 --- a/.github/workflows/yarn-test.yml +++ b/.github/workflows/yarn-test.yml @@ -34,7 +34,24 @@ jobs: - name: Set Yarn to version 2 run: yarn set version berry # Set Yarn to v2 (Berry) - + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: cache builds + uses: actions/cache@v4 + id: yarn-cache + with: + path: | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + ${{ github.workspace }}/.next/cache + # Generate a new cache whenever packages or source files change. + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} + # If source files changed but packages didn't, rebuild from a prior cache. + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- + - name: Install dependencies run: yarn install --immutable From 8704059695326533808c34ddb393927d4426f337 Mon Sep 17 00:00:00 2001 From: Kang <555836+cnkang@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:54:51 +0800 Subject: [PATCH 8/8] improve github action --- .github/workflows/yarn-test.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/yarn-test.yml b/.github/workflows/yarn-test.yml index 20ce589..5b091d9 100644 --- a/.github/workflows/yarn-test.yml +++ b/.github/workflows/yarn-test.yml @@ -35,23 +35,16 @@ jobs: - name: Set Yarn to version 2 run: yarn set version berry # Set Yarn to v2 (Berry) - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - - name: cache builds + - name: Cache Yarn and Next.js build uses: actions/cache@v4 - id: yarn-cache with: path: | - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - ${{ github.workspace }}/.next/cache - # Generate a new cache whenever packages or source files change. - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} - # If source files changed but packages didn't, rebuild from a prior cache. + .yarn/cache + .next/cache + key: ${{ runner.os }}-node-${{ matrix.node-version }}-nextjs-${{ hashFiles('yarn.lock', 'src/**/*') }} restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- - + ${{ runner.os }}-node-${{ matrix.node-version }}-nextjs-${{ hashFiles('yarn.lock') }}- + - name: Install dependencies run: yarn install --immutable