Skip to content

Commit 0b345d8

Browse files
joyeecheungRafaelGSSaduh95
authored
Blog: add more information about require(esm) in v23 (#7126)
* Blog: add more information about require(esm) in v23 * Update apps/site/pages/en/blog/release/v23.0.0.md Co-authored-by: Antoine du Hamel <[email protected]> Signed-off-by: Rafael Gonzaga <[email protected]> --------- Signed-off-by: Rafael Gonzaga <[email protected]> Co-authored-by: Rafael Gonzaga <[email protected]> Co-authored-by: Antoine du Hamel <[email protected]>
1 parent 2801b51 commit 0b345d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

apps/site/pages/en/blog/release/v23.0.0.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ We’re excited to announce the release of Node.js 23! Key highlights include:
1818
Node.js 23 will replace Node.js 22 as the ‘Current’ release line when Node.js 22 enters long-term support (LTS) later this month.
1919
According to the release schedule, Node.js 23 will remain the ‘Current’ release for the next six months, until April 2025.
2020

21+
### `require(esm)` is now enabled by default
22+
23+
Support for loading native ES modules using `require()` had been available on v20.x and v22.x under the command line flag `--experimental-require-module`. In v23.x, this feature is now enabled by default. This feature is still experimental, and we are looking for user feedback to make more final tweaks before fully stabilizing it. For this reason, on v23.x, when the Node.js instance encounters a native ES module in `require()` for the first time, it will emit an experimental warning.
24+
25+
If there happens to be any regressions caused by this feature, users can report it to the Node.js issue tracker. Meanwhile this feature can also be disabled using `--no-experimental-require-module` as a workaround. We expect to test this feature using v23.x, find out any potential regressions and make adjustments accordingly, before backporting the unflagging to v22.x. This will likely happen in a later semver-minor release after the the LTS promotion at the end of October.
26+
27+
With this feature enabled, Node.js will no longer throw `ERR_REQUIRE_ESM` if `require()` is used to load a ES module. It can, however, throw `ERR_REQUIRE_ASYNC_MODULE` if the ES module being loaded or its dependencies contain top-level `await`. When the ES module is loaded successfully by `require()`, the returned object will be a ES module namespace object similar to what's returned by `import()`, and can be checked using `util.isModuleNamespaceObject()`.
28+
29+
Users can check `process.features.require_module` to see whether `require(esm)` is enabled in the current Node.js instance. For packages, the `"module-sync"` exports condition can be used as a way to detect `require(esm)` support in the current Node.js instance and allow both `require()` and `import` to load the same native ES module. See [the documentation](https://nodejs.org/docs/latest/api/modules.html#loading-ecmascript-modules-using-require) for more details about this feature.
30+
2131
### Other Notable Changes
2232

2333
- \[[`7ad0cc3e57`](https://github.com/nodejs/node/commit/7ad0cc3e57)] - **(SEMVER-MAJOR)** **build**: remove support for 32-bit Windows (Michaël Zasso) [#53184](https://github.com/nodejs/node/pull/53184)

0 commit comments

Comments
 (0)