Skip to content

feat: add turbopack support for Next.js v16#43

Merged
Ethan-Arrowood merged 4 commits into
mainfrom
feat/turbopack-support-v16
May 6, 2026
Merged

feat: add turbopack support for Next.js v16#43
Ethan-Arrowood merged 4 commits into
mainfrom
feat/turbopack-support-v16

Conversation

@Ethan-Arrowood
Copy link
Copy Markdown
Member

@Ethan-Arrowood Ethan-Arrowood commented May 6, 2026

Summary

  • Next.js v16 defaults to Turbopack as its bundler. The plugin previously hardcoded webpack for both build and serve, disabling turbopack entirely.
  • Adds a webpack boolean plugin option (defaults to false) so v16 uses turbopack by default, matching the standard Next.js developer experience. Users can set webpack: true to opt back into webpack, mirroring the next build --webpack CLI flag.
  • Updates withHarper() to include a turbopack config key in the returned Next.js config. Without this, Next.js v16 errors when it detects a webpack config function (added by withHarper) with no corresponding turbopack config.
  • v14 and v15 behavior is unchanged — the webpack option is ignored for those versions.

Test plan

  • npm run build — TypeScript compiles clean
  • next-16.pw.ts — turbopack path (default): 3/3 passed
  • next-16-webpack.pw.ts — webpack path (webpack: true): 3/3 passed
  • Verify v14 and v15 tests still pass (not run yet — no changes to their code paths)

🤖 Generated with Claude Code


Now incorporates changes from #44 and #45 too for v14 and v15 support.

Ethan-Arrowood and others added 2 commits May 6, 2026 08:37
Next.js v16 defaults to Turbopack. The plugin previously hardcoded
webpack for both build and serve, disabling turbopack entirely.

- Add `webpack` boolean plugin option (defaults to false) so users can
  opt into webpack when needed, mirroring the `next build --webpack` CLI flag
- Update `withHarper()` to include a `turbopack` config key, preventing
  Next.js v16 from erroring when it sees a webpack config without one
- Add `next-16-webpack` fixture and integration test to cover both bundler paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ethan-Arrowood and others added 2 commits May 6, 2026 10:06
* feat: add turbopack support for Next.js v15 and refactor bundler option

Replace the `webpack: boolean` plugin option with a `bundler` option
that accepts "webpack" or "turbopack". The default is version-aware:
- v16: turbopack (matches Next.js v16 default)
- v15: webpack (matches Next.js v15 default)
- v14: webpack (no turbopack support)

Users can now explicitly set `bundler: turbopack` for v15 to opt in,
or `bundler: webpack` for v16 to opt out.

- Add `next-15-turbopack` fixture and integration test
- Update `next-16-webpack` fixture to use `bundler: webpack`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add v14 turbopack guard and validate all versions (#45)

Next.js v14 does not support turbopack via the createServer or
nextBuild APIs. Log an error and fall back to webpack if a user
sets `bundler: turbopack` with a v14 application.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works like a champ! Nice work!

[http/1] [debug]: Building Next.js application at /Users/chris/project
▲ Next.js 16.2.4 (Turbopack)

@Ethan-Arrowood Ethan-Arrowood merged commit fc55db3 into main May 6, 2026
6 checks passed
@Ethan-Arrowood Ethan-Arrowood deleted the feat/turbopack-support-v16 branch May 6, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants