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

sources: clarify behavior of null case #86

Open
takikawa opened this issue May 21, 2024 · 1 comment
Open

sources: clarify behavior of null case #86

takikawa opened this issue May 21, 2024 · 1 comment

Comments

@takikawa
Copy link
Collaborator

An entry in sources can be null according to the spec, but the full behavior of this isn't clear. For example, if the sources entry is null, then you might guess from the spec that if a sourcesContent entry is provided then it's an "anonymous" original source.

But this doesn't really work if you have multiple such anonymous sources, because browsers collapse them into one. e.g., with the following source map:

{
  "version": 3,
  "names": [],
  "sources": [null, null],
  "sourcesContent": ["foobar1\nline2", "foobar2\nbazquux"],
  "mappings":"AAAA,SCCS"
}

In Chrome and Firefox, you'll only see one source file in the debugger named null that points to the first content.

Also, if you have the same map but delete sourcesContent:

{
  "version": 3,
  "names": [],
  "sources": [null, null],
  "mappings":"AAAA,SCCS"
}

and have a file named null sitting around, browsers may also load that as a source as well.

@jkup
Copy link
Collaborator

jkup commented May 22, 2024

This might be a good one to bring to plenary and ask browsers what they would like / if they would be willing to change their behavior here!

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

2 participants