Add `chokidar` to install step and fix `esbuild.config.mjs` file extension
While migrating an app to use esbuild-rails I noticed the following to issues. If you don't install chokidar yourself to your app it would fail to build:
❯ yarn build
yarn run v1.22.19
warning ../package.json: No license field
$ node esbuild.config.mjs
node:internal/modules/esm/resolve:838
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'chokidar' imported from
[project]/esbuild.config.mjs
at packageResolve (node:internal/modules/esm/resolve:838:9)
at moduleResolve (node:internal/modules/esm/resolve:907:18)
at defaultResolve (node:internal/modules/esm/resolve:1037:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:241:38)
at ModuleJob._link (node:internal/modules/esm/module_job:132:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
~~I'm almost wondering if the esbuild-rails package itself should depend on chokidar.~~ Edit: I guess we can just add an note to the README.
Additionally I also updated the esbuild config file extension in the README.
esbuild-rails itself doesn't use chokidar.
The example script does use it to show how to implement automatic reloading though.
Ah right, fair enough. Do you want to keep it in the install instructions or should I move it out of the main yarn/npm i code block?
That seems good to me. 👍
Should we mention it's optional somewhere?
Or is there any way to lazy import chokidar like we can do in Ruby? 🤔