-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix js.Build sourcemap comment #12869
base: master
Are you sure you want to change the base?
fix js.Build sourcemap comment #12869
Conversation
Created a small test repo just to showcase a forced console error with the correct file name and line number here: https://github.com/BrianLeishman/hugo-milkdown-esbuild git clone https://github.com/BrianLeishman/hugo-milkdown-esbuild --recurse-submodules
cd hugo-milkdown-esbuild
npm ci
hugo server |
Thanks for this. This looks good, but it has worked before (I remember testing it), and the reason it broke is because we don't have a proper test for it. So, we need that. If you add a test in the |
Sounds good! I did just realize though a few minutes ago that I am using the absolute path "assets" to determine the physical location of the input file, and I don't think that's right, but I'm not familiar enough yet with the hugo source to know how to resolve the real path (relative of the workspace) of a file in "assets". I'll work on the test and the better file resolution now. |
Both of those changes should be good to go! Resolve real location of file in assets fs on the os fsTested this by moving my "ts" folder to the root of the workspace, and mounting into "assets" view the module mounting config in hugo.toml, getting the correct path, and then testing again by removing the mount and placing directly in assets. This was easier than expected since there was an example in the same file. Source comment testWith the new comment assertion, the test fails if I undo my changes to the comment output, but passes with this update. |
https://esbuild.github.io/api/#sourcemap
esbuild sitemap option when set to "external" doesn't actually include the sitemap comment in the file (maybe it used to?). The "linked" option does do this, but I think we want to keep using external here since we want to generate our own source map comment still.
In this PR I update the code to simply add our source map comment vs trying to replace the existing one (as one doesn't exist.)
I also update the
Sourcefile
esbuild option to be the name of the given file in "assets" so that the source map will specify the actual file, vs just saying "stdin".