Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simon-he95/mini-rollup
https://github.com/simon-he95/mini-rollup
mini-rollup
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/simon-he95/mini-rollup
- Owner: Simon-He95
- Created: 2022-05-22T04:18:20.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:41:53.000Z (11 months ago)
- Last Synced: 2023-12-15T06:47:27.278Z (11 months ago)
- Topics: mini-rollup
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mini Rollup
## 思路分析
- 根据entry主入口处理绝对路径,获取文件code,并解析成ast
- 遍历ast收集所有的import和export(存放的是变量和code)
- 如果在当前模块域中找不到对应变量的申明,会从import中寻找对应变量的定义,找到根据from的source读取外部依赖文件,解析他的export
- 解析时会当前文件code中截取对应模块的code放到_source上,解析找到对应变量的定义收集起来,完成tree-shaking
- 结合entry的code拼接成最终的bundlerCode## tree shaking 原理
- 从入口模块查找所有使用的变量
- 找变量的依赖,是从哪里定义的,把定义语句打包进当前模块
- 无关代码就被排除了