When Andy and I were discussing this initially, I had proposed the following:
- Add "x_ms_mediaTypes" to the source map
- This contains an array of unique media types
- Add "x_ms_sourceMediaTypes" to the source map
- This is a string that contains a variable sized Base64VLQ encoded set of offsets
- Each entry from left-to-right is respective to the same ordinal entry within the "sources" array
- Missing entries are right-filled to the end of the "sources" array
- Each offset is encoded using the Base64 VLQ format, without separators
- If this property is not present, it is assumed that it is filled with offset zero
- No assumption is made on the order of entries in the "sources" array, as that is currently implementation dependent
An example of this encoding might be:
```
{
...
"sources": ["a.js", "b.ts", "c.js", "d.js", "e.js", "f.js"],
...
" x_ms_mediaTypes": ["application/javascript", "application/x.typescript"],
"x_ms_sourceMediaType": "ACBAAA"
}
```
Or, with right-filling:
```
{
...
"sources": ["a.js", "b.ts", "c.js", "d.js", "e.js", "f.js"],
...
"x_ms_mediaTypes": ["application/javascript", "application/x.typescript"],
"x_ms_sourceMediaType": "ACBA"
}
```
The reasons I originally considered using a modified application of Base64 VLQ were:
- By using offsets over indices, long runs of the same media type can be more readily compressed.
- Using a modified application of Base64 VLQ (without separators) reduces uncompressed bytes over the wire, as well as being more readily compressed.
- Tools that understand source maps already understand Base64 VLQ
We ended up going with a parallel array of indices to make it more human readable, though compression and reduced footprint may win out in the end.
Ron
> overloading sourcesMediaType. As these are optional, generally useful, and
> we can add them without changing the meaning of any existing source maps,
> we can add this to the spec without problem. As long as we can agree on the
> form.
>
> Regarding size, Brian and Google Web Toolkit team have been pretty
> successful in reducing the size of the source maps by removing information
> that isn't useful to the debuggers (reducing them to basically line
> mappings rather than token maps). This is controlled by the source map
> producer but can be done as a post-process. But that is a discussion for
> another thread.
>
> If we do add this, I would like to document common "known" media types in
> the spec appendix (CSS,HTML,JS,CoffeeScript,TypeScript,SASS,etc) to reduce
> the ambiguity that naturally comes along with using media types.
>
>
>
>