-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Conditionally load uncommon paths #90514
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
Open
timneutkens
wants to merge
4
commits into
canary
Choose a base branch
from
02-25-conditionally_load_uncommon_paths
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+226
−200
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,27 @@ | ||
| import browserslist from 'next/dist/compiled/browserslist' | ||
| import { MODERN_BROWSERSLIST_TARGET } from '../shared/lib/constants' | ||
|
|
||
| export function getSupportedBrowsers( | ||
| dir: string, | ||
| isDevelopment: boolean | ||
| ): string[] { | ||
| let browsers: any | ||
| try { | ||
| const browsersListConfig = browserslist.loadConfig({ | ||
| path: dir, | ||
| env: isDevelopment ? 'development' : 'production', | ||
| }) | ||
| // Running `browserslist` resolves `extends` and other config features into a list of browsers | ||
| if (browsersListConfig && browsersListConfig.length > 0) { | ||
| browsers = browserslist(browsersListConfig) | ||
| } | ||
| } catch {} | ||
|
|
||
| // When user has browserslist use that target | ||
| if (browsers && browsers.length > 0) { | ||
| return browsers | ||
| } | ||
|
|
||
| // Uses modern browsers as the default. | ||
| return MODERN_BROWSERSLIST_TARGET | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,86 @@ | ||
| import { formatIssue, isRelevantWarning } from '../shared/lib/turbopack/utils' | ||
| import type { TurbopackResult } from './swc/types' | ||
|
|
||
| /** | ||
| * Processes and reports build issues from Turbopack entrypoints. | ||
| * | ||
| * @param entrypoints - The result object containing build issues to process. | ||
| * @param isDev - A flag indicating if the build is running in development mode. | ||
| * @return This function does not return a value but logs or throws errors based on the issues. | ||
| * @throws {Error} If a fatal issue is encountered, this function throws an error. In development mode, we only throw on | ||
| * 'fatal' and 'bug' issues. In production mode, we also throw on 'error' issues. | ||
| */ | ||
| export function printBuildErrors( | ||
| entrypoints: TurbopackResult, | ||
| isDev: boolean | ||
| ): void { | ||
| // Issues that we want to stop the server from executing | ||
| const topLevelFatalIssues = [] | ||
| // Issues that are true errors, but we believe we can keep running and allow the user to address the issue | ||
| const topLevelErrors = [] | ||
| // Issues that are warnings but should not affect the running of the build | ||
| const topLevelWarnings = [] | ||
|
|
||
| // Track seen formatted error messages to avoid duplicates | ||
| const seenFatalIssues = new Set<string>() | ||
| const seenErrors = new Set<string>() | ||
| const seenWarnings = new Set<string>() | ||
|
|
||
| for (const issue of entrypoints.issues) { | ||
| // We only want to completely shut down the server | ||
| if (issue.severity === 'fatal' || issue.severity === 'bug') { | ||
| const formatted = formatIssue(issue) | ||
| if (!seenFatalIssues.has(formatted)) { | ||
| seenFatalIssues.add(formatted) | ||
| topLevelFatalIssues.push(formatted) | ||
| } | ||
| } else if (isRelevantWarning(issue)) { | ||
| const formatted = formatIssue(issue) | ||
| if (!seenWarnings.has(formatted)) { | ||
| seenWarnings.add(formatted) | ||
| topLevelWarnings.push(formatted) | ||
| } | ||
| } else if (issue.severity === 'error') { | ||
| const formatted = formatIssue(issue) | ||
| if (isDev) { | ||
| // We want to treat errors as recoverable in development | ||
| // so that we can show the errors in the site and allow users | ||
| // to respond to the errors when necessary. In production builds | ||
| // though we want to error out and stop the build process. | ||
| if (!seenErrors.has(formatted)) { | ||
| seenErrors.add(formatted) | ||
| topLevelErrors.push(formatted) | ||
| } | ||
| } else { | ||
| if (!seenFatalIssues.has(formatted)) { | ||
| seenFatalIssues.add(formatted) | ||
| topLevelFatalIssues.push(formatted) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // TODO: print in order by source location so issues from the same file are displayed together and then add a summary at the end about the number of warnings/errors | ||
| if (topLevelWarnings.length > 0) { | ||
| console.warn( | ||
| `Turbopack build encountered ${ | ||
| topLevelWarnings.length | ||
| } warnings:\n${topLevelWarnings.join('\n')}` | ||
| ) | ||
| } | ||
|
|
||
| if (topLevelErrors.length > 0) { | ||
| console.error( | ||
| `Turbopack build encountered ${ | ||
| topLevelErrors.length | ||
| } errors:\n${topLevelErrors.join('\n')}` | ||
| ) | ||
| } | ||
|
|
||
| if (topLevelFatalIssues.length > 0) { | ||
| throw new Error( | ||
| `Turbopack build failed with ${ | ||
| topLevelFatalIssues.length | ||
| } errors:\n${topLevelFatalIssues.join('\n')}` | ||
| ) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.