Skip to content

Question about --css=bootstarp #70

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

Closed
jasonfb opened this issue Jan 18, 2022 · 6 comments
Closed

Question about --css=bootstarp #70

jasonfb opened this issue Jan 18, 2022 · 6 comments

Comments

@jasonfb
Copy link

jasonfb commented Jan 18, 2022

Hey I just wanted to ask this query about starting with --css=bootstrap — it seems like when one does that (at least against 7.0.1), something else happens over in Stimulus (I know we're here in cssbundling-rails).

In particular, I noticed that javascript/controllers/index.js has something different and interesting...

// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

import { application } from "./application"

import HelloController from "./hello_controller.js"
application.register("hello", HelloController)

it seems to suggest that this explicit registration pattern to update this file using rails stimulus:manifest:update is needed where as the other index.js file (at the same location) generated by the 7.0.1 without --css=bootsstrap seems to do this other thing:

import { application } from "controllers/application"

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)

just was curious if you could clarify the intention or maybe one is newer than the other? perhaps if the dynamic one is newer (seems smarter to me than a long list of registered controller names) it needs to be backported to the --css=bootstrap? or perhaps I'm missing something.

Thank you @dhh !

-Jason

@jasonfb
Copy link
Author

jasonfb commented Jan 18, 2022

also with --css=bootstrap I can't get any stimulus controllers to connect, even if I do add them using the rails stimulus:manifest:update as explained in the index file..

whereas an app built without this gem (no --css=bootstrap) the stimmy controllers seem to connect up just fine.

@jasonfb
Copy link
Author

jasonfb commented Jan 26, 2022

so. I guess my question is this:

is importmap designed to be used in conjunction with cssbundling-rails and/or jsbundling-rails or as an alternative?

What it seems to me is that these apps installed with cssbundling-rails and jsbundling-rails (which I believe happens if you use either the --css or the --js flag), you get a Rails default with no importmap and the the stimulus + Turbo gems installed, but then what happens is that Turbo + Stimulus don't actually work. unless I'm missing something obvious, I think there's just a piece missing to wire up stimulus and Turbo on these kinds of apps.

@jasonfb
Copy link
Author

jasonfb commented Jan 26, 2022

I think perhaps the answer to my question above is "as an alternative"

when I try to install importmap on top of apps created like this, things seem to get somewhat worse: two application.js files are created (one was already inside of contollers/) and then Sprockets starts giving me errors:

Sprockets::DoubleLinkError in AdminDashboard::Users#index
Showing /Users/jason/Work/Hot_Glue/Example Apps/SimpleInvoicer/app/views/layouts/application.html.erb where line # raised:
Multiple files with the same output path cannot be linked ("application.js")

Note that I still get this even after I removed javascript_include_tag out of my application erb file and only have javascript_importmap_tags in this file.

I can't seem to retroactively fit importmap into these kinds of app at all, even trying to monkey patch the working (Default rails new) install into this non-functional install. So maybe this is the wrong route to go down. with these three new options it's just to see how the pieces fit together.

@jasonfb
Copy link
Author

jasonfb commented Jan 26, 2022

FYI — it the problem is on my machine it is almost certainly (I think?) the same root cause as rails/jsbundling-rails#74

See my discussion with @dhh on that issue. Will get to the bottom of it soon-- I suspect cached yanked gems somewhere but if a 3rd party (who is not @dhh or me) could re-create on their machine to let us know what you get that would be helpful. all the details are over in the other story.

I guess the only relevant question here remains:

is importmap designed to be used in conjunction with cssbundling-rails and/or jsbundling-rails or as an alternative?

@jasonfb
Copy link
Author

jasonfb commented Jan 27, 2022

I was running these using rails s which has no webpack so it's possible that was my problem here. nevertheless, the mystery about the inconsistent files at app/javascript/controllers/index.js remains.

Since I was verbose above I will close this an re-file with only the question about the two app/javascript/controllers/index.js files

@jasonfb jasonfb closed this as completed Jan 27, 2022
@jasonfb
Copy link
Author

jasonfb commented Feb 10, 2022

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

No branches or pull requests

1 participant