Improve the exports
and modify the tsup build config
#346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements two changes. The first is to expand the
import
andrequire
sections of theexports
field in thepackage.json
. I've been noticing some packages have been splitting these out in order to specify atypes
object for each version of the build. tsup already generated a different types file for each build type automatically, so this seems like a good practice to ensure that when the user is importing the types, they're coming from the right place.Previously I was just relying on the types paths being inferred from the JS file's import path. This seems to have been working fine, but I believe that regardless of whether you were using CJS or ESM, only the
index.d.ts
file would ever be imported.This is in-line with how the new
@chakra-ui/react
pacakge.json is formatted, so I'm mostly following their lead on this one.The other change I made in this PR is to modify the tsup build config. I've never really know whether minifying the output was a good practice when building an npm package. It could be helpful if I was generating a version for direct browser usage, but this package is only ever really meant to be used by node projects that generally have their own build process. So I decided to turn off minification, as well as source map generation.
This is also in-line with Chakra, as I looked through their build files and none of them are minified.