bigskysoftware / bigskysoftware/htmx
ESM typings mismatch (Deno)
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
The docs say we should use `window.htmx = require('htmx.org')`. But that's CJS. What should I use for ESM?
I'm using esbuild with the npm htmx package.
I tried `import htmx from "htmx.org"`. Guess the type of `htmx`: it's a module. But the actual runtime value is the library itself.
I should be able to write `htmx.onLoad`, but my LSP suggests `htmx.default.onLoad` instead.
For now, I'm doing this:
```ts
import htmx from "htmx.org";
import type HTMX from "htmx.org";
declare namespace globalThis {
let htmx: typeof HTMX.default;
}
globalThis.htmx = htmx as unknown as typeof HTMX.default;
(htmx as unknown as typeof htmx.default).config.methodsThatUseUrlParams.length = 0
import("htmx-ext-debug");
```
What I expect is this:
```ts
import htmx from "htmx.org";
htmx.config.methodsThatUseUrlParams.length = 0
globalThis.htmx = htmx;
import("htmx-ext-debug");
```
> [!NOTE]
> The plugins have bad ESM support too, and they require exposing `htmx` globally to use them.
Contributor guide
Assessment
This issue has not been assessed yet.