lib: defer source map payload decoding until first use · nodejs/node@c2bb3ae · GitHub
Skip to content

Commit c2bb3ae

Browse files
codebytereaduh95
authored andcommitted
lib: defer source map payload decoding until first use
With source maps enabled, every module that carries a sourceMappingURL had its map decoded (or read from disk), JSON-parsed and its sources resolved to absolute URLs while the module was being loaded, and the per-line length table used for coverage was built with a per-code-point loop. None of that is needed unless a stack trace is later mapped. Keep the URL on the cache entry and resolve the payload on the first findSourceMap() for that file. Under NODE_V8_COVERAGE the payload is still resolved at load time, since the cache is serialized during shutdown. lineLengths() now splits on '\n' with indexOf and only falls back to the code point walk when the source contains U+2028/U+2029. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: #65490 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent 127cb31 commit c2bb3ae

2 files changed

Lines changed: 122 additions & 15 deletions

File tree

Lines changed: 77 additions & 0 deletions

‎lib/internal/source_map/source_map_cache.js‎

Lines changed: 45 additions & 15 deletions

0 commit comments

Comments
 (0)