Sitelet https://web.archive.org/web/20200908104812/https://github.com/scala-js/scala-js/issues/3563/
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

Adding comments header for compiled & optimized files #3563

Open
DirkToewe opened this issue Feb 18, 2019 · 2 comments
Open

Adding comments header for compiled & optimized files #3563

DirkToewe opened this issue Feb 18, 2019 · 2 comments
Labels

Comments

@DirkToewe
Copy link

@DirkToewe DirkToewe commented Feb 18, 2019

Adding a plain text to the header of a compiled and optimized .js-file may be useful for multiple reasons:

  • Adding metadata like version, compiler settings, date, ...
  • Adding execution information, e.g. #!/usr/bin/env node
  • Adding a License, Author, Support info, URL, ...

Such a plain text header could easily be added to a .js in a postprocessing step after compilation. However, if I am not mistaken, the Sourcemap would also have to be remapped. That seems to me like a quite involved chore.

This brings me to the following feature request: Would it be possible to add a "headerString" option to the SBT plugin, such that such a header can be added more easily?

@sjrd
Copy link
Member

@sjrd sjrd commented Feb 18, 2019

For context: we used to have something similar, called scalaJSOutputWrapper, which allowed to inject arbitrary code before and after the output of Scala.js. It was deprecated in c8681b6 because it causes unsoundness: the code is injected in an unknown scope controlled by the compiler, and things can unexpectedly go wrong.

In general, we cannot allow injection of arbitrary code. We could consider the injection of comment-only code , though.

@DirkToewe
Copy link
Author

@DirkToewe DirkToewe commented Feb 18, 2019 •

Comments alone would already be very helpful to me. The #!/usr/bin/env node shebang may be useful to others but I don't have a use case for it.

@gzm0 gzm0 added the enhancement label Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.