Skip to content

Commit 949f252

Browse files
authored
esm: unflag --experimental-import-text
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net> PR-URL: #67778 Fixes: #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>
1 parent 2fdac69 commit 949f252

13 files changed

Lines changed: 53 additions & 43 deletions

‎doc/api/cli.md‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,19 +1516,6 @@ passing a second `parentURL` argument for contextual resolution.
15161516

15171517
Previously gated the entire `import.meta.resolve` feature.
15181518

1519-
### `--experimental-import-text`
1520-
1521-
<!-- YAML
1522-
added:
1523-
- v26.5.0
1524-
- v24.19.0
1525-
-->
1526-
1527-
> Stability: 1.0 - Early development
1528-
1529-
Enable experimental support for importing modules with
1530-
`with { type: 'text' }`.
1531-
15321519
### `--experimental-inspector-network-resource`
15331520

15341521
<!-- YAML
@@ -2333,6 +2320,20 @@ added: v21.2.0
23332320
23342321
Disable exposition of [Navigator API][] on the global scope.
23352322

2323+
### `--no-experimental-import-text`
2324+
2325+
<!-- YAML
2326+
added:
2327+
- v26.5.0
2328+
- v24.19.0
2329+
changes:
2330+
- version: REPLACEME
2331+
pr-url: https://github.com/nodejs/node/pull/67778
2332+
description: Text imports are unflagged but still experimental.
2333+
-->
2334+
2335+
Disable importing modules with `with { type: 'text' }`.
2336+
23362337
### `--no-experimental-require-module`
23372338

23382339
<!-- YAML
@@ -4369,7 +4370,6 @@ one is included in the list below.
43694370
* `--experimental-dtls`
43704371
* `--experimental-eventsource`
43714372
* `--experimental-import-meta-resolve`
4372-
* `--experimental-import-text`
43734373
* `--experimental-json-modules`
43744374
* `--experimental-modules`
43754375
* `--experimental-package-map`
@@ -4414,6 +4414,7 @@ one is included in the list below.
44144414
* `--no-deprecation`
44154415
* `--no-experimental-ffi`
44164416
* `--no-experimental-global-navigator`
4417+
* `--no-experimental-import-text`
44174418
* `--no-experimental-sqlite`
44184419
* `--no-experimental-strip-types`
44194420
* `--no-experimental-vfs`

