standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

Files constantly updated while using esm #771

Closed cullylarson closed 5 years ago

cullylarson commented 5 years ago

I really don't have much information about this. I just tried using the package, saw the issue occur, and decided to stop using it. Thought I'd let you all know in case it's useful.

I installed esm and set it up using method 1 from Getting Started (require = require("esm")(module)).

I'm running a dev server using forever:

forever --watch --minUptime 2000 --spinSleepTime 5000 --watchDirectory='./server/' server/app.js

I immediately started to notice that the server was restarting every couple seconds. Also, whenever I want to save an open file in vim, I got a warning that the file was modified. For some reason forever stopped restarting all the time, but it would do a few restarts every time I saved a file. However, the vim issue never went away. This led me to believe that files were being modified in some way (maybe just timestamps or some other attribute). It got annoying, so I got rid of esm and the problem went away.

jdalton commented 5 years ago

Thanks for the heads up I guess. I implemented in just the last release a mechanism to touch files packaged by npm since it sets files mtime and birthtime to some time in 1985 making it hard to detect changes under certain conditions. I'll revert the change for now.

Update:

esm v3.2.22 is released :tada:

cullylarson commented 5 years ago

If it's only touching files in node_modules, it would not have produced the results I was seeing. forever only detects changes in the ./server/ folder and the vim issue only happens with files I currently have open (nothing in the node_modules folder). Though maybe you're thinking it's accidentally touching files outside node_modules? That would likely produce the results I was seeing.

jdalton commented 5 years ago

The heuristic I was using (reverted now) for touching files was that if their mtime was === to their birthtime. In those cases I'd touch them to update their mtime. I didn't gate to node_modules.