Skip to content

fix(plugin): normalize workspace package import paths in metadata generator#3798

Open
maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang:fix/issue-3453-plugin-metadata-import-paths
Open

fix(plugin): normalize workspace package import paths in metadata generator#3798
maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang:fix/issue-3453-plugin-metadata-import-paths

Conversation

@maruthang
Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

PluginMetadataGenerator (via ModelClassVisitor and ControllerClassVisitor) computes relative paths from the source directory to the physical node_modules/ location of workspace packages. This produces import paths like ../node_modules/@amk/utils/src/dto/order.dto in the generated metadata, which causes TypeScript TS2742 errors at compile time.

Issue Number: #3453

What is the new behavior?

A normalizePackagePath helper is extracted in plugin-utils.ts. It detects when a resolved path passes through node_modules/ and strips everything up to that boundary, returning a bare package specifier (e.g., @amk/utils/src/dto/order.dto). Both ModelClassVisitor and ControllerClassVisitor now use this helper in their collectedMetadata() methods, so generated metadata always contains correct importable package paths.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

7 new unit tests added in test/plugin/normalize-package-path.spec.ts covering bare package paths, scoped packages, deep paths, and paths that should not be modified. All 152 tests pass.

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