_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

Add npm install instruction to installation section similar to htmx.org

Open j0holo opened this issue 2 years ago • 4 comments

htmx.org does have instruction how to install it via NPM. Hyperscript is also install-able via NPM but this is not documented.

Would it be a good idea to highlight this also in the hyperscript documentation.

Example below from htmx.org replaced with hyperscript (checked the node_modules dir if it exists).

npm

For npm-style build systems, you can install hyperscript via [npm](https://www.npmjs.com/):

npm install hyperscript.org

After installing, you’ll need to use appropriate tooling to use node_modules/hyperscript.org/dist/_hyperscript.js (or .min.js). For example, you might bundle hyperscript with some extensions and project-specific code.

j0holo avatar May 28 '23 16:05 j0holo

For some reason, when used from npm (and packaged with esbuild), it doesn't work.

import "htmx.org"
import "hyperscript.org"

htmx is working fine, does hyperscript require an extra step?

ia3andy avatar Jun 06 '23 18:06 ia3andy

@ia3andy hyperscript works for me if I directly import it into my HTML. I have no luck by importing it into a typescript file and tanspiling it to JavaScript.

j0holo avatar Jun 06 '23 18:06 j0holo

ok, after looking at the sources, this works:

import _hyperscript from "hyperscript.org";

_hyperscript.browserInit();

But maybe there is some way to avoid it (like htmx)?

ia3andy avatar Jun 06 '23 18:06 ia3andy

With a bundler (I use parcel because it just works for simple projects) it is still clean I guess.

import 'htmx.org';
import _hyperscript from 'hyperscript.org';

_hyperscript.browserInit()

console.log("loading index.ts...");

And importing it in index.html as <script defer type="module" src="index.ts"></script> works.

_hyperscript is still in development:

hyperscript is under construction, working towards 1.0. While the syntax and features are largely complete, we're focused on more tests and docs.

j0holo avatar Jun 06 '23 19:06 j0holo