This guide covers the complete process for publishing your Docusaurus plugins to npm.
# Check if you're logged in
pnpm npm:check
# Login if needed
pnpm npm:loginBefore publishing, update the package names in:
packages/docusaurus-plugin-llms-txt/package.json- Change@your-orgto your actual npm organization- Update the repository URLs to your actual GitHub repository
# Install dependencies
pnpm install
# Build all packages
pnpm build:packages
# Run tests and linting
pnpm test
pnpm lintChangesets provide automated versioning and changelog generation:
pnpm changesetThis will:
- Ask you which packages changed
- Ask for the type of change (patch, minor, major)
- Ask for a description of the changes
- Create a changeset file in
.changeset/
# Update package versions and generate changelogs
pnpm changeset:version
# Install updated dependencies
pnpm install
# Publish to npm
pnpm changeset:publishIf you prefer manual control:
Edit packages/*/package.json files to bump versions following semantic versioning:
- Patch (0.0.X): Bug fixes
- Minor (0.X.0): New features (backward compatible)
- Major (X.0.0): Breaking changes
pnpm prerelease# Navigate to the package directory
cd packages/docusaurus-plugin-llms-txt
# Publish to npm
npm publishFor testing or pre-release versions without Git commits:
pnpm canaryCreates versions like 1.0.0-canary-20241204123456 with the canary npm tag.
pnpm alphaCreates versions like 1.0.0-alpha-20241204123456 with the alpha npm tag.
pnpm betaCreates versions like 1.0.0-beta-20241204123456 with the beta npm tag.
pnpm dev:releaseCreates versions like 1.0.0-dev-20241204123456 with the dev npm tag.
For longer prerelease cycles with Git tracking:
# Choose your tag: alpha, beta, rc, etc.
pnpm prerelease:enter alpha
# Version packages (creates 1.0.0-alpha.0, 1.0.0-alpha.1, etc.)
pnpm prerelease:version
# Commit changes
git add .
git commit -m "Enter alpha prerelease"
# Publish with the specified tag
pnpm prerelease:publish# Add changesets as normal
pnpm changeset
# Version packages (increments prerelease number)
pnpm prerelease:version
# Commit and publish
git add .
git commit -m "Version alpha packages"
pnpm prerelease:publish# Exit prerelease mode
pnpm prerelease:exit
# Version packages (removes prerelease suffix)
pnpm prerelease:version
# Commit and publish to latest
git add .
git commit -m "Exit prerelease and release stable version"
pnpm prerelease:publishUsers can install specific prerelease versions:
# Install specific tag
npm install @your-org/package@alpha
npm install @your-org/package@beta
npm install @your-org/package@dev
npm install @your-org/package@canary
# Install specific version
npm install @your-org/package@1.0.0-alpha.0- Use branches: Run prereleases from a separate branch, not main
- Choose appropriate tags:
alpha: Early testing, potentially unstablebeta: Feature complete, testing for bugscanary: Nightly/continuous releasesdev: Development buildsrc: Release candidate, nearly ready for production
- Communicate clearly: Document which prerelease channel users should use
- Clean up: Remember to exit prerelease mode when done
Run this command to verify everything is ready:
pnpm publish:checkThis runs the prepublishOnly script which:
- Cleans build artifacts
- Rebuilds the package
- Runs linting
- Runs type checking
Each package should have these key fields in package.json:
{
"name": "@your-org/package-name",
"version": "1.0.0",
"description": "Clear description",
"main": "./lib/index.js",
"types": "./lib/public/index.d.ts",
"files": ["lib", "README.md", "CHANGELOG.md"],
"keywords": ["docusaurus", "plugin", "..."],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"peerDependencies": {
"@docusaurus/core": "^3.10.0"
}
}The setup automatically handles:
- ✅ Independent versioning for each package
- ✅ Automatic dependency updates between internal packages
- ✅ Changelog generation
- ✅ Git tag creation
- ✅ Build verification before publishing
If you want to publish under an organization (recommended):
npm org create your-org-nameChange all package names from @your-org/ to @your-actual-org/
For public packages under an organization:
{
"publishConfig": {
"access": "public"
}
}Follow these conventions:
- 1.0.0 → 1.0.1: Bug fixes
- 1.0.0 → 1.1.0: New features (backward compatible)
- 1.0.0 → 2.0.0: Breaking changes
Changesets automatically generate changelogs, but they follow this format:
## 1.1.0
### Minor Changes
- abc123: Add new feature X
- def456: Improve performance of Y
### Patch Changes
- ghi789: Fix bug in ZThis project uses local publishing only for better control over releases. All publishing should be done from your local machine, not through CI/CD.
- Full control: You decide exactly when to publish
- Immediate feedback: See errors and fix them in real-time
- No CI complexity: No need to manage secrets or debug workflow failures
- Safer: Less chance of accidental publishes from automated processes
-
Ensure you're on the main branch with latest changes:
git checkout main git pull origin main
-
Create a changeset for your changes:
pnpm changeset
-
Version the packages:
pnpm changeset:version
-
Commit the version changes:
git add . git commit -m "chore: version packages"
-
Build and test everything:
pnpm prerelease
-
Publish to npm:
pnpm changeset:publish
-
Push the version tags and commits:
git push --follow-tags origin main
# Check what would be published
pnpm publish:check
# Build all packages
pnpm build:packages
# Test everything before publishing
pnpm prerelease
# Create a changeset
pnpm changeset
# Version packages
pnpm changeset:version
# Publish to npm
pnpm changeset:publish
# Check npm login status
pnpm npm:check
# Login to npm
pnpm npm:login# Canary release (snapshot with timestamp)
pnpm canary
# Alpha release (snapshot with timestamp)
pnpm alpha
# Beta release (snapshot with timestamp)
pnpm beta
# Dev release (snapshot with timestamp)
pnpm dev:release# Enter prerelease mode (specify tag: alpha, beta, rc, etc.)
pnpm prerelease:enter <tag>
# Exit prerelease mode
pnpm prerelease:exit
# Version packages in prerelease mode
pnpm prerelease:version
# Publish prerelease packages
pnpm prerelease:publish"npm ERR! 403 Forbidden"
- Check if you're logged in:
pnpm npm:check - Verify package name isn't taken
- Check organization permissions
"npm ERR! Package already exists"
- Version number already published
- Update version in package.json
- Or use
pnpm changesetto manage versions
Build failures before publish
- Run
pnpm cleanthenpnpm build:packages - Check TypeScript errors:
pnpm type-check - Check linting:
pnpm lint
Changeset not detecting changes
- Ensure you have uncommitted changes
- Run
git statusto verify changes exist - Check that you're in a git repository
After publishing, verify your package:
# Check package info
npm info @your-org/docusaurus-plugin-llms-txt
# Install in a test project
npm install @your-org/docusaurus-plugin-llms-txt-
Always test before publishing
pnpm prerelease
-
Use semantic versioning consistently
-
Write clear changeset descriptions
-
Keep README and documentation updated
-
Test package installation in a separate project
-
Use canary releases for testing
-
Monitor package downloads and issues
After successful publishing:
- Update documentation if needed
- Announce the release in relevant channels
- Monitor for issues in GitHub issues
- Test the published package in a real project
- Update examples if APIs changed
For questions about publishing:
- Check npm documentation
- Review Changesets documentation
- Open an issue in this repository