Skip to content

Commit 66e7487

Browse files
committed
es6 support
1 parent 828dd1f commit 66e7487

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

session 3/chapters/1. Software Package Manager.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,39 @@ NPX stands for Node Package Executor. It is a new addition to NPM version 5.2.0
8383
There are more features that you can benefit from using NPX. Check this guide to learn more about NPX.
8484

8585
for more information, [read here](https://www.section.io/engineering-education/npm-vs-yarn-which-one-to-choose/)
86+
87+
# Metadata Inside package.json
88+
89+
## The name property
90+
91+
The `name property` in a `package.json` file is one of the fundamental components of the `package.json` structure. At its core, name is a string that is exactly what you would expect - the name of the module that the `package.json` is describing.
92+
93+
Inside your `package.json`, the `name property` as a string would look something like this:
94+
95+
## The main property
96+
97+
It's the main entry point to your node package (library) for npm. It's needed if your npm project becomes a node package (library) which can be installed via npm by others.
98+
99+
The `main property` of a `package.json` is a direction to the entry point to the module that the `package.json` is describing.
100+
101+
In a Node.js application, when the module is called via a require statement, the module's exports from the file named in the `main property` will be what's returned to the Node.js application.
102+
103+
Inside your `package.json`, the `main property`, with an entry point of `app.js`, would look like this:
104+
105+
```
106+
"main": "app.js",
107+
```
108+
109+
# Commonjs and ES6 modules
110+
111+
![es6 module support](../images/es6-experimental.jpg)
112+
113+
When you have `'type': 'module'` in the package.json file, your source code should use import syntax. When you do not have, you should use require syntax.
114+
115+
- Adding `'type': 'commonjs'` to the package.json enables `commonjs` modules.
116+
117+
![commonjs](../images/type-commonjs.jpg)
118+
119+
- Adding `'type': 'module'` to the package.json enables `ES6` modules.
120+
121+
![ES6](../images/type-es6.jpg)
124 KB
Loading

session 3/images/type-commonjs.jpg

46.5 KB
Loading

session 3/images/type-es6.jpg

57 KB
Loading

0 commit comments

Comments
 (0)