Skip to content

Commit 1221b1b

Browse files
committed
Move the statement about import assertions to where it is used
1 parent c84d6d9 commit 1221b1b

File tree

1 file changed

+3
-2
lines changed
  • files/en-us/web/javascript/reference/statements/import

1 file changed

+3
-2
lines changed

files/en-us/web/javascript/reference/statements/import/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ import "module-name";
3232
- : Name that will refer to the default export from the module. Must be a valid JavaScript identifier.
3333
- `module-name`
3434
- : The module to import from. Only single quoted and double quoted string literals are allowed. The evaluation of the specifier is host-specified. Most hosts align with browsers and resolve the specifiers as URLs relative to the current module URL (see [`import.meta.url`](/en-US/docs/Web/JavaScript/Reference/Operators/import.meta)). Node, bundlers, and other non-browser environments often define their own features on top of this, so you should find documentation for them to understand the exact rules. The [module specifier resolution](#module_specifier_resolution) section also has more information.
35+
36+
The `"module-name"` may be followed by the `with` keyword and a set of [import attributes](/en-US/docs/Web/JavaScript/Reference/Statements/import/with) such as the module `type`.
37+
3538
- `name`
3639
- : Name of the module object that will be used as a kind of namespace when referring to the imports. Must be a valid JavaScript identifier.
3740
- `exportN`
3841
- : Name of the exports to be imported. The name can be either an identifier or a string literal, depending on what `module-name` declares to export. If it is a string literal, it must be aliased to a valid identifier.
3942
- `aliasN`
4043
- : Names that will refer to the named imports. Must be a valid JavaScript identifier.
4144

42-
The `"module-name"` may be followed by a set of [import attributes](/en-US/docs/Web/JavaScript/Reference/Statements/import/with), starting with the `with` keyword.
43-
4445
## Description
4546

4647
`import` declarations can only be present in modules, and only at the top-level (i.e., not inside blocks, functions, etc.). If an `import` declaration is encountered in non-module contexts (for example, `<script>` tags without `type="module"`, `eval`, `new Function`, which all have "script" or "function body" as parsing goals), a `SyntaxError` is thrown. To load modules in non-module contexts, use the [dynamic import](/en-US/docs/Web/JavaScript/Reference/Operators/import) syntax instead.

0 commit comments

Comments
 (0)