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

Fix `withHydrate` wrapped named exports #149

Closed natemoo-re closed 3 years ago

natemoo-re commented 3 years ago

Fixes #147! Also fixed a few other bugs I encountered along the way.

Based on @nikita-graf's awesome suggestion of traversing the AST in a Rollup plugin, except I'm not actually modifying the AST to inject any variables. Instead, a components local name is still used as the hydration key (c=InternalComponent) but the Rollup plugin finds the withHydrate HOC calls and emits a JSON file which maps hydration keys (internal Component names) to the exported Component identifiers. This was tested manually against a new named-exports example as well as the existing examples (which all used export default withHydrate(Component)).

changeset-bot[bot] commented 3 years ago

🦋 Changeset detected

Latest commit: 015905af53c1ea522c4f9de80bc23623c66e48f6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages | Name | Type | | --------- | ----- | | microsite | Patch | | site | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

microsite – ./site

🔍 Inspect: https://vercel.com/nmoo/microsite/6qZZ5zbd3VJ5em61pWhQVpCeQNW6
✅ Preview: Canceled

[Deployment for 015905a canceled]

microsite-examples – ./

🔍 Inspect: https://vercel.com/nmoo/microsite-examples/AntHqpDW1MvVESh7BvP6jEpPxrpN
✅ Preview: https://microsite-examples-git-fix-named-with-hydrate-nmoo.vercel.app