htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Unable to bundle htmx

Open TheDavidFactor opened this issue 1 year ago • 2 comments

I followed the directions here: https://htmx.org/docs/#webpack

So now my app.js looks like this:

Image

While htmx is working, the hx-* attributes work, the htmx function is not initialized.

If I comment out the htmx section of my app.js and load it directly from CDN via a script tag it works as expected.

Any assistance, even pointing me to the part of the very fine manual I missed, would be appreciated!

TheDavidFactor avatar Nov 03 '25 17:11 TheDavidFactor

import htmx from "htmx.org";
window.htmx = htmx;

You can try this instead. Your bundler may not support the older require style imports but this should import it as a proper ES Module.

MichaelWest22 avatar Nov 03 '25 20:11 MichaelWest22

That worked. Would it make sense to update documentation? If so, that's something I'm willing to attempt

TheDavidFactor avatar Nov 04 '25 17:11 TheDavidFactor