React components (also pages and layout ) on UI folder makes server restart

Hi! I’m using Meteor 1.4.4.1 with react. Following the suggested directory structure here https://guide.meteor.com/structure.html I have imports/ui/components, imports/ui/pages and imports/ui/layouts folders with react components within that folders.

if I change the files within that folders, I get => Meteor server restarted in the console (and takes a long bit to finish) but if I move imports/ui/* to imports/client/ui/* I get the normal => Client modified – refreshing.

Sholud I move all imports/ui/* to imports/client/*?
Did I miss something or the docs are outdated?

Bump!

No one having the same issue?

Hmm, I think I read something about this somewhere, that you have to split even imports/ up into client/ and server/. I’m not sure though.
I still use the old “global” project structure.

Hi @herteby! I’m facing this issue, if I split the imports to client/server the issue goes away, but I want to confirm this because I don’t want any security issues later on

With the imports/ui path the components will be available to both the client and server - that’s why the server restarts as well when you change one of those files.

When you put a file in a client/ or server/ director that file will only be available on the respective target.

If you move your ui components to imports/client/ui there shouldn’t be any issues unless you’re doing some server side rendering.

Cool, I’ve done that but I wanted to be certain about this

@spencercarli
But what I find weird though, and @razor7 too, is that files in the imports directory are not supposed to be included unless you import them, right? So then you’d think that it’d just be wether the file doing the importing (or it’s “root importer”) is located in client/ or server/ that matters?

The file watcher triggers rebuilds when files change. It has no understanding of where a file is imported, so file changes in a location available to client and server components will trigger rebuilds in both.

1 Like

Also, I’ve noticed that you can go deeper into subdirectories, and creating a client/server folder still works the same. Example /imports/routes/client - /imports/routes/server in case you need more detailed organization

2 Likes