Skip to content

Sourcemaps not generated for OpenNext bundling step #1124

@logaretm

Description

@logaretm

Is your feature request related to a problem?

When deploying a Next.js app to Cloudflare Workers via OpenNext, the sourcemap chain is broken because OpenNext doesn't produce sourcemaps for its own bundling step.

Next.js (Turbopack) produces sourcemaps for its build output in .next/server/. OpenNext then bundles these into .open-next/worker.js (and intermediate files like handler.mjs), but this step does not generate sourcemaps.

When Wrangler subsequently bundles .open-next/worker.js into the final deployable worker.js, it produces a worker.js.map but that sourcemap can only resolve one level back to OpenNext's intermediate files (handler.mjs), which are themselves minified/bundled.

Without sourcemaps from the OpenNext bundling step, Wrangler can't chain them, and the resolution stops at handler.mjs rather than reaching the original .ts/.tsx source files.

This disrupts observability tooling like Sentry from showing stacktraces accurately.

Describe the solution you'd like

Ideally we would like for Opennext to generate the missing sourcemaps to bridge the resolution gap.

worker.js (Wrangler output)
  → worker.js.map
    → handler.mjs (OpenNext output)
      → handler.mjs.map (MISSING) <--- Need this
        → original source files (.ts/.tsx)

There is a PR/issue already discussing this in #824

If OpenNext produced sourcemaps for its bundling step, Wrangler could flatten/chain them into the final worker.js.map, enabling error monitoring tools like Sentry to resolve stack traces all the way back to the original source code.

Describe alternatives you've considered

No workarounds seem to be possible

@opennextjs/cloudflare version

1.15.1

Additional context

No response

Before submitting

  • I have checked that there isn't already a similar feature request
  • This is a single feature (not multiple features in one request)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions