node icon indicating copy to clipboard operation
node copied to clipboard

lib,src: extract sourceMappingURL from module

Open unbyte opened this issue 1 year ago • 5 comments

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

unbyte avatar Feb 07 '24 07:02 unbyte

Review requested:

  • [ ] @nodejs/loaders
  • [ ] @nodejs/vm

nodejs-github-bot avatar Feb 07 '24 07:02 nodejs-github-bot

@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:

  1. Node.js utilizes regex to extract sourceURLs in all files and sourceMappingURLs in ESM files,
  2. 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.

unbyte avatar Feb 07 '24 16:02 unbyte

I think it's okay to leave the source URL for a follow-up. Can you leave a TODO/FIXME comment for them?

joyeecheung avatar Feb 07 '24 17:02 joyeecheung

@joyeecheung Of course! Done.

unbyte avatar Feb 07 '24 17:02 unbyte

CI: https://ci.nodejs.org/job/node-test-pull-request/57082/

nodejs-github-bot avatar Feb 14 '24 19:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57331/

nodejs-github-bot avatar Feb 23 '24 07:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57336/

nodejs-github-bot avatar Feb 23 '24 09:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57423/

nodejs-github-bot avatar Feb 26 '24 02:02 nodejs-github-bot

Landed in fc0f2cf4750a

legendecas avatar Feb 26 '24 03:02 legendecas