summaryrefslogtreecommitdiff
path: root/doc/api/modules.md
diff options
context:
space:
mode:
authorBradley Farias <bfarias@godaddy.com>2019-09-27 12:12:18 -0500
committerGuy Bedford <guybedford@gmail.com>2019-10-05 20:11:15 -0400
commit0b495a899bdf9a26b25a6e31177512531c841e0e (patch)
treed0c3a6b3768c0882ddf2eae1a01df419b50bb38f /doc/api/modules.md
parente1e2f669f65fd53323b8a58d80ed3cee039706b7 (diff)
downloadandroid-node-v8-0b495a899bdf9a26b25a6e31177512531c841e0e.tar.gz
android-node-v8-0b495a899bdf9a26b25a6e31177512531c841e0e.tar.bz2
android-node-v8-0b495a899bdf9a26b25a6e31177512531c841e0e.zip
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.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/api/modules.md b/doc/api/modules.md
index 32490cf47f..9ed9273e0b 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