最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Difference between lib and es folder - Stack Overflow

programmeradmin1浏览0评论

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?

Share Improve this question edited Oct 17, 2019 at 15:19 Timmy Mucks asked Oct 17, 2019 at 4:43 Timmy MucksTimmy Mucks 2471 gold badge3 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

When 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

发布评论

评论列表(0)

  1. 暂无评论