Skip to content

Broken paths with sourcemap with file:/// references #1745

@haxiomic

Description

@haxiomic

I'm bundling a single js file, app.js with a sourcemap app.js.map, this sourcemap references source files by absolute paths with file:///

{
"version":3,
"file":"app.js",
"sourceRoot":"",
"sources":[
    "file:////Users/geo/Projects/example/src/DomUI.hx",

When bundling with --sourcemap

esbuild bin/app.js --bundle --outfile=bin/bundle.js --sourcemap

The sorucemap sources are included but lose the full file:/// protocol, so the browser complains about missing source files

bundle.js.map

{
  "version": 3,
  "sources": [
      "file:/Users/geo/Projects/lush-energies/src/DomUI.hx", 

If I manually replace with file:///Users/... then everything works :)

I'd guess the issue is on this line

path.Text = c.fs.Join(c.fs.Dir(file.InputFile.Source.KeyPath.Text), source)

When I get a moment out of crunch (could be a while) I'll try to get a Go environment going so I can explore this one

Using:

  • esbuild 0.7.22
  • macOS chrome
  • webserver is live-server 1.2.1 on npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions