chore(plugins): publish to JSR alone, and drop the npm build #5

Merged
chrnx merged 4 commits from chore/jsr-only-plugins into develop 2026-09-23 16:35:03 +00:00
11 changed files with 48 additions and 1510 deletions
Showing only changes of commit 4caf8809df - Show all commits

No files matched your search

+3 -4
View File
@@ -55,10 +55,9 @@ jobs:
- run: npm run complexity:check
- run: npm run typecheck
- run: npm test
# The npm tarball is a build artifact, so a broken build is a broken release. `typecheck` will
# not catch it: that runs with `noEmit`, and tsup emits through esbuild, which resolves and
# bundles on its own terms.
- run: npm run build
# No build step: JSR publishes `src/` and transpiles it. `deno publish --dry-run`, in the
# `runtimes` job below, is what stands in for it — that is the publish path these packages
# actually take.
# A fixed matrix, not `fromJSON`: Gitea Actions support for a dynamic matrix was not verified. Each
# entry runs only the packages whose engines name that runtime (scripts/run-runtime.mjs).
+22 -7
View File
@@ -18,7 +18,6 @@ npm run typecheck
npm test # Node: every package's contract tests + the workspace checks
npm run test:deno # packages whose engines declare deno
npm run test:bun # packages whose engines declare bun
npm run build # tsup, every package: dist/ as CJS + ESM + declarations, for npm only
```
Run all of them before proposing anything as finished. CI runs each one and each gates a merge.
@@ -49,12 +48,28 @@ a pull request. Until core is consumed from npm (Plan B3), CI runs on Gitea only
beside every one that is not supported. Nobody should have to open an issue to learn where a
plugin runs.
10. A breaking change goes under `### Breaking`, first in the package's CHANGELOG.
11. **The two registries are served different things.** `deno.json` exports `./src/index.ts`, because
JSR transpiles TypeScript itself and hands Node a typed ESM package. `package.json` exports
`./dist/`, built by tsup as CJS *and* ESM, because npm transpiles nothing and Node refuses to
strip types under `node_modules` — `--experimental-strip-types` does not lift that, so a package
exporting `.ts` installs cleanly and then throws on the first import, everywhere but Bun.
`test/workspace.test.ts` pins both halves.
11. **Plugins publish to JSR alone.** `deno.json` exports `./src/index.ts` and there is no build:
JSR transpiles the TypeScript itself and hands consumers a typed ESM package with generated
declarations. Every `package.json` here stays `private`, so an accidental `npm publish` fails
rather than shipping entry points that describe a `dist/` nobody produces. `test/workspace.test.ts`
pins that.
The second registry was dropped because it was not buying a reader anything. `npx jsr add
@green-tea/<name>` installs under npm, yarn, pnpm and bun via `npm.jsr.io` — one line in
`.npmrc`, and the import specifier stays `@green-tea/<name>`; the `@jsr/` name appears only in
the lockfile. What it cost was a tsup config per package, a dual `exports` map, and a `dist/`
that could go stale between a merge and a release.
JSR is also the only one of the two that can say **where a plugin runs**. Its `runtimeCompat` is
per package, which matters for a framework whose claim is one app on four runtimes: `jwt` needs
`node:fs/promises` and cannot serve workerd, while `metrics` imports nothing and runs everywhere.
npm has nowhere to record that difference, so rule 9's `engines`/README pair was the only place
it lived. It is declared in the JSR package settings, not in `deno.json` — the config schema
accepts `name`, `version`, `license`, `exports` and `publish`, and nothing else.
What this gives up: no discovery on npmjs.org, where the marketplace is the channel anyway, and
a site behind a registry proxy that mirrors npmjs.org and refuses a second one cannot reach the
plugins. Core still can — it publishes to both.
## Conventions
-1353
View File
File diff suppressed because it is too large. Load diff
-2
View File
@@ -10,7 +10,6 @@
"node": ">=22"
},
"scripts": {
"build": "npm run build --workspaces",
"lint": "eslint --no-error-on-unmatched-pattern packages test",
"format": "prettier --write \"packages/*/{src,test}/**/*.ts\" \"test/**/*.ts\"",
"format:check": "prettier --check \"packages/*/{src,test}/**/*.ts\" \"test/**/*.ts\"",
@@ -29,7 +28,6 @@
"cognitive-complexity-ts": "^0.8.2",
"eslint": "^9.39.5",
"prettier": "^3.9.6",
"tsup": "^8.5.1",
"tsx": "^4.23.5",
"typescript": "^5.5.0",
"typescript-eslint": "^8.70.0"
-24
View File
@@ -16,30 +16,6 @@
"deno": ">=2",
"bun": ">=1.3"
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build"
},
"dependencies": {
"jose": "^6.2.12"
},
-17
View File
@@ -1,17 +0,0 @@
import { defineConfig } from 'tsup';
// The npm half of the dual publish. JSR serves `src/` straight from `deno.json` and transpiles it
// itself, so nothing here is JSR's problem — this exists because a plain `npm i` gets none of that
// and Node refuses to strip types under `node_modules`.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node22',
// Convention rule 8 keeps core in `devDependencies`, and tsup bundles devDependencies by default.
// Without this line the emitted declarations would inline core's types rather than import them,
// and every plugin would ship a frozen private copy of a contract core owns.
external: ['@green-tea/core'],
});
-24
View File
@@ -16,30 +16,6 @@
"deno": ">=2",
"bun": ">=1.3"
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@green-tea/core": "26.9.0-beta.2"
}
-17
View File
@@ -1,17 +0,0 @@
import { defineConfig } from 'tsup';
// The npm half of the dual publish. JSR serves `src/` straight from `deno.json` and transpiles it
// itself, so nothing here is JSR's problem — this exists because a plain `npm i` gets none of that
// and Node refuses to strip types under `node_modules`.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node22',
// Convention rule 8 keeps core in `devDependencies`, and tsup bundles devDependencies by default.
// Without this line the emitted declarations would inline core's types rather than import them,
// and every plugin would ship a frozen private copy of a contract core owns.
external: ['@green-tea/core'],
});
-24
View File
@@ -16,30 +16,6 @@
"deno": ">=2",
"bun": ">=1.3"
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@green-tea/core": "26.9.0-beta.2"
}
-17
View File
@@ -1,17 +0,0 @@
import { defineConfig } from 'tsup';
// The npm half of the dual publish. JSR serves `src/` straight from `deno.json` and transpiles it
// itself, so nothing here is JSR's problem — this exists because a plain `npm i` gets none of that
// and Node refuses to strip types under `node_modules`.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node22',
// Convention rule 8 keeps core in `devDependencies`, and tsup bundles devDependencies by default.
// Without this line the emitted declarations would inline core's types rather than import them,
// and every plugin would ship a frozen private copy of a contract core owns.
external: ['@green-tea/core'],
});
+23 -21
View File
@@ -14,6 +14,7 @@ const README_RUNTIMES: Record<string, string> = { Node: 'node', Deno: 'deno', Bu
interface PackageJson {
name: string;
version: string;
private?: boolean;
engines?: Record<string, string>;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
@@ -105,29 +106,30 @@ for (const dir of packages) {
assert.ok(readJson<DenoJson>('deno.json').workspace?.includes(`./packages/${dir}`));
});
test(`${dir}: npm is served the build and JSR the source`, () => {
// The two registries are fed different things on purpose. JSR transpiles TypeScript itself, so
// it gets `src/`. npm does not, and Node refuses to strip types under `node_modules` — a package
// whose `exports` pointed at a `.ts` file installed fine and then threw on the first import.
test(`${dir}: JSR is served the source`, () => {
// JSR transpiles TypeScript itself and hands consumers a typed ESM package, so it gets `src/`
// and the packages carry no build of their own.
assert.equal(deno.exports, './src/index.ts', 'JSR should publish the TypeScript source');
assert.deepEqual(pkg.exports, {
'.': {
import: { types: './dist/index.d.ts', default: './dist/index.js' },
require: { types: './dist/index.d.cts', default: './dist/index.cjs' },
},
});
assert.equal(pkg.main, './dist/index.cjs');
assert.equal(pkg.module, './dist/index.js');
assert.equal(pkg.types, './dist/index.d.ts');
});
test(`${dir}: the tarball ships the build and nothing else`, () => {
// Without `files`, npm packs the whole directory — the first tarball carried `test/` along.
assert.deepEqual(pkg.files, ['dist', 'README.md', 'CHANGELOG.md']);
assert.equal(pkg.scripts?.build, 'tsup');
// A stale `dist/` is the one packaging failure no static check can see, so the build runs again
// on the way out rather than trusting whatever CI left behind.
assert.equal(pkg.scripts?.prepublishOnly, 'npm run build');
test(`${dir}: nothing here is publishable to npm`, () => {
// Plugins publish to JSR alone. `npx jsr add` installs them under npm, yarn, pnpm and bun
// through `npm.jsr.io`, which leaves the import specifier intact, so the second registry bought
// a per-package tsup build and a dual `exports` map without buying a reader anything.
//
// JSR is also the only one of the two that can say *where a plugin runs*, per package. That is
// not cosmetic for a framework whose claim is one app on four runtimes: `jwt` needs
// `node:fs/promises` and `metrics` imports nothing at all, and npm has nowhere to record the
// difference.
//
// `private` is the guard, not a leftover: it is what makes an accidental `npm publish` fail
// instead of shipping a package whose entry points describe a `dist/` nobody builds.
assert.equal(pkg.private, true, 'a plugin must not be publishable to npm');
for (const field of ['main', 'module', 'types', 'exports', 'files'] as const) {
assert.equal(pkg[field], undefined, `${field} describes an npm tarball that is never built`);
}
assert.equal(pkg.scripts?.build, undefined, 'there is no build to run');
});
}