[英]How does the @shopify/polaris project get built from github repo to npm dependency?
I'm interested in learning how the @shopify/polaris project in github is built and published to npm
. 我对学习如何在github中构建@ shopify / polaris项目并将其发布到
npm
感兴趣。 My main questions are: 我的主要问题是:
index.es.js
and index.js
files being generated? index.es.js
和index.js
文件? Are those being generated programmatically on my computer, or are they published to npm
like this? npm
? .npmignore
in the repo. .npmignore
不到.npmignore
。 Below I have the files in the npm
package, and the github, and you can see they're different. 下面,我在
npm
包和github中都有文件,您可以看到它们是不同的。
Here's what the polaris
project looks like when it's installed via NPM / yarn. 这是通过NPM / yarn安装的
polaris
项目的外观。
.
├── CHANGELOG.md
├── README.md
├── index.es.js
├── index.js
├── package.json
├── src
├── styles
├── styles.css
├── styles.scss
└── types
Here's what the project looks like on github. 这是该项目在github上的样子。
.
├── CHANGELOG.md
├── README.md
├── circle.yml
├── config
├── documentation
├── examples
├── package.json
├── scripts
├── src
├── tests
├── tsconfig.json
├── tslint.json
└── yarn.lock
We use Rollup to generate the different entry files for Polaris. 我们使用汇总来为Polaris生成不同的条目文件。 You can see our generic config file here: https://github.com/Shopify/polaris/blob/master/config/rollup/index.js .
您可以在此处查看我们的通用配置文件: https : //github.com/Shopify/polaris/blob/master/config/rollup/index.js 。 Note that it does all the work of compiling our TypeScript source files (using TypeScript and Babel), as well as kicking off the work required to bundle our CSS and icons as appropriate.
请注意,它完成了编译TypeScript源文件(使用TypeScript和Babel)的所有工作,并开始了将CSS和图标适当捆绑在一起所需的工作。 This config generator is then run three times, which you can see here: https://github.com/Shopify/polaris/blob/master/scripts/build.js#L36-L38
然后,此配置生成器将运行三次,您可以在此处查看: https : //github.com/Shopify/polaris/blob/master/scripts/build.js#L36-L38
main
entry file ( .js
, and spits out the CSS for our CDN) main
条目文件( .js
,并为我们的CDN吐出CSS) module
entry file ( .es.js
) module
条目文件( .es.js
) embedded
entry file embedded
条目文件 We then copy these into their final locations for the NPM publish. 然后,将它们复制到NPM发布的最终位置。
As for how we control what files are in the NPM package, we use the files
key in our package.json
; 至于我们如何控制NPM包中的
files
,我们使用package.json
的files
键 ; these are the relevant lines . 这些是相关的内容 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.