unbuild
unbuild copied to clipboard
fix: correct `declaration` option behavior
๐ Linked issue
โ Type of change
- [ ] ๐ Documentation (updates to the documentation, readme, or JSdoc annotations)
- [x] ๐ Bug fix (a non-breaking change that fixes an issue)
- [ ] ๐ Enhancement (improving an existing functionality like performance)
- [ ] โจ New feature (a non-breaking change that adds functionality)
- [ ] ๐งน Chore (updates to the build process or auxiliary tools and libraries)
- [ ] โ ๏ธ Breaking change (fix or feature that would cause existing functionality to change)
๐ Description
The document write:
/**
* * `compatible` means "src/index.ts" will generate "dist/index.d.mts", "dist/index.d.cts" and "dist/index.d.ts".
* * `node16` means "src/index.ts" will generate "dist/index.d.mts" and "dist/index.d.cts".
* * `true` is equivalent to `compatible`.
* * `false` will disable declaration generation.
* * `undefined` will auto detect based on "package.json". If "package.json" has "types" field, it will be `"compatible"`, otherwise `false`.
*/
The behavior of the declaration option is inconsistent with the documentation.
- If I write use
'node16', it will also convert totrue. - If I write use
false, it may convert totrueif we have types or typing field in package.json. see https://github.com/unjs/unbuild/issues/313 (This is a reasonable requirement since we may use other tools to package .d.ts. Just use unbuild to package .js)
So I create a bug fix for it.
๐ Checklist
- [x] I have linked an issue or discussion.
- [x] I have updated the documentation accordingly.
i encounter this problem
Thanks for PR dear @xiaoxiangmoe and sorry for late merge. I've rebased it together with #371 to land