Skip to content

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

@alan-agius4

Description

@alan-agius4

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions