Skip to content

Commit

Permalink
feat(vite): upgrade to v5 (#10197)
Browse files Browse the repository at this point in the history
Redoing #10167 since I've split
out some of the changes in
#10196 and want a cleaner
commit history to debug CI.
  • Loading branch information
jtoar committed Mar 11, 2024
1 parent 827dd9b commit 4fd86e8
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 132 deletions.
4 changes: 4 additions & 0 deletions packages/cli/src/commands/buildHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export const handler = async ({
// it could affect other things that run in parallel while building.
// We don't have any parallel tasks right now, but someone might add
// one in the future as a performance optimization.
//
// Disable the new warning in Vite v5 about the CJS build being deprecated
// so that users don't have to see it when this command is called with --verbose
process.env.VITE_CJS_IGNORE_WARNING = 'true'
await execa(
`node ${require.resolve(
'@redwoodjs/vite/bins/rw-vite-build.mjs',
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/commands/devHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export const handler = async ({
// Written this way to make it easier to read

// 1. default: Vite (SPA)
//
// Disable the new warning in Vite v5 about the CJS build being deprecated
// so that users don't have to see it every time the dev server starts up.
process.env.VITE_CJS_IGNORE_WARNING = 'true'
let webCommand = `yarn cross-env NODE_ENV=development rw-vite-dev ${forward}`

// 2. Vite with SSR
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"isbot": "3.7.1",
"react": "0.0.0-experimental-e5205658f-20230913",
"react-server-dom-webpack": "0.0.0-experimental-e5205658f-20230913",
"vite": "4.5.2",
"vite": "5.1.5",
"vite-plugin-cjs-interop": "2.1.0",
"yargs-parser": "21.1.1"
},
Expand All @@ -94,7 +94,7 @@
"@types/react": "^18.2.55",
"@types/yargs-parser": "21.0.3",
"glob": "10.3.10",
"rollup": "3.29.4",
"rollup": "4.12.1",
"tsx": "4.6.2",
"typescript": "5.3.3",
"vitest": "1.3.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/lib/getMergedConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ export function getMergedConfig(rwConfig: Config, rwPaths: Paths) {
? rwPaths.web.distClient
: rwPaths.web.dist,
emptyOutDir: true,
manifest: !env.ssrBuild ? 'client-build-manifest.json' : undefined,
manifest: !env.isSsrBuild ? 'client-build-manifest.json' : undefined,
// Note that sourcemap can be boolean or 'inline'
sourcemap: !env.ssrBuild && rwConfig.web.sourceMap,
sourcemap: !env.isSsrBuild && rwConfig.web.sourceMap,
rollupOptions: {
input: getRollupInput(!!env.ssrBuild),
input: getRollupInput(!!env.isSsrBuild),
},
},
// @MARK: do not set buildSsrCjsExternalHeuristics here
Expand Down
4 changes: 0 additions & 4 deletions packages/vite/src/rsc/rscBuildForServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export async function rscBuildForServer(
// TODO (RSC): No redwood-vite plugin, add it in here
const rscServerBuildOutput = await viteBuild({
envFile: false,
legacy: {
// @MARK: for the worker, we're building ESM! (not CJS)
buildSsrCjsExternalHeuristics: false,
},
ssr: {
// Externalize everything except packages with files that have
// 'use client' in them (which are the files in `clientEntryFiles`)
Expand Down
192 changes: 69 additions & 123 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8802,10 +8802,10 @@ __metadata:
isbot: "npm:3.7.1"
react: "npm:0.0.0-experimental-e5205658f-20230913"
react-server-dom-webpack: "npm:0.0.0-experimental-e5205658f-20230913"
rollup: "npm:3.29.4"
rollup: "npm:4.12.1"
tsx: "npm:4.6.2"
typescript: "npm:5.3.3"
vite: "npm:4.5.2"
vite: "npm:5.1.5"
vite-plugin-cjs-interop: "npm:2.1.0"
vitest: "npm:1.3.1"
yargs-parser: "npm:21.1.1"
Expand Down Expand Up @@ -8925,93 +8925,93 @@ __metadata:
languageName: node
linkType: hard

"@rollup/rollup-android-arm-eabi@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-android-arm-eabi@npm:4.9.5"
"@rollup/rollup-android-arm-eabi@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-android-arm-eabi@npm:4.12.1"
conditions: os=android & cpu=arm
languageName: node
linkType: hard

"@rollup/rollup-android-arm64@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-android-arm64@npm:4.9.5"
"@rollup/rollup-android-arm64@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-android-arm64@npm:4.12.1"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard

"@rollup/rollup-darwin-arm64@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-darwin-arm64@npm:4.9.5"
"@rollup/rollup-darwin-arm64@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-darwin-arm64@npm:4.12.1"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@rollup/rollup-darwin-x64@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-darwin-x64@npm:4.9.5"
"@rollup/rollup-darwin-x64@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-darwin-x64@npm:4.12.1"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@rollup/rollup-linux-arm-gnueabihf@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.9.5"
"@rollup/rollup-linux-arm-gnueabihf@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.12.1"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard

"@rollup/rollup-linux-arm64-gnu@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.9.5"
"@rollup/rollup-linux-arm64-gnu@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.12.1"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@rollup/rollup-linux-arm64-musl@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-linux-arm64-musl@npm:4.9.5"
"@rollup/rollup-linux-arm64-musl@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-linux-arm64-musl@npm:4.12.1"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@rollup/rollup-linux-riscv64-gnu@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.9.5"
"@rollup/rollup-linux-riscv64-gnu@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.12.1"
conditions: os=linux & cpu=riscv64 & libc=glibc
languageName: node
linkType: hard

"@rollup/rollup-linux-x64-gnu@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-linux-x64-gnu@npm:4.9.5"
"@rollup/rollup-linux-x64-gnu@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-linux-x64-gnu@npm:4.12.1"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@rollup/rollup-linux-x64-musl@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-linux-x64-musl@npm:4.9.5"
"@rollup/rollup-linux-x64-musl@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-linux-x64-musl@npm:4.12.1"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@rollup/rollup-win32-arm64-msvc@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.9.5"
"@rollup/rollup-win32-arm64-msvc@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.12.1"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"@rollup/rollup-win32-ia32-msvc@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.9.5"
"@rollup/rollup-win32-ia32-msvc@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.12.1"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@rollup/rollup-win32-x64-msvc@npm:4.9.5":
version: 4.9.5
resolution: "@rollup/rollup-win32-x64-msvc@npm:4.9.5"
"@rollup/rollup-win32-x64-msvc@npm:4.12.1":
version: 4.12.1
resolution: "@rollup/rollup-win32-x64-msvc@npm:4.12.1"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
Expand Down Expand Up @@ -17777,7 +17777,7 @@ __metadata:
languageName: node
linkType: hard

"esbuild@npm:^0.18.0, esbuild@npm:^0.18.10, esbuild@npm:~0.18.20":
"esbuild@npm:^0.18.0, esbuild@npm:~0.18.20":
version: 0.18.20
resolution: "esbuild@npm:0.18.20"
dependencies:
Expand Down Expand Up @@ -27997,14 +27997,14 @@ __metadata:
languageName: node
linkType: hard

"postcss@npm:^8.2.14, postcss@npm:^8.4.21, postcss@npm:^8.4.24, postcss@npm:^8.4.27, postcss@npm:^8.4.32":
version: 8.4.33
resolution: "postcss@npm:8.4.33"
"postcss@npm:^8.2.14, postcss@npm:^8.4.21, postcss@npm:^8.4.24, postcss@npm:^8.4.35":
version: 8.4.35
resolution: "postcss@npm:8.4.35"
dependencies:
nanoid: "npm:^3.3.7"
picocolors: "npm:^1.0.0"
source-map-js: "npm:^1.0.2"
checksum: 10c0/16eda83458fcd8a91bece287b5920c7f57164c3ea293e6c80d0ea71ce7843007bcd8592260a5160b9a7f02693e6ac93e2495b02d8c7596d3f3f72c1447e3ba79
checksum: 10c0/e8dd04e48001eb5857abc9475365bf08f4e508ddf9bc0b8525449a95d190f10d025acebc5b56ac2e94b3c7146790e4ae78989bb9633cb7ee20d1cc9b7dc909b2
languageName: node
linkType: hard

Expand Down Expand Up @@ -29756,37 +29756,23 @@ __metadata:
languageName: node
linkType: hard

"rollup@npm:3.29.4, rollup@npm:^3.27.1":
version: 3.29.4
resolution: "rollup@npm:3.29.4"
dependencies:
fsevents: "npm:~2.3.2"
dependenciesMeta:
fsevents:
optional: true
bin:
rollup: dist/bin/rollup
checksum: 10c0/65eddf84bf389ea8e4d4c1614b1c6a298d08f8ae785c0c087e723a879190c8aaddbab4aa3b8a0524551b9036750c9f8bfea27b377798accfd2ba5084ceff5aaa
languageName: node
linkType: hard

"rollup@npm:^4.2.0":
version: 4.9.5
resolution: "rollup@npm:4.9.5"
dependencies:
"@rollup/rollup-android-arm-eabi": "npm:4.9.5"
"@rollup/rollup-android-arm64": "npm:4.9.5"
"@rollup/rollup-darwin-arm64": "npm:4.9.5"
"@rollup/rollup-darwin-x64": "npm:4.9.5"
"@rollup/rollup-linux-arm-gnueabihf": "npm:4.9.5"
"@rollup/rollup-linux-arm64-gnu": "npm:4.9.5"
"@rollup/rollup-linux-arm64-musl": "npm:4.9.5"
"@rollup/rollup-linux-riscv64-gnu": "npm:4.9.5"
"@rollup/rollup-linux-x64-gnu": "npm:4.9.5"
"@rollup/rollup-linux-x64-musl": "npm:4.9.5"
"@rollup/rollup-win32-arm64-msvc": "npm:4.9.5"
"@rollup/rollup-win32-ia32-msvc": "npm:4.9.5"
"@rollup/rollup-win32-x64-msvc": "npm:4.9.5"
"rollup@npm:4.12.1, rollup@npm:^4.2.0":
version: 4.12.1
resolution: "rollup@npm:4.12.1"
dependencies:
"@rollup/rollup-android-arm-eabi": "npm:4.12.1"
"@rollup/rollup-android-arm64": "npm:4.12.1"
"@rollup/rollup-darwin-arm64": "npm:4.12.1"
"@rollup/rollup-darwin-x64": "npm:4.12.1"
"@rollup/rollup-linux-arm-gnueabihf": "npm:4.12.1"
"@rollup/rollup-linux-arm64-gnu": "npm:4.12.1"
"@rollup/rollup-linux-arm64-musl": "npm:4.12.1"
"@rollup/rollup-linux-riscv64-gnu": "npm:4.12.1"
"@rollup/rollup-linux-x64-gnu": "npm:4.12.1"
"@rollup/rollup-linux-x64-musl": "npm:4.12.1"
"@rollup/rollup-win32-arm64-msvc": "npm:4.12.1"
"@rollup/rollup-win32-ia32-msvc": "npm:4.12.1"
"@rollup/rollup-win32-x64-msvc": "npm:4.12.1"
"@types/estree": "npm:1.0.5"
fsevents: "npm:~2.3.2"
dependenciesMeta:
Expand Down Expand Up @@ -29820,7 +29806,7 @@ __metadata:
optional: true
bin:
rollup: dist/bin/rollup
checksum: 10c0/7f241ad4028f32c1300eb8391493f192f622ed7e9564f993d8f3862be32dd995c8237f4691ea76327a323ef62808495a497eabf0c8fb0c6fa6556a69653a449f
checksum: 10c0/f8311b90e8d4cc46abbc14c3b292c4992438f5fd7e821d2094a7e940eaf6f67af2850c209f6412c2de5b66b4110af25226374950e90a3b3085929c104b127d48
languageName: node
linkType: hard

Expand Down Expand Up @@ -33319,53 +33305,13 @@ __metadata:
languageName: node
linkType: hard

"vite@npm:4.5.2":
version: 4.5.2
resolution: "vite@npm:4.5.2"
dependencies:
esbuild: "npm:^0.18.10"
fsevents: "npm:~2.3.2"
postcss: "npm:^8.4.27"
rollup: "npm:^3.27.1"
peerDependencies:
"@types/node": ">= 14"
less: "*"
lightningcss: ^1.21.0
sass: "*"
stylus: "*"
sugarss: "*"
terser: ^5.4.0
dependenciesMeta:
fsevents:
optional: true
peerDependenciesMeta:
"@types/node":
optional: true
less:
optional: true
lightningcss:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
bin:
vite: bin/vite.js
checksum: 10c0/68969ccf72ad2078aec7d9e023fce6de03746a4761f9308924212fff7bd42487145b270166cec66cddacfd7b1315ec5aa39ead174fbd7fcd463637a96ff4c9d1
languageName: node
linkType: hard

"vite@npm:^5.0.0":
version: 5.0.12
resolution: "vite@npm:5.0.12"
"vite@npm:5.1.5, vite@npm:^5.0.0":
version: 5.1.5
resolution: "vite@npm:5.1.5"
dependencies:
esbuild: "npm:^0.19.3"
fsevents: "npm:~2.3.3"
postcss: "npm:^8.4.32"
postcss: "npm:^8.4.35"
rollup: "npm:^4.2.0"
peerDependencies:
"@types/node": ^18.0.0 || >=20.0.0
Expand Down Expand Up @@ -33395,7 +33341,7 @@ __metadata:
optional: true
bin:
vite: bin/vite.js
checksum: 10c0/c51b8e458851943c903fddde6973e720099ef8a5f364fb107cddade59c9e90f6d9ad98b61a7419cdfa0c6374236e10bff965d0c2d9e7b1790c68b874e5e7950c
checksum: 10c0/29be99ba0bec5e3ad50290510ba764b6c1016979a1ba70cf2071be9f1338f27e582a120836222e1fad6efb01c886a8fb57cb33471fadd0fceaa922bfc92bbbf7
languageName: node
linkType: hard

Expand Down

0 comments on commit 4fd86e8

Please sign in to comment.