developit / htm

Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.
Apache License 2.0
8.64k stars 169 forks source link

just a small note: standalone bundle of htm with preact and preact/signals #239

Open rozek opened 1 year ago

rozek commented 1 year ago

First of all: thank you very much for this marvelous package!

For my personal needs, however, I "had" to bundle htm not only with preact but also with preact/signals - which surprisingly worked out-of-the-box.

However, I won't open a pull request as this "enhancement" does not add any new functionality but just makes the import a bit more convenient...

Of course, you may close this "issue" whenever you like.

developit commented 1 year ago

Hiya! I do think this would be really nice to offer, but as you mentioned it's a bit of a divergence from what the standalone entry has previously included.

FWIW, you can grab a combined version using npm.reversehttp.com (it has a UI for getting combined bundles):

<!DOCTYPE html>
<body>
<script type="module">
import {
  html, h, useSignal, render
} from 'https://npm.reversehttp.com/@preact/signals-core,@preact/signals,htm/preact,preact';

function App() {
  const count = useSignal(0);
  return html`
    <button onClick=${() => count.value++}>
      ${count}
    </button>
  `;
}

render(h(App), document.body);
</script>
</body>

Here's a demo of the above on JSFiddle: https://jsfiddle.net/developit/6gjqnma9/

rozek commented 1 year ago

Wow, that's interesting and can be quite useful from time to time!

Thank you very much for the hint!