From a3a2521e2faee9285e51951a1659020c0f524600 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Wed, 25 Nov 2026 10:39:32 -0500 Subject: [PATCH] esm: unflag `--experimental-import-text` Signed-off-by: Chengzhong Wu --- doc/api/cli.md | 29 ++++++++++--------- doc/api/esm.md | 16 ++++++++-- doc/node.1 | 11 ++++--- src/node_options.cc | 3 +- src/node_options.h | 2 +- .../test-defer-import-text-module.mjs | 2 +- ...t-esm-import-attributes-validation-text.js | 2 +- .../test-esm-import-text-disabled.mjs | 1 + test/es-module/test-esm-import-text.mjs | 1 - .../es-module/test-esm-loader-text-format.mjs | 3 +- 10 files changed, 42 insertions(+), 28 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 6a8b3756fe72..948a1e93b7f2 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1516,19 +1516,6 @@ passing a second `parentURL` argument for contextual resolution. Previously gated the entire `import.meta.resolve` feature. -### `--experimental-import-text` - - - -> Stability: 1.0 - Early development - -Enable experimental support for importing modules with -`with { type: 'text' }`. - ### `--experimental-inspector-network-resource` + +Disable importing modules with `with { type: 'text' }`. + ### `--no-experimental-require-module` + +> Stability: 1.2 - Release candidate -Text modules are available behind the `--experimental-import-text` flag. +Text modules can be disabled with the [`--no-experimental-import-text`][] flag. Text files can be referenced by `import`: @@ -1341,6 +1352,7 @@ resolution for ESM specifiers. [`"type"`]: packages.md#type [`--experimental-package-map`]: cli.md#--experimental-package-mappath [`--input-type`]: cli.md#--input-typetype +[`--no-experimental-import-text`]: cli.md#--no-experimental-import-text [`data:` URLs]: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data [`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export [`import()`]: #import-expressions diff --git a/doc/node.1 b/doc/node.1 index 05fc5418e474..5a711e67dc4a 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -880,10 +880,6 @@ Enable experimental \fBimport.meta.resolve()\fR parent URL support, which allows passing a second \fBparentURL\fR argument for contextual resolution. Previously gated the entire \fBimport.meta.resolve\fR feature. . -.It Fl -experimental-import-text -Enable experimental support for importing modules with -\fBwith { type: 'text' }\fR. -. .It Fl -experimental-inspector-network-resource Enable experimental support for inspector network resources. . @@ -1249,6 +1245,9 @@ This flag is only available in builds with FFI support. .It Fl -no-experimental-global-navigator Disable exposition of Navigator API on the global scope. . +.It Fl -no-experimental-import-text +Disable importing modules with \fBwith { type: 'text' }\fR. +. .It Fl -no-experimental-require-module Legacy alias for \fB--no-require-module\fR. . @@ -2318,8 +2317,6 @@ one is included in the list below. .It \fB--experimental-import-meta-resolve\fR .It -\fB--experimental-import-text\fR -.It \fB--experimental-json-modules\fR .It \fB--experimental-modules\fR @@ -2408,6 +2405,8 @@ one is included in the list below. .It \fB--no-experimental-global-navigator\fR .It +\fB--no-experimental-import-text\fR +.It \fB--no-experimental-sqlite\fR .It \fB--no-experimental-strip-types\fR diff --git a/src/node_options.cc b/src/node_options.cc index 96755e2950cf..35219e28ef13 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -869,7 +869,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "experimental support for importing source as text with import " "attributes", BOOL_FIELD(experimental_import_text), - kAllowedInEnvvar); + kAllowedInEnvvar, + true); AddOption("--experimental-import-meta-resolve", "experimental ES Module import.meta.resolve() parentURL support", BOOL_FIELD(experimental_import_meta_resolve), diff --git a/src/node_options.h b/src/node_options.h index 5a59e9eff72e..b0e3fba2314b 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -226,7 +226,7 @@ class EnvironmentOptions : public Options { DEFINE_BOOL_FIELD(experimental_quic) = EXPERIMENTALS_DEFAULT_VALUE; DEFINE_BOOL_FIELD(experimental_global_navigator) = true; DEFINE_BOOL_FIELD(experimental_global_web_crypto) = true; - DEFINE_BOOL_FIELD(experimental_import_text) = EXPERIMENTALS_DEFAULT_VALUE; + DEFINE_BOOL_FIELD(experimental_import_text) = true; DEFINE_BOOL_FIELD(experimental_import_meta_resolve) = EXPERIMENTALS_DEFAULT_VALUE; DEFINE_BOOL_FIELD(entry_is_url) = false; diff --git a/test/es-module/test-defer-import-text-module.mjs b/test/es-module/test-defer-import-text-module.mjs index e6710d72fd73..63f87534af7e 100644 --- a/test/es-module/test-defer-import-text-module.mjs +++ b/test/es-module/test-defer-import-text-module.mjs @@ -1,4 +1,4 @@ -// Flags: --js-defer-import-eval --experimental-import-text +// Flags: --js-defer-import-eval // Test that uses import.defer for a text module. Currently // defer importing of a synthetic module should be a no-op diff --git a/test/es-module/test-esm-import-attributes-validation-text.js b/test/es-module/test-esm-import-attributes-validation-text.js index 9b509a2d08e3..94984e084012 100644 --- a/test/es-module/test-esm-import-attributes-validation-text.js +++ b/test/es-module/test-esm-import-attributes-validation-text.js @@ -1,4 +1,4 @@ -// Flags: --expose-internals --experimental-import-text +// Flags: --expose-internals 'use strict'; require('../common'); diff --git a/test/es-module/test-esm-import-text-disabled.mjs b/test/es-module/test-esm-import-text-disabled.mjs index 28084f0393b0..91681a2559de 100644 --- a/test/es-module/test-esm-import-text-disabled.mjs +++ b/test/es-module/test-esm-import-text-disabled.mjs @@ -1,3 +1,4 @@ +// Flags: --no-experimental-import-text import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-import-text.mjs b/test/es-module/test-esm-import-text.mjs index cc3dddb26d48..647aed3b78dc 100644 --- a/test/es-module/test-esm-import-text.mjs +++ b/test/es-module/test-esm-import-text.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-import-text import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-loader-text-format.mjs b/test/es-module/test-esm-loader-text-format.mjs index 2a35992dbcf4..0fe9c4291325 100644 --- a/test/es-module/test-esm-loader-text-format.mjs +++ b/test/es-module/test-esm-loader-text-format.mjs @@ -1,8 +1,9 @@ +// Flags: --no-experimental-import-text import '../common/index.mjs'; import assert from 'node:assert'; import { registerHooks } from 'node:module'; -// A user loader can use `text` with and without import attributes without the feature flag. +// A user loader can use `text` with and without import attributes when the feature is disabled. registerHooks({ load(url, context, nextLoad) {