Skip to content
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

Rename currentIssues to currentEntryIssues #62524

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ import { isInterceptionRouteAppPath } from '../server/future/helpers/interceptio
import {
getTurbopackJsConfig,
handleEntrypoints,
type IssuesMap,
type EntryIssuesMap,
handleRouteType,
handlePagesErrorRoute,
formatIssue,
Expand Down Expand Up @@ -1390,7 +1390,7 @@ export default async function build(
page: new Map(),
}

const currentIssues: IssuesMap = new Map()
const currentEntryIssues: EntryIssuesMap = new Map()

const manifestLoader = new TurbopackManifestLoader({ buildId, distDir })

Expand All @@ -1412,7 +1412,7 @@ export default async function build(
await handleEntrypoints({
entrypoints,
currentEntrypoints,
currentIssues,
currentEntryIssues,
manifestLoader,
nextConfig: config,
rewrites: emptyRewritesObjToBeImplemented,
Expand Down Expand Up @@ -1446,7 +1446,7 @@ export default async function build(
pathname: page,
route,

currentIssues,
currentEntryIssues,
entrypoints: currentEntrypoints,
manifestLoader,
rewrites: emptyRewritesObjToBeImplemented,
Expand All @@ -1461,7 +1461,7 @@ export default async function build(
dev: false,
pathname: normalizeAppPath(page),
route,
currentIssues,
currentEntryIssues,
entrypoints: currentEntrypoints,
manifestLoader,
rewrites: emptyRewritesObjToBeImplemented,
Expand All @@ -1471,7 +1471,7 @@ export default async function build(

enqueue(() =>
handlePagesErrorRoute({
currentIssues,
currentEntryIssues,
entrypoints: currentEntrypoints,
manifestLoader,
rewrites: emptyRewritesObjToBeImplemented,
Expand All @@ -1488,8 +1488,8 @@ export default async function build(
page: string
message: string
}[] = []
for (const [page, pageIssues] of currentIssues) {
for (const issue of pageIssues.values()) {
for (const [page, entryIssues] of currentEntryIssues) {
for (const issue of entryIssues.values()) {
errors.push({
page,
message: formatIssue(issue),
Expand Down
47 changes: 24 additions & 23 deletions packages/next/src/server/dev/hot-reloader-turbopack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { trace } from '../../trace'
import type { VersionInfo } from './parse-version-info'
import {
type ChangeSubscriptions,
type IssuesMap,
type EntryIssuesMap,
formatIssue,
getTurbopackJsConfig,
handleEntrypoints,
Expand Down Expand Up @@ -151,7 +151,7 @@ export async function createHotReloaderTurbopack(
app: new Map(),
}

const currentIssues: IssuesMap = new Map()
const currentEntryIssues: EntryIssuesMap = new Map()

const manifestLoader = new TurbopackManifestLoader({ buildId, distDir })

Expand Down Expand Up @@ -253,7 +253,7 @@ export async function createHotReloaderTurbopack(
let hmrEventHappened = false
let hmrHash = 0
const sendEnqueuedMessages = () => {
for (const [, issueMap] of currentIssues) {
for (const [, issueMap] of currentEntryIssues) {
if (issueMap.size > 0) {
// During compilation errors we want to delay the HMR events until errors are fixed
return
Expand Down Expand Up @@ -307,7 +307,7 @@ export async function createHotReloaderTurbopack(
}

type ClientState = {
clientIssues: IssuesMap
clientIssues: EntryIssuesMap
hmrPayloads: Map<string, HMR_ACTION_TYPES>
turbopackUpdates: TurbopackUpdate[]
subscriptions: Map<string, AsyncIterator<any>>
Expand All @@ -333,7 +333,7 @@ export async function createHotReloaderTurbopack(
const changed = await changedPromise

for await (const change of changed) {
processIssues(currentIssues, key, change)
processIssues(currentEntryIssues, key, change)
const payload = await makePayload(change)
if (payload) {
sendHmr(key, payload)
Expand All @@ -347,7 +347,7 @@ export async function createHotReloaderTurbopack(
await subscription.return?.()
changeSubscriptions.delete(key)
}
currentIssues.delete(key)
currentEntryIssues.delete(key)
}

async function subscribeToHmrEvents(client: ws, id: string) {
Expand Down Expand Up @@ -409,7 +409,7 @@ export async function createHotReloaderTurbopack(
currentEntrypoints,

changeSubscriptions,
currentIssues,
currentEntryIssues: currentEntryIssues,
manifestLoader,
nextConfig: opts.nextConfig,
rewrites: opts.fsChecker.rewrites,
Expand Down Expand Up @@ -486,7 +486,7 @@ export async function createHotReloaderTurbopack(
// TODO: Figure out if socket type can match the NextJsHotReloaderInterface
onHMR(req, socket: Socket, head) {
wsServer.handleUpgrade(req, socket, head, (client) => {
const clientIssues: IssuesMap = new Map()
const clientIssues: EntryIssuesMap = new Map()
const subscriptions: Map<string, AsyncIterator<any>> = new Map()

clients.add(client)
Expand Down Expand Up @@ -582,15 +582,15 @@ export async function createHotReloaderTurbopack(
client.send(JSON.stringify(turbopackConnected))

const errors: CompilationError[] = []
const addIssues = (pageIssues: Map<string, Issue>) => {
for (const issue of pageIssues.values()) {
const addIssues = (entryIssues: Map<string, Issue>) => {
for (const issue of entryIssues.values()) {
errors.push({
message: formatIssue(issue),
})
}
}
clientIssues.forEach(addIssues)
currentIssues.forEach(addIssues)
currentEntryIssues.forEach(addIssues)

const sync: SyncAction = {
action: HMR_ACTIONS_SENT_TO_BROWSER.SYNC,
Expand Down Expand Up @@ -622,22 +622,23 @@ export async function createHotReloaderTurbopack(
// Not implemented yet.
},
async getCompilationErrors(page) {
const appKey = getEntryKey('app', 'server', page)
const pagesKey = getEntryKey('pages', 'server', page)
const appEntryKey = getEntryKey('app', 'server', page)
const pagesEntryKey = getEntryKey('pages', 'server', page)

const thisPageIssues =
currentIssues.get(appKey) ?? currentIssues.get(pagesKey)
if (thisPageIssues !== undefined && thisPageIssues.size > 0) {
const thisEntryIssues =
currentEntryIssues.get(appEntryKey) ??
currentEntryIssues.get(pagesEntryKey)
if (thisEntryIssues !== undefined && thisEntryIssues.size > 0) {
// If there is an error related to the requesting page we display it instead of the first error
return [...thisPageIssues.values()].map(
return [...thisEntryIssues.values()].map(
(issue) => new Error(formatIssue(issue))
)
}

// Otherwise, return all errors across pages
const errors = []
for (const pageIssues of currentIssues.values()) {
for (const issue of pageIssues.values()) {
for (const entryIssues of currentEntryIssues.values()) {
for (const issue of entryIssues.values()) {
errors.push(new Error(formatIssue(issue)))
}
}
Expand Down Expand Up @@ -687,7 +688,7 @@ export async function createHotReloaderTurbopack(
let finishBuilding = startBuilding(pathname, requestUrl, false)
try {
await handlePagesErrorRoute({
currentIssues,
currentEntryIssues,
entrypoints: currentEntrypoints,
manifestLoader,
rewrites: opts.fsChecker.rewrites,
Expand Down Expand Up @@ -737,7 +738,7 @@ export async function createHotReloaderTurbopack(
page,
pathname,
route,
currentIssues,
currentEntryIssues: currentEntryIssues,
entrypoints: currentEntrypoints,
manifestLoader,
readyIds,
Expand Down Expand Up @@ -781,7 +782,7 @@ export async function createHotReloaderTurbopack(
const errors = new Map<string, CompilationError>()
const addErrors = (
errorsMap: Map<string, CompilationError>,
issues: IssuesMap
issues: EntryIssuesMap
) => {
for (const issueMap of issues.values()) {
for (const [key, issue] of issueMap) {
Expand All @@ -798,7 +799,7 @@ export async function createHotReloaderTurbopack(
}
}
}
addErrors(errors, currentIssues)
addErrors(errors, currentEntryIssues)

for (const client of clients) {
const state = clientStates.get(client)
Expand Down
Loading