natemoo-re / microsite

Do more with less JavaScript. Microsite is a smarter, performance-obsessed static site generator powered by Preact and Snowpack.
https://npm.im/microsite
MIT License
878 stars 16 forks source link

Preact CDN lookup fails for non-hardcoded submodules #137

Closed ratorx closed 3 years ago

ratorx commented 3 years ago

Currently, the Preact CDN transformation only works for preact and preact/hooks. I also see that this is because they are hardcoded as the only things to lookup.

Unfortunately the way the fallback substitution is done breaks other preact submodules (e.g. preact/compat). It tries to load $PINNED_PREACT_URL.js/compat, which is invalid.

My specific issue is with preact/compat, so this could be solved easily just by adding another hardcoded entry to PREACT_CDN_LOOKUP, but it might be worthwhile to not hardcode the import paths and resolve them as they come up.

natemoo-re commented 3 years ago

Totally agreed. Would rather not have anything hardcoded. I'll fix this!