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

Source mappings may now contain null entries in 0.24.1 causes errors generate non spec compliant map? #4080

Open
alan-agius4 opened this issue Feb 14, 2025 · 0 comments · May be fixed by #4082

Comments

@alan-agius4
Copy link

The mentioned change causes errors when using @ampproject/remapping, likely because it does not comply with the specification. The original issue was reported ampproject/remapping#200), but it was later clarified that the behavior aligns with the spec.

rootSources, derived from the map's sources field, contains 16 items. However, segment[1] is 16, meaning rootSources[16] results in undefined. Passing undefined to originalPositionFor triggers an error.

This is not an issue with remapping itself; rather, it's invalid for a source map to reference a 17th source (index 16) when only 16 sources exist. According to the [source map specification](https://tc39.es/ecma426/#decode-source-map-mappings) (9.a.iii.14):

If any of sourceIndex, originalLine, or originalColumn are less than 0, or if sourceIndex is greater than or equal to sources’s [size](https://infra.spec.whatwg.org/#list-size), [optionally report an error](https://tc39.es/ecma426/#optionally-report-an-error).

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

Successfully merging a pull request may close this issue.

1 participant