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

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

Open
hhugo opened this issue Apr 5, 2023 · 0 comments
Open

Comments

@hhugo
Copy link
Member

hhugo commented Apr 5, 2023

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.

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

1 participant