Skip to content

[FEATURE REQUEST] Use source-map sections in js_of_ocaml link command. #1446

@hhugo

Description

@hhugo

Support sourcemap sections fields so that we no longer need to merge sourcemaps mappings in js_of_ocaml link

Index map: supporting post processing
To support concatenating generated code and other common post processing, an alternate representation of a map is supported:
{
"version" : 3,
"file": “app.js”,
"sections": [
 { "offset": {"line":0, "column":0}, "url": “url_for_part1.map” }
 { "offset": {"line":100, "column":10}, "map": 
   {
     "version" : 3,
     "file": “section.js”,
     "sources": ["foo.js", "bar.js"],
     "names": ["src", "maps", "are", "fun"],
     "mappings": "AAAA,E;;ABCDE;"
   }
 }
],
}


The index map follow the form of the standard map
Line 1: The entire file is an JSON object.
Line 2: The version field. See the description of the standard map.
Line 3: The name field. See the description of the standard map.
Line 4: The sections field.

The “sections” field is an array of JSON objects that itself has two fields “offset” and a source map reference.  “offset” is an object with two fields, “line” and “column”, that represent the offset into generated code that the referenced source map represents.
The other field must be either “url” or “map”. A “url” entry must be a URL where a source map can be found for this section and the url is resolved in the same way as the “sources” fields in the standard map. A “map” entry must be an embedded complete source map object.  An embedded map does not inherit any values from the containing index map.

The sections must be sorted by starting position and the represented sections may not overlap.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions