bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
38.61k stars 1.31k forks source link

how to install htmx 2 via jsdelivr #2971

Closed tacman closed 1 week ago

tacman commented 1 month ago

jsdelivr https://www.jsdelivr.com/package/npm/htmx.org gets the package data from npm https://www.npmjs.com/package/htmx.org

I'd like to use htmx 2, but all our front-end assets are wrapped in an importmap and installed via Symfony's assetmapper, which only gets packages from jsdelivr.

Is there a way to install htmx2 via jsdelivr? I know the website says its not marked as latest to keep people from accidentally upgrading, but if a developer says "latest", that's what they'd get. I don't understand npm versioning well, but I use packagist for php depdendencies. If I install htmx for the first time in a new project, I would expect to get 2.0. If I have it in an existing project, it should be locked to ^1.9 or whatever.

Thanks, I look forward to using htmx2!

youssame commented 1 month ago

@tacman I think htmx2 is available in jsdelivr <script src=" https://cdn.jsdelivr.net/npm/htmx.org@2.0.0/dist/htmx.min.js "></script> Check this

tacman commented 1 month ago

Indeed it is -- thanks!

tacman commented 1 week ago

Something is amiss:

image

The dropdown to the right indicates that it's on the 2.0 branch, but the version is tagged as 1.9 in the upper left.

https://www.jsdelivr.com/package/npm/htmx.org?version=2.0.0

Telroshan commented 1 week ago

Hey, looks like the 1.9.12 version tag you're seing references the latest version of htmx. As we released htmx 2 which is a breaking release, and as we unfortunately didn't use to version htmx in our previous install instructions, we're voluntarily letting some time pass before tagging htmx 2 as latest, to give a chance to existing users to update their setup before the breaking release becomes the default one. So, what you're seeing is actually expected!

tacman commented 1 week ago

image

image

I literally don't know what version I'm running. I'm installing it using Symfony's AssetMapper, and it's configured like this:

    'htmx.org' => [
        'version' => '1.9.12',
    ],

I don't mind BC changes, but I'm confused which docs I should even follow.

Telroshan commented 1 week ago

I literally don't know what version I'm running

I'm a bit confused, unless I'm misunderstanding something, your configuration precisely mentions what version of htmx should be installed, 1.9.12 in this case

Disclaimer: I don't know how Symfony's asset mapping works, but it looks very similar to what a package.json would achieve in a npm project for ex

Hope this helps!

tacman commented 1 week ago

Indeed,

bin/console importmap:require htmx.org@2.0.3

installs the latest version. I find the web page confusing, though, but perhaps jsdelivr is simply saying "The latest version is 2.0, but this is the installation page for 1.9.2".

I imagine once you've tagged 2.0 as the latest that it'll be clearer. Thanks.

Telroshan commented 1 week ago

Well, as the link you are using is https://www.jsdelivr.com/package/npm/htmx.org?version=2.0.0 (notice the version parameter in the URL), you properly land on the 2.0.0 page with its installation instructions. The only thing is that jsdeliver will always display the latest version in the tag at the top of the page, no matter what other version you pick in the versions dropdown.

But as you said, once v2 becomes latest, this shouldn't be confusing anymore!