Skip to content

fix: NPM package cleanups #17

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roninjin10
Copy link

@roninjin10 roninjin10 commented Oct 28, 2024

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:

import { foo } from 'foo'

Rather than commonjs

const foo = require('foo').foo

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.

// this shouldn't cause some side effect
import 'my-package'

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

  • Are the types right
  • Publint

Type of change

  • Bug fix

Checklist:

Additional Notes:

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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