reclaimprotocol / reclaim-js-sdk

JavaScript SDK for easy integration of Reclaim Protocol that enables authenticated web data export via HTTPS and zero-knowledge proofs
25 stars 4 forks source link

fix: NPM package cleanups #17

Open roninjin10 opened 3 weeks ago

roninjin10 commented 3 weeks ago

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

Type of change

Checklist:

Additional Notes:

CLAassistant commented 3 weeks ago

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.