TIL Accessing an ESM import variable is 10x slower than CJS because of live bindings
Conversation
Replying to
OP's benchmarks might be influenced by class concerns, but the slowdown is coming from accessing the ESM variable
You can replace the class with a no-op function and get similar results
1
Show replies
Replying to
Possible, but this is optimizable at the engine level. We put in place few invariants that can help, e.g.: accessing these bindings will never throw. It is a matter of pushing implementers to optimize those code paths. That can certainly happen if we start using ESM more in apps.



