- npm account: https://www.npmjs.com/signup
- Verify email
- Login:
npm login
# Update version in package.json
npm version patch # 1.0.0 -> 1.0.1
# or
npm version minor # 1.0.0 -> 1.1.0
# or
npm version major # 1.0.0 -> 2.0.0pnpm buildThis creates:
dist/index.js- ESM bundledist/index.cjs- CommonJS bundledist/index.d.ts- TypeScript definitions
Link the package locally:
# In the library root
pnpm link --global
# In another project
pnpm link --global react-expression-editornpm publish --access publicThe prepublishOnly script will automatically run pnpm build.
Only these files (defined in package.json "files" field):
{
"files": ["dist"]
}So users get:
dist/- Built JavaScript and TypeScript filespackage.jsonREADME.md
The example/ folder is NOT published (development only).
Users can install with:
npm install react-expression-editorAnd use it:
import { ExpressionEditor } from 'react-expression-editor';
<ExpressionEditor value={expr} onChange={setExpr} />react-expression-editor (published)
├── dist/
│ ├── index.js # ESM entry
│ ├── index.cjs # CommonJS entry
│ └── index.d.ts # TypeScript definitions
├── package.json
└── README.md
example/ (NOT published, development only)
pnpm build
ls -la dist/Verify dist/ contains:
- index.js
- index.cjs
- index.d.ts
# Terminal 1: Build library
pnpm build
# Terminal 2: Run example
cd example && pnpm devVisit http://localhost:3000 and verify everything works.
npm publish --dry-runThis shows what would be published without actually publishing.
You need to bump the version:
npm version patch
npm publishMake sure:
- You're logged in:
npm whoami - You own the package or have permissions
- Package is public:
npm publish --access public
Skip TypeScript check during build:
# Edit package.json
"build": "vite build" # Remove "tsc &&"- Patch (1.0.x): Bug fixes
- Minor (1.x.0): New features, backwards compatible
- Major (x.0.0): Breaking changes
Keep a CHANGELOG.md to track changes between versions:
# Changelog
## [1.1.0] - 2024-01-15
### Added
- Custom theme support
- Drag & drop callbacks
### Fixed
- Autocomplete positioning
## [1.0.0] - 2024-01-01
- Initial release