From 795f32bf91070856ee74615da37049d05017c562 Mon Sep 17 00:00:00 2001 From: Ajay A Date: Sat, 8 Nov 2025 15:04:35 +0000 Subject: [PATCH] doc: highlight module loading difference between import and require PR-URL: https://github.com/nodejs/node/pull/59815 Reviewed-By: Chengzhong Wu --- doc/api/esm.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/esm.md b/doc/api/esm.md index 873147ffacd..64e9c68289d 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -332,6 +332,12 @@ syncBuiltinESMExports(); fs.readFileSync === readFileSync; ``` +> When importing built-in modules, all the named exports (i.e. properties of the module exports object) +> are populated even if they are not individually accessed. +> This can make initial imports of built-in modules slightly slower compared to loading them with +> `require()` or `process.getBuiltinModule()`, where the module exports object is evaluated immediately, +> but some of its properties may only be initialized when first accessed individually. + ## `import()` expressions [Dynamic `import()`][] provides an asynchronous way to import modules. It is