[Flight] module.findSourceMap
compatible source URLs when findSourceMapURL
is not implemented
#33969
+119
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementing
findSourceMapURL
is still preferred since it prevents debuggers from overriding the source in the sources panelWhen Client and Server run in the same VM, the Client could reuse the original source URL to get the source map. This isn't possible at the moment since React alters the value from
StructuredCallSite#getScriptNameOrSourceURL
in a way that is incompatible with how Node.js uses this value as a key in its internal source map cache. This mostly works for files with just alphanumeric characters. But it breaks when e.g. square brackets or spaces are used in file paths.The only alternative in Node.js is implementing
findSourceMapURL
by getting the source map payload based on the original source URL and serializing that into adata:
URL. Not only is this wasteful due to the added serialization+deserialization step, it also significantly increases memory consumption since Node.js holds onto source maps forever and doesn't deduplicate sourcemaps on source mapping URLs. Deduplication based on source map URLs is definitely something we should contribute upstream regardless. GCing source maps may be more involved. And then we'd still have the overhead of added serialization+deserialization.Alternate to #33731