fix: NPM package cleanups #17
Open
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.
Description
For this PR I audited the package.json for improvements that can be made with regard to publishing a npm package.
The biggest impact of these changes is this library tree shakes now which means bundlers like webpack and vite will remove unused code creating smaller bundles and better user experience.
type: module
I added type module which makes this package an ESM package by default. ESM packages are packages using modern javascript:
Rather than commonjs
ESM works better with modern build tools like vite for end users as cjs cannot treeshake
Build cjs and esm
I updated the tsup config to build both cjs and esm. This creates universal compatability. I also updated the main, module, types, and exports fields according to best practices to properly point at these files. Previously ESM was not specified
sideEffects: false
So modern bundlers tree shake as much as possible as a best practice all packages that don't have side effects e.g.
Should specify sideEffects: false. This allows bundlers like webpack and vite to properly treeshake
Github link
I updated the github link to best practices
Testing (ignore for documentation update)
I added two lint tools that double check for compatability for npm packages
Type of change
Checklist:
Additional Notes: