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

feat: add unstable_renameRequire to allow disabling the require rename transform #1230

Conversation

EvanBacon
Copy link
Contributor

Summary

Renaming require to _$$_REQUIRE is an extraneous babel traversal that apparently is used internally at Meta for additional dependency extraction. Since the modules are scoped as iife functions, and there's no special convention to preserve native require syntax, this transform does not appear to add any value to standard projects. Per advice from @robhogan, I've added a flag to disable this transform, which we can enable by default in Expo CLI.

Saves ~165ms when transforming the production react renderer module.

Test plan

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Mar 5, 2024
@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@EvanBacon
Copy link
Contributor Author

Bundling our kitchen sink app (3301 modules):

bun expo export -p ios --no-bytecode --max-workers=0 --no-minify -c

  • Before: 61,953ms
  • After: 58,145ms

I'm finding I can only accurately measure savings with threading disabled. With threads enabled, the results can sometimes be slower, but are ~100ms faster (total average: 27,491ms).

@robhogan robhogan changed the title feat: add unstable_disableRequireRename to disable the require rename transform feat: add unstable_renameRequire to allow disabling the require rename transform Mar 31, 2024
@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.48%. Comparing base (3606983) to head (9d2a3dd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1230   +/-   ##
=======================================
  Coverage   83.48%   83.48%           
=======================================
  Files         207      207           
  Lines       10734    10734           
  Branches     2675     2676    +1     
=======================================
  Hits         8961     8961           
  Misses       1773     1773           

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

@facebook-github-bot
Copy link
Contributor

@robhogan merged this pull request in 7250388.

@EvanBacon EvanBacon deleted the @evanbacon/transform-worker/skip-require-rename branch April 8, 2024 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants