Commit 949f252ce85 for nodejs

commit 949f252ce85386cbef8a4627358d23c8d8c8446a
Author: Chengzhong Wu <legendecas@gmail.com>
Date:   Sat Nov 28 00:04:43 2026 +0800

    esm: unflag `--experimental-import-text`

    Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
    PR-URL: https://github.com/nodejs/node/pull/67778
    Fixes: https://github.com/nodejs/node/issues/67267
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Paolo Insogna <paolo@cowtech.it>
    Reviewed-By: LiviaMedeiros <livia@cirno.name>
    Reviewed-By: Efe Karasakal <hi@efe.dev>
    Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>

diff --git a/doc/api/cli.md b/doc/api/cli.md
index 288bdbe8a6b..e3260ded1dc 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`
-
-<!-- YAML
-added:
-  - v26.5.0
-  - v24.19.0
--->
-
-> Stability: 1.0 - Early development
-
-Enable experimental support for importing modules with
-`with { type: 'text' }`.
-
 ### `--experimental-inspector-network-resource`

 <!-- YAML
@@ -2333,6 +2320,20 @@ added: v21.2.0

 Disable exposition of [Navigator API][] on the global scope.

+### `--no-experimental-import-text`
+
+<!-- YAML
+added:
+  - v26.5.0
+  - v24.19.0
+changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67778
+    description: Text imports are unflagged but still experimental.
+-->
+
+Disable importing modules with `with { type: 'text' }`.
+
 ### `--no-experimental-require-module`

 <!-- YAML
@@ -4369,7 +4370,6 @@ one is included in the list below.
 * `--experimental-dtls`
 * `--experimental-eventsource`
 * `--experimental-import-meta-resolve`
-* `--experimental-import-text`
 * `--experimental-json-modules`
 * `--experimental-modules`
 * `--experimental-package-map`
@@ -4414,6 +4414,7 @@ one is included in the list below.
 * `--no-deprecation`
 * `--no-experimental-ffi`
 * `--no-experimental-global-navigator`
+* `--no-experimental-import-text`
 * `--no-experimental-sqlite`
 * `--no-experimental-strip-types`
 * `--no-experimental-vfs`
diff --git a/doc/api/esm.md b/doc/api/esm.md
index bc4af89045f..09c4733eb9e 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -708,9 +708,20 @@ imported from the same path.

 ## Text modules

-> Stability: 1.0 - Early development
+<!-- YAML
+added:
+  - v26.5.0
+  - v24.19.0
+changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67778
+    description: Text modules no longer require the `--experimental-import-text`
+                 flag.
+-->
+
+> 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 a8ed4f334fc..2d7a264a7db 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 96755e2950c..35219e28ef1 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 5a59e9eff72..b0e3fba2314 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 e6710d72fd7..63f87534af7 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-errors.js b/test/es-module/test-esm-import-attributes-errors.js
index 5219e8d7b81..c8ffd9320ad 100644
--- a/test/es-module/test-esm-import-attributes-errors.js
+++ b/test/es-module/test-esm-import-attributes-errors.js
@@ -26,11 +26,6 @@ async function test() {
     { code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
   );

-  await assert.rejects(
-    import(jsModuleDataUrl, { with: { type: 'text' } }),
-    { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
-  );
-
   await assert.rejects(
     import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }),
     { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
diff --git a/test/es-module/test-esm-import-attributes-errors.mjs b/test/es-module/test-esm-import-attributes-errors.mjs
index d265e3591be..1168c109fdc 100644
--- a/test/es-module/test-esm-import-attributes-errors.mjs
+++ b/test/es-module/test-esm-import-attributes-errors.mjs
@@ -21,11 +21,6 @@ await assert.rejects(
   { code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
 );

-await assert.rejects(
-  import(jsModuleDataUrl, { with: { type: 'text' } }),
-  { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
-);
-
 await assert.rejects(
   import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }),
   { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
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 9b509a2d08e..94984e08401 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 28084f0393b..2fa67385c64 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';

@@ -10,3 +11,8 @@ await assert.rejects(
   import('data:text/plain,hello%20world', { with: { type: 'text' } }),
   { code: 'ERR_UNKNOWN_MODULE_FORMAT' },
 );
+
+await assert.rejects(
+  import('data:text/javascript,export{}', { with: { type: 'text' } }),
+  { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' },
+);
diff --git a/test/es-module/test-esm-import-text.mjs b/test/es-module/test-esm-import-text.mjs
index cc3dddb26d4..647aed3b78d 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-invalid-data-urls.js b/test/es-module/test-esm-invalid-data-urls.js
index 6eafe75e7d7..765e359aff1 100644
--- a/test/es-module/test-esm-invalid-data-urls.js
+++ b/test/es-module/test-esm-invalid-data-urls.js
@@ -4,15 +4,16 @@ const assert = require('assert');

 (async () => {
   await assert.rejects(import('data:text/plain,export default0'), {
-    code: 'ERR_UNKNOWN_MODULE_FORMAT',
+    code: 'ERR_IMPORT_ATTRIBUTE_MISSING',
     message:
-      'Unknown module format: text/plain for URL data:text/plain,' +
-      'export default0',
+      'Module "data:text/plain,export default0" needs an import attribute ' +
+      'of "type: text"',
   });
   await assert.rejects(import('data:text/plain;base64,'), {
-    code: 'ERR_UNKNOWN_MODULE_FORMAT',
+    code: 'ERR_IMPORT_ATTRIBUTE_MISSING',
     message:
-      'Unknown module format: text/plain for URL data:text/plain;base64,',
+      'Module "data:text/plain;base64," needs an import attribute of ' +
+      '"type: text"',
   });
   await assert.rejects(import('data:text/css,.error { color: red; }'), {
     code: 'ERR_UNKNOWN_MODULE_FORMAT',
diff --git a/test/es-module/test-esm-loader-text-format.mjs b/test/es-module/test-esm-loader-text-format.mjs
index 2a35992dbcf..0fe9c429132 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) {