Skip to content

Commit dfcc563

Browse files
authored
Update index.md
The Article got Partial pasted into a discussion in microsoft/TypeScript#27957 (comment) and i found out that it makes false claims that confuses new users. So i corrected the relevant parts as the Users do not understand that we migrate forward to ESM and not ship old none needed CJS if it is not needed.
1 parent 2b0e941 commit dfcc563

File tree

1 file changed

+5
-6
lines changed
  • files/en-us/web/javascript/reference/statements/import

1 file changed

+5
-6
lines changed

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ used in embedded scripts unless such script has a `type="module"`. Bindings
2424
imported are called live bindings because they are updated by the module that exported
2525
the binding.
2626

27-
There is also a function-like dynamic **`import()`**, which
28-
does not require scripts of `type="module"`.
27+
There is also a dynamic **`import()`** function, which
28+
does allow to import modules inside <script> tags.
2929

3030
Backward compatibility can be ensured using attribute `nomodule` on the
3131
{{HTMLElement("script")}} tag.
@@ -185,7 +185,7 @@ returned object.
185185
```js
186186
(async () => {
187187
if (somethingIsTrue) {
188-
  const { default: myDefault, foo, bar } = await import('/modules/my-module.js');
188+
  const myDefault = (await import('/modules/my-module.js')).default;
189189
}
190190
})();
191191
```
@@ -209,9 +209,8 @@ reasons why you might need to use dynamic import:
209209
effects unless some condition is true. (It is recommended not to have any side effects
210210
in a module, but you sometimes cannot control this in your module dependencies.)
211211

212-
Use dynamic import only when necessary. The static form is preferable for loading
213-
initial dependencies, and can benefit more readily from static analysis tools and [tree shaking](/en-US/docs/Glossary/Tree_shaking).
214-
212+
Use dynamic import only when necessary or when your using a old NodeJS package that forces you to run inside a CommonJS Context.
213+
215214
To dynamically import a module, the `import` keyword may be called as a
216215
function. When used this way, it returns a promise.
217216

0 commit comments

Comments
 (0)