‎doc/api/esm.md‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,20 @@ imported from the same path.
708708
709709
## Text modules
710710
711-
> Stability: 1.0 - Early development
711+
<!-- YAML
712+
added:
713+
- v26.5.0
714+
- v24.19.0
715+
changes:
716+
- version: REPLACEME
717+
pr-url: https://github.com/nodejs/node/pull/67778
718+
description: Text modules no longer require the `--experimental-import-text`
719+
flag.
720+
-->
721+
722+
> Stability: 1.2 - Release candidate
712723
713-
Text modules are available behind the `--experimental-import-text` flag.
724+
Text modules can be disabled with the [`--no-experimental-import-text`][] flag.
714725
715726
Text files can be referenced by `import`:
716727
@@ -1341,6 +1352,7 @@ resolution for ESM specifiers.
13411352
[`"type"`]: packages.md#type
13421353
[`--experimental-package-map`]: cli.md#--experimental-package-mappath
13431354
[`--input-type`]: cli.md#--input-typetype
1355+
[`--no-experimental-import-text`]: cli.md#--no-experimental-import-text
13441356
[`data:` URLs]: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data
13451357
[`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
13461358
[`import()`]: #import-expressions

‎doc/node.1‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -880,10 +880,6 @@ Enable experimental \fBimport.meta.resolve()\fR parent URL support, which allows
880880
passing a second \fBparentURL\fR argument for contextual resolution.
881881
Previously gated the entire \fBimport.meta.resolve\fR feature.
882882
.
883-
.It Fl -experimental-import-text
884-
Enable experimental support for importing modules with
885-
\fBwith { type: 'text' }\fR.
886-
.
887883
.It Fl -experimental-inspector-network-resource
888884
Enable experimental support for inspector network resources.
889885
.
@@ -1249,6 +1245,9 @@ This flag is only available in builds with FFI support.
12491245
.It Fl -no-experimental-global-navigator
12501246
Disable exposition of Navigator API on the global scope.
12511247
.
1248+
.It Fl -no-experimental-import-text
1249+
Disable importing modules with \fBwith { type: 'text' }\fR.
1250+
.
12521251
.It Fl -no-experimental-require-module
12531252
Legacy alias for \fB--no-require-module\fR.
12541253
.
@@ -2318,8 +2317,6 @@ one is included in the list below.
23182317
.It
23192318
\fB--experimental-import-meta-resolve\fR
23202319
.It
2321-
\fB--experimental-import-text\fR
2322-
.It
23232320
\fB--experimental-json-modules\fR
23242321
.It
23252322
\fB--experimental-modules\fR
@@ -2408,6 +2405,8 @@ one is included in the list below.
24082405
.It
24092406
\fB--no-experimental-global-navigator\fR
24102407
.It
2408+
\fB--no-experimental-import-text\fR
2409+
.It
24112410
\fB--no-experimental-sqlite\fR
24122411
.It
24132412
\fB--no-experimental-strip-types\fR

‎src/node_options.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
869869
"experimental support for importing source as text with import "
870870
"attributes",
871871
BOOL_FIELD(experimental_import_text),
872-
kAllowedInEnvvar);
872+
kAllowedInEnvvar,
873+
true);
873874
AddOption("--experimental-import-meta-resolve",
874875
"experimental ES Module import.meta.resolve() parentURL support",
875876
BOOL_FIELD(experimental_import_meta_resolve),

‎src/node_options.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class EnvironmentOptions : public Options {
226226
DEFINE_BOOL_FIELD(experimental_quic) = EXPERIMENTALS_DEFAULT_VALUE;
227227
DEFINE_BOOL_FIELD(experimental_global_navigator) = true;
228228
DEFINE_BOOL_FIELD(experimental_global_web_crypto) = true;
229-
DEFINE_BOOL_FIELD(experimental_import_text) = EXPERIMENTALS_DEFAULT_VALUE;
229+
DEFINE_BOOL_FIELD(experimental_import_text) = true;
230230
DEFINE_BOOL_FIELD(experimental_import_meta_resolve) =
231231
EXPERIMENTALS_DEFAULT_VALUE;
232232
DEFINE_BOOL_FIELD(entry_is_url) = false;

‎test/es-module/test-defer-import-text-module.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --js-defer-import-eval --experimental-import-text
1+
// Flags: --js-defer-import-eval
22

33
// Test that uses import.defer for a text module. Currently
44
// defer importing of a synthetic module should be a no-op

‎test/es-module/test-esm-import-attributes-errors.js‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ async function test() {
2626
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
2727
);
2828

29-
await assert.rejects(
30-
import(jsModuleDataUrl, { with: { type: 'text' } }),
31-
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
32-
);
33-
3429
await assert.rejects(
3530
import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }),
3631
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }

‎test/es-module/test-esm-import-attributes-errors.mjs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ await assert.rejects(
2121
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
2222
);
2323

24-
await assert.rejects(
25-
import(jsModuleDataUrl, { with: { type: 'text' } }),
26-
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
27-
);
28-
2924
await assert.rejects(
3025
import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }),
3126
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }

‎test/es-module/test-esm-import-attributes-validation-text.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --expose-internals --experimental-import-text
1+
// Flags: --expose-internals
22
'use strict';
33
require('../common');
44

‎test/es-module/test-esm-import-text-disabled.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --no-experimental-import-text
12
import '../common/index.mjs';
23
import assert from 'assert';
34

@@ -10,3 +11,8 @@ await assert.rejects(
1011
import('data:text/plain,hello%20world', { with: { type: 'text' } }),
1112
{ code: 'ERR_UNKNOWN_MODULE_FORMAT' },
1213
);
14+
15+
await assert.rejects(
16+
import('data:text/javascript,export{}', { with: { type: 'text' } }),
17+
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' },
18+
);

0 commit comments

Comments
 (0)