nx icon indicating copy to clipboard operation
nx copied to clipboard

fix(bundling): Correct declarationRootDir handling for esbuild

Open danielsharvey opened this issue 1 year ago • 3 comments

Refine declarationDir logic for esbuild plugin as follows

  • IF no custom declaration root AND outDir structure mirrors {projectRoot} e.g if project root packages/mylib and output directory is dist/packages/mylib THEN we adjust declarationDir to place types in outDir
  • ELSE if we have specified a custom declarationRootDir, place declarations in outDir

Add test to check for the case when declarationDir id specified.

Closes #28814.

Current Behavior

As reported in #28814, the esbuild plugin declarationRootDir configuration was/is not working properly when output path matches workspace.

Expected Behavior

When specifying the esbuild plugin declarationRootDir configuration setting, this setting should be honoured when types are generated AND the generated types should be placed in the configured output path.

The specific new behaviour is detail in the PR outline above.

Related Issue(s)

Fixes #28814.

danielsharvey avatar Dec 03 '24 15:12 danielsharvey

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jun 9, 2025 9:47am

vercel[bot] avatar Dec 03 '24 15:12 vercel[bot]

View your CI Pipeline Execution ↗ for commit 895496916f5df0e1fe6abbd8b7c45d50eec30e30.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 33m 34s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 17s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 2s View ↗
nx documentation ✅ Succeeded 2m 20s View ↗

☁️ Nx Cloud last updated this comment at 2025-06-09 10:17:05 UTC

nx-cloud[bot] avatar Dec 03 '24 15:12 nx-cloud[bot]

Not sure how to address the "Workflow does not have enough agents to satisfy all assignment rules." CI error. It appears build system not code error related.

danielsharvey avatar Dec 03 '24 22:12 danielsharvey

Unfortunately, there does not seem to be a straightforward way to implement this without causing further failures, and as this has sat now for some time without additional attention, I'm going to close this PR.

Please know I very much appreciate the time spent on this PR originally, and if you would like to open a new one, I'd be more than happy to take a look.

Coly010 avatar Dec 11 '25 09:12 Coly010

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

github-actions[bot] avatar Dec 18 '25 00:12 github-actions[bot]