build: publish a real build to npm, and the source to JSR #3

Merged
chrnx merged 1 commits from feature/package-builds into develop 2026-09-19 17:06:44 +00:00
Owner

Every package exported ./src/index.ts and had no build at all, which made the npm half of the dual publish unusable. Measured against the staging registry with @green-tea/metrics installed into a clean project:

Consumer Before
Node 22 ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING
Node --experimental-strip-types same error — the flag does not lift it
Deno via npm same error
Bun worked

Node refuses to strip types under node_modules unconditionally, so this was not a version floor or a missing flag. The release pipeline in spec 2.4 has no build step, so it would have published that to both registries at once.

What changed

JSR needs no help. It transpiles on publish and hands Node an ESM package with generated declarations — verified by unpacking a real npm.jsr.io tarball. So deno.json is untouched and keeps exporting src/.

The build exists for npm alone, as CJS and ESM. Core is "type": "commonjs" and publishes both formats for all four entry points, so a CJS application has to be able to require() a plugin.

Core stays external in the declarations. tsup bundles devDependencies by default and convention rule 8 puts core there, so without external: ['@green-tea/core'] every plugin would ship a frozen private copy of a contract core owns.

Also: eslint.config.mjs ignored a bare 'dist', which never matched packages/*/dist — the linter started analysing the build output the moment one existed.

Verification

Packed all three and consumed them from outside the workspace, rather than only compiling them:

Check Result
Node require() passes
Node import passes
Bun passes
Deno via npm passes
tsc under node16 and bundler clean

Tarball now carries dist/ + README + CHANGELOG and nothing else; it used to ship test/.

Gates

Two new tests per package in test/workspace.test.ts pin that npm is served dist/ and JSR src/, plus files and the build scripts. Confirmed they bite: restoring exports: './src/index.ts' on metrics fails both. npm run build added to CI, and convention rule 11 records why the two registries are fed different things.

Still private: true — nothing is published by this PR.

Every package exported `./src/index.ts` and had no build at all, which made the npm half of the dual publish unusable. Measured against the staging registry with `@green-tea/metrics` installed into a clean project: | Consumer | Before | | --- | --- | | Node 22 | `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` | | Node `--experimental-strip-types` | same error — the flag does not lift it | | Deno via npm | same error | | Bun | worked | Node refuses to strip types under `node_modules` unconditionally, so this was not a version floor or a missing flag. The release pipeline in spec 2.4 has no build step, so it would have published that to both registries at once. ## What changed **JSR needs no help.** It transpiles on publish and hands Node an ESM package with generated declarations — verified by unpacking a real `npm.jsr.io` tarball. So `deno.json` is untouched and keeps exporting `src/`. **The build exists for npm alone**, as CJS *and* ESM. Core is `"type": "commonjs"` and publishes both formats for all four entry points, so a CJS application has to be able to `require()` a plugin. **Core stays external in the declarations.** tsup bundles devDependencies by default and convention rule 8 puts core there, so without `external: ['@green-tea/core']` every plugin would ship a frozen private copy of a contract core owns. Also: `eslint.config.mjs` ignored a bare `'dist'`, which never matched `packages/*/dist` — the linter started analysing the build output the moment one existed. ## Verification Packed all three and consumed them from outside the workspace, rather than only compiling them: | Check | Result | | --- | --- | | Node `require()` | passes | | Node `import` | passes | | Bun | passes | | Deno via npm | passes | | `tsc` under `node16` and `bundler` | clean | Tarball now carries `dist/` + README + CHANGELOG and nothing else; it used to ship `test/`. ## Gates Two new tests per package in `test/workspace.test.ts` pin that npm is served `dist/` and JSR `src/`, plus `files` and the build scripts. Confirmed they bite: restoring `exports: './src/index.ts'` on metrics fails both. `npm run build` added to CI, and convention rule 11 records why the two registries are fed different things. Still `private: true` — nothing is published by this PR.
chrnx added 1 commit 2026-09-19 16:59:12 +00:00
build: publish a real build to npm, and the source to JSR
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 10s
CI / build (pull_request) Successful in 18s
CI / runtimes (deno) (pull_request) Successful in 11s
CI / runtimes (edge) (pull_request) Successful in 9s
3b1eceecb9
Every package exported `./src/index.ts` and had no build at all, which made the
npm half of the dual publish unusable. Measured against a staging registry with
`@green-tea/metrics` installed into a clean project: Node threw
ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING, `--experimental-strip-types` threw
the same error because Node refuses to strip types under `node_modules`
unconditionally, and Deno-via-npm threw it too. Only Bun could import it. The
release pipeline would have published that to both registries at once.

JSR needs no help — it transpiles on publish and hands Node an ESM package with
generated declarations — so `deno.json` keeps exporting `src/`. The build exists
for npm alone, as CJS and ESM: core is `"type": "commonjs"` and publishes both,
so a CJS application has to be able to `require()` a plugin.

Core stays external in the declarations. tsup bundles devDependencies by
default, and convention rule 8 puts core there, so without that line every
plugin would have shipped a frozen private copy of a contract core owns.

Verified by packing all three and consuming them from outside the workspace:
`require()` and `import` both resolve under Node, Bun and Deno, and `tsc`
type-checks clean under `node16` and `bundler` resolution.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
chrnx merged commit dcc9c3d42b into develop 2026-09-19 17:06:44 +00:00
Sign in to join this conversation.