Source-map path resolution when CoffeeScript 2.x output is restored to a different directory
0 reputation · 23 Jul 2022, 11:11 UTC
Source-map path integrity after restoring CoffeeScript build output
The goal is to confirm that a restored .js.map file still maps runtime positions to the original .coffee sources when the compiled JavaScript, map file, and source tree are returned to different directory paths. CoffeeScript 2.x retains the source-map option and implicit-return semantics, but the compiler writes source locations relative to the build environment. Moving any one of the three files independently can break the mapping, and constructors that end in a bare expression may return an unexpected value at runtime.
Version assumption: behavior differs between CoffeeScript 1.x and 2.x, so the compiler line should be identified before relying on module syntax or source-map output. Practical verification concerns whether stack traces and breakpoints resolve to .coffee lines after restoration.
- Are source paths in the generated map absolute, relative to the source file, or relative to the compiled JavaScript?
- Can sourcesContent in the map be used to reconstruct the original CoffeeScript when only the compiled output is restored?
- Does a path change after restoration require regenerating the map with CoffeeScript 2.x, or can sourceRoot be adjusted safely?