Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 795f32b

Browse filesBrowse files
Ajay-2005aduh95
authored andcommitted
doc: highlight module loading difference between import and require
PR-URL: #59815 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 2127754 commit 795f32b
Copy full SHA for 795f32b

File tree

Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ syncBuiltinESMExports();
332332
fs.readFileSync === readFileSync;
333333
```
334334

335+
> When importing built-in modules, all the named exports (i.e. properties of the module exports object)
336+
> are populated even if they are not individually accessed.
337+
> This can make initial imports of built-in modules slightly slower compared to loading them with
338+
> `require()` or `process.getBuiltinModule()`, where the module exports object is evaluated immediately,
339+
> but some of its properties may only be initialized when first accessed individually.
340+
335341
## `import()` expressions
336342

337343
[Dynamic `import()`][] provides an asynchronous way to import modules. It is

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.