Skip to content

Commit 41c970d

Browse files
committed
Add ignore comments
1 parent 1f43650 commit 41c970d

File tree

5 files changed

+112
-35
lines changed

5 files changed

+112
-35
lines changed

packages/next/src/server/base-server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ export default abstract class Server<
439439
this.experimentalTestProxy = experimentalTestProxy
440440
this.serverOptions = options
441441

442-
this.dir = path.resolve(dir)
442+
this.dir = path.resolve(/* turbopackIgnore: true */ dir)
443443

444444
this.quiet = quiet
445445
this.loadEnvConfig({ dev })
@@ -453,7 +453,10 @@ export default abstract class Server<
453453
this.fetchHostname = formatHostname(this.hostname)
454454
}
455455
this.port = port
456-
this.distDir = path.join(this.dir, this.nextConfig.distDir)
456+
this.distDir = path.join(
457+
/* turbopackIgnore: true */ this.dir,
458+
this.nextConfig.distDir
459+
)
457460
this.publicDir = this.getPublicDir()
458461
this.hasStaticDir = !minimalMode && this.getHasStaticDir()
459462

packages/next/src/server/image-optimizer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ async function writeToCacheDir(
141141
upstreamEtag: string
142142
) {
143143
const filename = join(
144+
/* turbopackIgnore: true */
144145
dir,
145146
`${maxAge}.${expireAt}.${etag}.${upstreamEtag}.${extension}`
146147
)
@@ -464,20 +465,25 @@ export class ImageOptimizerCache {
464465
distDir: string
465466
nextConfig: NextConfigComplete
466467
}) {
467-
this.cacheDir = join(distDir, 'cache', 'images')
468+
this.cacheDir = join(/* turbopackIgnore: true */ distDir, 'cache', 'images')
468469
this.nextConfig = nextConfig
469470
}
470471

471472
async get(cacheKey: string): Promise<IncrementalResponseCacheEntry | null> {
472473
try {
473-
const cacheDir = join(this.cacheDir, cacheKey)
474+
const cacheDir = join(/* turbopackIgnore: true */ this.cacheDir, cacheKey)
474475
const files = await promises.readdir(cacheDir)
475476
const now = Date.now()
476477

477478
for (const file of files) {
478479
const [maxAgeSt, expireAtSt, etag, upstreamEtag, extension] =
479480
file.split('.', 5)
480-
const buffer = await promises.readFile(join(cacheDir, file))
481+
const buffer = await promises.readFile(
482+
/* turbopackIgnore: true */ join(
483+
/* turbopackIgnore: true */ cacheDir,
484+
file
485+
)
486+
)
481487
const expireAt = Number(expireAtSt)
482488
const maxAge = Number(maxAgeSt)
483489

@@ -530,7 +536,7 @@ export class ImageOptimizerCache {
530536

531537
try {
532538
await writeToCacheDir(
533-
join(this.cacheDir, cacheKey),
539+
join(/* turbopackIgnore: true */ this.cacheDir, cacheKey),
534540
value.extension,
535541
revalidate,
536542
expireAt,

packages/next/src/server/load-components.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ async function loadComponentsImpl<N = any>({
177177

178178
let reactLoadableManifestPath
179179
if (!process.env.TURBOPACK) {
180-
reactLoadableManifestPath = join(distDir, REACT_LOADABLE_MANIFEST)
180+
reactLoadableManifestPath = join(
181+
/* turbopackIgnore: true */ distDir,
182+
REACT_LOADABLE_MANIFEST
183+
)
181184
} else if (isAppPath) {
182185
reactLoadableManifestPath = join(
186+
/* turbopackIgnore: true */
183187
distDir,
184188
'server',
185189
'app',
@@ -188,6 +192,7 @@ async function loadComponentsImpl<N = any>({
188192
)
189193
} else {
190194
reactLoadableManifestPath = join(
195+
/* turbopackIgnore: true */
191196
distDir,
192197
'server',
193198
'pages',
@@ -213,7 +218,7 @@ async function loadComponentsImpl<N = any>({
213218
subresourceIntegrityManifest,
214219
] = await Promise.all([
215220
loadManifestWithRetries<BuildManifest>(
216-
join(distDir, BUILD_MANIFEST),
221+
join(/* turbopackIgnore: true */ distDir, BUILD_MANIFEST),
217222
manifestLoadAttempts
218223
),
219224
tryLoadManifestWithRetries<ReactLoadableManifest>(
@@ -224,12 +229,16 @@ async function loadComponentsImpl<N = any>({
224229
isAppPath || process.env.TURBOPACK
225230
? undefined
226231
: loadManifestWithRetries<DynamicCssManifest>(
227-
join(distDir, `${DYNAMIC_CSS_MANIFEST}.json`),
232+
join(
233+
/* turbopackIgnore: true */ distDir,
234+
`${DYNAMIC_CSS_MANIFEST}.json`
235+
),
228236
manifestLoadAttempts
229237
).catch(() => undefined),
230238
isAppPath && hasClientManifest
231239
? tryLoadClientReferenceManifest(
232240
join(
241+
/* turbopackIgnore: true */
233242
distDir,
234243
'server',
235244
'app',
@@ -241,13 +250,21 @@ async function loadComponentsImpl<N = any>({
241250
: undefined,
242251
isAppPath
243252
? loadManifestWithRetries<ActionManifest>(
244-
join(distDir, 'server', SERVER_REFERENCE_MANIFEST + '.json'),
253+
join(
254+
/* turbopackIgnore: true */ distDir,
255+
'server',
256+
SERVER_REFERENCE_MANIFEST + '.json'
257+
),
245258
manifestLoadAttempts
246259
).catch(() => null)
247260
: null,
248261
sriEnabled
249262
? loadManifestWithRetries<DeepReadonly<Record<string, string>>>(
250-
join(distDir, 'server', SUBRESOURCE_INTEGRITY_MANIFEST + '.json')
263+
join(
264+
/* turbopackIgnore: true */ distDir,
265+
'server',
266+
SUBRESOURCE_INTEGRITY_MANIFEST + '.json'
267+
)
251268
).catch(() => undefined)
252269
: undefined,
253270
])

packages/next/src/server/next-server.ts

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ export default class NextNodeServer extends BaseServer<
353353
interceptTestApis()
354354
}
355355

356-
this.middlewareManifestPath = join(this.serverDistDir, MIDDLEWARE_MANIFEST)
356+
this.middlewareManifestPath = join(
357+
/* turbopackIgnore: true */ this.serverDistDir,
358+
MIDDLEWARE_MANIFEST
359+
)
357360

358361
// This is just optimization to fire prepare as soon as possible. It will be
359362
// properly awaited later. We add the catch here to ensure that it does not
@@ -537,24 +540,29 @@ export default class NextNodeServer extends BaseServer<
537540
}
538541

539542
protected getPublicDir(): string {
540-
return join(this.dir, CLIENT_PUBLIC_FILES_PATH)
543+
return join(/* turbopackIgnore: true */ this.dir, CLIENT_PUBLIC_FILES_PATH)
541544
}
542545

543546
protected getHasStaticDir(): boolean {
544-
return fs.existsSync(join(this.dir, 'static'))
547+
return fs.existsSync(
548+
/* turbopackIgnore: true */ join(
549+
/* turbopackIgnore: true */ this.dir,
550+
'static'
551+
)
552+
)
545553
}
546554

547555
protected getPagesManifest(): PagesManifest | undefined {
548556
return loadManifest(
549-
join(this.serverDistDir, PAGES_MANIFEST)
557+
join(/* turbopackIgnore: true */ this.serverDistDir, PAGES_MANIFEST)
550558
) as PagesManifest
551559
}
552560

553561
protected getAppPathsManifest(): PagesManifest | undefined {
554562
if (!this.enabledDirectories.app) return undefined
555563

556564
return loadManifest(
557-
join(this.serverDistDir, APP_PATHS_MANIFEST)
565+
join(/* turbopackIgnore: true */ this.serverDistDir, APP_PATHS_MANIFEST)
558566
) as PagesManifest
559567
}
560568

@@ -579,9 +587,14 @@ export default class NextNodeServer extends BaseServer<
579587
}
580588

581589
protected getBuildId(): string {
582-
const buildIdFile = join(this.distDir, BUILD_ID_FILE)
590+
const buildIdFile = join(
591+
/* turbopackIgnore: true */ this.distDir,
592+
BUILD_ID_FILE
593+
)
583594
try {
584-
return fs.readFileSync(buildIdFile, 'utf8').trim()
595+
return fs
596+
.readFileSync(/* turbopackIgnore: true */ buildIdFile, 'utf8')
597+
.trim()
585598
} catch (err: any) {
586599
if (err.code === 'ENOENT') {
587600
throw new Error(
@@ -959,7 +972,11 @@ export default class NextNodeServer extends BaseServer<
959972

960973
protected getNextFontManifest(): NextFontManifest | undefined {
961974
return loadManifest(
962-
join(this.distDir, 'server', NEXT_FONT_MANIFEST + '.json')
975+
join(
976+
/* turbopackIgnore: true */ this.distDir,
977+
'server',
978+
NEXT_FONT_MANIFEST + '.json'
979+
)
963980
) as NextFontManifest
964981
}
965982

@@ -1523,17 +1540,25 @@ export default class NextNodeServer extends BaseServer<
15231540

15241541
return {
15251542
name: pageInfo.name,
1526-
paths: pageInfo.files.map((file) => join(this.distDir, file)),
1543+
paths: pageInfo.files.map((file) =>
1544+
join(/* turbopackIgnore: true */ this.distDir, file)
1545+
),
15271546
wasm: (pageInfo.wasm ?? []).map((binding) => ({
15281547
...binding,
1529-
filePath: join(this.distDir, binding.filePath),
1548+
filePath: join(
1549+
/* turbopackIgnore: true */ this.distDir,
1550+
binding.filePath
1551+
),
15301552
})),
15311553
assets:
15321554
pageInfo.assets &&
15331555
pageInfo.assets.map((binding) => {
15341556
return {
15351557
...binding,
1536-
filePath: join(this.distDir, binding.filePath),
1558+
filePath: join(
1559+
/* turbopackIgnore: true */ this.distDir,
1560+
binding.filePath
1561+
),
15371562
}
15381563
}),
15391564
env: pageInfo.env,
@@ -1545,14 +1570,26 @@ export default class NextNodeServer extends BaseServer<
15451570
try {
15461571
const functionsConfig = this.renderOpts.dev
15471572
? {}
1548-
: require(join(this.distDir, 'server', FUNCTIONS_CONFIG_MANIFEST))
1573+
: require(
1574+
join(
1575+
/* turbopackIgnore: true */ this.distDir,
1576+
'server',
1577+
FUNCTIONS_CONFIG_MANIFEST
1578+
)
1579+
)
15491580

15501581
if (
15511582
this.renderOpts.dev ||
15521583
functionsConfig?.functions?.['/_middleware']
15531584
) {
15541585
// if used with top level await, this will be a promise
1555-
return require(join(this.distDir, 'server', 'middleware.js'))
1586+
return require(
1587+
join(
1588+
/* turbopackIgnore: true */ this.distDir,
1589+
'server',
1590+
'middleware.js'
1591+
)
1592+
)
15561593
}
15571594
} catch (err) {
15581595
if (
@@ -1889,7 +1926,7 @@ export default class NextNodeServer extends BaseServer<
18891926
}
18901927

18911928
this._cachedPreviewManifest = loadManifest(
1892-
join(this.distDir, PRERENDER_MANIFEST)
1929+
join(/* turbopackIgnore: true */ this.distDir, PRERENDER_MANIFEST)
18931930
) as PrerenderManifest
18941931

18951932
return this._cachedPreviewManifest
@@ -1898,7 +1935,10 @@ export default class NextNodeServer extends BaseServer<
18981935
protected getRoutesManifest(): NormalizedRouteManifest | undefined {
18991936
return getTracer().trace(
19001937
NextNodeServerSpan.getRoutesManifest,
1901-
() => loadManifest(join(this.distDir, ROUTES_MANIFEST)) as RoutesManifest
1938+
() =>
1939+
loadManifest(
1940+
join(/* turbopackIgnore: true */ this.distDir, ROUTES_MANIFEST)
1941+
) as RoutesManifest
19021942
)
19031943
}
19041944

@@ -2060,7 +2100,10 @@ export default class NextNodeServer extends BaseServer<
20602100
if (this._serverDistDir) {
20612101
return this._serverDistDir
20622102
}
2063-
const serverDistDir = join(this.distDir, SERVER_DIRECTORY)
2103+
const serverDistDir = join(
2104+
/* turbopackIgnore: true */ this.distDir,
2105+
SERVER_DIRECTORY
2106+
)
20642107
this._serverDistDir = serverDistDir
20652108
return serverDistDir
20662109
}

packages/next/src/server/require.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,23 @@ export function getMaybePagePath(
2929
// If we have a cached path, we can return it directly.
3030
if (pagePath) return pagePath
3131

32-
const serverBuildPath = path.join(distDir, SERVER_DIRECTORY)
32+
const serverBuildPath = path.join(
33+
/* turbopackIgnore: true */ distDir,
34+
SERVER_DIRECTORY
35+
)
3336
let appPathsManifest: undefined | PagesManifest
3437

3538
if (isAppPath) {
3639
appPathsManifest = loadManifest(
37-
path.join(serverBuildPath, APP_PATHS_MANIFEST),
40+
path.join(
41+
/* turbopackIgnore: true */ serverBuildPath,
42+
APP_PATHS_MANIFEST
43+
),
3844
!isDev
3945
) as PagesManifest
4046
}
4147
const pagesManifest = loadManifest(
42-
path.join(serverBuildPath, PAGES_MANIFEST),
48+
path.join(/* turbopackIgnore: true */ serverBuildPath, PAGES_MANIFEST),
4349
!isDev
4450
) as PagesManifest
4551

@@ -78,7 +84,7 @@ export function getMaybePagePath(
7884
return null
7985
}
8086

81-
pagePath = path.join(serverBuildPath, pagePath)
87+
pagePath = path.join(/* turbopackIgnore: true */ serverBuildPath, pagePath)
8288

8389
pagePathCache?.set(cacheKey, pagePath)
8490
return pagePath
@@ -106,14 +112,16 @@ export async function requirePage(
106112
): Promise<any> {
107113
const pagePath = getPagePath(page, distDir, undefined, isAppPath)
108114
if (pagePath.endsWith('.html')) {
109-
return promises.readFile(pagePath, 'utf8').catch((err) => {
110-
throw new MissingStaticPage(page, err.message)
111-
})
115+
return promises
116+
.readFile(/* turbopackIgnore: true */ pagePath, 'utf8')
117+
.catch((err) => {
118+
throw new MissingStaticPage(page, err.message)
119+
})
112120
}
113121

114122
const mod = process.env.NEXT_MINIMAL
115123
? // @ts-ignore
116124
__non_webpack_require__(pagePath)
117-
: require(pagePath)
125+
: require(/* turbopackIgnore: true */ pagePath)
118126
return mod
119127
}

0 commit comments

Comments
 (0)