mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Fix an issue where if a user set `NEXT_RSPACK` as an environment variable then `next` would think it was using rspack but `withRspack` would think it was using `--webpack`. The issue is that the idempotency check was too strict. This partially reverts https://github.com/vercel/next.js/pull/84885
21 lines
753 B
JavaScript
21 lines
753 B
JavaScript
Error.stackTraceLimit = 100
|
|
module.exports = function withRspack(config) {
|
|
if (process.env.NEXT_RSPACK) {
|
|
// we have already been called. This can happen when using build workers.
|
|
return config
|
|
}
|
|
if (process.env.TURBOPACK === 'auto') {
|
|
delete process.env.TURBOPACK
|
|
process.env.RSPACK_CONFIG_VALIDATE = 'loose-silent'
|
|
process.env.NEXT_RSPACK = 'true'
|
|
} else {
|
|
// Either The TURBOPACK flag wasn't set which means --wepack was, or the TURBOPACK flag was set to 1 because --turbopack was passed.
|
|
console.trace(
|
|
`Cannot call withRspack and pass the ${process.env.TURBOPACK ? '--turbopack' : '--webpack'} flag.`
|
|
)
|
|
console.error('Please configure only one bundler.')
|
|
process.exit(1)
|
|
}
|
|
return config
|
|
}
|