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

Fix outputting un-necessary trace files for edge functions #43304

Merged
merged 3 commits into from Nov 24, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -2002,7 +2002,7 @@ export default async function getBaseWebpackConfig(
}),
(isClient || isEdgeServer) && new DropClientPage(),
config.outputFileTracing &&
(isNodeServer || isEdgeServer) &&
isNodeServer &&
!dev &&
new (require('./webpack/plugins/next-trace-entrypoints-plugin')
.TraceEntryPointsPlugin as typeof import('./webpack/plugins/next-trace-entrypoints-plugin').TraceEntryPointsPlugin)(
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/edge-render-getserversideprops/index.test.ts
Expand Up @@ -4,6 +4,7 @@ import { fetchViaHTTP, normalizeRegEx, renderViaHTTP } from 'next-test-utils'
import cheerio from 'cheerio'
import { join } from 'path'
import escapeStringRegexp from 'escape-string-regexp'
import fs from 'fs-extra'

describe('edge-render-getserversideprops', () => {
let next: NextInstance
Expand All @@ -16,6 +17,28 @@ describe('edge-render-getserversideprops', () => {
})
afterAll(() => next.destroy())

if ((global as any).isNextStart) {
it('should not output trace files for edge routes', async () => {
expect(await fs.pathExists(join(next.testDir, '.next/pages'))).toBe(false)
expect(
await fs.pathExists(join(next.testDir, '.next/server/pages/[id].js'))
).toBe(true)
expect(
await fs.pathExists(
join(next.testDir, '.next/server/pages/[id].js.nft.json')
)
).toBe(false)
expect(
await fs.pathExists(join(next.testDir, '.next/server/pages/index.js'))
).toBe(true)
expect(
await fs.pathExists(
join(next.testDir, '.next/server/pages/index.js.nft.json')
)
).toBe(false)
})
}

it('should have correct query/params on index', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
Expand Down