bigskysoftware / htmx-extensions

159 stars 46 forks source link

Uncaught TypeError: htmx.defineExtension is not a function #92

Open tchoutri opened 2 weeks ago

tchoutri commented 2 weeks ago

I have the following JS file for my frontend:

// custom.js
window.htmx = require('htmx.org');
// app.js
import './custom.js';
import 'htmx-ext-sse';

And in the console browser, when I arrive on page where I try to use ext-sse, I see the following:

Uncaught TypeError: htmx.defineExtension is not a function
    <anonymous> sse.js:12
    <anonymous> sse.js:288
    <anonymous> app.js:6627

I'm not sure how to proceed. I followed the instructions for Webpack (despite using esbuild), and I'm surprised that htmx does not get picked up.

For reference, I have the following in my devDependencies:

    "htmx-ext-sse": "^2.2.2",
    "htmx.org": "^2.0.2",
Telroshan commented 2 weeks ago

Hey, yes the webpack instructions have changed with htmx 2, there's a documentation update PR that's in progress, you may want to try what's inside, it could work for you

Hope this helps!