We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 354ff4f commit 0ffa040Copy full SHA for 0ffa040
doc/api/esm.md
@@ -13,6 +13,27 @@ ECMAScript modules are [the official standard format][] to package JavaScript
13
code for reuse. Modules are defined using a variety of [`import`][] and
14
[`export`][] statements.
15
16
+The following example of an ES module exports a function:
17
+
18
+```js
19
+// addTwo.js
20
+function addTwo(num) {
21
+ return num + 2;
22
+}
23
24
+export { addTwo };
25
+```
26
27
+The following example of an ES module imports the function from `addTwo.js`:
28
29
30
+// app.js
31
+import { addTwo } from './addTwo.js';
32
33
+// Prints: 6
34
+console.log(addTwo(4));
35
36
37
Node.js fully supports ECMAScript modules as they are currently specified and
38
provides limited interoperability between them and the existing module format,
39
[CommonJS][].
0 commit comments