From b8fae4cdcf250884824af3854b12d7fcf183d5c1 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sat, 5 Jul 2025 22:02:26 +0200 Subject: [PATCH 1/3] Glob all server files instead of specific subdirectories --- src/build/content/server.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/build/content/server.ts b/src/build/content/server.ts index 48be0382b6..1122a4d520 100644 --- a/src/build/content/server.ts +++ b/src/build/content/server.ts @@ -99,13 +99,10 @@ export const copyNextServerCode = async (ctx: PluginContext): Promise => { : ctx.nextDistDir const destDir = join(ctx.serverHandlerDir, nextFolder) - const paths = await glob( - [`*`, `server/*`, `server/chunks/*`, `server/edge-chunks/*`, `server/+(app|pages)/**/*.js`], - { - cwd: srcDir, - extglob: true, - }, - ) + const paths = await glob([`*`, `server/**/*`], { + cwd: srcDir, + extglob: true, + }) await Promise.all( paths.map(async (path: string) => { From 2ee28e85704460038c7fb88f3935b923d72b86b7 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sun, 6 Jul 2025 15:19:21 +0200 Subject: [PATCH 2/3] Add fixture for Turbopack app --- .../fixtures/hello-world-turbopack/app/layout.js | 7 +++++++ tests/fixtures/hello-world-turbopack/app/page.js | 3 +++ .../fixtures/hello-world-turbopack/next.config.ts | 9 +++++++++ tests/fixtures/hello-world-turbopack/package.json | 15 +++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/fixtures/hello-world-turbopack/app/layout.js create mode 100644 tests/fixtures/hello-world-turbopack/app/page.js create mode 100644 tests/fixtures/hello-world-turbopack/next.config.ts create mode 100644 tests/fixtures/hello-world-turbopack/package.json diff --git a/tests/fixtures/hello-world-turbopack/app/layout.js b/tests/fixtures/hello-world-turbopack/app/layout.js new file mode 100644 index 0000000000..4ee00a2185 --- /dev/null +++ b/tests/fixtures/hello-world-turbopack/app/layout.js @@ -0,0 +1,7 @@ +export default function RootLayout({ children }) { + return ( + + {children} + + ) +} diff --git a/tests/fixtures/hello-world-turbopack/app/page.js b/tests/fixtures/hello-world-turbopack/app/page.js new file mode 100644 index 0000000000..6baa6ade86 --- /dev/null +++ b/tests/fixtures/hello-world-turbopack/app/page.js @@ -0,0 +1,3 @@ +export default function Page() { + return

Hello, Next.js!

+} diff --git a/tests/fixtures/hello-world-turbopack/next.config.ts b/tests/fixtures/hello-world-turbopack/next.config.ts new file mode 100644 index 0000000000..9d94510be1 --- /dev/null +++ b/tests/fixtures/hello-world-turbopack/next.config.ts @@ -0,0 +1,9 @@ +/** @type {import('next').NextConfig} */ +const nextConfig = { + output: 'standalone', + eslint: { + ignoreDuringBuilds: true, + }, +} + +module.exports = nextConfig diff --git a/tests/fixtures/hello-world-turbopack/package.json b/tests/fixtures/hello-world-turbopack/package.json new file mode 100644 index 0000000000..02319b0b3b --- /dev/null +++ b/tests/fixtures/hello-world-turbopack/package.json @@ -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" + }, + "dependencies": { + "next": "latest", + "react": "18.2.0", + "react-dom": "18.2.0" + } +} From bca76bcc041a2e7212a6587ff5c89adb4a426062 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sun, 6 Jul 2025 15:21:33 +0200 Subject: [PATCH 3/3] Add test --- .../integration/hello-world-turbopack.test.ts | 72 +++++++++++++++++++ tests/utils/create-e2e-fixture.ts | 1 + 2 files changed, 73 insertions(+) create mode 100644 tests/integration/hello-world-turbopack.test.ts diff --git a/tests/integration/hello-world-turbopack.test.ts b/tests/integration/hello-world-turbopack.test.ts new file mode 100644 index 0000000000..dd681433b6 --- /dev/null +++ b/tests/integration/hello-world-turbopack.test.ts @@ -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 + +// 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(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('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!') +}) diff --git a/tests/utils/create-e2e-fixture.ts b/tests/utils/create-e2e-fixture.ts index d7af065d21..714d4012a3 100644 --- a/tests/utils/create-e2e-fixture.ts +++ b/tests/utils/create-e2e-fixture.ts @@ -316,6 +316,7 @@ async function cleanup(dest: string, deployId?: string): Promise { export const fixtureFactories = { simple: () => createE2EFixture('simple'), + helloWorldTurbopack: () => createE2EFixture('hello-world-turbopack'), outputExport: () => createE2EFixture('output-export'), ouputExportPublishOut: () => createE2EFixture('output-export', {