Rails 7 No loader is configured for ".coffee" files:

Viewed 50

I have an older app I am transitioning to Rails 7. I created a new app and Im essentially putting the gemfiles, controllers, models, and views that I used on the previous app. I keep seeing this error when I run $rails assets:precompile and I have the coffee gem for rails installed (comes preinstalled) but it list all my coffee files and says a loader is not configured. How do I configure a loader and where am I placing the file to load?

#terminal

rails assets:precompile
yarn install v1.22.19
[1/4]   Resolving packages...
success Already up-to-date.
✨  Done in 0.10s.
yarn run v1.22.19
$ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets
✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/coupon.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/bills.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/welcome.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/landing.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/dashboard.js.coffee

✘ [ERROR] Could not resolve "controllers/application"

    app/javascript/controllers/index.js:3:28:
      3 │ import { application } from "controllers/application"
        ╵                             ~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "controllers/application" as external to exclude it from the bundle, which
  will remove this error.

6 of 7 errors shown (disable the message limit with --log-limit=0)
node:child_process:879
    throw err;
    ^

Error: Command failed: /Users/Public/code/LDv1.1/node_modules/esbuild-darwin-64/bin/esbuild app/javascript/application.js app/javascript/bills.js.coffee app/javascript/coupon.js.coffee app/javascript/dashboard.js.coffee app/javascript/landing.js.coffee app/javascript/rails.validations.js app/javascript/welcome.js.coffee --bundle --sourcemap --outdir=app/assets/builds --public-path=assets
    at checkExecSyncError (node:child_process:841:11)
    at Object.execFileSync (node:child_process:876:15)
    at Object.<anonymous> (/Users/Public/code/LDv1.1/node_modules/esbuild/bin/esbuild:177:28)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 9665,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
rails aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors

Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)

P.S. When I run yarn build as the terminal says I get this error... yarn build

yarn run v1.22.19
$ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets
✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/welcome.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/bills.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/landing.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/coupon.js.coffee

✘ [ERROR] No loader is configured for ".coffee" files: app/javascript/dashboard.js.coffee

✘ [ERROR] Could not resolve "controllers/application"

    app/javascript/controllers/index.js:3:28:
      3 │ import { application } from "controllers/application"
        ╵                             ~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "controllers/application" as external to exclude it from the bundle, which
  will remove this error.

6 of 7 errors shown (disable the message limit with --log-limit=0)
node:child_process:879
    throw err;
    ^

Error: Command failed: /Users/Public/code/LDv1.1/node_modules/esbuild-darwin-64/bin/esbuild app/javascript/application.js app/javascript/bills.js.coffee app/javascript/coupon.js.coffee app/javascript/dashboard.js.coffee app/javascript/landing.js.coffee app/javascript/rails.validations.js app/javascript/welcome.js.coffee --bundle --sourcemap --outdir=app/assets/builds --public-path=assets
    at checkExecSyncError (node:child_process:841:11)
    at Object.execFileSync (node:child_process:876:15)
    at Object.<anonymous> (/Users/Public/code/LDv1.1/node_modules/esbuild/bin/esbuild:177:28)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 10205,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
0 Answers
Related