bigskysoftware / bigskysoftware/htmx-extensions

Uncaught TypeError: htmx.defineExtension is not a function

Open
#92 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
284
Forks
88
PR merge metrics
No merged PRs in 30d

Description

I have the following JS file for my frontend:

```js
// custom.js
window.htmx = require('htmx.org');
```

```js
// 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
sse.js:12
sse.js:288
app.js:6627
```

I'm not sure how to proceed. I followed the instructions for [Webpack](https://htmx.org/docs/#webpack) (despite using esbuild), and I'm surprised that `htmx` does not get picked up.

For reference, I have the following in my devDependencies:

```json
"htmx-ext-sse": "^2.2.2",
"htmx.org": "^2.0.2",
```

Contributor guide

Open the contributing guide

Research direction

Start with custom.js and app.js, then inspect htmx-ext-sse's sse.js at the reported lines and compare the htmx Webpack guidance. Reproduce the esbuild bundle with htmx.org 2.0.2 and htmx-ext-sse 2.2.2; done means the extension loads without the TypeError and SSE can be used.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.