| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3a4a0eb commit a8601ef
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -285,12 +285,12 @@ mandatory: | |||
| 285 | 285 | | ---------------- | ---------------- | | |
| 286 | 286 | | `'json'` | [JSON modules][] | | |
| 287 | 287 | ||
| 288 | - ## Builtin modules | ||
| 288 | + ## Built-in modules | ||
| 289 | 289 | ||
| 290 | - [Core modules][] provide named exports of their public API. A | ||
| 290 | + [Built-in modules][] provide named exports of their public API. A | ||
| 291 | 291 | default export is also provided which is the value of the CommonJS exports. | |
| 292 | 292 | The default export can be used for, among other things, modifying the named | |
| 293 | - exports. Named exports of builtin modules are updated only by calling | ||
| 293 | + exports. Named exports of built-in modules are updated only by calling | ||
| 294 | 294 | [`module.syncBuiltinESMExports()`][]. | |
| 295 | 295 | ||
| 296 | 296 | ```js | |
@@ -1128,8 +1128,8 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][]. | |||
| 1128 | 1128 | ||
| 1129 | 1129 | [6.1.7 Array Index]: https://tc39.es/ecma262/#integer-index | |
| 1130 | 1130 | [Addons]: addons.md | |
| 1131 | + [Built-in modules]: modules.md#built-in-modules | ||
| 1131 | 1132 | [CommonJS]: modules.md | |
| 1132 | - [Core modules]: modules.md#core-modules | ||
| 1133 | 1133 | [Determining module system]: packages.md#determining-module-system | |
| 1134 | 1134 | [Dynamic `import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import | |
| 1135 | 1135 | [ES Module Integration Proposal for WebAssembly]: https://github.com/webassembly/esm-integration | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,7 +312,7 @@ them as different modules and will reload the file multiple times. For example, | |||
| 312 | 312 | `require('./foo')` and `require('./FOO')` return two different objects, | |
| 313 | 313 | irrespective of whether or not `./foo` and `./FOO` are the same file. | |
| 314 | 314 | ||
| 315 | - ## Core modules | ||
| 315 | + ## Built-in modules | ||
| 316 | 316 | ||
| 317 | 317 | <!--type=misc--> | |
| 318 | 318 | ||
@@ -328,20 +328,31 @@ changes: | |||
| 328 | 328 | Node.js has several modules compiled into the binary. These modules are | |
| 329 | 329 | described in greater detail elsewhere in this documentation. | |
| 330 | 330 | ||
| 331 | - The core modules are defined within the Node.js source and are located in the | ||
| 331 | + The built-in modules are defined within the Node.js source and are located in the | ||
| 332 | 332 | `lib/` folder. | |
| 333 | 333 | ||
| 334 | - Core modules can be identified using the `node:` prefix, in which case | ||
| 334 | + built-in modules can be identified using the `node:` prefix, in which case | ||
| 335 | 335 | it bypasses the `require` cache. For instance, `require('node:http')` will | |
| 336 | 336 | always return the built in HTTP module, even if there is `require.cache` entry | |
| 337 | 337 | by that name. | |
| 338 | 338 | ||
| 339 | - Some core modules are always preferentially loaded if their identifier is | ||
| 339 | + Some built-in modules are always preferentially loaded if their identifier is | ||
| 340 | 340 | passed to `require()`. For instance, `require('http')` will always | |
| 341 | 341 | return the built-in HTTP module, even if there is a file by that name. The list | |
| 342 | - of core modules that can be loaded without using the `node:` prefix is exposed | ||
| 342 | + of built-in modules that can be loaded without using the `node:` prefix is exposed | ||
| 343 | 343 | as [`module.builtinModules`][]. | |
| 344 | 344 | ||
| 345 | + ### Built-in modules with mandatory `node:` prefix | ||
| 346 | + | ||
| 347 | + When being loaded by `require()`, some built-in modules must be requested with the | ||
| 348 | + `node:` prefix. This requirement exists to prevent newly introduced built-in | ||
| 349 | + modules from having a conflict with user land packages that already have | ||
| 350 | + taken the name. Currently the built-in modules that requires the `node:` prefix are: | ||
| 351 | + | ||
| 352 | + * [`node:sea`][] | ||
| 353 | + * [`node:test`][] | ||
| 354 | + * [`node:test/reporters`][] | ||
| 355 | + | ||
| 345 | 356 | ## Cycles | |
| 346 | 357 | ||
| 347 | 358 | <!--type=misc--> | |
@@ -484,7 +495,7 @@ folders as modules, and work for both `require` and `import`. | |||
| 484 | 495 | <!--type=misc--> | |
| 485 | 496 | ||
| 486 | 497 | If the module identifier passed to `require()` is not a | |
| 487 | - [core](#core-modules) module, and does not begin with `'/'`, `'../'`, or | ||
| 498 | + [built-in](#built-in-modules) module, and does not begin with `'/'`, `'../'`, or | ||
| 488 | 499 | `'./'`, then Node.js starts at the directory of the current module, and | |
| 489 | 500 | adds `/node_modules`, and attempts to load the module from that location. | |
| 490 | 501 | Node.js will not append `node_modules` to a path already ending in | |
@@ -1097,6 +1108,9 @@ This section was moved to | |||
| 1097 | 1108 | [`module.id`]: #moduleid | |
| 1098 | 1109 | [`module` core module]: module.md | |
| 1099 | 1110 | [`module` object]: #the-module-object | |
| 1111 | + [`node:sea`]: single-executable-applications.md#single-executable-application-api | ||
| 1112 | + [`node:test/reporters`]: test.md#test-reporters | ||
| 1113 | + [`node:test`]: test.md | ||
| 1100 | 1114 | [`package.json`]: packages.md#nodejs-packagejson-field-definitions | |
| 1101 | 1115 | [`path.dirname()`]: path.md#pathdirnamepath | |
| 1102 | 1116 | [`require.main`]: #requiremain | |
| Back | FazBrowse Home | New Git URL |
0 commit comments