Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chokidar to install step and fix esbuild.config.mjs file extension #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcoroth
Copy link

@marcoroth marcoroth commented Dec 23, 2024

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.

@excid3
Copy link
Owner

excid3 commented Dec 23, 2024

esbuild-rails itself doesn't use chokidar.

The example script does use it to show how to implement automatic reloading though.

@marcoroth
Copy link
Author

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?

@marcoroth marcoroth changed the title Add chodikar to install step and fix esbuild.config.mjs file extension Add chokidar to install step and fix esbuild.config.mjs file extension Dec 23, 2024
@excid3
Copy link
Owner

excid3 commented Dec 23, 2024

That seems good to me. 👍

Should we mention it's optional somewhere?

@excid3
Copy link
Owner

excid3 commented Dec 23, 2024

Or is there any way to lazy import chokidar like we can do in Ruby? 🤔

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

Successfully merging this pull request may close these issues.

2 participants