-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Let's say you're using a library like StimulusJS which requires that the application be initialized and then needs controllers mapped into the main application.
<script type="importmap">
{
"imports":
{
"@hotwired/stimulus": "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js",
"HomeFlowController": "/home_controller.js"
}
}
</script>
<script type="module">
import { Application, Controller } from "@hotwired/stimulus"
import HomeController from "HomeController"
window.Stimulus = Application.start()
Stimulus.register("home", HomeController)
</script>Currently the import map tag is rendered by itself, and then you need to create a separate <script type="module"> to then initialize the JS. This is a bit cumbersome and because it's detached from the import map that's generated. The natural flow feels like the module script tag should be able to be generated from within the configuration block for the AssetPipeline and then the js files that are being pinned can be referenced in the import statements.
Metadata
Metadata
Assignees
Labels
No labels