diff options
author | Bradley Farias <bfarias@godaddy.com> | 2019-09-27 20:12:18 +0300 |
---|---|---|
committer | Guy Bedford <guybedford@gmail.com> | 2019-10-06 03:11:15 +0300 |
commit | 0b495a899bdf9a26b25a6e31177512531c841e0e (patch) | |
tree | d0c3a6b3768c0882ddf2eae1a01df419b50bb38f /doc/api/modules.md | |
parent | e1e2f669f65fd53323b8a58d80ed3cee039706b7 (diff) |
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/modules.md')
-rw-r--r-- | doc/api/modules.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/api/modules.md b/doc/api/modules.md index 32490cf47f1..9ed9273e0b5 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -984,6 +984,36 @@ const requireUtil = createRequireFromPath('../src/utils/'); requireUtil('./some-tool'); ``` +### module.syncBuiltinESMExports() +<!-- YAML +added: REPLACEME +--> + +The `module.syncBuiltinESMExports()` method updates all the live bindings for +builtin ES Modules to match the properties of the CommonJS exports. It does +not add or remove exported names from the ES Modules. + +```js +const fs = require('fs'); +const { syncBuiltinESMExports } = require('module'); + +fs.readFile = null; + +delete fs.readFileSync; + +fs.newAPI = function newAPI() { + // ... +}; + +syncBuiltinESMExports(); + +import('fs').then((esmFS) => { + assert.strictEqual(esmFS.readFile, null); + assert.strictEqual('readFileSync' in fs, true); + assert.strictEqual(esmFS.newAPI, undefined); +}); +``` + [GLOBAL_FOLDERS]: #modules_loading_from_the_global_folders [`Error`]: errors.html#errors_class_error [`__dirname`]: #modules_dirname |