-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nextjs): Prepare for next 16 bundler default #17868
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
d209fac
3e8681e
2b52582
5fa6b29
1bc8187
2aa3877
1d46b0e
b1e0687
a0df026
d05629f
9ee2db2
8abbfa5
8256be8
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 @@ | ||
export const isDevMode = !!process.env.TEST_ENV && process.env.TEST_ENV.includes('development'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const isDevMode = !!process.env.TEST_ENV && process.env.TEST_ENV.includes('development'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,68 @@ export function supportsProductionCompileHook(version: string): boolean { | |
|
||
return false; | ||
} | ||
|
||
/** | ||
* Checks if the current Next.js version uses Turbopack as the default bundler. | ||
* Starting from Next.js 15.6.0-canary.38, turbopack became the default for `next build`. | ||
* | ||
* @param version - Next.js version string to check. | ||
* @returns true if the version uses Turbopack by default | ||
*/ | ||
export function isTurbopackDefaultForVersion(version: string): boolean { | ||
if (!version) { | ||
return false; | ||
} | ||
|
||
const { major, minor, prerelease } = parseSemver(version); | ||
|
||
if (major === undefined || minor === undefined) { | ||
return false; | ||
} | ||
|
||
// Next.js 16+ uses turbopack by default | ||
if (major >= 16) { | ||
return true; | ||
} | ||
|
||
// For Next.js 15, only canary versions 15.6.0-canary.40+ use turbopack by default | ||
// Stable 15.x releases still use webpack by default | ||
if (major === 15 && minor >= 6 && prerelease && prerelease.startsWith('canary.')) { | ||
if (minor >= 7) { | ||
return true; | ||
} | ||
const canaryNumber = parseInt(prerelease.split('.')[1] || '0', 10); | ||
if (canaryNumber >= 40) { | ||
return true; | ||
} | ||
} | ||
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. Bug: Turbopack Version Threshold MismatchThe Additional Locations (1) |
||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Determines which bundler is actually being used based on environment variables, | ||
* CLI flags, and Next.js version. | ||
* | ||
* @param nextJsVersion - The Next.js version string | ||
* @returns 'turbopack', 'webpack', or undefined if it cannot be determined | ||
*/ | ||
export function detectActiveBundler(nextJsVersion: string | undefined): 'turbopack' | 'webpack' | undefined { | ||
if (process.env.TURBOPACK || process.argv.includes('--turbo')) { | ||
return 'turbopack'; | ||
} | ||
|
||
// Explicit opt-in to webpack via --webpack flag | ||
if (process.argv.includes('--webpack')) { | ||
return 'webpack'; | ||
} | ||
|
||
// Fallback to version-based default behavior | ||
if (nextJsVersion) { | ||
const turbopackIsDefault = isTurbopackDefaultForVersion(nextJsVersion); | ||
return turbopackIsDefault ? 'turbopack' : 'webpack'; | ||
} | ||
|
||
// Unlikely but at this point, we just assume webpack for older behavior | ||
return 'webpack'; | ||
} | ||
Comment on lines
+114
to
+132
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. @chargome, this is incorrectly returning
I noticed our source maps stopped working in 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. Created a PR for this in #17971. |
Uh oh!
There was an error while loading. Please reload this page.