You’re not receiving notifications from this thread.
How to use ESBuild in Rails with JSBundling Discussion
This is awesome, I have been using it for a couple of weeks now. I didn’t necessarily think webpacker was slow, except maybe on Heroku builds. But when you use this, you wonder why you put up with webpacker for so long :)
Exactly. Working with Webpacker was painful compare to ESBuild. I'm really enjoying the workflow and process with Rails 7 new features.
Speaking of which, wouldn't you use importmap instead of dealing with JS complexity?
Does it make sense to have esbuild-rails built into Rails? And should the esbuild.config.js file go in the /config folder or do files in that folder have to be Ruby?
Not really. They tried that with webpacker and it didn't work because things change so often and every app needs flexibility to adjust for their use case.
The way JSbundling is setup, you can use any tools you want. The only requirement is they dump to the asset pipeline. That's super flexible and you can make any changes you need. Great balance I'd say.
JSX/React, yeah esbuild actually comes with support for JSX and typescript I believe, all built in with no configuration needed.
You may even consider looking into vite-ruby.
Vite uses esbuild for building the JS, but it also lets you build your CSS just as fast with built in live reloading.
This is great. Super easy to use and I don't feel like I have to dedicate a month to reading about optimization like webpacker.
The only problem I'm having is that, with an application loaded with controllers, the application.js build gets large pretty quickly. With webpacker, I used a plugin that spit out entrypoints for each controller, so that I could use them on a page-by-page basis (and also import third-party libraries within those controllers to avoid large packs).
I took a look at the esbuild documentation and was able to get sourcemaps by adding sourcemaps: true to the build in esbuild.config.js (using esbuild-rails). I tried splitting: true, format: "esm" but some of my controllers stopped working in unpredictable ways. I gather that it's still very much a work in progress.
I'm trying to wrap my head around a way to separate those controllers without creating import files for each.
It is so fast that I thought it wasn't working and something was wrong.
I'm not really huge into js, just want to sprinkle a few bits of ujs/stimulus/jquery type stuff in there and I usually find thats enough to get a lot done. Its been bewildering recently with webpacker to get simple stuff working at times. thanks for this video explaining more of whats going on.
Is it possible to include coffeescript files into our application.js using this new js bundling system?
I'm trying to import like this:
My file is here:
but get an error
[watch] build finished
20:01:04 js.1 | ✘ [ERROR] Could not resolve "./trixmodz"
20:01:04 js.1 |
20:01:04 js.1 | 13 │ import "./trixmodz"
20:01:04 js.1 | ╵ ~~~~~~~~~~~~
I keep getting the following routing error, but it looks like it's compiling correctly, maybe?
ActionController::RoutingError (No route matches [GET] "/assets/application.js-9dcbd890262770cf8651cbbfafa5b33aa1a83c242962fe28a6539c5725786e6d.map"):
I'm getting errors for sourcemaps on every request as well. I'm not sure why it's happening, but I assume it's because I'm using a non-stock configuration. i.e. I'm building two scripts - application.js and application-dev.js (only used in dev).
My scripts section for dev looks like:
and in my Procfile.dev:
assets: yarn dev
Hmm. Are you using hotwire-livereload? I just updated that gem (1.1.0) and my sourcemap errors are gone.
Hi! I wanted to watch this episode but got this error "This stream is not available anymore"
(I'm not sure whether you will get the exactly same error message, I translated it from Russian "Эта прямая трансляция больше не доступна.")
Hi, the production deployment is failing for me. I'm using Capistrano for the deployment, below you can find the details.
Do I have to add any Capistrano task?
Please help me to resolve this issue.
This works great, but I'm having trouble getting esbuild to pick up css from node modules. Do you have any suggestions?
I keep running into this issue when I run ./bin/dev
everything else seems to run
Error: Can't find stylesheet to import.
16:49:51 css.1 | ╷
16:49:51 css.1 | 1 │ @import 'bootstrap/scss/bootstrap';
16:49:51 css.1 | │
16:49:51 css.1 | ╵
16:49:51 css.1 | app/assets/stylesheets/application.bootstrap.scss 1:9 root stylesheet
Ruby ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
npm -v 8.19.1 not sure if this is even needed
/* Error: Can't find stylesheet to import.
- 1 | @import 'bootstrap/scss/bootstrap';
- app/assets/stylesheets/application.bootstrap.scss 1:9 root stylesheet */
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
border-bottom: 2px solid black;
content: "Error: Can't find stylesheet to import.\a \2577 \a 1 \2502 @import 'bootstrap/scss/bootstrap';\a \2502 \2575 \a app/assets/stylesheets/application.bootstrap.scss 1:9 root stylesheet";
I have been looking at Rails 7 and am now working on trying to upgrade an app using importmaps. In other words I don't have a big app working with esbuild. My notes on say what I put in above is based on https://www.bootrails.com/blog/rails-7-bootstrap-5-tutorial/.