Can Stimulus be used as an ES Module without a build system?

To use Stimulus without a build system, the handbook mentions adding a HTML script tag pointing at a UMD JavaScript file on unpkg.

Is (or could) Stimulus be provided such that it can be imported directly in ES6 code without using a build system?

import { Application, Controller } from ""

i.e. the module name mentioned in ES6 code is a real, full URL, as opposed to "stimulus" which requires a build system to resolve at compile-time.

1 Like

That would be awesome.
From the very little I know about ES6 module native support in browser, it works very well when there isn’t too many dependencies, which I assume is the case of Stimulus!

1 Like

It should be possible but you would need to manually build a table somewhere of where Stimulus can import controllers from, as normally this table is built from globbing the require context in application.js

1 Like

Regarding native browser support for ES Module dependencies…

When looking at this example, I noticed that the unpkg JavaScript CDN supports adding ?module to a script tag’s src value, resulting in module names in that script (and in its dependencies, recursively) being automatically rewritten to full URLs.

You can use Stimulus as an ES Mosule with;
import { Application } from “”;
To ease further, it would be great if Stimulus would be distributed not only as UMD but also as ESM.