It's no longer necessary to strip shebangs from modules #13129
Labels
needs investigation
requires further investigation before determining if it is an issue or not
suggestion
suggestions for new features (yet to be agreed)
Deno's module fetcher will strip a shebang if a module file starts with one. However, there is a stage-3 TC39 proposal to support shebangs (or "hashbangs") as part of JS syntax. In fact, this was implemented in V8 in 2018 and has shipped by default since V8 7.4. So this transformation can be removed.
This affects the output of
Deno.emit()
though. Althoughemit::bundle
will skip any shebangs in the source files, and sodeno bundle
andDeno.emit()
with thebundle
parameter are safe,emit::to_file_map
(which powersDeno.emit()
without thebundle
option) will output shebangs for the files that have them. This might be bad, depending on what kinds of environments the code generated byDeno.emit()
will be used in. We should consider whether to strip the shebang from the outputs.Another potential issue is positions in sourcemaps: since currently shebangs are stripped before the module is parsed, any sourcemaps generated by
tsc
orswc
would be off by one line for modules with shebangs. I don't know if this error is corrected at all, but if so, the correction would have to be undone. Also, if shebangs are stripped from theDeno.emit()
outputs, those sourcemaps would also need to be corrected to account for it.The text was updated successfully, but these errors were encountered: