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

Enable inline requires #1756

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Enable inline requires #1756

merged 1 commit into from
Oct 27, 2023

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Oct 26, 2023

Inline requires are a (technically not entirely safe) optimization that defers module initialization until an export from that module is actually used in the code. For example:

import { foo } from './foo' // DOES NOT trigger ./foo.js initialization

function doSomething() {
  console.log(foo) // TRIGGERS foo.js initialization
}

It's enabled in FB apps and is crucial for performance. It's not entirely safe because it relies on modules with exports not having temporal order sensitive global side effects. However, that's best practice anyway.

Not sure if this actually has perf impact for us. Measurements TBD.

Measurements (PROD mid/lower-range Android):

  • Logged out start time: 14s -> 9s
  • Logged in start time: 16s -> 11s

TODO

  • Check if this applies to default exports too (inlineRequires: true not working on default exports/imports facebook/metro#909)
  • Check that it actually fully works as expected — yes it does
  • Check if we should be using experimentalImportSupport seems fine?
  • Check if we should be using disableImportExportTransform seems fine?
  • Check that it doesn't break web — it doesn't because it's Metro-only

@gaearon gaearon requested a review from pfrazee October 27, 2023 00:37
Copy link
Collaborator

@pfrazee pfrazee left a comment

Choose a reason for hiding this comment

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

Yeah looks good!

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