feat: publish to NPM instead of JSR - #67
Merged
Merged
Conversation
The package is published to NPM now, instead of JSR. The TypeScript sources are compiled to JavaScript using `@swc/core` and the type declarations are emitted using TypeScript 7. Both steps run from the `prepublishOnly` hook into the `npm/` folder, which is what `exports` points to. This mirrors the setup used in `nRFCloud/billing-service-proto`. `semantic-release` publishes via `@semantic-release/npm` instead of `@sebbo2002/semantic-release-jsr`.
Member
Author
|
Security fix, no review required. |
coderbyheart
enabled auto-merge (squash)
August 5, 2026 12:10
coderbyheart
disabled auto-merge
August 5, 2026 12:10
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Publishes this package to NPM instead of JSR.
Why
JSR packages are consumed through JSR's NPM compatibility layer, as
npm:@jsr/nrfcloud__…aliases that resolve to tarball URLs onnpm.jsr.io.NPM v12 classifies those as
remotefetches and refuses them unlessallow-remoteis set.allow-remote=rootonly covers a project's own top-leveldependencies — as soon as one of them pulls in a transitive JSR dependency,
every host project consuming it has to relax the setting to
allow-remote=all.That is not a per-dependency exemption: it permits fetching arbitrary remote
tarballs anywhere in the dependency tree, for every dependency of the host
project, bypassing the registry. That is a large attack surface to open up in
every consuming project just to distribute a handful of internal libraries.
Publishing to NPM removes the need for it entirely: these packages become
ordinary registry dependencies.
What changed
jsr.jsonis removed.semantic-releasenow uses@semantic-release/npm(and@semantic-release/github, so a GitHub release is created as well) instead of@sebbo2002/semantic-release-jsr. The ad-hocnpm install -D @sebbo2002/semantic-release-jsrin the workflow is gone; bothplugins ship with
semantic-release.actions/setup-nodesetsregistry-url: https://registry.npmjs.orgso@semantic-release/npmcan authenticate.prepublishOnlyhook builds the published artifacts intonpm/, followingnRFCloud/billing-service-proto:.npm/compile.tstranspiles the TypeScript sources with@swc/coreand rewrites.tsimport specifiers to
.js.declarations using
.npm/tsconfig.npm.json.exportspoints at the compiled output innpm/,fileslimits the tarballto
npmandREADME.md, andnpm/is gitignored.tsconfig.jsongains"include": ["./**/*.ts", "./.npm/*.ts"]. TypeScript'sdefault include glob skips dot-directories, so without this the new build
scripts would never be type-checked.
"exclude": ["npm/**/*"]keeps thegenerated output out of the type check, and
"types": ["node"]is neededbecause the build scripts use Node.js built-ins.
Verified locally
npx tsc,npm testandnpm run prepublishOnlyall pass. The resultingtarball was installed into a scratch project, where the package type-checks
under TypeScript 7 and imports at runtime.
Needs doing on the NPM side before this can release
The
@nrfcloudscope needs to accept this package name. Publishing relies onnpm trusted publishing (the
workflow already grants
id-token: writeand passes noNODE_AUTH_TOKENto therelease step), so a trusted publisher for this repository has to be configured
on npmjs.com — or the release step needs an
NPM_TOKEN.publishConfig.accessis set topublic, which keeps the package as publiclyavailable as it was on JSR. Change it to
restrictedif it should becomeprivate instead.
Follow-up
This repo still consumes other nRF Cloud libraries through their JSR
npm-compatibility aliases (
npm:@jsr/nrfcloud__…). Those are left untouchedhere, because the NPM versions of those packages do not exist until their own
migration PRs have been merged and released. Once they have, a follow-up PR
should switch them to plain
@nrfcloud/…NPM dependencies (and drop@jsr:registryfrom.npmrc).