Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 12, 2025

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

  • Dual build system: Added npm package generation using @deno/dnt (Deno Node Transform)
  • Complete export mapping: Maps all 3 main modules (rest, userscript, websocket) from deno.jsonc exports to npm package structure
  • Format support: Generates both ESM and TypeScript definitions for maximum Node.js compatibility

🚀 CI/CD Integration

  • GitHub Actions: Updated publish workflow to deploy to both JSR and npm simultaneously
  • Dual jobs: Separate publish-jsr and publish-npm jobs for reliability
  • TLS Configuration: Added DENO_TLS_CA_STORE=system to all workflows to ensure reliable JSR package downloads

📚 Documentation & Examples

  • Installation options: README now shows both JSR and npm installation methods with badges
  • Import examples: Code samples demonstrate both jsr:@cosense/types and @cosense/types import styles
  • Usage guide: Clear examples for both Deno and Node.js users
  • ⚠️ Node.js Notice: Added experimental support notice explaining compatibility status and providing guidance for users

Package Structure

The npm package maintains the same API surface as JSR:

// JSR (existing)
import type { PageList } from "jsr:@cosense/types/rest";
import type { Scrapbox } from "jsr:@cosense/types/userscript";

// npm (new)  
import type { PageList } from "@cosense/types/rest";
import type { Scrapbox } from "@cosense/types/userscript";

All 3 export paths from the original deno.jsonc configuration are preserved: rest, userscript, and websocket.

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-run
  • deno task npm:build - Generates complete npm package structure
  • deno task npm:check - Validates npm package for publishing

This 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.

@Copilot Copilot AI self-assigned this Aug 12, 2025
@Copilot Copilot AI changed the title [WIP] @takker99/scrapbox-userscript-std/pull/237 を参考に、npm対応を入れてほしい。 package nameは@cosense/typesとする。 Add npm publishing support for dual JSR and npm distribution Aug 12, 2025
@Copilot Copilot AI requested a review from takker99 August 12, 2025 06:13
Copilot finished work on behalf of takker99 August 12, 2025 06:13
Copy link
Contributor

@takker99 takker99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 1点だけ補足した。対応よろしく。

@Copilot Copilot AI requested a review from takker99 August 12, 2025 06:34
Copilot finished work on behalf of takker99 August 12, 2025 06:34
@takker99 takker99 marked this pull request as ready for review August 12, 2025 06:46
@takker99 takker99 merged commit 0840b18 into main Aug 12, 2025
2 checks passed
@takker99 takker99 deleted the copilot/fix-23021ea6-5d9d-44b9-9088-d6c00ca8bc47 branch August 12, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants