Version
- Node.js v24.8.0
- Node.js v22.18.0
Platform
Observed on macOS (x64), but likely reproducible on other platforms.
Description
When loading typescript, using import is ~100ms slower than require.
This seems to come from the cjs-module-lexer step Node.js runs for CommonJS packages. Since typescript itself is CommonJS, require avoids the overhead and is noticeably faster.

Reproduction
https://github.com/chenjiahan/nodejs-repro-require-import-typescript
// import.mjsimporttypescriptfrom"typescript";console.log(typescript);// require.cjsconsttypescript=require("typescript");console.log(typescript);Example results (macOS, Node.js v24.8.0):
# ~200mstime node ./import.mjs
# ~100mstime node ./require.cjs
Ref
Version
Platform
Observed on macOS (x64), but likely reproducible on other platforms.
Description
When loading
typescript, usingimportis ~100ms slower thanrequire.This seems to come from the
cjs-module-lexerstep Node.js runs for CommonJS packages. Sincetypescriptitself is CommonJS,requireavoids the overhead and is noticeably faster.Reproduction
Example results (macOS, Node.js v24.8.0):
Ref