Skip to content
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

Add external source maps to js.Build #8132

Closed
richtera opened this issue Jan 11, 2021 · 7 comments
Closed

Add external source maps to js.Build #8132

richtera opened this issue Jan 11, 2021 · 7 comments

Comments

@richtera
Copy link
Contributor

The current symbol resolver seems to work very well and I have not seen any problems using jsconfig files anymore in the last version. So I think things are working very well, but there are two areas I had fixed in my PR which I would love to create a new PR for. These are external map files and better error reporting.
I was trying to extract these from my jsconfig/tsconfig PR, but I think a lot of things have changed around it. I will put together a new PR for it, but I don't quite understand how a file and it's symbol file is piped through the fingerprint pipeline. I know that this happens properly in sass for example, but I couldn't quite figure out where to look for the code. Also the error reporting of JS doesn't seem to output all of the error information returned from esbuild and will just output the error token without any line or file context. It also skips some kind of import stack to be able to find and repair the error.

@bep
Copy link
Member

bep commented Jan 11, 2021

but I don't quite understand how a file and it's symbol file is piped through the fingerprint pipeline.

What do you mean by this? What's a "symbol file"?

@bep
Copy link
Member

bep commented Jan 11, 2021

OK, I assume you mean "source maps". Yes, I reverted the external source map option that was added. If that is needed, there is example code in, e.g. the dartsass package.

@richtera
Copy link
Contributor Author

Perfect. That's what I needed. Yes. I will recover the "external" source map support from my PR and the output of ESBuild error messages (currently it seems to only show the main error and no context information to find it unless this was fixed after 79.1) Thanks for the info I will make the PR associated with this issue number.

@bep bep changed the title External sym maps and error output for JSBuild. Add external source maps to js.Build Jan 12, 2021
@bep bep added Enhancement and removed Proposal labels Jan 12, 2021
@bep bep added this to the v0.81 milestone Jan 12, 2021
@richtera
Copy link
Contributor Author

In order to support es5 targets we might need to support sourceMaps for babel as well and use babel inside of the esbuild pipeline.

richtera added a commit to getselfstudy/hugo that referenced this issue Jan 15, 2021
WIP
Added rollup for testing.
Added sourceMaps option for babel. Babel can also read sourcemaps from
  the output of an esbuild if they are "inline", it will then
  convert the file and remap the source maps and then re-export them
  but currently not if they are "external".
Added support for sourcemap = "external" for esbuild.

Ref gohugoio#8132
@richtera
Copy link
Contributor Author

There is a little bit of a rabbit hole here.

  1. I was able to get source maps working for babel
  2. It was able to read the inline source maps from esbuild
  3. But the output source maps work for some files and not others. I think it's related to requiring larger node dependencies within a particular file, then it will lose context of lines and character offsets within that file.
  4. I tried to add a rollup pipeline which also works, but with my current javascript project, rollup is complicated due to the polyfill and resolve configuration. If someone has a good rollup configuration it should work as long as it has input: "-" as the input config in the rollup.config.js file.

I have a WIP commit that's mostly working, but I needed to test it on a netlify build. With previous versions I just committed a binary hugo into the repo and then used it to build, but with this particular hugo version I get a

./build.sh: line 65: /opt/build/repo/platform-themes/local-hugo/hugo: No such file or directory

It maybe related to the version of go I am using on my build system vs the netlify container. Is there a "standard" way to create universal test binaries?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants