feat: Unified tree-shakeable package #1645
Closed
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.
Summary
This PR transforms
near-api-jsinto a unified, tree-shakeable package that bundles all@near-js/*packages, similar to how Zod works.Breaking Changes
Nearclassconnect()function@near-js/*packages are now bundled into the main packageChanges
Package Structure
src/index.tsthat exports from all@near-js/*packages@near-js/*code into single package (300KB ESM, 309KB CJS)Configuration
tsup.config.tsto bundle@near-js/*while keeping external deps externalpackage.jsonexports for ESM/CJS compatibilitytype: "module"with dual format supportDependencies
randombytes,secp256k1, and other peer depsBenefits
✅ Single package installation - no need to install multiple
@near-js/*packages✅ Tree-shakeable - bundlers only include what you import
✅ Modern ESM + CJS - dual format with proper exports field
✅ 163 total exports - all functionality from all packages
✅ Works like popular packages - similar to Zod, etc.
Usage
Testing
Migration Guide
For users upgrading from v6:
Before:
After:
Next Steps