developit / nextjs-preact-demo

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

Aliases not working on server side rendering #11

Closed robinvdvleuten closed 3 years ago

robinvdvleuten commented 4 years ago

When Next.js is bundling for server side rendering, all dependencies are externalized. So when you inspect the bundle output, you'll see that React is still used;

/***/ "react":
/*!************************!*\
  !*** external "react" ***!
  \************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = require("react");
developit commented 4 years ago

This should be okay, because those require() statements will be resolved to preact/compat by Node. Though I believe right now external dependencies that require React can end up with their own copy - to fix that we need to switch from npm aliases to module-alias.

marvinhagemeister commented 3 years ago

Just checked with current master and react is not present in any bundler or chunk 🎉