Samuel
@samuel.fm
I did not know what this was a thing, so cool
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. 1 8