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

ref: No more dynamic requires #801

Merged
merged 2 commits into from
Feb 21, 2025
Merged

ref: No more dynamic requires #801

merged 2 commits into from
Feb 21, 2025

Conversation

BYK
Copy link
Member

@BYK BYK commented Feb 21, 2025

This patch changes all dynamic requires except for a few, 'safe' cases and 'sentry/cli' related ones as it will be removed in a follow up

This patch changes all dynamic requires except for a few, 'safe' cases and 'sentry/cli' related ones as it will be removed in a follow up
@BYK BYK requested a review from Lms24 February 21, 2025 10:28
@BYK BYK enabled auto-merge (squash) February 21, 2025 10:28
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 49.67%. Comparing base (5705509) to head (68b3c55).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/telemetry.ts 40.00% 3 Missing ⚠️
src/nextjs/templates.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #801      +/-   ##
==========================================
- Coverage   49.70%   49.67%   -0.03%     
==========================================
  Files          52       52              
  Lines        3501     3503       +2     
  Branches      824      825       +1     
==========================================
  Hits         1740     1740              
- Misses       1627     1628       +1     
- Partials      134      135       +1     
Flag Coverage Δ
e2e-tests 84.61% <ø> (ø)
unit-tests 48.32% <75.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Had a question about opn but otherwise LGTM


try {
// If we run directly in setup-wizard
projectPackage = require('../../package.json');
projectPackage = JSON.parse(
readFileSync('../../package.json', 'utf-8'),
Copy link
Member

Choose a reason for hiding this comment

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

Funny story about these: require is more fault tolerant than JSON.parse. Bun decided to permit comments in package.json files. Whatever drove them to make this decision is beyond me but here we are. JSON.parse will crash on Json with comments.

I opened #561 a while ago but closed it because it never came up in reality. I'm fine with using JSON.parse for the moment and revisit when people actually report crashes.

Gotta love the JS ecosystem

Copy link
Member Author

Choose a reason for hiding this comment

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

It is tricky to make dynamic requires work with the static binaries. It is not impossible but is a bit more explicit (you need to use node:module and do makeRequire with an explicit starting path).

If we get complaints, I can switch to that.

@BYK BYK requested a review from Lms24 February 21, 2025 10:55
@BYK BYK merged commit 668f183 into master Feb 21, 2025
19 checks passed
@BYK BYK deleted the byk/ref/death-to-requires branch February 21, 2025 10:57
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.

2 participants