Watching subdirectories unavailable on Linux
See original GitHub issueHey @rsms I wasn’t immediately sure if this was something on estrella’s end or a limitation of esbuild, so excuse my assumptions if they’re off!
When I have an entry point file which is importing a module from a sub-directory, estrella only seems to execute a rebuild when something changes in the entry-point file. However if I move my files from the sub-directory to the same directory as the entry-point file, things will rebuild when any file is changed.
I guess my expectation would be to have files, which are referenced by the entry-point file but are not in the base-level directory, trigger a rebuild when they change.
An example set up running on Node 12.16.3.
./src/index.js
import MyModule from "./modules/my-module";
(function () {
MyModule.foo();
// returns string bar
})();
./src/modules/my-module.js
const MyModule = (function () {
return {
foo: function () {
return "bar";
}
};
})();
export default MyModule;
./build.js
#!/usr/bin/env node
const path = require("path");
const { build, cliopts } = require("estrella");
const { createServer } = require("serve-http");
const options = {
entry: "./src/index.js",
outfile: "./public/bundle.js",
bundle: true,
minify: true
};
build(options);
cliopts.watch && createServer({
port: 3000,
pubdir: path.join(__dirname, "./public"),
});
Thus far whenever I change anything within my-module.js
a rebuild won’t trigger. Only when the change is within index.js
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
Thanks @rsms will try it out and report back if I find any quirks.
Alternatively I also hacked something together using
node-watch
which has a significantly smaller footprint thanchokidar
(less battle tested though). I don’t get the warm and fuzzy feeling of seeing estrella’s nice console logs but it solves the problem on Linux for the short term. 😄I actually have a dedicated Ubuntu MacBook in my office :–)
Unfortunately this is a limitation with NodeJS’s
fs.watch
function. The documentation mentions “The recursive option is only supported on macOS and Windows.”I’ll rename this issue to be about improving deep-directory watch support. There are a lot of 3rd party libraries implementing this in JS but they are all rather heavy and I’m trying to keep estrella small.
In the meantime, what you can do is some hack like this: