Skip to content

Doesn't work when bundling #162

@adamchainz

Description

@adamchainz

Make a new folder and run these four commands to set up a basic bundle with esbuild (webpack competitor):

npm install htmx.org hyperscript.org esbuild
echo 'require("htmx.org/dist/htmx.js"); require("hyperscript.org/dist/_hyperscript.js");' > app.js
npm exec -- esbuild app.js --bundle --outfile=bundle.js
echo '<html><head><script type="text/javascript" src="bundle.js"></script></head></html>' > index.html

... and then open index.html in the browser. htmx successfully loads and works, but hyperscript breaks with a couple of these errors:

Uncaught ReferenceError: _hyperscript is not defined

It looks like hyperscript's module loading wrapper is only applied to the runtime, and not the individual commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions