Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit c75342c

Browse files
concavelenzjkrems
authored andcommitted
Source Map Revision 3 Proposal as of 2013-11-18
Co-authored-by: John Lenz <[email protected]>
1 parent c0dc49a commit c75342c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

source-map-rev3.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ August 20, 2012 | John Lenz | Add CSS linkage recommendation
2222
October 24, 2012 | John Lenz | Add clarifying section on source locations.
2323
February 19, 2013 | John Lenz | Add “sourcesContent” line to support self contained source maps.<p>Added note regarding using data uri to load source maps.
2424
May 16, 2013 | John Lenz | Updated linking convention to use # instead of @. @ conflicts with internet explorer’s conditional code
25+
November 18, 2013 | John Lenz | Noted that “file” is an optional field.<p>Minor typographical corrections
2526

2627
## License
2728

@@ -68,26 +69,26 @@ Source Mapping URL | The URL referencing the location of a source map from the g
6869

6970

7071
1. `{`
71-
2. `version : 3,`
72-
3. `file: "out.js",`
73-
4. `sourceRoot : "",`
74-
5. `sources: ["foo.js", "bar.js"],`
75-
6. `sourcesContent: [null, null],`
76-
7. `names: ["src", "maps", "are", "fun"],`
77-
8. `mappings: "AA,AB;;ABCDE;"`
72+
2. `"version" : 3,`
73+
3. `"file": "out.js",`
74+
4. `"sourceRoot": "",`
75+
5. `"sources": ["foo.js", "bar.js"],`
76+
6. `"sourcesContent": [null, null],`
77+
7. `"names": ["src", "maps", "are", "fun"],`
78+
8. `"mappings": "A,AAAB;;ABCDE;"`
7879
9. `}`
7980

8081
Line 1: The entire file is a single JSON object
8182

8283
Line 2: File version (always the first entry in the object) and must be a positive integer.
8384

84-
Line 3: The name of the generated code that this source map is associated with.
85+
Line 3: An optional name of the generated code that this source map is associated with.
8586

8687
Line 4: An optional source root, useful for relocating source files on a server or removing repeated values in the “sources” entry. This value is prepended to the individual entries in the “source” field.
8788

8889
Line 5: A list of original sources used by the “mappings” entry.
8990

90-
Line 6: An optional list of source content, useful when the “source” can’t be hosted. The contents are listed in the same order as the sources in line 5. “null” may be used of some original sources should be retrieved by name.
91+
Line 6: An optional list of source content, useful when the “source” can’t be hosted. The contents are listed in the same order as the sources in line 5. “null” may be used if some original sources should be retrieved by name.
9192

9293
Line 7: A list of symbol names used by the “mappings” entry.
9394

@@ -218,7 +219,7 @@ The generated code may include a line at the end of the source, with the followi
218219
```
219220

220221

221-
Note: The prefix for this annotation was initially “//@” however this conflicts with Internet Explorer’s conditional comments and was changed to “//#”. It is reasonable for tools to also accept “//@” but “//#” is preferred.
222+
Note: The prefix for this annotation was initially “//@” however this conflicts with Internet Explorer’s Conditional Compilation and was changed to “//#”. It is reasonable for tools to also accept “//@” but “//#” is preferred.
222223

223224
This recommendation works well for JavaScript, it is expected that other source files will have other conventions:
224225

@@ -243,7 +244,7 @@ Regardless of the method used to retrieve the source mapping URL the same proces
243244

244245

245246

246-
* If the generated source is not associated with a script element that has a “src” attribute and there exists a `//@sourceURL` comment in the generated code, that comment should be used to determine the source origin.
247+
* If the generated source is not associated with a script element that has a “src” attribute and there exists a `//# sourceURL` comment in the generated code, that comment should be used to determine the source origin. Note: Previously, this was “//@ sourceURL”, as with “//@ sourceMappingURL”, it is reasonable to accept both but //# is preferred.
247248
* If the generated code is associated with a script element and the script element has a “src” attribute, the “src” attribute of the script element will be the source origin.
248249
* If the generated code is associated with a script element and the script element does not have a “src” attribute, then the source origin will be the page’s origin.
249250
* If the generated code is being evaluated as a string with the `eval()` function or via `new Function()`, then the source origin will be the page’s origin.

0 commit comments

Comments
 (0)