Some sourcemap notes
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
sourcesfilenames correct was to use theoutDirsetting and then dofilepath.Join(outdir, pathFromSources). Also see this comment: https://github.com/evanw/esbuild/issues/2218#issuecomment-1666231520 - Filenames on form
/foo/bar.jsorc:\\foo\\bar.jsinsourcesworks 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:
- https://github.com/evanw/esbuild/issues/1745
- https://github.com/evanw/esbuild/issues/3183
- https://github.com/evanw/esbuild/issues/3613
- https://github.com/evanw/esbuild/issues/3982
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.