developit / developit/microbundle

Bug: Shouldn't fall back to pkg name in the absence of output flag & pkg main

未關閉
#884 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。