PostsBlogReposAbout
Samuel27 Oct 2023
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
Alona28 Oct 2023
oooh, where is this, i wanna read more
2
Samuel
@samuel.fm
github.com/bluesky-soci...
Enable inline requires by gaearon · Pull Request #1756 · bluesky-social/social-app
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 ...
github.com
1
28 October 2023 at 9:30 amView on Bluesky