| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c249289 commit 1eb55f3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -293,12 +293,12 @@ mandatory: | |||
| 293 | 293 | | ---------------- | ---------------- | | |
| 294 | 294 | | `'json'` | [JSON modules][] | | |
| 295 | 295 | ||
| 296 | - ## Builtin modules | ||
| 296 | + ## Built-in modules | ||
| 297 | 297 | ||
| 298 | - [Core modules][] provide named exports of their public API. A | ||
| 298 | + [Built-in modules][] provide named exports of their public API. A | ||
| 299 | 299 | default export is also provided which is the value of the CommonJS exports. | |
| 300 | 300 | The default export can be used for, among other things, modifying the named | |
| 301 | - exports. Named exports of builtin modules are updated only by calling | ||
| 301 | + exports. Named exports of built-in modules are updated only by calling | ||
| 302 | 302 | [`module.syncBuiltinESMExports()`][]. | |
| 303 | 303 | ||
| 304 | 304 | ```js | |
@@ -1145,8 +1145,8 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][]. | |||
| 1145 | 1145 | ||
| 1146 | 1146 | [6.1.7 Array Index]: https://tc39.es/ecma262/#integer-index | |
| 1147 | 1147 | [Addons]: addons.md | |
| 1148 | + [Built-in modules]: modules.md#built-in-modules | ||
| 1148 | 1149 | [CommonJS]: modules.md | |
| 1149 | - [Core modules]: modules.md#core-modules | ||
| 1150 | 1150 | [Determining module system]: packages.md#determining-module-system | |
| 1151 | 1151 | [Dynamic `import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import | |
| 1152 | 1152 | [ES Module Integration Proposal for WebAssembly]: https://github.com/webassembly/esm-integration | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -380,7 +380,7 @@ them as different modules and will reload the file multiple times. For example, | |||
| 380 | 380 | `require('./foo')` and `require('./FOO')` return two different objects, | |
| 381 | 381 | irrespective of whether or not `./foo` and `./FOO` are the same file. | |
| 382 | 382 | ||
| 383 | - ## Core modules | ||
| 383 | + ## Built-in modules | ||
| 384 | 384 | ||
| 385 | 385 | <!--type=misc--> | |
| 386 | 386 | ||
@@ -396,20 +396,31 @@ changes: | |||
| 396 | 396 | Node.js has several modules compiled into the binary. These modules are | |
| 397 | 397 | described in greater detail elsewhere in this documentation. | |
| 398 | 398 | ||
| 399 | - The core modules are defined within the Node.js source and are located in the | ||
| 399 | + The built-in modules are defined within the Node.js source and are located in the | ||
| 400 | 400 | `lib/` folder. | |
| 401 | 401 | ||
| 402 | - Core modules can be identified using the `node:` prefix, in which case | ||
| 402 | + built-in modules can be identified using the `node:` prefix, in which case | ||
| 403 | 403 | it bypasses the `require` cache. For instance, `require('node:http')` will | |
| 404 | 404 | always return the built in HTTP module, even if there is `require.cache` entry | |
| 405 | 405 | by that name. | |
| 406 | 406 | ||
| 407 | - Some core modules are always preferentially loaded if their identifier is | ||
| 407 | + Some built-in modules are always preferentially loaded if their identifier is | ||
| 408 | 408 | passed to `require()`. For instance, `require('http')` will always | |
| 409 | 409 | return the built-in HTTP module, even if there is a file by that name. The list | |
| 410 | - of core modules that can be loaded without using the `node:` prefix is exposed | ||
| 410 | + of built-in modules that can be loaded without using the `node:` prefix is exposed | ||
| 411 | 411 | as [`module.builtinModules`][]. | |
| 412 | 412 | ||
| 413 | + ### Built-in modules with mandatory `node:` prefix | ||
| 414 | + | ||
| 415 | + When being loaded by `require()`, some built-in modules must be requested with the | ||
| 416 | + `node:` prefix. This requirement exists to prevent newly introduced built-in | ||
| 417 | + modules from having a conflict with user land packages that already have | ||
| 418 | + taken the name. Currently the built-in modules that requires the `node:` prefix are: | ||
| 419 | + | ||
| 420 | + * [`node:sea`][] | ||
| 421 | + * [`node:test`][] | ||
| 422 | + * [`node:test/reporters`][] | ||
| 423 | + | ||
| 413 | 424 | ## Cycles | |
| 414 | 425 | ||
| 415 | 426 | <!--type=misc--> | |
@@ -552,7 +563,7 @@ folders as modules, and work for both `require` and `import`. | |||
| 552 | 563 | <!--type=misc--> | |
| 553 | 564 | ||
| 554 | 565 | If the module identifier passed to `require()` is not a | |
| 555 | - [core](#core-modules) module, and does not begin with `'/'`, `'../'`, or | ||
| 566 | + [built-in](#built-in-modules) module, and does not begin with `'/'`, `'../'`, or | ||
| 556 | 567 | `'./'`, then Node.js starts at the directory of the current module, and | |
| 557 | 568 | adds `/node_modules`, and attempts to load the module from that location. | |
| 558 | 569 | Node.js will not append `node_modules` to a path already ending in | |
@@ -1166,6 +1177,9 @@ This section was moved to | |||
| 1166 | 1177 | [`module.id`]: #moduleid | |
| 1167 | 1178 | [`module` core module]: module.md | |
| 1168 | 1179 | [`module` object]: #the-module-object | |
| 1180 | + [`node:sea`]: single-executable-applications.md#single-executable-application-api | ||
| 1181 | + [`node:test/reporters`]: test.md#test-reporters | ||
| 1182 | + [`node:test`]: test.md | ||
| 1169 | 1183 | [`package.json`]: packages.md#nodejs-packagejson-field-definitions | |
| 1170 | 1184 | [`path.dirname()`]: path.md#pathdirnamepath | |
| 1171 | 1185 | [`require.main`]: #requiremain | |
| Back | FazBrowse Home | New Git URL |
0 commit comments