Skip to content
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

Integration with ViewComponents in rails 7 #524

Closed
edugonch opened this issue Mar 4, 2022 · 1 comment
Closed

Integration with ViewComponents in rails 7 #524

edugonch opened this issue Mar 4, 2022 · 1 comment

Comments

@edugonch
Copy link

edugonch commented Mar 4, 2022

I'm trying to use viewcomponents on a brand new rails 7 app, I have done this before in rails 6 using the hack that is on viewcomponents.org

`import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("controllers", true, /.js$/)
const contextComponents = require.context("../../components", true, /_controller.js$/)
application.load(
definitionsFromContext(context).concat(
definitionsFromContext(contextComponents)
)
)`

But looks like things have change on rails 7, now on index.js I have something like this:
`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)`

and I'm not sure how to implement the hack on this new format, do you know how I can workarround this problem?

@edugonch
Copy link
Author

edugonch commented Mar 5, 2022

Looks like the viewcomponent comunity already have some dirty solutions for this
ViewComponent/view_component#1064

@edugonch edugonch closed this as completed Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant