Skip to content

The external file loader causes source maps to have null mappings #4119

@jwmerrill

Description

@jwmerrill

The esbuild file loader generates comments listing the original source file in bundled output. Example:

// img/triangle.png
var triangle_default = "./triangle-5XHGZ7W6.png";

In esbuild v0.24.1 through v0.25.1, a source map mapping with source: null is generated for the first comment of this kind in each file that uses the file loader plugin.

This problem does not appear to occur if the file that uses the external file plugin is the first file in the bundled output.

Mappings like this with null source cause Safari (18.3) (but not Chrome 135.0.7049.28 or Firefox 137.0b9) to fail to show any source mapped source files.

A very similar issue was fixed in v0.25.1 (changelog, PR), but the issue reported here was not fixed by that change.

Minimal reproduction

I made a separate repo to reproduce this issue because I don't know how to use the external file loader on https://esbuild.github.io/try/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions