Add warning when mismatching @next/swc version is being used (#45880)
This adds a debug warning to help catch when a stale `@next/swc` version is being used. x-ref: [slack thread](https://vercel.slack.com/archives/C02HY34AKME/p1676331498415309?thread_ts=1676315836.304549&cid=C02HY34AKME) ---------
This commit is contained in:
parent
a485dc9af1
commit
5a5b683a97
1 changed files with 11 additions and 0 deletions
|
@ -39,6 +39,16 @@ export const __isCustomTurbopackBinary = async (): Promise<boolean> => {
|
|||
)
|
||||
}
|
||||
|
||||
function checkVersionMismatch(pkgData: any) {
|
||||
const version = pkgData.version
|
||||
|
||||
if (version && version !== nextVersion) {
|
||||
Log.warn(
|
||||
`Mismatching @next/swc version, detected: ${version} while Next.js is on ${nextVersion}. Please ensure these match`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// These are the platforms we'll try to load wasm bindings first,
|
||||
// only try to load native bindings if loading wasm binding somehow fails.
|
||||
// Fallback to native binding is for migration period only,
|
||||
|
@ -291,6 +301,7 @@ function loadNative(isCustomTurbopack = false) {
|
|||
let pkg = `@next/swc-${triple.platformArchABI}`
|
||||
try {
|
||||
bindings = require(pkg)
|
||||
checkVersionMismatch(require(`${pkg}/package.json`))
|
||||
break
|
||||
} catch (e: any) {
|
||||
if (e?.code === 'MODULE_NOT_FOUND') {
|
||||
|
|
Loading…
Reference in a new issue