Skip to content

OXC.bundle/2 with sourcemap: true hard-fails when Rolldown omits map for empty output #4

@mtarnovan

Description

@mtarnovan

Summary

OXC.bundle/2 currently returns an error when sourcemap: true and Rolldown does not attach a map (e.g. empty or effectively-empty bundle output):

{:error, [%{message: "Rolldown did not produce a source map"}]}

This bubbles up to Volt builds and can fail otherwise-valid builds.

Environment

  • oxc 0.10.0
  • Elixir 1.19.4 / OTP 28
  • macOS Darwin 25.4.0

Minimal Repro

mix run -e 'files=[{"main.js", ""}]; IO.inspect(OXC.bundle(files, entry: "main.js", sourcemap: true, format: :iife))'

Actual

{:error, [%{message: "Rolldown did not produce a source map"}]}

Expected

One of:

  1. Return success with sourcemap: nil / omitted map for this edge case, or
  2. Handle this case in a non-fatal way so callers can still receive generated code.

Additional context

Sourcemap disabled works as expected:

mix run -e 'files=[{"main.js", ""}]; IO.inspect(OXC.bundle(files, entry: "main.js", sourcemap: false, format: :iife))'
# => {:ok, "(function() {\n\n\n})();"}

Potential throw site appears in native/oxc_ex_nif/src/bundle.rs:

let sourcemap_json = chunk
    .map
    .as_ref()
    .map(oxc_sourcemap::SourceMap::to_json_string)
    .ok_or_else(|| vec!["Rolldown did not produce a source map".to_string()])?;

Happy to test any proposed patch quickly.

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