-
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
No way to Ignore devDependencies? #719
Comments
I have seen this as well, and hopefully someone else can chime in with their successful method of ignoring node_modules without hitting the missing package.json issue. However, since performance is your problem, have you tried using the flow server instead of running |
I have, but that makes no difference for me at all (still ~13secs). I've tried running the server in both the background and foreground too, neither with any apparent effect. |
That's really surprising. You start the server then just run |
Ignore the last message. I'd misunderstood that you have to run |
I've since found out that the `flow` command can be used to first start a server, and then to perform the equivalent of `flow check` against the background server. Additionally, I've raised an issue that should hopefully address making `flow check` faster in CI: * facebook/flow#719
I am also having issues with this. I wish to ignore mode_modules for performance, but still be able to require a npm package. Would be nice to be able to have flow not cover *EDIT for clarify: I understand the solution of starting the flow server with |
Glad it's not just me. To provide some further justification for why this would be helpful in my case, consider that our developers will run the same |
Some additional info. I just remembered why I ignored Maybe flow isn't suited for my use-case, but if you want to support these kind of scenarios, there needs to be a way to ignore |
Update for anyone having this problem and finding this issue. It turns out flow handles these situations in a very nice way using Declarations (at least as far as my use case is concerned) By ignoring An example would be: src/test.js /* @flow */
import { Foo } from 'foo';
export default class Bar {
foo : Foo,
constructor() {
this.foo = new Foo();
}
} lib/foo.js declare module foo {
declare class Foo {
}
} .flowconfig
|
Another workaround: Use a project structure like:
Manage your dev dependencies with the outer package.json and runtime deps with the inner package.json. Flow will ignore the dev dependencies since they are outside its scope. |
@GGAlanSmithee note that the |
@nevir I'm not sure I follow. How would I'm not sure how the config behaves as far as what takes precendence over what, but your second statement could be troublesome if Thinking about it, it might be best to just use absolute paths? [ignore]
node_modules/.*
[include]
src/.*
[libs]
lib/.* EDIT: If using an absolute path to |
It's my understanding that every js file in your project is included by AFAIK the main use of On Tue, Dec 29, 2015, 02:40 Alan Smithee notifications@github.com wrote:
|
Ignoring node_modules and declaring required modules works fine for me. However, using gulp-flowtype which basically runs flow on changed files automatically, flow always reports errors of missing package.json files for each declared module. Do you know if there's a workaround for this? |
Just piling on here with an example of a hacky workaround. I am auto-generating ignore rules based on my package.json. I added it to my project in this patch: https://github.com/mozilla/web-ext/pull/23/files Because of npm module flattening these auto-generated ignore rules made the standalone flow check run twice as fast, so it seemed worth it. That's 3.5 seconds instead of 7 seconds which is a big deal for continuous integration. I decided not to ignore all modules (and define interfaces) because I wanted to let Flow tell me when I'm missing an external module or using it wrong. |
I think lazy-loading (#1461) would address this better because if you opted out your test files (i.e. no |
Version 0.22 should greatly improve this problem. As of that version, Flow does not parse non- I'm going to try on my end to see, but I'd encourage everyone here to upgrade and try it out. |
That sounds like it'll be a huge improvement! I'm assuming it's still scanning all JS files under |
@nevir Yeah, we still check, because dependencies might be |
This is still a huge pain if you have a big node_modules directory, and not using an SSD. It is caused by the combination of these design decisions:
This leaves you with only ineffective solutions, since you have to explicitly blacklist modules you don't want, and cannot whitelist modules you do want. I'm resorting to just generating a list of all node_modules using the linux
Another, slightly more sophisticated solution to generate the ignore section with regexes is here: https://gist.github.com/lydell/ee05b5acbc1f51eea649926af956dc98 |
Closing in favor of #869 |
This is a question as much as anything, and I'm hoping you're just going to tell me that I'm doing it wrong.
If I try to use
flow check
on even a very simple NPM library with just one dependency it's unusably slow (~13secs) because of all thedevDependencies
I'm using. If I add.*/node_modules*
to theignore
section of.flowconfig
than it becomes much faster (~1sec), but fails because it can't find the single non dev-dependency, showing this message:Adding entries to the
include
section to counter this doesn't seem to help, regardless of how I do it. Given that this isn't very sustainable either (you'd essentially have to maintain two dependency manifests), is there a better way of ignoringdevDependencies
to improve performance?The text was updated successfully, but these errors were encountered: