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(cjs-build): enable evaluating import.meta in cjs build #1236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

meienberger
Copy link

Purpose

A while ago, a PR was merged to disable import.meta evaluation altogether to support new versions of Webpack. This sometimes causes issues in CJS projects.

In the comments, there were some discussions about whether we should have a conditional and keep the previous behavior for CJS builds. This PR addresses exactly this by putting back compile-time evaluation of import.meta.url

I have created a comparative build between two projects using the same code and a dependency (@sentry/node) that uses import.meta.url. You can see the difference in the output index.js

Before the change:

Screenshot 2024-11-19 at 20 28 09

After:

Screenshot 2024-11-19 at 20 29 34

Closes #1019

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Please add a test to confirm this is working as expected.

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.

Cannot use 'import.meta' outside a module on 0.36.0 (not 0.34.0)
2 participants