Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to express 5 #18537

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"typescript",
"eslint-plugin-react-hooks", // prevent bumping to messy -rc-<hash>-<date>
"@rollup/plugin-dynamic-import-vars", // prefer version using tinyglobby
"@types/express", // express latest is still on v4, so types should also be v4

// pinned
"slash3",
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This is statically replaced during build so it will allow tree-shaking of unused

## Setting Up the Dev Server

When building an SSR app, you likely want to have full control over your main server and decouple Vite from the production environment. It is therefore recommended to use Vite in middleware mode. Here is an example with [express](https://expressjs.com/):
When building an SSR app, you likely want to have full control over your main server and decouple Vite from the production environment. It is therefore recommended to use Vite in middleware mode. Here is an example with [express](https://expressjs.com/) (v4):

```js{15-18} twoslash [server.js]
import fs from 'node:fs'
Expand Down
2 changes: 1 addition & 1 deletion playground/css-lightningcss-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"lightningcss": "^1.28.1",
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/css-lightningcss-proxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function createServer(root = process.cwd(), hmrPort) {
// use vite's connect instance as middleware
app.use(vite.middlewares)

app.use('*', async (req, res, next) => {
app.use('*all', async (req, res, next) => {
try {
let [url] = req.originalUrl.split('?')
if (url.endsWith('/')) url += 'index.html'
Expand Down
2 changes: 1 addition & 1 deletion playground/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@vitejs/test-json-module": "file:./json-module",
"express": "^4.21.1",
"express": "^5.0.1",
"vue": "^3.5.12"
}
}
2 changes: 1 addition & 1 deletion playground/json/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function createServer(root = process.cwd(), hmrPort) {
// use vite's connect instance as middleware
app.use(vite.middlewares)

app.use('*', async (req, res) => {
app.use('*all', async (req, res) => {
try {
let [url] = req.originalUrl.split('?')
if (url.endsWith('/')) url += 'index.ssr.html'
Expand Down
2 changes: 1 addition & 1 deletion playground/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"vite": "workspace:*",
"@vitejs/plugin-legacy": "workspace:*",
"express": "^4.21.1",
"express": "^5.0.1",
"terser": "^5.36.0"
}
}
2 changes: 1 addition & 1 deletion playground/optimize-missing-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"@vitejs/test-missing-dep": "file:./missing-dep"
},
"devDependencies": {
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/optimize-missing-deps/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function createServer(root = process.cwd(), hmrPort) {
})
app.use(vite.middlewares)

app.use('*', async (req, res) => {
app.use('*all', async (req, res) => {
try {
let template = fs.readFileSync(resolve('index.html'), 'utf-8')
template = await vite.transformIndexHtml(req.originalUrl, template)
Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-conditions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"@vitejs/test-ssr-conditions-no-external": "file:./no-external"
},
"devDependencies": {
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/ssr-conditions/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function createServer(root = process.cwd(), hmrPort) {

app.use(vite.middlewares)

app.use('*', async (req, res) => {
app.use('*all', async (req, res) => {
try {
const url = req.originalUrl

Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"@vitejs/test-module-condition": "file:./module-condition"
},
"devDependencies": {
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/ssr-deps/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function createServer(root = process.cwd(), hmrPort) {
// use vite's connect instance as middleware
app.use(vite.middlewares)

app.use('*', async (req, res) => {
app.use('*all', async (req, res) => {
try {
const url = req.originalUrl

Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {},
"devDependencies": {
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/ssr-html/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function createServer(root = process.cwd(), hmrPort) {
// use vite's connect instance as middleware
app.use(vite.middlewares)

app.use('*', async (req, res, next) => {
app.use('*all', async (req, res, next) => {
try {
let [url] = req.originalUrl.split('?')
if (url.endsWith('/')) url += 'index.html'
Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-noexternal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"dependencies": {
"@vitejs/test-external-cjs": "file:./external-cjs",
"@vitejs/test-require-external-cjs": "file:./require-external-cjs",
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/ssr-noexternal/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function createServer(
app.use(vite.middlewares)
}

app.use('*', async (req, res) => {
app.use('*all', async (req, res) => {
try {
const url = req.originalUrl

Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-pug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"debug": "node --inspect-brk server"
},
"devDependencies": {
"express": "^4.21.1",
"express": "^5.0.1",
"pug": "^3.0.3"
}
}
2 changes: 1 addition & 1 deletion playground/ssr-pug/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function createServer(root = process.cwd(), hmrPort) {
// use vite's connect instance as middleware
app.use(vite.middlewares)

app.use('*', async (req, res) => {
app.use('*all', async (req, res) => {
try {
let [url] = req.originalUrl.split('?')
url = url.replace(/\.html$/, '.pug')
Expand Down
2 changes: 1 addition & 1 deletion playground/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"dependencies": {},
"devDependencies": {
"express": "^4.21.1"
"express": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion playground/ssr/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function createServer(
// use vite's connect instance as middleware
app.use(vite.middlewares)

app.use('*', async (req, res, next) => {
app.use('*all', async (req, res, next) => {
try {
const url = req.originalUrl

Expand Down
Loading