-
Notifications
You must be signed in to change notification settings - Fork 275
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
feat: support npm alias name for prebundle #663
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #663 +/- ##
==========================================
+ Coverage 93.77% 93.79% +0.02%
==========================================
Files 55 54 -1
Lines 1525 1531 +6
Branches 361 364 +3
==========================================
+ Hits 1430 1436 +6
Misses 95 95
☔ View full report in Codecov by Sentry. |
@@ -147,7 +147,7 @@ export function getConfig(opts: { | |||
pkg: depPkg, | |||
output: path.resolve( | |||
opts.cwd, | |||
`${output || DEFAULT_OUTPUT_DIR}/${depPkg.name}/index.js`, | |||
`${output || DEFAULT_OUTPUT_DIR}/${depName}/index.js`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接使用用户的配置值可能会存在 Breaking Change,目前想到这两种 case:
- 配置值可能是 NPM 包的文件路径(类似
pkg/lib/other
) - 配置值可能是项目的本地文件(类似 Umi 仓库中 bundler-utils 子包的情况,虽然没有直接使用 father)
想到的解法你看看是否合适,创建 getDepPkgName(depName, depPkg)
的工具方法,有两层逻辑:
- 如果
depName
不是绝对路径或.
开头的相对路径,则尝试截取 depName 中包名的部分,比如pkg/lib/other
=>pkg
,@org/pkg/index
=>@org/pkg
- 反之兜底到
depPkg.name
,同时需要看下 issue 里提到的minimatch
获取 pkg 失败的问题,按理说getDepPkg
有使用 pkgUp 处理,应该能拿到才是
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
很好我处理下,我没留意还有其他用法
关于 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
close: #662