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 12, 2024
1 parent 798ca4d commit e11d73e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 72 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
3 changes: 3 additions & 0 deletions packages/cli/src/commands/devHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export const handler = async ({

const redwoodConfigPath = getConfigPath()

// 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'
const webCommand =
getConfig().web.bundler !== 'webpack' // @NOTE: can't use enums, not TS
? `yarn cross-env NODE_ENV=development rw-vite-dev ${forward}`
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@vitejs/plugin-react": "4.2.1",
"buffer": "6.0.3",
"core-js": "3.35.1",
"vite": "4.5.2",
"vite": "5.1.5",
"yargs-parser": "21.1.1"
},
"devDependencies": {
Expand Down
8 changes: 2 additions & 6 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,8 @@ export default function redwoodPluginVite(): PluginOption[] {
build: {
outDir: options.build?.outDir || rwPaths.web.dist,
emptyOutDir: true,
manifest: !env.ssrBuild ? 'build-manifest.json' : undefined,
sourcemap: !env.ssrBuild && rwConfig.web.sourceMap, // Note that this can be boolean or 'inline'
},
// To produce a cjs bundle for SSR
legacy: {
buildSsrCjsExternalHeuristics: env.ssrBuild,
manifest: !env.isSsrBuild ? 'build-manifest.json' : undefined,
sourcemap: !env.isSsrBuild && rwConfig.web.sourceMap, // Note that this can be boolean or 'inline'
},
optimizeDeps: {
esbuildOptions: {
Expand Down
76 changes: 11 additions & 65 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8764,7 +8764,7 @@ __metadata:
glob: "npm:10.3.10"
tsx: "npm:4.6.2"
typescript: "npm:5.3.3"
vite: "npm:4.5.2"
vite: "npm:5.1.5"
vitest: "npm:1.3.1"
yargs-parser: "npm:21.1.1"
bin:
Expand Down Expand Up @@ -17586,7 +17586,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 @@ -27792,14 +27792,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 @@ -29515,20 +29515,6 @@ __metadata:
languageName: node
linkType: hard

"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"
Expand Down Expand Up @@ -33040,53 +33026,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 @@ -33116,7 +33062,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 e11d73e

Please sign in to comment.