Skip to content
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

预编译的输出目录, 是否应该 name 为目录名称, 而不是 depPkg.name #662

Open
nanianlisao opened this issue Jun 9, 2023 · 4 comments · Fixed by #663

Comments

@nanianlisao
Copy link
Contributor

nanianlisao commented Jun 9, 2023

当对某个依赖需要并行存在多版本的情况下,

"devDependencies": {
    "globby": "11.1.0",
    "globby13": "npm:globby@^13.1.1",
}

此时 我们需要预编译 globby 和 globby13 两个包, 因此 我们配置

 prebundle: {
    deps: ['globby', 'globby13']
  },

希望能生成 globby 和 globby13 两个预编译的包。

同时 prebundle内部 getDepPkgPath 这个方法 对一些情况未兼容, 导致取到的package.json 是错误的。
如 "minimatch" 导致取到的pkg.name是undefined 。

@nanianlisao nanianlisao changed the title 预编译的输出目录, 是否应该 name 预编译的输出目录, 是否应该 name 为目录名称, 而不是 depPkg.name Jun 9, 2023
@PeachScript
Copy link
Member

NPM 别名用法暂未支持,有兴趣欢迎 PR

@nanianlisao
Copy link
Contributor Author

我认为这个pr 并没有真正的解决这个问题。 当然,他解决了获取到的package.json 的name 不符合的场景。(恰恰是minimatch的场景。)

但是可能存在更多的情况。 如 terser,他在dist下垫的 package.json 实际是存在name的。因此 目前的解决方式 看起来似乎会有问题。

不过庆幸的是, terser 在 exports 中 导出了 “./package.json” , 因此 并没有根据require.resolve 找到 dist 下垫的那一层 package.json。

但不得不说, 这是个隐患

@PeachScript
Copy link
Member

@nanianlisao 感谢评论,你提的隐患 @Dunqing 在 PR 里评论了,会单独提 PR 处理:#663 (comment)

如果你有解法也欢迎直接提交 PR

@Dunqing
Copy link
Contributor

Dunqing commented Jun 15, 2023

reopen下?

@PeachScript PeachScript reopened this Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants