@gjsify/rolldown-plugin-pnp 0.4.35 → 0.4.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +32 -0
  2. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -87,6 +87,38 @@ export async function pnpPlugin(opts = {}) {
87
87
  // `@girs/*` packages don't list `gi:` as a dep).
88
88
  if (source.startsWith('gi://'))
89
89
  return { id: source, external: true };
90
+ // `node:`-prefixed specifiers (`node:fs`, `node:path`, etc.)
91
+ // are a Node-resolver concept Yarn PnP does NOT understand —
92
+ // `pnpApi.resolveRequest('node:fs', issuer)` throws
93
+ // `UNDECLARED_DEPENDENCY` because PnP treats `node:fs` as an
94
+ // ordinary specifier requiring an explicit declaration in the
95
+ // consumer's package.json.
96
+ //
97
+ // Returning `null` here is NOT enough under Rolldown: when
98
+ // `process.versions.pnp` is truthy, Rolldown's `bindingifyResolve`
99
+ // (see `node_modules/rolldown/dist/shared/bindingify-input-options-*.mjs`)
100
+ // unconditionally enables `yarnPnp: true` in the Rust resolver.
101
+ // That makes the native resolver run PnP for every unresolved
102
+ // bare specifier after the plugin `pre`-order chain returns null
103
+ // — including `node:fs` — and surface the exact
104
+ // `non-Node resolution context` error PnP throws for builtins.
105
+ // The user-facing `resolve` options have no knob to disable that.
106
+ //
107
+ // Instead we MUST actively intercept `node:*` here and route
108
+ // it through the rest of the plugin chain via `this.resolve()`
109
+ // (`skipSelf: true` keeps us out of the recursion). The gjsify
110
+ // alias plugin maps `node:<X>` → `@gjsify/<X>` and the
111
+ // re-resolved `@gjsify/<X>` specifier flows back through this
112
+ // hook in the next pass, where PnP resolves it cleanly via the
113
+ // polyfill-package relay below. Without this carve-out, every
114
+ // external PnP consumer importing `node:fs` etc. hits
115
+ // `[RESOLVE_ERROR] Could not resolve 'node:fs'` — exactly the
116
+ // failure mode surfaced by `tests/e2e/cli-only-pnp/` after the
117
+ // toolchain-hardening landed.
118
+ if (source.startsWith('node:')) {
119
+ const resolved = await this.resolve(source, importer, { skipSelf: true });
120
+ return resolved;
121
+ }
90
122
  if (!importer)
91
123
  return null;
92
124
  // Importer may be a file URL string or an absolute path.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-pnp",
3
- "version": "0.4.35",
3
+ "version": "0.4.37",
4
4
  "description": "Yarn PnP resolver plugin for Rolldown / Rollup / Vite",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "license": "MIT",
40
40
  "peerDependencies": {
41
- "rolldown": "^1.0.0"
41
+ "rolldown": "^1.0.3"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "rolldown": {
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "^25.9.1",
50
- "rolldown": "^1.0.0",
51
- "typescript": "^6.0.3"
50
+ "rolldown": "^1.0.3",
51
+ "typescript": "^5.9.3"
52
52
  }
53
53
  }