Skip to content

Commit 8b96134

Browse files
aldeedMylesBorins
authored andcommittedApr 3, 2020
doc: import clarifications with links to MDN
Backport-PR-URL: #32610 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 62b5bd4 commit 8b96134

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed
 

‎doc/api/esm.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -929,17 +929,14 @@ import packageMain from 'commonjs-package'; // Works
929929
import { method } from 'commonjs-package'; // Errors
930930
```
931931

932+
It is also possible to
933+
[import an ES or CommonJS module for its side effects only][].
934+
932935
### `import()` expressions
933936

934-
Dynamic `import()` is supported in both CommonJS and ES modules. It can be used
937+
[Dynamic `import()`][] is supported in both CommonJS and ES modules. It can be used
935938
to include ES module files from CommonJS code.
936939

937-
```js
938-
(async () => {
939-
await import('./my-app.mjs');
940-
})();
941-
```
942-
943940
## CommonJS, JSON, and Native Modules
944941

945942
CommonJS, JSON, and Native modules can be used with
@@ -1737,6 +1734,7 @@ success!
17371734
[Babel]: https://babeljs.io/
17381735
[CommonJS]: modules.html
17391736
[Conditional Exports]: #esm_conditional_exports
1737+
[Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports
17401738
[ECMAScript-modules implementation]: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md
17411739
[ES Module Integration Proposal for Web Assembly]: https://github.com/webassembly/esm-integration
17421740
[Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md
@@ -1748,13 +1746,14 @@ success!
17481746
[`esm`]: https://github.com/standard-things/esm#readme
17491747
[`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
17501748
[`getFormat` hook]: #esm_code_getformat_code_hook
1751-
[`import()`]: #esm_import-expressions
1749+
[`import()`]: #esm_import_expressions
17521750
[`import.meta.url`]: #esm_import_meta
17531751
[`import`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
17541752
[`module.createRequire()`]: modules.html#modules_module_createrequire_filename
17551753
[`module.syncBuiltinESMExports()`]: modules.html#modules_module_syncbuiltinesmexports
17561754
[`transformSource` hook]: #esm_code_transformsource_code_hook
17571755
[dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook
1756+
[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
17581757
[special scheme]: https://url.spec.whatwg.org/#special-scheme
17591758
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
17601759
[transpiler loader example]: #esm_transpiler_loader

0 commit comments

Comments
 (0)
Please sign in to comment.