Skip to content

fix: resolve package roots to output paths#476

Open
kikiminyes wants to merge 1 commit into
LeDDGroup:masterfrom
kikiminyes:fix-package-root-declaration-output
Open

fix: resolve package roots to output paths#476
kikiminyes wants to merge 1 commit into
LeDDGroup:masterfrom
kikiminyes:fix-package-root-declaration-output

Conversation

@kikiminyes

Copy link
Copy Markdown

Closes #182.

When a package-root alias resolved through packageId.subModuleName, the transformer used the source package directory as the module output directory. In declaration output with outDir, that could emit paths back to the source tree instead of the generated declaration tree.

This keeps package-root imports based on the resolved source file's emitted output directory, then trims any implicit package subpath such as subdir/main.d.ts so existing package-main behavior stays intact.

Validation:

  • Reproduced Unexpected behavior in import a local package. #182 with the linked repro; the generated declaration still pointed at ../../../../../packages/components before this fix.
  • Added a project-reference regression test covering a nested source importing a package root with outDir.
  • yarn compile
  • yarn test
  • yarn prettier --check src/utils/resolve-module-name.ts test/tests/project-ref.test.ts test/projects/project-ref/tsconfig.base.json test/projects/project-ref/b/tsconfig.json test/projects/project-ref/b/deep/package-root.ts test/projects/project-ref/b/packages/pkg-root/index.ts test/projects/project-ref/b/packages/pkg-root/package.json
  • yarn eslint src/utils/resolve-module-name.ts test/tests/project-ref.test.ts test/projects/project-ref/b/deep/package-root.ts test/projects/project-ref/b/packages/pkg-root/index.ts

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.

Unexpected behavior in import a local package.

1 participant