Skip to content
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

lib,src: extract sourceMappingURL from module #51690

Closed
wants to merge 7 commits into from

Conversation

unbyte
Copy link
Contributor

@unbyte unbyte commented Feb 7, 2024

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

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/vm

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Feb 7, 2024
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if tests pass, left a few nits

@unbyte unbyte requested a review from aduh95 February 7, 2024 15:30
Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we extract the sourceURL using the V8 API as well?

@unbyte
Copy link
Contributor Author

unbyte commented Feb 7, 2024

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

@joyeecheung
Copy link
Member

joyeecheung commented Feb 7, 2024

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

@unbyte
Copy link
Contributor Author

unbyte commented Feb 7, 2024

@joyeecheung
Of course! Done.

@legendecas legendecas added request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Feb 8, 2024
Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

Note for who lands this PR: please amend the commit message with the PR title as the message of the first commit was not aligned with it.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 14, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@legendecas legendecas added the source maps Issues and PRs related to source map support. label Feb 26, 2024
@nodejs-github-bot
Copy link
Collaborator

legendecas pushed a commit that referenced this pull request Feb 26, 2024
PR-URL: #51690
Refs: #51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@legendecas
Copy link
Member

Landed in fc0f2cf

@legendecas legendecas closed this Feb 26, 2024
marco-ippolito pushed a commit that referenced this pull request Feb 26, 2024
PR-URL: #51690
Refs: #51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Feb 26, 2024
PR-URL: #51690
Refs: #51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Feb 27, 2024
PR-URL: #51690
Refs: #51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@marco-ippolito marco-ippolito mentioned this pull request Mar 1, 2024
richardlau pushed a commit that referenced this pull request Mar 25, 2024
PR-URL: #51690
Refs: #51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
PR-URL: #51690
Refs: #51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@richardlau richardlau mentioned this pull request Mar 25, 2024
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
PR-URL: nodejs#51690
Refs: nodejs#51522
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. source maps Issues and PRs related to source map support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants