-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process: add lineLength to source-map-cache #29863
Conversation
|
||
const debug = require('internal/util/debuglog').debuglog('source_map'); | ||
const { findSourceMap } = require('internal/source_map/source_map_cache'); | ||
const { overrideStackTrace } = require('internal/errors'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled prepare_stack_trace.js
into its own file, because it seemed like it wasn't directly related to the source map caching functionality (and source_map_cache.js
was starting to get a bit confusing).
@@ -38,18 +37,22 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance) { | |||
|
|||
const match = content.match(/\/[*/]#\s+sourceMappingURL=(?<sourceMappingURL>[^\s]+)/); | |||
if (match) { | |||
const data = dataFromUrl(basePath, match.groups.sourceMappingURL); | |||
const url = data ? null : match.groups.sourceMappingURL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's getting to the point where we write quite a bit of data to disk (and memory) -- we don't actually need the url
field, if we've successfully parsed the map, so let's avoid storing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can't really comment on the changes to the source map logic but everything else looks ok
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@targos I believe I've addressed your comments, mind giving this a final look? |
This comment has been minimized.
This comment has been minimized.
Without the line lengths of in-memory transpiled source, it's not possible to convert from byte ofsets to line/column offsets.
1a5488c
to
15994ab
Compare
This comment has been minimized.
This comment has been minimized.
Without the line lengths of in-memory transpiled source, it's not possible to convert from byte ofsets to line/column offsets. PR-URL: #29863 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 4ca61f4 |
Without the line lengths of in-memory transpiled source, it's not possible to convert from byte ofsets to line/column offsets. PR-URL: #29863 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Without the line lengths of in-memory transpiled source, it's not possible to convert from byte ofsets to line/column offsets. PR-URL: #29863 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesProblem
I realized when integrating source-map functionality with coverage that we're missing a piece of information necessary to support tools like ts-node:
require.extensions
) we lack enough information to translate from bytes to lines/columns.we end up with a bad reports that look like this, due to missing information:
👆 note that exactly the wrong code is highlighted 😆
Solution
If we track the line lengths of the source file that source maps were extracted from, this provides enough information to remap from byte offset to line/column offset.
I've introduced an additional value into the cache,
lineLengths
, to facilitate this.we can now generate the following report: