Commit aef30f5
authored
JavaScript: setupSharedDependencies must search inside the recipe directory itself (#7515)
When a recipe is installed by local path (e.g.
`mod config recipes npm install /path/to/my-recipes`), `targetModulePath`
is the package directory itself. `path.dirname(targetModulePath)` jumps
to the parent and the upward `node_modules` walk never enters the
package's own `node_modules`, so the target package root for shared
dependencies (`@openrewrite/rewrite`, `vscode-jsonrpc`, `mutative`) is
never found and the host→target require.cache mapping is skipped.
The downstream symptom is the dual-package problem: the recipe ends up
with its own `@openrewrite/rewrite` instance, distinct from the host's,
so `recipe instanceof ScanningRecipe` in `rpc/request/visit.ts` returns
`false`. The runtime then skips the `scan:` phase entirely. Editors are
still invoked (~3000 times per cemex run in our reproducer), but every
accumulator is empty, so `UpgradeDependencyVersion` silently returns
`doc` from `package.json` and no version bumps land — even though the
install in the temp dir would have succeeded.
When `targetModulePath` resolves to a directory, start the
`node_modules` walk from the directory itself; only fall back to
`path.dirname` when it resolves to a file.
Repro: any local-path-installed recipe set whose `package.json`
declares `@openrewrite/rewrite` as a dependency. Before this change,
rpc.log shows `Could not find @openrewrite/rewrite in target's
node_modules`. After, it shows `Mapped <N> modules for
@openrewrite/rewrite`.1 parent ec7cf41 commit aef30f5
1 file changed
Lines changed: 9 additions & 1 deletion
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
201 | 209 | | |
202 | 210 | | |
203 | 211 | | |
| |||
0 commit comments