Skip to content

🐛 Resolve Vite dependencies from their parent package#179

Open
longlho wants to merge 1 commit into
DataDog:mainfrom
perplexityai:agent/fix-package-tree-resolution
Open

🐛 Resolve Vite dependencies from their parent package#179
longlho wants to merge 1 commit into
DataDog:mainfrom
perplexityai:agent/fix-package-tree-resolution

Conversation

@longlho

@longlho longlho commented Jul 23, 2026

Copy link
Copy Markdown

Motivation

The Vite plugin resolves every transitive package from the SDK's module location. This assumes dependencies are hoisted and can omit dd-trace runtime 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

yarn vitest run src/entries/vite-plugin.spec.ts

Checklist

  • Tested locally (playground)
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated related documentation.
  • Agentic code review findings addressed or explicitly dismissed.

@longlho
longlho marked this pull request as ready for review July 23, 2026 01:49
@longlho
longlho requested a review from a team as a code owner July 23, 2026 01:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant