-
Notifications
You must be signed in to change notification settings - Fork 90
fix: glob subdirectories in server/chunks to support turbopack builds #2987
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
Merged
+117
−1
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b8fae4c
Glob all server files instead of specific subdirectories
timneutkens 2ee28e8
Add fixture for Turbopack app
timneutkens bca76bc
Add test
timneutkens ab831a1
scale back the globs to only allow sub directories in server/(edge-)c…
pieh 2a10af5
test: make sure all ways to build turbopack fixture would set --turbo…
pieh a4e67eb
Merge remote-tracking branch 'origin/main' into fix/turbopack-minimal
pieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <h1>Hello, Next.js!</h1> | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: 'standalone', | ||
eslint: { | ||
ignoreDuringBuilds: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "hello-world-app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"postinstall": "next build --turbopack", | ||
"dev": "next dev --turbopack", | ||
"build": "next build --turbopack" | ||
}, | ||
"dependencies": { | ||
"next": "latest", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { load } from 'cheerio' | ||
import { getLogger } from 'lambda-local' | ||
import { cp } from 'node:fs/promises' | ||
import { HttpResponse, http, passthrough } from 'msw' | ||
import { setupServer } from 'msw/node' | ||
import { v4 } from 'uuid' | ||
import { Mock, afterAll, afterEach, beforeAll, beforeEach, expect, test, vi } from 'vitest' | ||
import { type FixtureTestContext } from '../utils/contexts.js' | ||
import { createFixture, invokeFunction, runPlugin } from '../utils/fixture.js' | ||
import { generateRandomObjectID, startMockBlobStore } from '../utils/helpers.js' | ||
|
||
vi.mock('node:fs/promises', async (importOriginal) => { | ||
const fsPromisesModule = (await importOriginal()) as typeof import('node:fs/promises') | ||
return { | ||
...fsPromisesModule, | ||
cp: vi.fn(fsPromisesModule.cp.bind(fsPromisesModule)), | ||
} | ||
}) | ||
|
||
let server: ReturnType<typeof setupServer> | ||
|
||
// Disable the verbose logging of the lambda-local runtime | ||
getLogger().level = 'alert' | ||
|
||
const purgeAPI = vi.fn() | ||
|
||
beforeAll(() => { | ||
server = setupServer( | ||
http.post('https://api.netlify.com/api/v1/purge', async ({ request }) => { | ||
purgeAPI(await request.json()) | ||
|
||
return HttpResponse.json({ | ||
ok: true, | ||
}) | ||
}), | ||
http.all(/.*/, () => passthrough()), | ||
) | ||
server.listen() | ||
}) | ||
|
||
afterAll(() => { | ||
// Disable API mocking after the tests are done. | ||
server.close() | ||
}) | ||
|
||
beforeEach<FixtureTestContext>(async (ctx) => { | ||
// set for each test a new deployID and siteID | ||
ctx.deployID = generateRandomObjectID() | ||
ctx.siteID = v4() | ||
vi.stubEnv('SITE_ID', ctx.siteID) | ||
vi.stubEnv('DEPLOY_ID', ctx.deployID) | ||
// hide debug logs in tests | ||
vi.spyOn(console, 'debug').mockImplementation(() => {}) | ||
|
||
purgeAPI.mockClear() | ||
|
||
await startMockBlobStore(ctx) | ||
}) | ||
|
||
afterEach(() => { | ||
vi.unstubAllEnvs() | ||
}) | ||
|
||
test<FixtureTestContext>('Test that the hello-world-turbopack next app is working', async (ctx) => { | ||
await createFixture('hello-world-turbopack', ctx) | ||
await runPlugin(ctx) | ||
|
||
// test the function call | ||
const home = await invokeFunction(ctx) | ||
expect(home.statusCode).toBe(200) | ||
expect(load(home.body)('h1').text()).toBe('Hello, Next.js!') | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.