From c6ce9fd2e26674bf98f5f07c71e556e169fc759e Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Wed, 13 Nov 2024 23:38:08 +0000 Subject: [PATCH] esm: experimental addon modules --- doc/api/cli.md | 13 +++- doc/api/esm.md | 19 +++-- doc/node.1 | 3 + lib/internal/modules/esm/formats.js | 5 ++ lib/internal/modules/esm/load.js | 3 + lib/internal/modules/esm/translators.js | 81 ++++++++++++++++++--- lib/internal/validators.js | 14 ++++ src/node_options.cc | 4 + src/node_options.h | 1 + test/addons/esm/binding-export-default.cc | 17 +++++ test/addons/esm/binding-export-primitive.cc | 17 +++++ test/addons/esm/binding.cc | 17 +++++ test/addons/esm/binding.gyp | 19 +++++ test/addons/esm/test-esm.mjs | 48 ++++++++++++ test/addons/esm/test.js | 9 +++ 15 files changed, 252 insertions(+), 18 deletions(-) create mode 100644 test/addons/esm/binding-export-default.cc create mode 100644 test/addons/esm/binding-export-primitive.cc create mode 100644 test/addons/esm/binding.cc create mode 100644 test/addons/esm/binding.gyp create mode 100644 test/addons/esm/test-esm.mjs create mode 100644 test/addons/esm/test.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 7b132e701327d1..e5778172a1f96e 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -48,7 +48,8 @@ Otherwise, the file is loaded using the CommonJS module loader. See When loading, the [ES module loader][Modules loaders] loads the program entry point, the `node` command will accept as input only files with `.js`, `.mjs`, or `.cjs` extensions; with `.wasm` extensions when -[`--experimental-wasm-modules`][] is enabled; and with no extension when +[`--experimental-wasm-modules`][] is enabled; with `.node` extensions when +[`--experimental-addon-modules`][] is enabled; and with no extension when [`--experimental-default-type=module`][] is passed. ## Options @@ -903,6 +904,14 @@ and `"` are usable. It is possible to run code containing inline types by passing [`--experimental-strip-types`][]. +### `--experimental-addon-modules` + + + +Enable experimental addon modules with extension `.node` support. + ### `--experimental-default-type=type`