fix: keep source-tracing helpers out of toolkit-lib public API#1731
Conversation
Import findCreationStackTrace into cdk-explorer via a relative path to toolkit-lib's private module instead of re-exporting it from the package index. Matches the existing pattern in lsp/server.ts and avoids expanding toolkit-lib's public API surface.
| import { buildConstructTreeAsync, CloudAssembly, MANIFEST_FILE, type ConstructTreeNode } from '@aws-cdk/cloud-assembly-api'; | ||
| import { VALIDATION_REPORT_FILE, type PolicyValidationReportJson } from '@aws-cdk/cloud-assembly-schema'; | ||
| import { findCreationStackTrace } from '@aws-cdk/toolkit-lib'; | ||
| /* eslint-disable import/no-relative-packages */ |
There was a problem hiding this comment.
Please let's not disable the rule here. There should be an existing single file in CLI that lists all private imports from toolkit-lib.
https://github.com/aws/aws-cdk-cli/blob/main/packages/aws-cdk/lib/api/index.ts
https://github.com/aws/aws-cdk-cli/blob/main/packages/aws-cdk/lib/api-private.ts(<-- this one probably)
There was a problem hiding this comment.
Got it, made a file like this for the explorer package.
There was a problem hiding this comment.
To clarify, the reason I can't just use the file you mentioned directly is because it isn't re-exported from aws-cdk's index, so importing it cross-package would itself be a relative-package import, triggering the exact rule. Anyway, dependency direction forbids that.
…-private Route all relative deep imports into toolkit-lib internals through a single lib/api-private.ts barrel that carries the sole import/no-relative-packages disable, instead of scattering inline eslint-disable comments across consumers. Mirrors packages/aws-cdk/lib/api-private.ts. Covers findCreationStackTrace (source-tracing), plus WATCH_EXCLUDE_DEFAULTS and createIgnoreMatcher used by the LSP server.
Follow-up to review feedback on #1681.
findCreationStackTrace/findMutationStackTraceswere re-exported from toolkit-lib's publicapi/source-tracingindex, adding new public API surface.Instead, cdk-explorer imports
findCreationStackTracedirectly from toolkit-lib's private module via a relative path, the same mechanism already used inlsp/server.ts. Keeps the helpers out of toolkit-lib's public API.Verification: cdk-explorer + toolkit-lib compile clean, cdk-explorer core jest suites pass.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license