From f80dc5b99e82cf14dc6dfdc061cac735ee036a55 Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Thu, 5 Jun 2025 18:01:55 -0700 Subject: [PATCH] chore: enable turbopack by default in monorepo (#12684) No issues with turbopack reported so far, let's enable it by default in our monorepo. The `--turbo` flag for our package.json `dev` and `test:e2e` scripts has been replaced with an opt-out `--no-turbo` flag --- .github/workflows/main.yml | 4 ++-- package.json | 4 ++-- test/dev.ts | 9 +++++++-- test/runE2E.ts | 8 ++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe814a3d6..b030f679b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -364,7 +364,7 @@ jobs: run: pnpm exec playwright install-deps chromium - name: E2E Tests - run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.suite }}.json pnpm test:e2e:prod:ci ${{ matrix.suite }} + run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.suite }}.json pnpm test:e2e:prod:ci:noturbo ${{ matrix.suite }} env: PLAYWRIGHT_JSON_OUTPUT_NAME: results_${{ matrix.suite }}.json NEXT_TELEMETRY_DISABLED: 1 @@ -500,7 +500,7 @@ jobs: run: pnpm exec playwright install-deps chromium - name: E2E Tests - run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.suite }}.json pnpm test:e2e:prod:ci:turbo ${{ matrix.suite }} + run: PLAYWRIGHT_JSON_OUTPUT_NAME=results_${{ matrix.suite }}.json pnpm test:e2e:prod:ci ${{ matrix.suite }} env: PLAYWRIGHT_JSON_OUTPUT_NAME: results_${{ matrix.suite }}.json NEXT_TELEMETRY_DISABLED: 1 diff --git a/package.json b/package.json index a6d8de817..b6a0b45b7 100644 --- a/package.json +++ b/package.json @@ -98,10 +98,10 @@ "test:e2e": "pnpm runts ./test/runE2E.ts", "test:e2e:debug": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 PWDEBUG=1 DISABLE_LOGGING=true playwright test", "test:e2e:headed": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true playwright test --headed", + "test:e2e:noturbo": "pnpm runts ./test/runE2E.ts --no-turbo", "test:e2e:prod": "pnpm prepare-run-test-against-prod && pnpm runts ./test/runE2E.ts --prod", "test:e2e:prod:ci": "pnpm prepare-run-test-against-prod:ci && pnpm runts ./test/runE2E.ts --prod", - "test:e2e:prod:ci:turbo": "pnpm prepare-run-test-against-prod:ci && pnpm runts ./test/runE2E.ts --prod --turbo", - "test:e2e:turbo": "pnpm runts ./test/runE2E.ts --turbo", + "test:e2e:prod:ci:noturbo": "pnpm prepare-run-test-against-prod:ci && pnpm runts ./test/runE2E.ts --prod --no-turbo", "test:int": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand", "test:int:postgres": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand", "test:int:sqlite": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=sqlite DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand", diff --git a/test/dev.ts b/test/dev.ts index ca9629ced..2b29b847d 100644 --- a/test/dev.ts +++ b/test/dev.ts @@ -55,9 +55,12 @@ if (!testSuiteArg || !fs.existsSync(path.resolve(dirname, testSuiteArg))) { process.exit(0) } -console.log(`Selected test suite: ${testSuiteArg}`) +// Enable turbopack by default, unless --no-turbo is passed +const enableTurbo = args.turbo !== false -if (args.turbo === true) { +console.log(`Selected test suite: ${testSuiteArg}${enableTurbo ? ' [Turbopack]' : ' [Webpack]'}`) + +if (enableTurbo) { process.env.TURBOPACK = '1' } @@ -111,6 +114,8 @@ const app = nextImport({ hostname: 'localhost', port: availablePort, dir: rootDir, + turbo: enableTurbo, + turbopack: enableTurbo, }) const handle = app.getRequestHandler() diff --git a/test/runE2E.ts b/test/runE2E.ts index 4e2555a63..9cd436969 100644 --- a/test/runE2E.ts +++ b/test/runE2E.ts @@ -20,9 +20,9 @@ if (prod) { shelljs.env.PAYLOAD_TEST_PROD = 'true' } -const turbo = process.argv.includes('--turbo') +const turbo = process.argv.includes('--no-turbo') ? false : true -process.argv = process.argv.filter((arg) => arg !== '--prod' && arg !== '--turbo') +process.argv = process.argv.filter((arg) => arg !== '--prod' && arg !== '--no-turbo') const playwrightBin = path.resolve(dirname, '../node_modules/.bin/playwright') @@ -125,8 +125,8 @@ function executePlaywright( spawnDevArgs.push('--prod') } - if (turbo) { - spawnDevArgs.push('--turbo') + if (!turbo) { + spawnDevArgs.push('--no-turbo') } process.env.START_MEMORY_DB = 'true'