Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the exports and modify the tsup build config #346

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

csandman
Copy link
Owner

This PR implements two changes. The first is to expand the import and require sections of the exports field in the package.json. I've been noticing some packages have been splitting these out in order to specify a types 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.

Copy link

pkg-pr-new bot commented Oct 31, 2024

Open in Stackblitzchakra-react-select-demo

yarn add https://pkg.pr.new/[email protected]

commit: 765b644

Copy link

github-actions bot commented Oct 31, 2024

📊 Package size report   -42.1%↓

File Before After
dist/index.js 16.2 kB 100%↑32.5 kB
dist/index.js.map 72.7 kB
dist/index.mjs 14.8 kB 109%↑30.9 kB
dist/index.mjs.map 72.7 kB
package.json 3.0 kB 5%↑3.1 kB
README.md 47.5 kB -0.03%↓47.5 kB
Total (Includes all files) 267.8 kB -42.1%↓154.9 kB
Tarball size 59.8 kB -48%↓31.1 kB
Unchanged files
File Size
dist/index.d.mts 19.9 kB
dist/index.d.ts 19.9 kB
LICENSE.md 1.1 kB

🤖 This report was automatically generated by pkg-size-action

@csandman csandman merged commit e8916bb into main Nov 1, 2024
5 checks passed
@csandman csandman deleted the exports-and-build branch November 1, 2024 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants