Some sourcemap notes
Opened this issue · 1 comments
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:
- The only way I found to get the
sources
filenames correct was to use theoutDir
setting and then dofilepath.Join(outdir, pathFromSources)
. Also see this comment: #2218 (comment) - Filenames on form
/foo/bar.js
orc:\\foo\\bar.js
insources
works great in Chrome on MacOs, but fails on Windows. Converting it into a URL (file:
) makes it work for both.
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.