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

Termination of mappings and purely generated code #32

Open
devversion opened this issue Apr 12, 2023 · 1 comment
Open

Termination of mappings and purely generated code #32

devversion opened this issue Apr 12, 2023 · 1 comment

Comments

@devversion
Copy link

Based on personal/subjective experience, source maps occasionally lack termination segments that cause purely generated code (like TypeScript helpers) to be incorrectly attributed to the preceding source mapping. This is nothing wrong in the spec, but more of an easy pitfall because source map generators/tools might forget explicitly terminating mappings.

Here is an example issue where Terser (a popular JavaScript minifier incorrectly did not terminate mappings): terser/terser#1106 (comment).

Possible ideas?

  • The current spec is not super clear about "purely generated code": https://sourcemaps.info/spec.html. Potentially this can be made more clear, noted on the 1-length segments.
  • Mappings may be terminated differently, e.g. making the end-range of a mapping explicit. This obviously has other significant consequences but I'm just listing possibilities here... not saying this is the right thing :)

What are examples of purely generated code?

  • TypeScript for example may generate helpers to support JS syntax not supported in e.g. the latest Chromium version. Arguably, this code may be attributed to certain original source file spots, but for shared helpers (that may be used X times)- this is wrong.
  • Code transformers may insert additional code into generated files. This code should not be accidentally attributed to source files from a preceding mapping.

Possible issues?

  • Stack traces might show errors attributed to user code, while the error originates from generated code..
  • Size measurements, trying to measure how much each source file contributes, can be significantly flawed.
@jkup
Copy link
Collaborator

jkup commented Aug 9, 2023

This sounds at least slightly related to #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants