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

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

Open
j0holo opened this issue May 28, 2023 · 4 comments
Open

Comments

@j0holo
Copy link

j0holo commented May 28, 2023

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.
@ia3andy
Copy link

ia3andy commented Jun 6, 2023

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?

@j0holo
Copy link
Author

j0holo commented Jun 6, 2023

@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.

@ia3andy
Copy link

ia3andy commented Jun 6, 2023

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)?

@j0holo
Copy link
Author

j0holo commented Jun 6, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants