node
node copied to clipboard
lib,src: extract sourceMappingURL from module
Node.js used regex to extract sourceMappingURL from the source code of ESM files. This method led to inaccuracies, notably the erroneous extraction of url from strings. This change attempts to retrieving the correct url from V8 for ESM files.
Refs: #51522
Review requested:
- [ ] @nodejs/loaders
- [ ] @nodejs/vm
@joyeecheung
Shouldn't we extract the sourceURL using the V8 API as well?
This is what I want to do. In fact I initiated this PR after identifying several issues with the source map support in Node.js, notably:
- Node.js utilizes regex to extract sourceURLs in all files and sourceMappingURLs in ESM files,
- Node.js requires the
eval
-ed code text to include both sourceURL and sourceMappingURL for stack trace rewriting.
This PR specifically addresses the handling of sourceMappingURL without delving into sourceURL-related changes. This limitation is intentional to keep the scope manageable for my first contribution to Node.js.
Moving forward, I'm going to resolve the identified issues, including the extraction of sourceURL.
I think it's okay to leave the source URL for a follow-up. Can you leave a TODO/FIXME comment for them?
@joyeecheung Of course! Done.
CI: https://ci.nodejs.org/job/node-test-pull-request/57082/
CI: https://ci.nodejs.org/job/node-test-pull-request/57331/
CI: https://ci.nodejs.org/job/node-test-pull-request/57336/
CI: https://ci.nodejs.org/job/node-test-pull-request/57423/
Landed in fc0f2cf4750a