Add npm publishing support for dual JSR and npm distribution #77
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.
This PR implements npm publishing capabilities to complement the existing JSR distribution, addressing the community request for npm availability based on takker99/scrapbox-userscript-std#237.
Overview
The package is currently published to JSR (JavaScript Registry) but users have requested npm support for broader ecosystem compatibility. This implementation adds dual publishing while maintaining full backward compatibility with existing JSR users.
Key Changes
🔧 Build Infrastructure
@deno/dnt
(Deno Node Transform)rest
,userscript
,websocket
) fromdeno.jsonc
exports to npm package structure🚀 CI/CD Integration
publish-jsr
andpublish-npm
jobs for reliabilityDENO_TLS_CA_STORE=system
to all workflows to ensure reliable JSR package downloads📚 Documentation & Examples
jsr:@cosense/types
and@cosense/types
import stylesPackage Structure
The npm package maintains the same API surface as JSR:
All 3 export paths from the original
deno.jsonc
configuration are preserved:rest
,userscript
, andwebsocket
.Setup Required
To enable npm publishing, add an
NPM_TOKEN
secret to the repository with an automation token from npmjs.com. The package will be published as@cosense/types
(matching the JSR name) when tags are pushed.Testing
Both JSR and npm build methods have been tested and successfully generate all modules with proper TypeScript definitions:
deno task check
- Full JSR validation including lint, format, test, and publish dry-rundeno task npm:build
- Generates complete npm package structuredeno task npm:check
- Validates npm package for publishingThis implementation provides a seamless experience for users regardless of their preferred package registry while maintaining the existing developer workflow.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.