Skip to content

htmx-json does not work with ES module imports #38

Description

@Massi03dev

Description:
I'm trying to use htmx-json in a modern ES Modules setup (Webpack) with npm-installed packages.

Steps to reproduce:

  1. Install the packages:
npm install htmx.org htmx-json
  1. Import them like this:
import 'htmx.org';
import 'htmx-json';
  1. Run the project.

Expected behavior:
The htmx-json extension should work and provide attributes like json-text, json-each, etc.

Actual behavior:
The extension does not work. It seems that htmx-json cannot find the global htmx variable, which is not automatically exposed in ES module environments.

Temporary workaround that works:

import htmx from 'htmx.org';

// Make htmx global
window.htmx = htmx;

Promise.all([
  import('htmx-json'),
]).then(() => {
  console.log('All extensions loaded');
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions