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

fix(profiling): Make esbuild detect node binaries with CJS require #15056

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jan 17, 2025

Attempt to fix #15026

esbuild only loads the node binaries when they are loaded with require() in CJS and import() in ESM. By adding a build-time replacement string for rollup, we can either add require or import depending on the build output.

The first approach did not work as the the Node binaries were added to the build output but import() cannot load node binaries (only JS modules). Now, the returned value from createRequire is renamed to require to make it more obvious to e.g. esbuild. However, currently there is no support for createRequire in esbuild: evanw/esbuild#1828

For CJS, the native require is used and not the returned value from createRequire, as this variable would get renamed during build (e.g. require$1) which causes esbuild to ignore the node binaries as well.

@s1gr1d s1gr1d marked this pull request as draft January 17, 2025 14:02
@s1gr1d s1gr1d self-assigned this Jan 20, 2025
@s1gr1d s1gr1d changed the title fix(profiling): Make esbuild load node binaries fix(profiling): Make esbuild load node binaries (only CJS) Jan 22, 2025
@s1gr1d s1gr1d changed the title fix(profiling): Make esbuild load node binaries (only CJS) fix(profiling): Make esbuild detect node binaries with CJS require Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bundling with @sentry/[email protected] no longer outputs .node files, 8.47.0 does
1 participant