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 gsp tracing issue #57766

Merged
merged 3 commits into from
Oct 30, 2023
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/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ export async function collectBuildTraces({

const sharedIgnores = [
'**/next/dist/compiled/next-server/**/*.dev.js',
'**/node_modules/react{,-dom,-dom-server-turbopack}/**/*.development.js',
isStandalone ? null : '**/next/dist/compiled/jest-worker/**/*',
'**/next/dist/compiled/webpack/(bundle4|bundle5).js',
'**/node_modules/webpack5/**/*',
Expand Down Expand Up @@ -294,6 +293,7 @@ export async function collectBuildTraces({

const serverIgnores = [
...sharedIgnores,
'**/node_modules/react{,-dom,-dom-server-turbopack}/**/*.development.js',
'**/*.d.ts',
'**/*.map',
'**/next/dist/pages/**/*',
Expand Down
88 changes: 88 additions & 0 deletions test/e2e/app-dir/app/standalone-gsp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { createNextDescribe } from 'e2e-utils'
import fs from 'fs-extra'
import os from 'os'
import path from 'path'
import {
findPort,
initNextServerScript,
killApp,
fetchViaHTTP,
} from 'next-test-utils'

if (!(globalThis as any).isNextStart) {
it('should skip for non-next start', () => {})
} else {
createNextDescribe(
'output: standalone with getStaticProps',
{
files: __dirname,
skipStart: true,
dependencies: {
swr: 'latest',
},
},
({ next }) => {
beforeAll(async () => {
await next.patchFile(
'next.config.js',
(await next.readFile('next.config.js')).replace('// output', 'output')
)

await next.patchFile(
'pages/gsp.js',
`
import useSWR from 'swr'

console.log(useSWR)

export default function Home() {
return <h1>Hello</h1>
}

export async function getStaticProps() {
return {
props: {
foo: "bar",
},
};
}
`
)

await next.start()
})

it('should work correctly with output standalone', async () => {
const tmpFolder = path.join(
os.tmpdir(),
'next-standalone-' + Date.now()
)
await fs.move(path.join(next.testDir, '.next/standalone'), tmpFolder)
let server: any

try {
const testServer = path.join(tmpFolder, 'server.js')
const appPort = await findPort()
server = await initNextServerScript(
testServer,
/- Local:/,
{
...process.env,
PORT: appPort.toString(),
},
undefined,
{
cwd: tmpFolder,
}
)

const res = await fetchViaHTTP(appPort, '/gsp')
expect(res.status).toBe(200)
} finally {
if (server) await killApp(server)
await fs.remove(tmpFolder)
}
})
}
)
}