mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
doc: revise data imports and node: imports sections
Revise for conformance with style guide and clarity. PR-URL: https://github.com/nodejs/node/pull/42734 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
1 parent
b6c23b0312
commit
1b668d4be6
1 file changed
+10
-11
+10
-11
@@ -174,7 +174,7 @@ The volume root may be referenced via `/`, `//` or `file:///`. Given the
|
||||
differences between [URL][] and path resolution (such as percent encoding
|
||||
details), it is recommended to use [url.pathToFileURL][] when importing a path.
|
||||
|
||||
#### `data:` Imports
|
||||
#### `data:` imports
|
||||
|
||||
<!-- YAML
|
||||
added: v12.10.0
|
||||
@@ -182,24 +182,23 @@ added: v12.10.0
|
||||
|
||||
[`data:` URLs][] are supported for importing with the following MIME types:
|
||||
|
||||
* `text/javascript` for ES Modules
|
||||
* `text/javascript` for ES modules
|
||||
* `application/json` for JSON
|
||||
* `application/wasm` for Wasm
|
||||
|
||||
`data:` URLs only resolve [_Bare specifiers_][Terminology] for builtin modules
|
||||
and [_Absolute specifiers_][Terminology]. Resolving
|
||||
[_Relative specifiers_][Terminology] does not work because `data:` is not a
|
||||
[special scheme][]. For example, attempting to load `./foo`
|
||||
from `data:text/javascript,import "./foo";` fails to resolve because there
|
||||
is no concept of relative resolution for `data:` URLs. An example of a `data:`
|
||||
URLs being used is:
|
||||
|
||||
```js
|
||||
import 'data:text/javascript,console.log("hello!");';
|
||||
import _ from 'data:application/json,"world!"' assert { type: 'json' };
|
||||
```
|
||||
|
||||
#### `node:` Imports
|
||||
`data:` URLs only resolve [bare specifiers][Terminology] for builtin modules
|
||||
and [absolute specifiers][Terminology]. Resolving
|
||||
[relative specifiers][Terminology] does not work because `data:` is not a
|
||||
[special scheme][]. For example, attempting to load `./foo`
|
||||
from `data:text/javascript,import "./foo";` fails to resolve because there
|
||||
is no concept of relative resolution for `data:` URLs.
|
||||
|
||||
#### `node:` imports
|
||||
|
||||
<!-- YAML
|
||||
added:
|
||||
|
||||
Reference in new issue
Block a user