Closed BBBigCat closed 2 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
这些更改专注于增强模块加载的灵活性,具体实现是使用新的 loadModule
函数来替代 require.resolve
直接加载模块。此外,还引入了一个新的工具函数 resolveProjectDep
来解析项目依赖。这些改动将允许根据路径动态加载模块,提升项目的整体灵活性。
文件路径 | 更改摘要 |
---|---|
packages/preset-umi/src/features/forget/forget.ts | 修改使用 require.resolve 的方式,改为使用 loadModule 函数动态加载模块。引入了 dirname 和 resolveProjectDep 。新增 loadModule 函数,参数为 moduleName: string 和 path: string 。 |
packages/preset-umi/src/features/configPlugins/configPlugins.ts | 将 resolveProjectDep 从 ../../utils/resolveProjectDep 引入,移除对 @umijs/utils 中 resolve 的引用。 |
packages/preset-umi/src/utils/resolveProjectDep.ts | 新增 resolveProjectDep 函数,用于基于提供的选项(包、当前工作目录、依赖名)解析项目依赖。 |
一只机智的小兔子, 轻轻弹跳,代码如诗。 灵活加载,不再迷茫, 模块寻踪,路径导航。 项目依赖,轻松解决, 代码世界,自在遨游。
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
这么修改,如果项目没有安装,还能找到内置的 babel-plugin-react-compiler 吗?
不能,这种实现方式有问题,我再改下
优先使用用户安装的
babel-plugin-react-compiler
相关 issue
Summary by CodeRabbit
新功能
loadModule
函数以动态加载模块,增强模块加载的灵活性。重构
forget
功能以使用loadModule
函数代替require.resolve
,动态加载模块。resolveProjectDep
函数移动到utils
目录,并在相关模块中引用。