-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Update config docs to warn about antipattern #5850
base: main
Are you sure you want to change the base?
Conversation
To warn about incorrect usage of module.system.node.resolve_dirname.
This one drove us nuts for a long time. Unsure if breaking |
Yeah it's a shame it's more verbose. There's also a trick where you can use a dot-slash in |
@STRML This was done because everybody asked to not check whole node_modules, but only direct and transitive dependencies. I think both alias and root resolve are bad practices because every tool can support this features differently or not support at all. This features do not have a spec and they are not even a convention. I usually force to not create deep folders. Also there's solution via monorepos. |
I agree they're not good practices. I prefer to use The docs update in this PR doesn't recommend magic paths, it just says you should use |
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.
@mrkev has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
I think this'd be good, but the import is failing. Could you rebase so I can give it a shot? |
bump @callumlocke |
Problem
This is a common pattern:
It lets you write, eg,
import foo from 'common/foo'
to get hold ofsrc/common/foo.js
from anywhere in your codebase, even from a deeply nested module, so you can avoid long../../../
relative paths.The problem is, Flow v0.57.0 added a new feature:
This is a good feature. But for anyone using the above technique, it breaks Flow in a very confusing way: it treats
src
as anode_modules
-like directory, and stops checking all your files in there reliably. It may report errors in some files, but misses many others. Then while you're developing, the watch-driven Flow server will occasionally discover more errors, which mysteriously disappear next time you do a fullflow check
. It feels indeterminate and unpredictable, and in my case it led to days of debugging.From the number of issues relating to this, it seems it's easy to miss the problem when you first upgrade past 0.57.0 – the weird behaviour often surfaces much later, because everything seems to be working fine at first (
No errors!
).Solution
Update the docs to explain that it is now an antipattern to use
module.system.node.resolve_dirname
for internal code, and that you should usemodule.name_mapper
instead.Closes #5180
Closes #5316
Relates to #5647
Also closes flow/flow-bin#91
(There have been many more issues stemming from this same problem, but most have been closed as duplicates.)