-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib 包中依赖的 lodash-es 换成 lodash/xxx #2871
Comments
Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. |
es是为了tree-shaking吧 |
import XXX from 'lodash/xxx'的方式自动就是了,只导入了用到的函数,其实就不存在tree-shaking的说法了。 |
tree-shaking 依赖于 es module |
难道你们写代码的时候import语句都是手动写的吗🤣?我都是用到的时候tab一下vscode自动导入了 |
其实他用lodash-es有个好处就是我框架自带了lodash完整版,这样我可以配置alias,lodash-es为lodash即可,但是如果用lodash/xx的方式就会没那么好处理 |
确实,lodash-es 配合 webpack 才能发挥优势,其他场景下好像没有多大必要。这里有相关 benchmark。 |
目前lib目录里是require('lodash-es'),导致无法按需加载,nextjs最新版本会报错;可以的话换成 lodash/xxx 的形式比较好 |
@Oscar-ren 欢迎提 PR。 |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
问题描述
哈喽,我发现 lib 中依赖的 lodash-es 不是 cjs 规范,我需要额外配置转换,比如使用 jest 的时候,而不是 webpack 打包,希望改为 lodash 统一模块规范,同时我注意到 #101 这个 PR 为了解决全量引入问题,在使用 lodash 下,按需引入建议用 babel-plugin-import 统一处理,减少改动
重现链接
重现步骤
预期行为
平台
屏幕截图或视频(可选)
No response
补充说明(可选)
No response
The text was updated successfully, but these errors were encountered: