You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we're trying to harmonize source map implementations, it would be useful to list all of the implementations we can find, so that we can then compare them. This includes both generators and consumers.
I'll put forward the Scala.js compiler as generator.
Some of our interpretations are:
Every source tree carries its source position through transformations (counting the entire pipeline, there are dozens of transformation phases) and eventually reaches every JavaScript AST node.
When printing a JS AST node, we emit source map segments that point to its position for all the text it generates, unless overridden by children nodes. So for example, an expression (a + b) attaches the parens, spaces and + sign to the position of the AST node for +, while a and b are attached to the positions of the identifier AST nodes.
We only give original names to the definition of identifiers. In let a = 1; a only the first a receives an original name in the source map.
Our source files are UTF-8 encoded usually, and strings in Scala are ~UTF-16 (like JS). In terms of output, we always emit ASCII.
In terms of implementation, perhaps one key aspect is that it is specialized for an incremental compilation pipeline. When changing part of a source program, the entire Scala compilation pipeline is incremental end-to-end, and that until re-pretting JS AST nodes and generating source maps. Source maps are actually a pain point here, since they must be regenerated from top to bottom every time. We have an intermediate data structure consisting of Fragments to make that as efficient as we could.
Will there be interesting differences between uses of the libraries when it comes to what we'd want to specify? E.g. will all users of mozilla/source-map generate "spec compliant source maps in all ways we care about" as soon as mozilla/source-map has been updated in accordance with a future hardened spec?
If not, it may also be helpful to collect things like postcss which indirectly produce source maps.
Activity
bomsy commentedon Jun 14, 2023
These would also be super helpful for understanding the systems to be tested.
Here is an implementation from mozilla used in firefox
https://github.com/mozilla/source-map
sjrd commentedon Jun 14, 2023
I'll put forward the Scala.js compiler as generator.
Some of our interpretations are:
(a + b)attaches the parens, spaces and+sign to the position of the AST node for+, whileaandbare attached to the positions of the identifier AST nodes.namesto the definition of identifiers. Inlet a = 1; aonly the firstareceives an original name in the source map.In terms of implementation, perhaps one key aspect is that it is specialized for an incremental compilation pipeline. When changing part of a source program, the entire Scala compilation pipeline is incremental end-to-end, and that until re-pretting JS AST nodes and generating source maps. Source maps are actually a pain point here, since they must be regenerated from top to bottom every time. We have an intermediate data structure consisting of
Fragments to make that as efficient as we could.You can see our implementation here:
https://github.com/scala-js/scala-js/blob/v1.13.1/linker/shared/src/main/scala/org/scalajs/linker/backend/javascript/SourceMapWriter.scala
If you're not familiar with Scala, it's worth noting that this file looks nothing like typical Scala code. This is almost C code written with Scala syntax, because of how performance-sensitive it is.
7rulnik commentedon Jun 14, 2023
There is also a fork of source-map — https://github.com/7rulnik/source-map-js
mitsuhiko commentedon Jun 14, 2023
This is our Rust library: https://crates.io/crates/sourcemap
The most notable users of this library to the best of my knowledge are Sentry, SWC and Deno.
It's pretty low level, we have higher level wrappers on top of that (js-source-scopes, symbolic, and symbolicator) for consumption.
jaro-sevcik commentedon Jun 14, 2023
Here is Chrome DevTools implementation: https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/core/sdk/SourceMap.ts
connor4312 commentedon Jun 14, 2023
There is also https://www.npmjs.com/package/@jridgewell/source-map which is namely used in Terser. It tries to be compatible with Mozilla's source map library, but I have found some variance in the past.
hybrist commentedon Jun 14, 2023
Will there be interesting differences between uses of the libraries when it comes to what we'd want to specify? E.g. will all users of mozilla/source-map generate "spec compliant source maps in all ways we care about" as soon as mozilla/source-map has been updated in accordance with a future hardened spec?
If not, it may also be helpful to collect things like postcss which indirectly produce source maps.
jridgewell commentedon Jun 14, 2023
I maintain:
ochameau commentedon Jul 12, 2023
While trying to revive mozilla original source-map implementation, I went throught all major source map implementations I could easily find online and come up with this summary:
https://docs.google.com/document/d/1cRNI5s9ECI6V7argqw0g7TDp79gNrOZiVYLIRDD9FlA/edit#heading=h.3dsnp8frk1tz
You will see links to sources of each of them and some recap about the specifics of each.
sokra commentedon Sep 22, 2023
https://github.com/webpack/webpack-sources has a SourceMap implementation here: https://github.com/webpack/webpack-sources/blob/main/lib/SourceMapSource.js
legendecas commentedon Oct 8, 2023
SourceMap in Node.js: https://github.com/nodejs/node/tree/main/lib/internal/source_map
mischnic commentedon Nov 15, 2023
https://github.com/parcel-bundler/source-map is used by Parcel and Lightning CSS
mswilson commentedon Aug 3, 2026
https://github.com/benthemonkey/source-map