chore(plugins): publish to JSR alone, and drop the npm build
The second registry was costing a tsup config per package, a dual `exports` map and a `dist/` that could go stale between a merge and a release — and it was not buying a reader anything. `npx jsr add @green-tea/<name>` installs under npm, yarn, pnpm and bun through `npm.jsr.io`: one line in `.npmrc`, and the import specifier stays `@green-tea/<name>`. The `@jsr/` name only ever appears in the lockfile. Nothing is published yet — all three packages are absent from both registries — so this costs no consumer anything, and it is the reversible direction: adding npm later breaks nobody, while removing it after a publish would. JSR is also the only one of the two that can record *where a plugin runs*, per package, which is not cosmetic for a framework whose claim is one app on four runtimes. `jwt` needs `node:fs/promises` and cannot serve workerd; `metrics` imports nothing and runs everywhere. npm has nowhere to put that. `private: true` stays and becomes the guard: an accidental `npm publish` now fails rather than shipping entry points that describe a build nobody runs. `test/workspace.test.ts` pins that invariant instead of the dual-registry one. The CI job keeps the name `build` deliberately — renaming it would change a required status check on the protected branches, which is a separate change. `deno publish --dry-run` in the `runtimes` job now stands in for the build, and it is the publish path these packages actually take. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
11 files changed
+48
-1510
No files matched your search
+23
-21
@@ -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');
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user