Skip to content

Commit cf23a89

Browse files
skyclouds2001RafaelGSS
authored andcommitted
doc: update unflag info of import.meta.resolve
PR-URL: #55810 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent dd99c78 commit cf23a89

File tree

1 file changed

+32
-80
lines changed

1 file changed

+32
-80
lines changed

doc/api/esm.md

Lines changed: 32 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
<!-- YAML
88
added: v8.5.0
99
changes:
10-
- version: v20.18.3
10+
- version: REPLACEME
1111
pr-url: https://github.com/nodejs/node/pull/55333
1212
description: Import attributes are no longer experimental.
13-
- version: v20.10.0
13+
- version:
14+
- v21.0.0
15+
- v20.10.0
16+
- v18.20.0
1417
pr-url: https://github.com/nodejs/node/pull/50140
1518
description: Add experimental support for import attributes.
16-
- version: v20.0.0
19+
- version:
20+
- v20.0.0
21+
- v18.19.0
1722
pr-url: https://github.com/nodejs/node/pull/44710
1823
description: Module customization hooks are executed off the main thread.
1924
- version:
@@ -260,7 +265,10 @@ added:
260265
- v17.1.0
261266
- v16.14.0
262267
changes:
263-
- version: v20.10.0
268+
- version:
269+
- v21.0.0
270+
- v20.10.0
271+
- v18.20.0
264272
pr-url: https://github.com/nodejs/node/pull/50140
265273
description: Switch from Import Assertions to Import Attributes.
266274
-->
@@ -330,12 +338,14 @@ modules it can be used to load ES modules.
330338
* {Object}
331339

332340
The `import.meta` meta property is an `Object` that contains the following
333-
properties. It is only supported in ES modules.
341+
properties.
334342

335343
### `import.meta.dirname`
336344

337345
<!-- YAML
338-
added: v20.11.0
346+
added:
347+
- v21.2.0
348+
- v20.11.0
339349
-->
340350

341351
> Stability: 1.2 - Release candidate
@@ -348,7 +358,9 @@ added: v20.11.0
348358
### `import.meta.filename`
349359

350360
<!-- YAML
351-
added: v20.11.0
361+
added:
362+
- v21.2.0
363+
- v20.11.0
352364
-->
353365

354366
> Stability: 1.2 - Release candidate
@@ -382,15 +394,21 @@ added:
382394
- v13.9.0
383395
- v12.16.2
384396
changes:
385-
- version: v20.6.0
397+
- version:
398+
- v20.6.0
399+
- v18.19.0
386400
pr-url: https://github.com/nodejs/node/pull/49028
387-
description: Unflag `import.meta.resolve`, with `parentURL` parameter still
388-
flagged.
389-
- version: v20.6.0
401+
description: No longer behind `--experimental-import-meta-resolve` CLI flag,
402+
except for the non-standard `parentURL` parameter.
403+
- version:
404+
- v20.6.0
405+
- v18.19.0
390406
pr-url: https://github.com/nodejs/node/pull/49038
391407
description: This API no longer throws when targeting `file:` URLs that do
392408
not map to an existing file on the local FS.
393-
- version: v20.0.0
409+
- version:
410+
- v20.0.0
411+
- v18.19.0
394412
pr-url: https://github.com/nodejs/node/pull/44710
395413
description: This API now returns a string synchronously instead of a Promise.
396414
- version:
@@ -593,7 +611,7 @@ separate cache.
593611
594612
<!-- YAML
595613
changes:
596-
- version: v20.18.3
614+
- version: REPLACEME
597615
pr-url: https://github.com/nodejs/node/pull/55333
598616
description: JSON modules are no longer experimental.
599617
-->
@@ -686,71 +704,6 @@ spawn(execPath, [
686704
});
687705
```
688706
689-
## HTTPS and HTTP imports
690-
691-
> Stability: 1 - Experimental
692-
693-
Importing network based modules using `https:` and `http:` is supported under
694-
the `--experimental-network-imports` flag. This allows web browser-like imports
695-
to work in Node.js with a few differences due to application stability and
696-
security concerns that are different when running in a privileged environment
697-
instead of a browser sandbox.
698-
699-
### Imports are limited to HTTP/1
700-
701-
Automatic protocol negotiation for HTTP/2 and HTTP/3 is not yet supported.
702-
703-
### HTTP is limited to loopback addresses
704-
705-
`http:` is vulnerable to man-in-the-middle attacks and is not allowed to be
706-
used for addresses outside of the IPv4 address `127.0.0.0/8` (`127.0.0.1` to
707-
`127.255.255.255`) and the IPv6 address `::1`. Support for `http:` is intended
708-
to be used for local development.
709-
710-
### Authentication is never sent to the destination server.
711-
712-
`Authorization`, `Cookie`, and `Proxy-Authorization` headers are not sent to the
713-
server. Avoid including user info in parts of imported URLs. A security model
714-
for safely using these on the server is being worked on.
715-
716-
### CORS is never checked on the destination server
717-
718-
CORS is designed to allow a server to limit the consumers of an API to a
719-
specific set of hosts. This is not supported as it does not make sense for a
720-
server-based implementation.
721-
722-
### Cannot load non-network dependencies
723-
724-
These modules cannot access other modules that are not over `http:` or `https:`.
725-
To still access local modules while avoiding the security concern, pass in
726-
references to the local dependencies:
727-
728-
```mjs
729-
// file.mjs
730-
import worker_threads from 'node:worker_threads';
731-
import { configure, resize } from 'https://example.com/imagelib.mjs';
732-
configure({ worker_threads });
733-
```
734-
735-
```mjs
736-
// https://example.com/imagelib.mjs
737-
let worker_threads;
738-
export function configure(opts) {
739-
worker_threads = opts.worker_threads;
740-
}
741-
export function resize(img, size) {
742-
// Perform resizing in worker_thread to avoid main thread blocking
743-
}
744-
```
745-
746-
### Network-based loading is not enabled by default
747-
748-
For now, the `--experimental-network-imports` flag is required to enable loading
749-
resources over `http:` or `https:`. In the future, a different mechanism will be
750-
used to enforce this. Opt-in is required to prevent transitive dependencies
751-
inadvertently using potentially mutable state that could affect reliability
752-
of Node.js applications.
753-
754707
<i id="esm_experimental_loaders"></i>
755708
756709
## Loaders
@@ -793,8 +746,7 @@ does not determine whether the resolved URL protocol can be loaded,
793746
or whether the file extensions are permitted, instead these validations
794747
are applied by Node.js during the load phase
795748
(for example, if it was asked to load a URL that has a protocol that is
796-
not `file:`, `data:`, `node:`, or if `--experimental-network-imports`
797-
is enabled, `https:`).
749+
not `file:`, `data:` or `node:`.
798750
799751
The algorithm also tries to determine the format of the file based
800752
on the extension (see `ESM_FILE_FORMAT` algorithm below). If it does

0 commit comments

Comments
 (0)