-
Notifications
You must be signed in to change notification settings - Fork 9
docs: add migration guide for v2 #125
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,155 @@ | ||||||||||
| # @rspack/dev-server Migration Guide (v1 -> v2) | ||||||||||
|
|
||||||||||
| This guide covers breaking changes you need to handle when upgrading `@rspack/dev-server` from v1 to v2. | ||||||||||
|
|
||||||||||
| ## Breaking Changes | ||||||||||
|
|
||||||||||
| ### Drop Node 18 Support | ||||||||||
|
|
||||||||||
| Node.js 18 is no longer supported in v2. | ||||||||||
|
|
||||||||||
| The minimum supported Node.js version is now `^20.19.0 || >=22.12.0`. | ||||||||||
|
|
||||||||||
| ### Drop Rspack v1 Support | ||||||||||
|
|
||||||||||
| `@rspack/dev-server` v2 is designed to work with Rspack v2. Rspack v1 is no longer supported in v2. | ||||||||||
|
|
||||||||||
| ### Upgraded `http-proxy-middleware` to v3 | ||||||||||
|
|
||||||||||
| `http-proxy-middleware` has been updated to v3, which has some breaking changes: | ||||||||||
|
|
||||||||||
| - `proxy[].path` is removed. Use `pathFilter` (or `context`) instead. | ||||||||||
|
|
||||||||||
| ```diff | ||||||||||
| { | ||||||||||
| - path: '/api', | ||||||||||
| + pathFilter: '/api', | ||||||||||
| } | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| - `logLevel` / `logProvider` are replaced by `logger`. | ||||||||||
|
|
||||||||||
| ```diff | ||||||||||
| - logLevel: 'warn', | ||||||||||
| + logger: console, | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| - `onProxyReq` / `onProxyRes` / `onProxyReqWs` are moved to `on: { ... }`. | ||||||||||
|
|
||||||||||
| ```diff | ||||||||||
| - onProxyReq(proxyReq) { | ||||||||||
| - proxyReq.setHeader('x-from', 'dev-server'); | ||||||||||
| - }, | ||||||||||
| + on: { | ||||||||||
| + proxyReq(proxyReq) { | ||||||||||
| + proxyReq.setHeader('x-from', 'dev-server'); | ||||||||||
| + }, | ||||||||||
| + }, | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| - `proxy[].bypass` is removed, use `pathFilter` or `router` instead. | ||||||||||
| - When `bypass` was used and that function returned a boolean, it would automatically result in a 404 request. This can’t be achieved in a similar way now, or, if it returned a string, you can do what was done in the example above. | ||||||||||
| - `bypass` also allowed sending data; this can no longer be done. If you really need to do it, you’d have to create a new route in the proxy that sends the same data, or alternatively create a new route on the main server and, following the example above, send the data you wanted. | ||||||||||
|
|
||||||||||
| > Refer to the [http-proxy-middleware v3 migration guide](https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md) for details. | ||||||||||
|
|
||||||||||
| ### Upgraded Express to v5 | ||||||||||
|
|
||||||||||
| `express`` has been updated to v5, see [Introducing Express v5: A New Era for the Node.js Framework](https://expressjs.com/2024/10/15/v5-release.html) for details. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a small formatting typo here. The extra backtick breaks the code formatting for
Suggested change
|
||||||||||
| `express`` has been updated to v5, see [Introducing Express v5: A New Era for the Node.js Framework](https://expressjs.com/2024/10/15/v5-release.html) for details. | |
| `express` has been updated to v5, see [Introducing Express v5: A New Era for the Node.js Framework](https://expressjs.com/2024/10/15/v5-release.html) for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The references to "the example above" on lines 51 and 52 are a bit confusing, as the preceding examples are for
proxy[].pathandlogLevel, not for replacingbypass. To improve clarity, consider rephrasing to avoid referring to an unrelated example, or provide a small example for usingpathFilterorrouteras a replacement forbypassif possible.