evanw/esbuild

Some sourcemap notes

Opened this issue · 1 comments

bep commented

I revised and extended the esbuild integration in hugo with code splitting (yes, I know about the ordering issue(s)), and had some issues getting source maps working correctly across platforms.

Note that using the Go API it was fairly simple to rewrite the source maps sources field, so this isn't a blocker for me, but I thought I make an issue jotting down my experiences.

Two issues:

  1. The only way I found to get the sources filenames correct was to use the outDir setting and then do filepath.Join(outdir, pathFromSources). Also see this comment: #2218 (comment)
  2. Filenames on form /foo/bar.js or c:\\foo\\bar.js in sources works great in Chrome on MacOs, but fails on Windows. Converting it into a URL (file:) makes it work for both.
evanw commented

Yes, there are several open problems with source maps. Here are some similar ones to what you are bringing up:

The underlying root cause is esbuild treating these strings as file system paths instead of as URLs. However, changing this will break tools that operate on esbuild's output and that expect file system paths, so I'll need to fix these in a breaking change release.