ES6 modules, webpack & npm Flashcards
What does npm stand for?
node package manager
What does npm give you access to?
Gigantic repository of plugins, libraries and tools
Few examples of how you can use npm
- adapt pacakges of code for your apps
- download standalone tools
- share code with any npm user
- run packages without downloading using npx
- manage multiple versions of code and code dependencies
What are npm unscoped packages? Syntax for installing it?
Packages, that are always public. It means they can be searched for, downloaded and installed by anyone
npm install <package></package>
What is the requirement of installing scoped public packages? Syntax?
As long as the scope name is referenced, it can be downloaded by anyone.
npm install @scope/package-name
What does package.json file do? (3)
- Lists the packages your project depends on
- Specifies versions of a package that your project can use
- Makes your build reproducible, therefore it’s easier to share it with other
What kind of fields package.json must contain?
Name and Version fields. Author is not mandatory
{
“name”: “my-awesome-package”,
“version”: “1.0.0”,
“author”: “Your Name email@example.com”
}
Which command creates package.json?
npm init
more info: https://docs.npmjs.com/creating-a-package-json-file
What are ‘devDependencies’ and ‘Dependencies’? Where are they located and how are they created?
They are two properties which are added to package.json when a package is installed as development (devDependency) or production dependency.
When are devDependencies being used?
During the development stage, they are not needed on the production side. So it would be wiser to use –save-dev with those packages
When do you add a dependency into the ‘dependencies’ property? Knowing that devDependency is also an option
When this dependency is used both in development and production phase. So it would be wise to use –save with those packages
What is Webpack used for?
For bundling modules
How many components does ES6 modules have? What are they?
2
import and export
What is export declaration used to?
To export values from a JavaScript module
In order to use “import” or “export” declaration in source file, what the file must be interpreted as?
The file must be interpreted as module