Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Add statement about possibility of source map rejecting in case of an invalid version field #25

Merged
merged 4 commits into from
Mar 13, 2024

Conversation

JSMonk
Copy link
Member

@JSMonk JSMonk commented Jan 17, 2024

I'm not quite sure about can be rejected instead of should be rejected, but I feel there should be freedom for choosing such behavior for tooling, but it is discussable.
Want to hear your opinions @mitsuhiko @littledan @jkup

@JSMonk JSMonk requested review from mitsuhiko and jkup January 17, 2024 19:08
@nicolo-ribaudo
Copy link
Member

My opinion here is that we should enforce rejection as if it was, for example, an encoding error. There is a risk that one day in the future there will be a new source map version, and we should avoid source map v3 tools to accidentally consume a source map v(future) and provide wrong-but-not-rejected results.

@bomsy
Copy link
Collaborator

bomsy commented Jan 23, 2024

Also should we be specific about backward compatibility as well? E.g Implementations with support for v4 should still accept versions v3.

@littledan
Copy link
Member

How about "must"?

@littledan
Copy link
Member

Also should we be specific about backward compatibility as well? E.g Implementations with support for v4 should still accept versions v3.

I don't think we're going to do any more version number increments.

@mitsuhiko
Copy link
Collaborator

I would recommend to treat it as an error in the file, but I would not go as far as mandating a particular rejection, at least not for all consumers of a source map. It should however not be considered a valid source map.

(Which goes a little bit into what a tool should be doing for invalid source maps and quite frankly my recommendation would be to still try to apply it, even if there are issues with it.)

@JSMonk
Copy link
Member Author

JSMonk commented Jan 28, 2024

It sounds like a topic to discuss on one of the upcoming meeting.

source-map.bs Outdated
@@ -168,7 +168,7 @@ for practical reasons, the order cannot be defined in many JSON generators and
has never been enforced.

<dfn><code>version</code></dfn> is the version field which is always the number
`3` as an integer.
`3` as an integer. Source map can be rejected in case of a value different from `3`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...which must always be the number 3 as an integer. The source map may be rejected in case of a value different from 3.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

@jkup
Copy link
Collaborator

jkup commented Mar 13, 2024

Going to merge this. If, in the future, we realize there are multiple invalid fields that consumers try to recover, we should consider making a top level note that consumers may try to recover invalid source maps.

@jkup jkup merged commit 695bcf5 into tc39:main Mar 13, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Mar 13, 2024
SHA: 695bcf5
Reason: push, by jkup

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants