Repository navigation
fix(js,ts): an import from the app's root maps through the app's own tsconfig paths - #2740
Merged
Merged
Conversation
…tsconfig paths
bigbluebutton's client imports nearly everything from its root,
`import Icon from '/imports/ui/components/common/icon/component'`, which its
tsconfig maps with `"paths": { "/*": ["*"] }`. tsc maps a rooted name through
`paths` (only `./` and `../` count as relative there) and never reads it
from `baseUrl`. ownConfigCandidates refused every specifier starting with
`/`, so all 2,375 of these imports stayed unresolved and every name they
import linked by bare-name matching, often to the wrong one of several
same-named components.
A rooted specifier now goes through the nearest config's `paths` patterns
only; `baseUrl` is still never applied to it, and a protocol-relative
`//host/x` stays out. On bigbluebutton the unresolved refs fall from 26,189
to 22,565 and its rooted imports from 2,375 unresolved to 1 (a module that
isn't in the repository); 13 control repos are byte-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #2738. An import written from the app's root with a leading slash — bigbluebutton's
import Icon from '/imports/ui/components/common/icon/component', a style its client kept from its Meteor days — is mapped by the app's own config:tsc maps a rooted name through
paths(itspathstest treats only./and../as relative), but never reads one frombaseUrl. codegraph read neither:ownConfigCandidatesreturned nothing for any specifier starting with/. So all 2,375 of bigbluebutton's rooted imports parked unresolved, and every name they import linked by bare-name matching:importsedges by exact name and 45 by fuzzy match;Icon,FlexColumn,Header).Now a rooted specifier goes through the nearest config's
pathspatterns only, as tsc does;baseUrlis still never applied to it. A protocol-relative//host/xstays out.A/B
Both arms are on main ada1445 with main's kernel; the change is resolution-only. Nodes are identical.
bigbluebutton
/imports/api/breakouts, a module that isn't in the repository.importsedges resolved through the import: 2,374 file → file, each to exactly the file the specifier names, and 3,346 bindings;isMobilereferences. The file importsexport const isMobile = isPhone || isTabletfrom/imports/utils/deviceInfo, and main had bound it to an unrelatedisMobile()inlayout/utils.js.app/component.jsx'srender, which renders more than the 30 children a parent keeps (MAX_JSX_CHILDREN). More of its tags now resolve, so 4 later ones fall off; one of them,PollingContainer, was bound on main to a styled namesake inpolling/styles.ts.Session.setItemreachesObservableStorage.setItembecausein-memory.tsisexport default new ObservableStorage(new InMemoryStorage());PollContainerreachesPollCreationPanelContainerthroughpoll/container.jsx'simport X from './component'; export default X.Controls (13, byte-identical): outline, SigNoz, excalidraw, berry, mastodon, matx, mantis, minimal-kit, bulletproof-react, next-saas-starter, proshop, create-t3-turbo, and Rocket.Chat's
apps/meteor. Rocket.Chat's tsconfig declares the same"/*": ["./*"]mapping, but its sources have since moved to relative imports.Tests
tsconfig-baseurl-imports.test.ts:paths, and is never read frombaseUrl(a protocol-relative one neither);Iconin a folder that sorts first. The rooted import links its file; the tag renders, and the call reaches, what the import binds; astyled(Icon)wrapper renders it;All but the
baseUrl/ protocol-relative case fail on main.Full suite (
--maxWorkers=4, kernel built,CODEGRAPH_KERNEL_EXPECT=1) on the branch merged with ada1445: 689 of 689 files; 8,260 tests, 8,178 passed, 0 failed, 82 skipped.🤖 Generated with Claude Code