Closed eclectic-coding closed 1 year ago
What command did you run?
rails new jumpstart_app --no-rc -m ./jumpstart/template.rb
I used --no-rc
to ignore my local .railsrc
.
So, if I create a default rails 7 app (importmaps), add jsbundling-rails
gem, and then run command for esbuild, I get the same error.
This might be an issue with the gem.
Adding to this.
rails new myapp -d postgresql -m https://raw.githubusercontent.com/excid3/jumpstart/master/template.rb
Install esbuild
run yarn add esbuild from "."
yarn add v1.22.18
info No lockfile found.
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
info Direct dependencies
└─ esbuild@0.14.38
info All dependencies
├─ esbuild-darwin-64@0.14.38
└─ esbuild@0.14.38
✨ Done in 1.06s.
Add build script
run npm set-script build "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds" from "."
run yarn build from "."
yarn run v1.22.18
$ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds
✘ [ERROR] Could not resolve "@hotwired/turbo-rails"
app/javascript/application.js:2:7:
2 │ import "@hotwired/turbo-rails"
╵ ~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@hotwired/turbo-rails" as external to exclude it from the bundle,
which will remove this error.
✘ [ERROR] Could not resolve "controllers"
app/javascript/application.js:3:7:
3 │ import "controllers"
│ ~~~~~~~~~~~~~
╵ "./controllers"
Use the relative path "./controllers" to reference the file
"app/javascript/controllers/index.js". Without the leading "./", the path "controllers"
is being interpreted as a package path instead.
2 errors
node:child_process:867
throw err;
^
Error: Command failed: /Users/bakosy/tmp/myapp/node_modules/esbuild-darwin-64/bin/esbuild app/javascript/application.js --bundle --sourcemap --outdir=app/assets/builds
at checkExecSyncError (node:child_process:826:11)
at Object.execFileSync (node:child_process:864:15)
at Object.<anonymous> (/Users/bakosy/tmp/myapp/node_modules/esbuild/bin/esbuild:172:28)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 13020,
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.
run yarn add local-time esbuild-rails trix @hotwired/stimulus @hotwired/turbo-rails @rails/activestorage @rails/ujs @rails/request.js from "."
yarn add v1.22.18
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
success Saved lockfile.
success Saved 20 new dependencies.
info Direct dependencies
├─ @hotwired/stimulus@3.0.1
├─ @hotwired/turbo-rails@7.1.1
├─ @rails/activestorage@7.0.2-4
├─ @rails/request.js@0.0.6
├─ @rails/ujs@7.0.2-4
├─ esbuild-rails@1.0.3
├─ local-time@2.1.0
└─ trix@2.0.0-beta.0
info All dependencies
├─ @hotwired/stimulus@3.0.1
├─ @hotwired/turbo-rails@7.1.1
├─ @hotwired/turbo@7.1.0
├─ @rails/actioncable@7.0.2
├─ @rails/activestorage@7.0.2-4
├─ @rails/request.js@0.0.6
├─ @rails/ujs@7.0.2-4
├─ balanced-match@1.0.2
├─ brace-expansion@1.1.11
├─ concat-map@0.0.1
├─ esbuild-rails@1.0.3
├─ fs.realpath@1.0.0
├─ glob@7.2.0
├─ inflight@1.0.6
├─ inherits@2.0.4
├─ local-time@2.1.0
├─ minimatch@3.1.2
├─ path-is-absolute@1.0.1
├─ spark-md5@3.0.2
└─ trix@2.0.0-beta.0
✨ Done in 3.01s.
A little more...
~/tmp/myapp$ npm run build
> build
> esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds
✘ [ERROR] Could not resolve "@hotwired/turbo-rails"
app/javascript/application.js:2:7:
2 │ import "@hotwired/turbo-rails"
╵ ~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@hotwired/turbo-rails" as external to exclude it from
the bundle, which will remove this error.
✘ [ERROR] Could not resolve "controllers"
app/javascript/application.js:3:7:
3 │ import "controllers"
│ ~~~~~~~~~~~~~
╵ "./controllers"
Use the relative path "./controllers" to reference the file
"app/javascript/controllers/index.js". Without the leading "./", the path
"controllers" is being interpreted as a package path instead.
2 errors
The template install script currently breaks at
esbuild
. Here is the output:I did confirm that a default install of Rails works fine:
rails new awesomeapp -j esbuild