developit / developit/microbundle
Bug: Shouldn't fall back to pkg name in the absence of output flag & pkg main
- 主要语言
- JavaScript
- 星标
- 8.1k
- 派生
- 358
- PR 合并指标
- 30 天内没有已合并 PR
描述
Packages that don't use the `output` flag or have a `"main"` in their `package.json` have their preferred filename output ignored.
For example, say I have the following package:
```
{
"name": "foo",
"exports": {
".": "./dist/bar.js",
...
}
}
```
Unfortunately, because of the `replaceName()` here, the desired output is replaced by the package name instead.
https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L297-L303
https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L255-L260
`mainNoExtension` traces back to here, which defines a couple of fallbacks.
https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L219-L225
I can't really say that I understand why this was done in the first place, so don't want to go "fixing" it as there might be some relying on this. To me, it seems like that in the absence of the `output` flag, these fields should be read and used exactly, no replacing.
`mainNoExtension` seems like it should be the last of the fallbacks, not something that overwrites valid entries & chosen names.
贡献指南
这个仓库没有索引到贡献指南
调研方向
Start in src/index.js around the linked replaceName() calls at lines 255-260 and 297-303, then trace mainNoExtension at lines 219-225. Reproduce the package example with exports pointing to dist/bar.js and no output or main fields. Done means valid preferred filenames from package metadata are preserved while mainNoExtension remains only a fallback, with existing behavior checked for regressions.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- build-system
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100