diff options
author | Bradley Farias <bfarias@godaddy.com> | 2019-09-27 12:12:18 -0500 |
---|---|---|
committer | Guy Bedford <guybedford@gmail.com> | 2019-10-05 20:11:15 -0400 |
commit | 0b495a899bdf9a26b25a6e31177512531c841e0e (patch) | |
tree | d0c3a6b3768c0882ddf2eae1a01df419b50bb38f /doc/api/esm.md | |
parent | e1e2f669f65fd53323b8a58d80ed3cee039706b7 (diff) | |
download | node-new-0b495a899bdf9a26b25a6e31177512531c841e0e.tar.gz |
esm: remove proxy for builtin exports
PR-URL: https://github.com/nodejs/node/pull/29737
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r-- | doc/api/esm.md | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md index 5805284016..e0a548f042 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -555,10 +555,11 @@ cjs === 'cjs'; // true ## Builtin modules -Builtin modules will provide named exports of their public API, as well as a -default export which can be used for, among other things, modifying the named -exports. Named exports of builtin modules are updated when the corresponding -exports property is accessed, redefined, or deleted. +Builtin modules will provide named exports of their public API. A +default export is also provided which is the value of the CommonJS exports. +The default export can be used for, among other things, modifying the named +exports. Named exports of builtin modules are updated only by calling +[`module.syncBuiltinESMExports()`][]. ```js import EventEmitter from 'events'; @@ -578,8 +579,10 @@ readFile('./foo.txt', (err, source) => { ```js import fs, { readFileSync } from 'fs'; +import { syncBuiltinESMExports } from 'module'; fs.readFileSync = () => Buffer.from('Hello, ESM'); +syncBuiltinESMExports(); fs.readFileSync === readFileSync; ``` @@ -1008,6 +1011,7 @@ success! [`import.meta.url`]: #esm_import_meta [`import`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import [`module.createRequire()`]: modules.html#modules_module_createrequire_filename +[`module.syncBuiltinESMExports()`]: modules.html#modules_module_syncbuiltinesmexports [dynamic instantiate hook]: #esm_dynamic_instantiate_hook [package exports]: #esm_package_exports [special scheme]: https://url.spec.whatwg.org/#special-scheme |