I’m having trouble using stimulus controllers in my webpack build setup, I have imported stimulus and added my own *_controller.js files to the application. But when I add a controller from a npm package, my build size is doubled(or even more) because stimulus is pulled in again instead of just pulling in the controller.
Am I doing it wrong, or is this just not supported?
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
import Flatpickr from "stimulus-flatpickr";
const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))
application.register("flatpickr", Flatpickr);