ncc icon indicating copy to clipboard operation
ncc copied to clipboard

fix(cjs-build): enable evaluating import.meta in cjs build

Open nicotsx opened this issue 1 year ago • 0 comments

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

nicotsx avatar Nov 19 '24 19:11 nicotsx