fix(pipeline): resolve ../ climbs in tsconfig path alias targets#766
Open
apappas1129 wants to merge 2 commits into
Open
fix(pipeline): resolve ../ climbs in tsconfig path alias targets#766apappas1129 wants to merge 2 commits into
apappas1129 wants to merge 2 commits into
Conversation
tsconfig.json `paths` entries that climb out of their config's directory (e.g. a tsconfig at apps/web/tsconfig.json mapping "@shared/*" to "../../packages/shared/src/*", the standard monorepo layout) resolved to a broken path: resolve_target_relative() only stripped a single leading "./" and otherwise concatenated dir_prefix and target verbatim, leaving literal ".." segments in the result. Those never match a real module's FQN, since cbm_pipeline_fqn_module tokenizes on '/' without collapsing them - so every cross-package import through such an alias looked like dead code. resolve_target_relative now walks the target's path segments and pops a directory off dir_prefix for each "..", the same normalization cbm_pipeline_resolve_relative_import already does for plain relative imports. Closes DeusData#730. Signed-off-by: Alexandros Pappas <11921291+apappas1129@users.noreply.github.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes #730: tsconfig.json
pathsaliases that climb out of their config'sdirectory (e.g. a tsconfig at
apps/web/tsconfig.jsonmapping@shared/*to
../../packages/shared/src/*— the standard monorepo layout) resolvedto a broken repo-relative path.
resolve_target_relative()insrc/pipeline/path_alias.conly stripped asingle leading
"./"and otherwise concatenateddir_prefixandtargetverbatim, so a
../../target left literal".."segments in theresolved path (e.g.
apps/web/../../packages/shared/src/*). That stringnever matches a real module's FQN, since
cbm_pipeline_fqn_moduletokenizes on
/without collapsing..— so every cross-package importthrough such an alias was invisible to the graph and looked like dead
code.
This is also why #308 regressed: the original fix (v0.7.0) handled the
simple
"./src"case but never normalized../climbs, which is thepattern monorepos actually use for cross-package aliases.
The fix makes
resolve_target_relative()walk the target's path segmentsand pop a directory off
dir_prefixfor each.., mirroring thenormalization
cbm_pipeline_resolve_relative_importalready does forplain relative imports in
fqn.c.Checklist
git commit -s)make -f Makefile.cbm test) — full suite greenexcept one pre-existing, unrelated RSS-ceiling test in
test_incremental.c(2550MB vs 2048MB limit) on this machinemake -f Makefile.cbm lint-ci) — could not verifylocally, cppcheck/clang-format are not installed in this
environment; relying on CI
path_alias_loader_monorepo_dotdot_climbintests/test_path_alias.c,an end-to-end test with a real tsconfig containing a
../../aliastarget, asserting the resolved path is correct