@green-tea/core is published on JSR, and JSR serves src/ rather than the tsup build. The ESM build gets a createRequire banner; the source does not. Every lazy require() in src/ therefore has no require on JSR — and one of them is not guarded.
What happens
A Deno app that maps @green-tea/core to jsr:@green-tea/core@26.8.0-beta.1 and calls @Html('public/index.html') dies at boot:
error: Uncaught (in promise) ReferenceError: require is not defined
const nodePath = require('node:path') as typeof import('node:path');
at readViewFile (https://jsr.io/@green-tea/core/26.8.0-beta.1/src/views.ts:64:20)
at buildHtmlTransformer (…/src/views.ts:139:18)
at createApp (…/src/app/index.ts:187:20)
tsup.config.ts:17 is explicit about why this works everywhere else:
options.banner={js:"import { createRequire as _createRequire } from 'node:module'; const require = _createRequire(import.meta.url);"};
JSR never runs tsup. deno.json's exports point straight at ./src/index.ts, so the banner the source depends on is not there.
What is affected
Six call sites use the lazy require(), and they fail differently:
Site
On JSR
Severity
views.ts:64readViewFile
unguarded ReferenceError at boot
@Html file and template modes are dead
views.ts:98buildStaticResolver
catch reports "static needs a filesystem and is unavailable on this runtime (edge)"
wrong cause — Deno has a filesystem
multipart.ts:71loadBusboy
catch → null → 501 "busboy not installed"
wrong cause — it is installed
http/core.ts:34randomUUID
never reached: globalThis.crypto.randomUUID wins
safe
ws-adapter.ts:127loadWebSocketCtor
never reached: global WebSocket wins
safe
http/server.ts:47 node http
never reached: Node-only listen() path
safe
So the two that are guarded produce a misdiagnosis rather than a crash, which is worse to debug than the crash: both blame the runtime for a packaging problem, and both name edge while running on Deno.
Why it matters
Publishing to JSR is a deliberate position, stated in deno.json: "a docs example that imports @green-tea/core/bun has to work whichever registry the reader installed from." Right now it does not. The filesystem-backed features are exactly what a JSR reader would reach for on Deno, and they are the ones that break.
Nothing catches this today: the test suite runs against src/ under Vitest on Node, where require exists.
Scope
Replace the lazy require() calls with something that works unbuilt. createRequire(import.meta.url) in the source is the same trick the banner performs, and it is Node/Deno/Bun-portable; workerd is the constraint that made these lazy in the first place, so whatever replaces them has to stay unevaluated on the edge path.
Add one smoke test that runs an app from the JSR entry points — deno run against deno.json's exports, with @Html('file') and static: true — so this class of "works in the build, not in the source" cannot come back.
Until it is fixed, the JSR listing should say which features are unavailable there.
Related
Found while pointing the green-desk demo at JSR instead of npm. The npm package is unaffected — the banner does its job.
`@green-tea/core` is published on JSR, and JSR serves `src/` rather than the tsup build. The ESM build gets a `createRequire` banner; the source does not. Every lazy `require()` in `src/` therefore has no `require` on JSR — and one of them is not guarded.
## What happens
A Deno app that maps `@green-tea/core` to `jsr:@green-tea/core@26.8.0-beta.1` and calls `@Html('public/index.html')` dies at boot:
```
error: Uncaught (in promise) ReferenceError: require is not defined
const nodePath = require('node:path') as typeof import('node:path');
at readViewFile (https://jsr.io/@green-tea/core/26.8.0-beta.1/src/views.ts:64:20)
at buildHtmlTransformer (…/src/views.ts:139:18)
at createApp (…/src/app/index.ts:187:20)
```
`tsup.config.ts:17` is explicit about why this works everywhere else:
```js
options.banner = { js: "import { createRequire as _createRequire } from 'node:module'; const require = _createRequire(import.meta.url);" };
```
JSR never runs tsup. `deno.json`'s `exports` point straight at `./src/index.ts`, so the banner the source depends on is not there.
## What is affected
Six call sites use the lazy `require()`, and they fail differently:
| Site | On JSR | Severity |
|---|---|---|
| `views.ts:64` `readViewFile` | **unguarded `ReferenceError` at boot** | `@Html` file and template modes are dead |
| `views.ts:98` `buildStaticResolver` | `catch` reports *"`static` needs a filesystem and is unavailable on this runtime (edge)"* | wrong cause — Deno **has** a filesystem |
| `multipart.ts:71` `loadBusboy` | `catch` → `null` → 501 "busboy not installed" | wrong cause — it is installed |
| `http/core.ts:34` `randomUUID` | never reached: `globalThis.crypto.randomUUID` wins | safe |
| `ws-adapter.ts:127` `loadWebSocketCtor` | never reached: global `WebSocket` wins | safe |
| `http/server.ts:47` node http | never reached: Node-only `listen()` path | safe |
So the two that are guarded produce a **misdiagnosis** rather than a crash, which is worse to debug than the crash: both blame the runtime for a packaging problem, and both name `edge` while running on Deno.
## Why it matters
Publishing to JSR is a deliberate position, stated in `deno.json`: *"a docs example that imports `@green-tea/core/bun` has to work whichever registry the reader installed from."* Right now it does not. The filesystem-backed features are exactly what a JSR reader would reach for on Deno, and they are the ones that break.
Nothing catches this today: the test suite runs against `src/` under Vitest on Node, where `require` exists.
## Scope
- Replace the lazy `require()` calls with something that works unbuilt. `createRequire(import.meta.url)` in the source is the same trick the banner performs, and it is Node/Deno/Bun-portable; workerd is the constraint that made these lazy in the first place, so whatever replaces them has to stay unevaluated on the edge path.
- Add one smoke test that runs an app **from the JSR entry points** — `deno run` against `deno.json`'s `exports`, with `@Html('file')` and `static: true` — so this class of "works in the build, not in the source" cannot come back.
- Until it is fixed, the JSR listing should say which features are unavailable there.
## Related
Found while pointing the `green-desk` demo at JSR instead of npm. The npm package is unaffected — the banner does its job.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
@green-tea/coreis published on JSR, and JSR servessrc/rather than the tsup build. The ESM build gets acreateRequirebanner; the source does not. Every lazyrequire()insrc/therefore has norequireon JSR — and one of them is not guarded.What happens
A Deno app that maps
@green-tea/coretojsr:@green-tea/core@26.8.0-beta.1and calls@Html('public/index.html')dies at boot:tsup.config.ts:17is explicit about why this works everywhere else:JSR never runs tsup.
deno.json'sexportspoint straight at./src/index.ts, so the banner the source depends on is not there.What is affected
Six call sites use the lazy
require(), and they fail differently:views.ts:64readViewFileReferenceErrorat boot@Htmlfile and template modes are deadviews.ts:98buildStaticResolvercatchreports "staticneeds a filesystem and is unavailable on this runtime (edge)"multipart.ts:71loadBusboycatch→null→ 501 "busboy not installed"http/core.ts:34randomUUIDglobalThis.crypto.randomUUIDwinsws-adapter.ts:127loadWebSocketCtorWebSocketwinshttp/server.ts:47node httplisten()pathSo the two that are guarded produce a misdiagnosis rather than a crash, which is worse to debug than the crash: both blame the runtime for a packaging problem, and both name
edgewhile running on Deno.Why it matters
Publishing to JSR is a deliberate position, stated in
deno.json: "a docs example that imports@green-tea/core/bunhas to work whichever registry the reader installed from." Right now it does not. The filesystem-backed features are exactly what a JSR reader would reach for on Deno, and they are the ones that break.Nothing catches this today: the test suite runs against
src/under Vitest on Node, whererequireexists.Scope
require()calls with something that works unbuilt.createRequire(import.meta.url)in the source is the same trick the banner performs, and it is Node/Deno/Bun-portable; workerd is the constraint that made these lazy in the first place, so whatever replaces them has to stay unevaluated on the edge path.deno runagainstdeno.json'sexports, with@Html('file')andstatic: true— so this class of "works in the build, not in the source" cannot come back.Related
Found while pointing the
green-deskdemo at JSR instead of npm. The npm package is unaffected — the banner does its job.