| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,8 +7,8 @@ | |||
| 7 | 7 | * {Object} | |
| 8 | 8 | ||
| 9 | 9 | Provides general utility methods when interacting with instances of | |
| 10 | - `Module`, the `module` variable often seen in file modules. Accessed | ||
| 11 | - via `require('module')`. | ||
| 10 | + `Module`, the [`module`][] variable often seen in [CommonJS][] modules. Accessed | ||
| 11 | + via `import 'module'` or `require('module')`. | ||
| 12 | 12 | ||
| 13 | 13 | ### `module.builtinModules` | |
| 14 | 14 | <!-- YAML | |
@@ -27,6 +27,14 @@ if a module is maintained by a third party or not. | |||
| 27 | 27 | by the [module wrapper][]. To access it, require the `Module` module: | |
| 28 | 28 | ||
| 29 | 29 | ```js | |
| 30 | + // module.mjs | ||
| 31 | + // In an ECMAScript module | ||
| 32 | + import { builtinModules as builtin } from 'module'; | ||
| 33 | + ``` | ||
| 34 | + | ||
| 35 | + ```js | ||
| 36 | + // module.cjs | ||
| 37 | + // In a CommonJS module | ||
| 30 | 38 | const builtin = require('module').builtinModules; | |
| 31 | 39 | ``` | |
| 32 | 40 | ||
@@ -74,8 +82,8 @@ added: v12.12.0 | |||
| 74 | 82 | --> | |
| 75 | 83 | ||
| 76 | 84 | The `module.syncBuiltinESMExports()` method updates all the live bindings for | |
| 77 | - builtin ES Modules to match the properties of the CommonJS exports. It does | ||
| 78 | - not add or remove exported names from the ES Modules. | ||
| 85 | + builtin [ES Modules][] to match the properties of the [CommonJS][] exports. It | ||
| 86 | + does not add or remove exported names from the [ES Modules][]. | ||
| 79 | 87 | ||
| 80 | 88 | ```js | |
| 81 | 89 | const fs = require('fs'); | |
@@ -116,6 +124,14 @@ To enable source map parsing, Node.js must be run with the flag | |||
| 116 | 124 | [`NODE_V8_COVERAGE=dir`][]. | |
| 117 | 125 | ||
| 118 | 126 | ```js | |
| 127 | + // module.mjs | ||
| 128 | + // In an ECMAScript module | ||
| 129 | + import { findSourceMap, SourceMap } from 'module'; | ||
| 130 | + ``` | ||
| 131 | + | ||
| 132 | + ```js | ||
| 133 | + // module.cjs | ||
| 134 | + // In a CommonJS module | ||
| 119 | 135 | const { findSourceMap, SourceMap } = require('module'); | |
| 120 | 136 | ``` | |
| 121 | 137 | ||
@@ -192,3 +208,6 @@ consists of the following keys: | |||
| 192 | 208 | [`createRequire()`]: #module_module_createrequire_filename | |
| 193 | 209 | [module wrapper]: modules_cjs.html#modules_cjs_the_module_wrapper | |
| 194 | 210 | [source map include directives]: https://sourcemaps.info/spec.html#h.lmz475t4mvbx | |
| 211 | + [`module`]: modules.html#modules_the_module_object | ||
| 212 | + [CommonJS]: modules.html | ||
| 213 | + [ES Modules]: esm.html | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments