Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Watching files with multiple imports is broken #123

Closed
klaemo opened this issue May 12, 2015 · 9 comments
Closed

Watching files with multiple imports is broken #123

klaemo opened this issue May 12, 2015 · 9 comments
Assignees

Comments

@klaemo
Copy link

klaemo commented May 12, 2015

Hey,
it seems as if files with multiple imports don't get watched properly.

index.css

@import "./one.css";
@import "./two.css";

one.css

h1 {
  color: red;
}

two.css

h2 {
  color: blue;
}

running cssnext does compile the files correctly, but doesn't watch

$ cssnext --watch -v index.css bundle.css
[11:52:27] Output written /Users/clemens/Projects/cssnext-bug/bundle.css

commenting out one @import yields the expected result:

$ cssnext --watch -v index.css bundle.css
[11:52:40] Output written /Users/clemens/Projects/cssnext-bug/bundle.css
[11:52:40] Watching /Users/clemens/Projects/cssnext-bug/index.css

OSX 10.10.3
cssnext: 1.4.0
iojs: 1.8.1

Thank you! :)

@MoOx MoOx added the type: bug label May 12, 2015
@MoOx
Copy link
Owner

MoOx commented May 12, 2015

running cssnext does compile the files correctly, but doesn't watch

I am not sure on what you are saying since right after that you say that commenting an import is making a change.

Do you expect to get a verbose ouput that is saying that index.css is watched in the first place ?

$ cssnext --watch -v index.css bundle.css
[11:52:27] Output written /Users/clemens/Projects/cssnext-bug/bundle.css
[11:52:40] Watching /Users/clemens/Projects/cssnext-bug/index.css

And then when you comment an import you get

$ cssnext --watch -v index.css bundle.css
[11:52:27] Output written /Users/clemens/Projects/cssnext-bug/bundle.css
[11:52:40] Watching /Users/clemens/Projects/cssnext-bug/index.css
[11:52:47] Output written /Users/clemens/Projects/cssnext-bug/bundle.css

Is that what you would expect ?

@klaemo
Copy link
Author

klaemo commented May 12, 2015

No, the first one (with both imports) doesn't pick up any changes at all.

For the second one I restarted cssnext.

One import === changes get detected and recompiled.
Multiple imports === changes don't get detected and nothing gets recompiled

@MoOx
Copy link
Owner

MoOx commented May 12, 2015

Ok I will take a deeper look then, cause "it works for me™" on one project. Thanks for reporting !

@klaemo
Copy link
Author

klaemo commented May 12, 2015

The weird thing is: it used to work for me too :D then I reinstalled all my modules from scratch...

Taking a look at the code: watcher.on("ready") doesn't fire when there are multiple imports. I'll investigate further.

klaemo added a commit to klaemo/cssnext that referenced this issue May 12, 2015
watcher.on("ready") doesn't fire for multiple imports (why? I don't know!), we want to listen to changes regardless.

should fix MoOx#123
@jonathanong
Copy link

hmmm i think i'm seeing the same issue...

@iantearle
Copy link

Also seeing this.

@MoOx
Copy link
Owner

MoOx commented Jul 22, 2015

Looks like a chokidar bug paulmillr/chokidar#288 (comment)
I will push a workaround (by not relying on ready event).

@MoOx MoOx closed this as completed in 9aad8a9 Jul 22, 2015
@MoOx
Copy link
Owner

MoOx commented Jul 22, 2015

I will release this fix tomorrow morning (in 8 hours).
Meanwhile you can try it by installing cssnext from git (here are the installation instructions 1eaca83)

Should be better now. Sorry for the delay guys.

@klaemo
Copy link
Author

klaemo commented Jul 23, 2015

Thank you, Maxime 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants