Skip to content

Enable Turbopack for production builds #683

@hellno

Description

@hellno

Summary

Turbopack is Next.js's new Rust-based bundler that promises significantly faster builds. However, enabling Turbopack for production builds currently fails due to an incompatibility with @farcaster/hub-web.

Error Details

When running npx next build --turbopack, the build fails with:

./node_modules/@farcaster/hub-web/dist/index.mjs
Module not found: The high bits of the position 4586771 are not all 0s or 1s. modules_header_width=9, module=215

./node_modules/@farcaster/hub-web/dist/index.mjs
Module not found: The high bits of the position 4586771 are not all 0s or 1s. modules_header_width=9, module=215

This error occurs in Turbopack's Rust internals when processing the protobuf-heavy @farcaster/hub-web package.

Context

  • Next.js version: 15.5.9
  • @farcaster/hub-web version: 0.9.2 (bundled with @farcaster/core)
  • Current bundler: webpack (via Sentry wrapper)
  • Turbopack status: Works for dev server (next dev --turbo), fails for production builds

Why This Matters

Turbopack could significantly improve build times:

  • Current webpack build: ~25-35s
  • Expected Turbopack improvement: 2-5x faster for incremental builds
  • Better caching and parallelization

Root Cause

The @farcaster/hub-web package uses Protocol Buffers (protobuf) for Farcaster Hub communication. Turbopack's Rust-based module resolution appears to have issues with:

  1. Large generated protobuf files
  2. Complex module structure in the package's ESM output

Potential Solutions

  1. Wait for Turbopack fix: This appears to be a Turbopack beta limitation that may be fixed in future releases
  2. Report upstream to Vercel: File issue in Next.js/Turbopack repo with reproduction
  3. Use alternative Farcaster package: If available, use a package without protobuf dependency
  4. Conditional bundling: Exclude @farcaster/hub-web from Turbopack processing (if supported)

Related Links

Acceptance Criteria

  • Production build succeeds with next build --turbopack
  • Build times are measurably improved
  • No functionality regression in Farcaster Hub communication

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions