I'm seeing an esbuild error with a Rails 6.1.0 app I generated today:
$ bin/dev
11:37:41 web.1 | started with pid 27390
11:37:41 worker.1 | started with pid 27391
11:37:41 js.1 | started with pid 27392
11:37:41 css.1 | started with pid 27393
11:37:42 js.1 | yarn run v1.22.10
11:37:42 css.1 | yarn run v1.22.10
11:37:42 js.1 | $ node esbuild.config.js --watch
11:37:42 css.1 | $ sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules --watch
11:37:42 js.1 | ✘ [ERROR] Could not resolve "./application"
11:37:42 js.1 |
11:37:42 js.1 | controllers/index.js:1:28:
11:37:42 js.1 | 1 │ import { application } from "./application"
11:37:42 js.1 | ╵ ~~~~~~~~~~~~~~~
11:37:42 js.1 |
11:37:42 js.1 | error Command failed with exit code 1.
11:37:42 js.1 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
11:37:42 js.1 | exited with code 1
11:37:42 system | sending SIGTERM to all processes
11:37:43 css.1 | exited with code 1
11:37:43 worker.1 | terminated by SIGTERM
11:37:43 web.1 | terminated by SIGTERM
Changing line 1 of app/javascript/controllers/index.js from:
import { application } from "./application"
to
import { application } from "../application"
i.e. looking for application.js in the parent directory rather than the cuurent directory (by changing ./application to ../application seems to work, and gives the following output:
$ bin/dev
11:41:03 web.1 | started with pid 27461
11:41:03 worker.1 | started with pid 27462
11:41:03 js.1 | started with pid 27463
11:41:03 css.1 | started with pid 27464
11:41:03 js.1 | yarn run v1.22.10
11:41:03 css.1 | yarn run v1.22.10
11:41:03 js.1 | $ node esbuild.config.js --watch
11:41:03 css.1 | $ sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules --watch
11:41:03 js.1 | ▲ [WARNING] Import "application" will always be undefined because the file "application.js" has no exports
11:41:03 js.1 |
11:41:03 js.1 | controllers/index.js:1:9:
11:41:03 js.1 | 1 │ import { application } from "../application"
11:41:03 js.1 | ╵ ~~~~~~~~~~~
11:41:03 js.1 |
11:41:05 css.1 | Sass is watching for changes. Press Ctrl-C to stop.
11:41:05 css.1 |
11:41:05 web.1 | => Booting Puma
11:41:05 web.1 | => Rails 6.1.4.4 application starting in development
11:41:05 web.1 | => Run `bin/rails server --help` for more startup options
11:41:06 web.1 | Puma starting in single mode...
11:41:06 web.1 | * Puma version: 5.6.1 (ruby 2.6.3-p62) ("Birdie's Version")
11:41:06 web.1 | * Min threads: 5
11:41:06 web.1 | * Max threads: 5
11:41:06 web.1 | * Environment: development
11:41:06 web.1 | * PID: 27461
11:41:06 web.1 | * Listening on http://127.0.0.1:3000
11:41:06 web.1 | * Listening on http://[::1]:3000
11:41:06 web.1 | Use Ctrl-C to stop
11:41:06 worker.1 | 2022-02-09T19:41:06.634Z pid=27462 tid=ow738i4ga INFO: Booted Rails 6.1.4.4 application in development environment
11:41:06 worker.1 | 2022-02-09T19:41:06.634Z pid=27462 tid=ow738i4ga INFO: Running in ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
11:41:06 worker.1 | 2022-02-09T19:41:06.634Z pid=27462 tid=ow738i4ga INFO: See LICENSE and the LGPL-3.0 for licensing details.
11:41:06 worker.1 | 2022-02-09T19:41:06.634Z pid=27462 tid=ow738i4ga INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
11:41:06 worker.1 | 2022-02-09T19:41:06.634Z pid=27462 tid=ow738i4ga INFO: Booting Sidekiq 6.4.1 with redis options {}
I'm seeing an esbuild error with a Rails 6.1.0 app I generated today:
Changing line 1 of
app/javascript/controllers/index.js
from:import { application } from "./application"
to
import { application } from "../application"
i.e. looking for
application.js
in the parent directory rather than the cuurent directory (by changing./application
to../application
seems to work, and gives the following output: