Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ca3030

Browse filesBrowse files
aldeedMylesBorins
authored andcommitted
doc: import clarifications with links to MDN
PR-URL: #31479 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
1 parent 23ba088 commit 4ca3030
Copy full SHA for 4ca3030

File tree

Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+7-8Lines changed: 7 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -912,17 +912,14 @@ import packageMain from 'commonjs-package'; // Works
912912
import { method } from 'commonjs-package'; // Errors
913913
```
914914

915+
It is also possible to
916+
[import an ES or CommonJS module for its side effects only][].
917+
915918
### `import()` expressions
916919

917-
Dynamic `import()` is supported in both CommonJS and ES modules. It can be used
920+
[Dynamic `import()`][] is supported in both CommonJS and ES modules. It can be used
918921
to include ES module files from CommonJS code.
919922

920-
```js
921-
(async () => {
922-
await import('./my-app.mjs');
923-
})();
924-
```
925-
926923
## CommonJS, JSON, and Native Modules
927924

928925
CommonJS, JSON, and Native modules can be used with
@@ -1716,6 +1713,7 @@ success!
17161713
[Babel]: https://babeljs.io/
17171714
[CommonJS]: modules.html
17181715
[Conditional Exports]: #esm_conditional_exports
1716+
[Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports
17191717
[ECMAScript-modules implementation]: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md
17201718
[ES Module Integration Proposal for Web Assembly]: https://github.com/webassembly/esm-integration
17211719
[Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md
@@ -1725,13 +1723,14 @@ success!
17251723
[`esm`]: https://github.com/standard-things/esm#readme
17261724
[`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
17271725
[`getFormat` hook]: #esm_code_getformat_code_hook
1728-
[`import()`]: #esm_import-expressions
1726+
[`import()`]: #esm_import_expressions
17291727
[`import.meta.url`]: #esm_import_meta
17301728
[`import`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
17311729
[`module.createRequire()`]: modules.html#modules_module_createrequire_filename
17321730
[`module.syncBuiltinESMExports()`]: modules.html#modules_module_syncbuiltinesmexports
17331731
[`transformSource` hook]: #esm_code_transformsource_code_hook
17341732
[dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook
1733+
[import an ES or CommonJS module for its side effects only]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only
17351734
[special scheme]: https://url.spec.whatwg.org/#special-scheme
17361735
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
17371736
[the dual CommonJS/ES module packages section]: #esm_dual_commonjs_es_module_packages

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.