Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accidental relative imports from non namespace barrels #59544

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Aug 7, 2024

Noticed in #59542; no file in our codebase should be bypassing the namespace barrels except those in src/compiler (in rare cases) or test code.

The only reason things didn't break is because these imports were done within services, which is only ever consumed by other entrypoints; if this had been done from say, tsserver, the magic import rewriting done in our build would have caused "double bundling" where we'd include the same code twice.

However, the fact that it did work implies that we could get away with direct imports except in our entrypoints, which is great because I thought I had unintentionally made direct imports impossible by making our package smaller. Turns out, no, we still can do it for anything without that magic build step.

Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

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

Would prefer if this was some kind of warning if this is not desired. If we would do direct imports that would be ideal.

@jakebailey
Copy link
Member Author

Yeah, I'll write a lint rule quick that prevents this; given it seems like we can actually do direct imports, but only in some project, we'd need that lint rule anyway, just applied to a different set of packages.

@jakebailey jakebailey merged commit 5e9e6ad into microsoft:main Aug 8, 2024
32 checks passed
@jakebailey jakebailey deleted the fix-relative-imports branch August 8, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants