excid3 / madmin

A robust Admin Interface for Ruby on Rails apps
https://github.com/excid3/madmin
MIT License
546 stars 62 forks source link

Skypack CDN failing to return Stimulus packages #149

Closed molenick-mov closed 1 year ago

molenick-mov commented 2 years ago

I'm currently getting a 404 when madmin attempts to import Stimulus from the Skypack CDN.

The import URL madmin uses is: https://cdn.skypack.dev/stimulus

When I access that in the browser, I see

/*
 * Skypack CDN - stimulus@3.1.0
 *
 * Learn more:
 *   📙 Package Documentation: https://www.skypack.dev/view/stimulus
 *   📘 Skypack Documentation: https://www.skypack.dev/docs
 *
 * Pinned URL: (Optimized for Production)
 *   ▶️ Normal: https://cdn.skypack.dev/pin/stimulus@v3.1.0-i4YciFyhSrBaTZB4EvrT/mode=raw/stimulus
 *   ⏩ Minified: https://cdn.skypack.dev/pin/stimulus@v3.1.0-i4YciFyhSrBaTZB4EvrT/mode=raw,min/stimulus
 *
 */

// Browser-Optimized Imports (Don't directly import the URLs below in your application!)
export * from '/-/stimulus@v3.1.0-i4YciFyhSrBaTZB4EvrT/dist=es2019,mode=raw/stimulus';
export {default} from '/-/stimulus@v3.1.0-i4YciFyhSrBaTZB4EvrT/dist=es2019,mode=raw/stimulus';

When I check the export urls (https://cdn.skypack.dev/-/stimulus@v3.1.0-i4YciFyhSrBaTZB4EvrT/dist=es2019,mode=raw/stimulus), I get an error:

Not found: stimulus/3.1.0/3/stimulus
molenick-mov commented 2 years ago

Did the recent release of Stimulus 3.1.0 break these imports? See https://github.com/hotwired/stimulus/releases/tag/v3.1.0

molenick-mov commented 2 years ago

We fixed this in our project by overriding this template: https://github.com/excid3/madmin/blob/8f29bfd1e3d7dc1149c86c86e18dd6e8e684a87f/app/views/madmin/application/_javascript.html.erb#L6 and pinning Stimulus to v3.0.1:

import { Application, Controller } from 'https://cdn.skypack.dev/stimulus@3.0.1'

molenick-mov commented 1 year ago

Looks like this is happening again, this time with Turbo. Fixed by pinning to 7.1.0:

import * as Turbo from "https://cdn.skypack.dev/@hotwired/turbo@7.1.0"

excid3 commented 1 year ago

This has been fixed. 👍