Skip to content

fix: keep source-tracing helpers out of toolkit-lib public API#1731

Merged
megha-narayanan merged 2 commits into
aws:feat/cdk-lspfrom
megha-narayanan:fix/source-tracing-private-import
Jul 16, 2026
Merged

fix: keep source-tracing helpers out of toolkit-lib public API#1731
megha-narayanan merged 2 commits into
aws:feat/cdk-lspfrom
megha-narayanan:fix/source-tracing-private-import

Conversation

@megha-narayanan

@megha-narayanan megha-narayanan commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Follow-up to review feedback on #1681. findCreationStackTrace / findMutationStackTraces were re-exported from toolkit-lib's public api/source-tracing index, adding new public API surface.

Instead, cdk-explorer imports findCreationStackTrace directly from toolkit-lib's private module via a relative path, the same mechanism already used in lsp/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

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 */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it, made a file like this for the explorer package.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
@megha-narayanan
megha-narayanan deployed to integ-approval July 16, 2026 14:12 — with GitHub Actions Active
@megha-narayanan
megha-narayanan merged commit f3bf4c9 into aws:feat/cdk-lsp Jul 16, 2026
38 checks passed
@megha-narayanan
megha-narayanan deleted the fix/source-tracing-private-import branch July 16, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants