diff options
author | Myles Borins <mylesborins@google.com> | 2019-04-25 17:32:04 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2019-05-03 12:14:36 -0700 |
commit | d370d126c3a2ad302cd15ff8063631983d1b4610 (patch) | |
tree | c37824ba9a89b26dfeea46b1c0b6b4cc4303ac62 /doc/api/modules.md | |
parent | 411063c6f5750f4a2243ef5154c589109d9b807c (diff) | |
download | android-node-v8-d370d126c3a2ad302cd15ff8063631983d1b4610.tar.gz android-node-v8-d370d126c3a2ad302cd15ff8063631983d1b4610.tar.bz2 android-node-v8-d370d126c3a2ad302cd15ff8063631983d1b4610.zip |
module: throw on require('./path.mjs');
This is an extremely important part of the ESM implementation
that should have been unflagged as a breaking change in v12.0.0
to allow us to unflag ESM in Node.js 12.x before LTS. Assuming we
can get consensus on this behavior I would argue that this Semver-Major
behavior change could be viewed as a Semver-Patch fix in v12.0.1
PR-URL: https://github.com/nodejs/node/pull/27417
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'doc/api/modules.md')
-rw-r--r-- | doc/api/modules.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/api/modules.md b/doc/api/modules.md index 4acead178e..ca469d635e 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -132,6 +132,13 @@ variable. Since the module lookups using `node_modules` folders are all relative, and based on the real path of the files making the calls to `require()`, the packages themselves can be anywhere. +## Addenda: The .mjs extension + +It is not possible to `require()` files that have the `.mjs` extension. +Attempting to do so will throw [an error][]. The `.mjs` extension is +reserved for [ECMAScript Modules][] which cannot be loaded via `require()`. +See [ECMAScript Modules][] for more details. + ## All Together... <!-- type=misc --> @@ -950,6 +957,8 @@ requireUtil('./some-tool'); [`createRequire()`]: #modules_module_createrequire_filename [`module` object]: #modules_the_module_object [`path.dirname()`]: path.html#path_path_dirname_path +[ECMAScript Modules]: esm.html +[an error]: errors.html#errors_err_require_esm [exports shortcut]: #modules_exports_shortcut [module resolution]: #modules_all_together [module wrapper]: #modules_the_module_wrapper |