Skip to content

add ability to generate chained sourcemap for precompiled sources #372

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

karthik2804
Copy link
Collaborator

This PR adds the capability to the build tooling to chain the source map for the precompiled source with the input source map, allowing for better debugging.

In a follow-up PR, the plan is to move to build instead of webpack because the source maps generated by build are friendlier.

cc: @itowlson

@karthik2804 karthik2804 marked this pull request as draft July 23, 2025 10:50
@karthik2804
Copy link
Collaborator Author

Converting to draft to fix up a couple of alignment issues.

This commit fixes updating the sourcemap comment to point to the right
file. It also updates the test to use esbuild instead of webpack as the
sourcemaps generated by esbuild are friendlier without webpack speicif
protocol representing files. As we move to esbuild, the existing webpack
plugin is modified to suit esbuild as well.

Signed-off-by: Karthik Ganeshram <[email protected]>
@karthik2804 karthik2804 marked this pull request as ready for review July 23, 2025 11:48
@karthik2804
Copy link
Collaborator Author

The test has been updated to use esbuild and now the precompiled-source.js.map which is generated along with precompiled-source.js map back directly to the sources chaining the one generated by the build process. Note that we do not resolve maps inside the node_modules folder as some NPM packages have sourcemaps but not the source bundled.

@karthik2804
Copy link
Collaborator Author

@tschneidereit friendly bump for a review. Thanks!

Copy link
Collaborator

@tschneidereit tschneidereit left a comment

Choose a reason for hiding this comment

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

Apologies for the delay!

Comment on lines +12 to +18
build.onLoad({ filter: /node_modules/ }, args => {
return {
contents: fs.readFileSync(args.path, 'utf8')
+ '\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==',
loader: 'default',
}
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not blocking anything, but it'd be nice to have a comment here explaining how this test works: I have no idea how it does, myself :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated with a comment. But this basically stubs sourcemaps references by npm packages to avoid issues where the sourcemap refer to files not included in the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants