Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 091f0f0

Browse files
authored
Revert "fix(perf): exclude /_next/static/* from generated functions (#3100)"
This reverts commit 5e28132.
1 parent 8cd51b5 commit 091f0f0

File tree

6 files changed

+7
-87
lines changed

6 files changed

+7
-87
lines changed

‎src/build/functions/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ const getHandlerFile = async (ctx: PluginContext): Promise<string> => {
106106

107107
const templateVariables: Record<string, string> = {
108108
'{{useRegionalBlobs}}': ctx.useRegionalBlobs.toString(),
109-
'{{excludeStaticPath}}': posixJoin(ctx.buildConfig.basePath || '', '/_next/static/*'),
110109
}
111110
// In this case it is a monorepo and we need to use a own template for it
112111
// as we have to change the process working directory

‎src/build/templates/handler-monorepo.tmpl.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,4 @@ export default async function (req, context) {
4949
export const config = {
5050
path: '/*',
5151
preferStatic: true,
52-
excludedPath: [
53-
// We use `preferStatic: true` so we already won't run this on *existing* static assets,
54-
// but by excluding this entire path we also avoid invoking the function just to 404.
55-
'{{excludeStaticPath}}',
56-
],
5752
}

‎src/build/templates/handler.tmpl.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,4 @@ export default async function handler(req, context) {
4343
export const config = {
4444
path: '/*',
4545
preferStatic: true,
46-
excludedPath: [
47-
// We use `preferStatic: true` so we already won't run this on *existing* static assets,
48-
// but by excluding this entire path we also avoid invoking the function just to 404.
49-
'{{excludeStaticPath}}',
50-
],
5146
}

‎tests/e2e/page-router.test.ts

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { expect } from '@playwright/test'
22
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
33
import { test } from '../utils/playwright-helpers.js'
4-
import { join } from 'node:path'
5-
import { readdir } from 'node:fs/promises'
64

75
export function waitFor(millis: number) {
86
return new Promise((resolve) => setTimeout(resolve, millis))
@@ -616,34 +614,6 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
616614
/(s-maxage|max-age)/,
617615
)
618616
})
619-
620-
test.describe('static assets and function invocations', () => {
621-
test('should return 200 for an existing static asset without invoking a function', async ({
622-
page,
623-
pageRouter,
624-
}) => {
625-
// Since assets are hashed, we can't hardcode anything here. Find something to fetch.
626-
const [staticAsset] = await readdir(
627-
join(pageRouter.isolatedFixtureRoot, '.next', 'static', 'chunks'),
628-
)
629-
expect(staticAsset).toBeDefined()
630-
631-
const response = await page.goto(`${pageRouter.url}/_next/static/chunks/${staticAsset}`)
632-
633-
expect(response?.status()).toBe(200)
634-
expect(response?.headers()).not.toHaveProperty('x-nf-function-type')
635-
})
636-
637-
test('should return 404 for a nonexistent static asset without invoking a function', async ({
638-
page,
639-
pageRouter,
640-
}) => {
641-
const response = await page.goto(`${pageRouter.url}/_next/static/stale123abcdef.js`)
642-
643-
expect(response?.status()).toBe(404)
644-
expect(response?.headers()).not.toHaveProperty('x-nf-function-type')
645-
})
646-
})
647617
})
648618

649619
test.describe('Page Router with basePath and i18n', () => {
@@ -1382,15 +1352,13 @@ test.describe('Page Router with basePath and i18n', () => {
13821352

13831353
test('requesting a non existing page route that needs to be fetched from the blob store like 404.html', async ({
13841354
page,
1385-
pageRouterBasePathI18n,
1355+
pageRouter,
13861356
}) => {
1387-
const response = await page.goto(
1388-
new URL('base/path/non-existing', pageRouterBasePathI18n.url).href,
1389-
)
1357+
const response = await page.goto(new URL('non-existing', pageRouter.url).href)
13901358
const headers = response?.headers() || {}
13911359
expect(response?.status()).toBe(404)
13921360

1393-
expect(await page.textContent('p')).toBe('Custom 404 page for locale: en')
1361+
expect(await page.textContent('p')).toBe('Custom 404 page')
13941362

13951363
expect(headers['debug-netlify-cdn-cache-control']).toMatch(
13961364
/no-cache,no-store,max-age=0,must-revalidate,durable/m,
@@ -1400,15 +1368,13 @@ test.describe('Page Router with basePath and i18n', () => {
14001368

14011369
test('requesting a non existing page route that needs to be fetched from the blob store like 404.html (notFound: true)', async ({
14021370
page,
1403-
pageRouterBasePathI18n,
1371+
pageRouter,
14041372
}) => {
1405-
const response = await page.goto(
1406-
new URL('base/path/static/not-found', pageRouterBasePathI18n.url).href,
1407-
)
1373+
const response = await page.goto(new URL('static/not-found', pageRouter.url).href)
14081374
const headers = response?.headers() || {}
14091375
expect(response?.status()).toBe(404)
14101376

1411-
expect(await page.textContent('p')).toBe('Custom 404 page for locale: en')
1377+
expect(await page.textContent('p')).toBe('Custom 404 page')
14121378

14131379
// Prior to v14.2.4 notFound pages are not cacheable
14141380
// https://github.com/vercel/next.js/pull/66674
@@ -1421,36 +1387,4 @@ test.describe('Page Router with basePath and i18n', () => {
14211387
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
14221388
}
14231389
})
1424-
1425-
test.describe('static assets and function invocations', () => {
1426-
test('should return 200 for an existing static asset without invoking a function', async ({
1427-
page,
1428-
pageRouterBasePathI18n,
1429-
}) => {
1430-
// Since assets are hashed, we can't hardcode anything here. Find something to fetch.
1431-
const [staticAsset] = await readdir(
1432-
join(pageRouterBasePathI18n.isolatedFixtureRoot, '.next', 'static', 'chunks'),
1433-
)
1434-
expect(staticAsset).toBeDefined()
1435-
1436-
const response = await page.goto(
1437-
`${pageRouterBasePathI18n.url}/base/path/_next/static/chunks/${staticAsset}`,
1438-
)
1439-
1440-
expect(response?.status()).toBe(200)
1441-
expect(response?.headers()).not.toHaveProperty('x-nf-function-type')
1442-
})
1443-
1444-
test('should return 404 for a nonexistent static asset without invoking a function', async ({
1445-
page,
1446-
pageRouterBasePathI18n,
1447-
}) => {
1448-
const response = await page.goto(
1449-
`${pageRouterBasePathI18n.url}/base/path/_next/static/stale123abcdef.js`,
1450-
)
1451-
1452-
expect(response?.status()).toBe(404)
1453-
expect(response?.headers()).not.toHaveProperty('x-nf-function-type')
1454-
})
1455-
})
14561390
})

‎tests/utils/create-e2e-fixture.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export interface DeployResult {
2121
deployID: string
2222
url: string
2323
logs: string
24-
isolatedFixtureRoot: string
2524
}
2625

2726
type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'berry'
@@ -91,7 +90,6 @@ export const createE2EFixture = async (fixture: string, config: E2EConfig = {})
9190
cleanup: _cleanup,
9291
deployID: result.deployID,
9392
url: result.url,
94-
isolatedFixtureRoot: result.isolatedFixtureRoot,
9593
}
9694
} catch (error) {
9795
await _cleanup(true)
@@ -292,7 +290,6 @@ async function deploySite(
292290
url: `https://${deployID}--${siteName}.netlify.app`,
293291
deployID,
294292
logs: output,
295-
isolatedFixtureRoot,
296293
}
297294
}
298295

‎tests/utils/playwright-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const test = base.extend<
9898
if (response.url().includes('/_next/static/')) {
9999
expect(
100100
response.headers()['cache-control'],
101-
`_next/static asset (${response.url()}) should have immutable cache control`,
101+
'_next/static assets should have immutable cache control',
102102
).toContain('public,max-age=31536000,immutable')
103103
}
104104
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /