Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0: TypeError: import_htmx.default.config is undefined when defining config programmatically #2657

Open
danjac opened this issue Jun 20, 2024 · 4 comments
Labels
2.0 bug Something isn't working

Comments

@danjac
Copy link

danjac commented Jun 20, 2024

This was working in 1.9x:

import htmx from "htmx.org";

// global HTMX configuration
// https://htmx.org/docs/#config

htmx.config.historyCacheSize = 0;
htmx.config.refreshOnHistoryMiss = false;
htmx.config.scrollBehavior = "smooth";
htmx.config.scrollIntoViewOnBoost = false;
htmx.config.useTemplateFragments = true;

In 2.0.0 this causes the following error:

TypeError: import_htmx.default.config is undefined

The workaround of course is to use the <meta> tag, but has this behavior changed in 2.0?

@danjac
Copy link
Author

danjac commented Jun 20, 2024

I also tried the workaround described here for webpack: https://htmx.org/docs/#webpack however this did not work, same result (note: I'm using esbuild, not webpack).

@restless
Copy link

Have you seen this: #2628?

TL;DR;
Try import htmx from "htmx.org/dist/htmx.esm";

@danjac
Copy link
Author

danjac commented Jun 20, 2024

@restless yes, that appears to work, thanks. FYI if updating the docs for webpack, the solution also works for esbuild.

@davidlesieur
Copy link

Using Parcel here. import htmx from "htmx.org/dist/htmx.esm"; works in that case too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants