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

Watcher is still initialized for files that are ignored #121

Closed
puchm opened this issue Feb 15, 2021 · 5 comments
Closed

Watcher is still initialized for files that are ignored #121

puchm opened this issue Feb 15, 2021 · 5 comments

Comments

@puchm
Copy link
Contributor

puchm commented Feb 15, 2021

Hi,
I noticed that --exclude is far superior to --ignore in terms of startup performance. This is the startup command I used:

babel-watch --use-polling --watch /app --ignore node_modules --extensions .ts,.graphql src/main.ts

It all works once it starts up but it always takes about a minute to do so. I tried switching --ignore node_modules to --exclude /app/node_modules (which is the absolute path to my node_modules folder) and this improved it to about 10 seconds.

I looked into the source code and I think I know what is going on:

The watcher gets started on all files except what's inside --exclude (see this line). I think anything that matches --ignore should also be excluded. This way it wont start watchers on the whole node_modules folder if the user makes use of --ignore instead of --exclude.

If that is not possible it should be communicated clearly in the readme that --exclude is better in terms of startup performance and what is the difference between --exclude and --ignore (to be honest, I don't fully understand it).
Also, the node_modules folder should be the default for the --exclude option rather than the --ignore option.

Thank you for improving this in advance!
Moritz

@STRML
Copy link
Collaborator

STRML commented Feb 25, 2021

Hey, thanks. I don't think this is intentional. I believe the intention was to have the server restart on some file changes (like assets that may be cached), but not trigger babel. It doesn't seem that this is really usable for that purpose.

I haven't had time to dig through it, maybe you have, but I would consider renaming or repurposing some of these flags.

@puchm
Copy link
Contributor Author

puchm commented May 10, 2021

Just noticed this issue is still open. I don't have a lot of time to dig into this other than renaming these flags.

What is the difference between --ignore and --exclude?

If someone can explain that to me I could try to come up with more appropriate names or put an explanation into the readme.

@STRML
Copy link
Collaborator

STRML commented May 10, 2021

So:

  • --ignore will watch the file, but not transpile it with Babel
  • --exclude will not watch the file at all and thus it won't be transpiled either.

I don't actually see a good use case for --ignore because I assume that if you actually have this need, you already have it set in your babel config. There shouldn't be a need for a unique ignore list only when using babel-watch, but perhaps someone else has a different idea?

@puchm
Copy link
Contributor Author

puchm commented May 10, 2021

In this case I think the names are actually quite fitting. How about adding this explanation to the readme?

@STRML
Copy link
Collaborator

STRML commented May 10, 2021

It's technically already there, but not super clear, so I'll add an additional note.

@STRML STRML closed this as completed in 186f8a7 May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants