-
Notifications
You must be signed in to change notification settings - Fork 5
Add npm publishing support for dual JSR and npm distribution #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
takker99
merged 9 commits into
main
from
copilot/fix-6ec0a2ff-f2ad-42c5-b65e-98e76f6953de
Aug 11, 2025
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c0badb7
Initial plan
Copilot 0d9d1e2
Add npm publishing infrastructure: build script, workflows, and docum…
Copilot 8193d3d
Complete npm publishing setup with comprehensive build scripts and do…
Copilot 4e2bee8
Add DENO_TLS_CA_STORE=system to all workflows to fix JSR package down…
Copilot 2d0d03f
Merge branch 'main' into copilot/fix-6ec0a2ff-f2ad-42c5-b65e-98e76f69…
takker99 2ef03f9
refactor: remove npm build test workflow and streamline npm publishin…
takker99 74e1735
refactor: remove the unused snapshot
takker99 60be3a2
docs: update Node.js and npm support notice in README
takker99 31401b8
refactor: simplify version extraction in npm publish workflow
takker99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: npm-build-test | ||
|
|
||
| env: | ||
| DENO_VERSION: 2.x | ||
| NODE_VERSION: 20.x | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'scripts/build_npm.ts' | ||
| - 'package.json' | ||
| - 'deno.jsonc' | ||
| - '.github/workflows/publish.yml' | ||
| - '.github/workflows/npm-build-test.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test-npm-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: denoland/setup-deno@v2 | ||
| with: | ||
| deno-version: ${{ env.DENO_VERSION }} | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ env.NODE_VERSION }} | ||
| registry-url: 'https://registry.npmjs.org' | ||
| - name: Build npm package | ||
| run: deno task build:npm "0.0.0-test" | ||
| - name: Verify npm package structure | ||
| run: | | ||
| cd npm | ||
| echo "Package structure:" | ||
| find . -type f -name "*.js" -o -name "*.d.ts" -o -name "package.json" | head -20 | ||
| echo "Package.json content:" | ||
| cat package.json | head -30 | ||
| echo "Testing package installation..." | ||
| npm pack --dry-run | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| local_test/ | ||
| coverage/ | ||
| docs/ | ||
| npm/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| #!/usr/bin/env -S deno run -A | ||
|
|
||
| import { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts"; | ||
|
|
||
| await emptyDir("./npm"); | ||
|
|
||
| await build({ | ||
| entryPoints: [ | ||
| "./mod.ts", | ||
| { | ||
| name: "./browser", | ||
| path: "./browser/mod.ts", | ||
| }, | ||
| { | ||
| name: "./browser/dom", | ||
| path: "./browser/dom/mod.ts", | ||
| }, | ||
| { | ||
| name: "./browser/websocket", | ||
| path: "./websocket/mod.ts", | ||
| }, | ||
| { | ||
| name: "./parseAbsoluteLink", | ||
| path: "./parseAbsoluteLink.ts", | ||
| }, | ||
| { | ||
| name: "./rest", | ||
| path: "./rest/mod.ts", | ||
| }, | ||
| { | ||
| name: "./text", | ||
| path: "./text.ts", | ||
| }, | ||
| { | ||
| name: "./title", | ||
| path: "./title.ts", | ||
| }, | ||
| { | ||
| name: "./websocket", | ||
| path: "./websocket/mod.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api", | ||
| path: "./api.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages", | ||
| path: "./api/pages.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project", | ||
| path: "./api/pages/project.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/replace", | ||
| path: "./api/pages/project/replace.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/replace/links", | ||
| path: "./api/pages/project/replace/links.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/search", | ||
| path: "./api/pages/project/search.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/search/query", | ||
| path: "./api/pages/project/search/query.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/search/titles", | ||
| path: "./api/pages/project/search/titles.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/title", | ||
| path: "./api/pages/project/title.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/projects", | ||
| path: "./api/projects.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/projects/project", | ||
| path: "./api/projects/project.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/title/text", | ||
| path: "./api/pages/project/title/text.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/pages/project/title/icon", | ||
| path: "./api/pages/project/title/icon.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/users", | ||
| path: "./api/users.ts", | ||
| }, | ||
| { | ||
| name: "./unstable-api/users/me", | ||
| path: "./api/users/me.ts", | ||
| }, | ||
| ], | ||
| outDir: "./npm", | ||
| shims: { | ||
| // see JS docs for overview and more options | ||
| deno: true, | ||
| }, | ||
| package: { | ||
| // package.json properties | ||
| name: "@cosense/std", | ||
| version: Deno.args[0] ?? "0.0.0", | ||
| description: "UNOFFICIAL standard module for Scrapbox UserScript", | ||
| author: "takker99", | ||
| license: "MIT", | ||
| repository: { | ||
| type: "git", | ||
| url: "git+https://github.com/takker99/scrapbox-userscript-std.git", | ||
| }, | ||
| homepage: "https://github.com/takker99/scrapbox-userscript-std#readme", | ||
| bugs: { | ||
| url: "https://github.com/takker99/scrapbox-userscript-std/issues", | ||
| }, | ||
| keywords: [ | ||
| "scrapbox", | ||
| "userscript", | ||
| "typescript", | ||
| "deno" | ||
| ], | ||
| engines: { | ||
| node: ">=16.0.0", | ||
| }, | ||
| }, | ||
| // Don't use import map for npm build to avoid JSR dependency conflicts | ||
| // importMap: "./deno.jsonc", | ||
|
|
||
| // Disable tests for npm build as they're Deno-specific | ||
| test: false, | ||
| // Don't run type checking during build to avoid JSR dependency issues | ||
| typeCheck: false, | ||
| declaration: "inline", | ||
| scriptModule: "cjs", | ||
| compilerOptions: { | ||
| lib: ["esnext", "dom", "dom.iterable"], | ||
| target: "ES2020", | ||
| }, | ||
| }); | ||
|
|
||
| // Copy additional files | ||
| await Deno.copyFile("LICENSE", "npm/LICENSE"); | ||
| await Deno.copyFile("README.md", "npm/README.md"); | ||
|
|
||
| console.log("npm package built successfully!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env -S deno run -A | ||
|
|
||
| // Simple test to check if dnt is accessible | ||
| try { | ||
| console.log("Testing dnt import..."); | ||
| const { build } = await import("https://deno.land/x/dnt@0.40.0/mod.ts"); | ||
| console.log("✅ dnt imported successfully"); | ||
| console.log("Build function type:", typeof build); | ||
| } catch (error) { | ||
| console.error("❌ Failed to import dnt:", error.message); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.