-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove components alias and import components directly in tests #4735
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
Conversation
size-limit report
|
alex-page
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will miss components but this makes sense for the system today.
kyledurand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I'm going to open up a follow up PR where I nuke |
|
There it is ^^ #4739 |


WHY are these changes introduced?
Hitting two birds with one PR - removing a confusing way of importing files, and a chonky test speed improvement.
componentsis usable as an alias for importing the components in tests. However feel it should be removed as it is usage is not intuitive and has the potential to accidentally break consumers:In addition, using this file to access components means that Jest has to read and parse all components (as that file reexports every component) even if you only use a specific component or two in a given test. This slows tests down as jest is doing lots unneeded work. This gets particularly pathological when you're trying to run a single test or when you're running tests with a cold cache (i.e on CI).
In order to ensure that even relative path imports to the components index never reappear we should remove the components index file, per the recommendations and investigations in this web decision doc that spurned the investigation in this PR
WHAT is this pull request doing?
This PR replaces all instances of
import {BLAH} from 'components'withimport {BLAH} from '../../BLAH'or whatever is the correct relative path to that component is.loom.config.tsandtsconfig.jsonhave been updated to remove the ability to use'components'as an importable pathHow to 🎩
Tests / type-check passes
Stats!
I mentioned this improves performance on cold-cache test runs on CI.
Running 3 ci-style cold test runs
rm -rf .loom && CI=1 yarn teston main takes: 50.01s, 50.30s, 49.04s.Running 3 the same on this branch takes: 32.57s 32.39s 33.74s
So I've our tests are now almost twice as fast :D