I just want to clear my concepts? I'm using a npm
package named reactstrap which is installed on node_modules
folder. The package contains 4 folders.
- dist
- es
- lib
- src
I know src
folder contains the source code of the library but what is the difference between other these 3 folders.
What if I write something like this to import a ponent.
import {Button} from 'reactstrap';
The above line is using ES6 module
syntax to import a ponent.
Does this Button ponent is came from the es
folder or lib
folder?
What will be the syntax if I want to import the Button
ponent by using monJS module
pattern?
I just want to clear my concepts? I'm using a npm
package named reactstrap which is installed on node_modules
folder. The package contains 4 folders.
- dist
- es
- lib
- src
I know src
folder contains the source code of the library but what is the difference between other these 3 folders.
What if I write something like this to import a ponent.
import {Button} from 'reactstrap';
The above line is using ES6 module
syntax to import a ponent.
Does this Button ponent is came from the es
folder or lib
folder?
What will be the syntax if I want to import the Button
ponent by using monJS module
pattern?
1 Answer
Reset to default 5When use import/require
an package without specify an filepath, npm will use main
file that was specify in package.json (reactstrap package.json). it's same for es and monJS style.
'es', 'dist', 'lib',... is just folders that was built by different options, so it's just an optional for each project with specific usecase. You can see build option for each type here.
As you can see, dist folder was created by rollup, it let this package runable on browser, es module and monJs module. And lib folder was created by babel