developit / nextjs-preact-demo

Next.js 9.3 + Preact = 21kB
https://nextjs-preact.now.sh
384 stars 25 forks source link

Remove unnecessary alias #17

Closed zephraph closed 4 years ago

zephraph commented 4 years ago

Given the package.json trick that uses preact-compat/react-dom this alias isn't required.

vercel[bot] commented 4 years ago

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

🔍 Inspect: https://vercel.com/developit/nextjs-preact-demo/mxwwgiz1r ✅ Preview: https://nextjs-preact-demo-git-fork-zephraph-patch-1.developit.now.sh

developit commented 4 years ago

Hi @zephraph - the package.json alias is only applied to code that doesn't specify an incompatible React version range. If you install an npm dependency that includes {"peerDependencies":{"react":"^16"}}, it will end up bundling a copy of React 16 into your JS. The Webpack alias fixes this, by forcing all "react" and "react-dom" dependencies to be remapped to top-level version that is aliased to preact/compat.

zephraph commented 4 years ago

Oh! TIL. Thanks for the tip.