mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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>
This commit is contained in:
1 parent
2fdac690b4
commit
949f252ce8
13 files changed
+53
-43
No files matched your search
+15
-14
@@ -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`
|
||||
|
||||
+14
-2
@@ -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.
|
||||
-->
|
||||
|
||||
Text modules are available behind the `--experimental-import-text` flag.
|
||||
> Stability: 1.2 - Release candidate
|
||||
|
||||
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
|
||||
|
||||
+5
-6
@@ -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
|
||||
|
||||
+2
-1
@@ -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),
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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' }
|
||||
|
||||
@@ -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' }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --expose-internals --experimental-import-text
|
||||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
|
||||
@@ -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' },
|
||||
);
|
||||
@@ -1,4 +1,3 @@
|
||||
// Flags: --experimental-import-text
|
||||
import '../common/index.mjs';
|
||||
import assert from 'assert';
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user