-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next.js plugin for alternate bundler (#76186)
This adds a new package allowing users to opt-into using Rspack in place of webpack in Next.js. While there is some logic to handle rspack in core, the actual third-party dependencies are not included there, only conditionally loaded. This package: - Includes the actual npm dependencies on `@rspack/core` and `@rspack/plugin-react-refresh` - Sets the `NEXT_RSPACK` environment variable, which Next.js itself uses to load the dependencies - It exists as a kind of no-op `withRspack` decorator. @timneutkens is this the best approach to this?
- Loading branch information
1 parent
2074881
commit e9dcee6
Showing
8 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# @next/plugin-rspack | ||
|
||
This plugin allows you to use [Rspack](https://rspack.dev) in place of webpack with Next.js. | ||
|
||
## Installation | ||
|
||
``` | ||
npm install @next/plugin-rspack | ||
``` | ||
|
||
or | ||
|
||
``` | ||
yarn add @next/plugin-rspack | ||
``` | ||
|
||
## Usage | ||
|
||
Create or update a `next.config.js`/`next.config.ts` and wrap your existing configuration: | ||
|
||
```js | ||
const withRspack = require('@next/plugin-rspack') | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
/* config options here */ | ||
} | ||
|
||
module.exports = withRspack(nextConfig) | ||
``` | ||
|
||
## Usage with next-compose-plugins | ||
|
||
Alternatively, you can use `next-compose-plugins` to quickly integrate `@next/plugin-rspack` with other Next.js plugins: | ||
|
||
```js | ||
const withPlugins = require('next-compose-plugins') | ||
const withRspack = require('@next/plugin-rspack') | ||
|
||
module.exports = withPlugins([ | ||
[withRspack], | ||
// your other plugins here | ||
]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = function withRspack(config) { | ||
process.env.NEXT_RSPACK = 'true' | ||
process.env.BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN = 'true' | ||
process.env.BUILTIN_APP_LOADER = 'true' | ||
process.env.BUILTIN_SWC_LOADER = 'true' | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@next/plugin-rspack", | ||
"version": "15.2.0-canary.65", | ||
"repository": { | ||
"url": "vercel/next.js", | ||
"directory": "packages/next-plugin-rspack" | ||
}, | ||
"dependencies": { | ||
"@rspack/core": "npm:@rspack-canary/core@1.2.0-canary-37cc738d-20250207113050", | ||
"@rspack/plugin-react-refresh": "1.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters