-
Notifications
You must be signed in to change notification settings - Fork 61
[Question] 针对Vue cli加载插件模块的一点疑惑 #8
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
Comments
这一点其实我也不是很熟悉,不过从代码中的信息可以看出应该有以下几个原因:
如果有更好的答案,欢迎大佬来回答。 最后很感谢能够有想法请我喝一杯咖啡☕️5fa2b97 |
好的,感谢你的回复 |
目前我个人的结论是, 利用 |
@screetBloom 解析的到位 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
首先感谢你的分享给我阅读源码时提供的帮助
Background
vue cli加载插件模块使用的是自建的loadModule,而不是直接使用require。

这个点在源代码中频繁出现,但是大家似乎都没分析过这个点,个人很好奇为什么vue cli一定要自己实现一遍
在cli-service中加载模块的代码示例
loadModule具体实现的源码路径

sodatea 提交 Pr的issue
Question
我个人初期看到的时候觉得没必要自己去实现require,包括去看了
NodeJs Module模块createRequire、createRequireFromPath
的说明,也并没有看到需要自己去实现的一个必要性,但是其实这个函数贯穿了插件模块使用的全流程,让人比较困惑想咨询一下您对【loadModule】部分的看法,以及是否有必要自建require
建议
你可以在README中贴一下
alipay
或者wechat pay
的地址,或许我可以请你喝杯咖啡The text was updated successfully, but these errors were encountered: