Skip to content

TypeError: Expected CommonJS module to have a function wrapper when building with bun --bun #70

@shiny

Description

@shiny

I'm running into an error when trying to build a Next.js project using Bun. The build fails with:

TypeError: Expected CommonJS module to have a function wrapper. If you weren't messing around with Bun's internals, this is a bug in Bun
    at anonymous (null)

This only happens when I run the build with:

bun --bun build

Building with other configurations works as expected.

Environment:

  • Bun version: 1.2.19
  • Next.js version: 15.3.5

Steps to reproduce:

  1. Create a Next.js project
  2. use atomEffect
  3. Build using bun --bun build
  4. See the error

Similar to oven-sh/bun#21137

Expected behavior:
The project should build successfully without throwing this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions