🐛 Resolve Vite dependencies from their parent package#179
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07aa83bb14
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const packageRequire = createRequire(join(pkgDir, 'package.json')); | ||
| for (const dep of Object.keys(pkgJson.dependencies ?? {})) { | ||
| copyPackageTree(dep); | ||
| copyPackageTree(dep, packageRequire); |
There was a problem hiding this comment.
Preserve nested versions when copying package trees
In pnpm/non-hoisted Vite builds with duplicate transitive package names, this call resolves the second parent's dependency with the right packageRequire but still feeds only the package name into the global visited set and flat output/node_modules/<pkg> destination. The current dd-trace tree already has node-gyp-build v3 for @datadog/native-* and v4 for @datadog/pprof/wasm-js-rewriter in yarn.lock, so whichever one is copied first makes the other parent skip its own version and later resolve the wrong package in the packaged app. Preserve the resolved path/version in the key or copy dependencies under the requiring package's node_modules.
Useful? React with 👍 / 👎.
Motivation
The Vite plugin resolves every transitive package from the SDK's module location. This assumes dependencies are hoisted and can omit
dd-traceruntime dependencies in pnpm layouts.Changes
Resolve each transitive dependency from its parent package and add a regression test for a non-hoisted dependency graph.
Test instructions
Checklist