Skip to content

Commit 85d21f6

Browse files
authored
deprecate uni-require, and fix its stale repository metadata (#14)
The repo was renamed `uni-require` → `esm-plus`, but `packages/uni-require/package.json` still names the old path in `homepage`, `bugs` and `repository`. **This blocks the next publish.** npm verifies the sigstore provenance bundle against `repository.url`, and the trusted publisher for `uni-require` was re-registered against `cyberuni/esm-plus` on 2026-09-03. The banked `1.0.1` would have failed with: ``` E422 Unprocessable Entity - Error verifying sigstore provenance bundle: Failed to validate repository information ``` Same fault that blocked `jest-watch-suspend` earlier today, reached by a **rename** rather than a transfer. It hides the same way: GitHub redirects the old repo path indefinitely, so the value looks valid in a browser, in `gh`, and in `npm view` — it is only ever checked at publish, against the OIDC claim. `CHANGELOG.md` is deliberately untouched: historical release records whose links still resolve through the redirect. ## Not in this PR A separate, more serious bug exists in this package and needs a design decision — `createRequire(import.meta.url)` in `index.js` and `const uniRequire = require` in `index.cjs` are both bound to **uni-require's own module scope**, not the caller's, so `uniRequire.resolve()` resolves from the wrong place. That is the feature the README names as the package's main benefit. Raised separately. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ETjy9oQGyETyFmDBdR9Egz
2 parents fe3fa0b + be77e9c commit 85d21f6

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

packages/uni-require/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# uni-require
22

3+
> [!WARNING]
4+
> **Deprecated. Do not use this package.**
5+
>
6+
> `uniRequire.resolve()` — the capability this package exists to provide — has
7+
> never worked as documented. Both entry points bind `require` to *uni-require's*
8+
> own module scope rather than the caller's:
9+
>
10+
> ```js
11+
> // index.js
12+
> const uniRequire = createRequire(import.meta.url) // uni-require's URL, not yours
13+
>
14+
> // index.cjs
15+
> const uniRequire = require // uni-require's require, not yours
16+
> ```
17+
>
18+
> So `uniRequire.resolve('./x')` resolves relative to `uni-require`, not to your
19+
> module. This is not fixable while keeping the API: an ES module cannot discover
20+
> its caller's URL.
21+
>
22+
> ### Use Node's own `createRequire` instead
23+
>
24+
> ```js
25+
> import { createRequire } from 'node:module'
26+
> const require = createRequire(import.meta.url) // your URL — correct
27+
> ```
28+
>
29+
> Available since Node 12. It is one line, it is in the standard library, and it
30+
> resolves from the right place.
31+
>
32+
> The dual-packaging problem described below is also largely moot now: Node 22.12
33+
> and later support `require()` of an ES module directly.
34+
35+
336
The `require()` function is not available for ESM package.
437
538
But there are situation you need to use it,

packages/uni-require/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"import",
99
"esm"
1010
],
11-
"homepage": "https://github.com/cyberuni/uni-require",
11+
"homepage": "https://github.com/cyberuni/esm-plus",
1212
"bugs": {
13-
"url": "https://github.com/cyberuni/uni-require/issues"
13+
"url": "https://github.com/cyberuni/esm-plus/issues"
1414
},
1515
"repository": {
1616
"type": "git",
17-
"url": "https://github.com/cyberuni/uni-require.git",
17+
"url": "https://github.com/cyberuni/esm-plus.git",
1818
"directory": "packages/uni-require"
1919
},
2020
"license": "MIT",

0 commit comments

Comments
 (0)