unbuild icon indicating copy to clipboard operation
unbuild copied to clipboard

fix: correct `declaration` option behavior

Open xiaoxiangmoe opened this issue 2 years ago โ€ข 1 comments

๐Ÿ”— 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 to true.
  • If I write use false, it may convert to true if 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.

xiaoxiangmoe avatar Sep 14 '23 05:09 xiaoxiangmoe

i encounter this problem

Miofly avatar Nov 09 '23 02:11 Miofly

Thanks for PR dear @xiaoxiangmoe and sorry for late merge. I've rebased it together with #371 to land

pi0 avatar Jun 04 '24 22:06 pi0