preactjs / next-plugin-preact

Next.js plugin for preact X
394 stars 9 forks source link

Fails with `future.webpack5` option, unless `webpack` explicitly installed #34

Open lunelson opened 3 years ago

lunelson commented 3 years ago

On startup with a new Next.js project (v10.2.2) configured with this plugin, and with the next.config.js using the future.webpack5 option in order to enforce webpack 5 (usually it falls back to webpack 4 if a custom webpack config is detected, as is the case with this plugin), the dev command fails with the following message.

The message goes away if I explicitly install webpack to the project.


...
info  - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5
Error: Cannot find module 'webpack/lib/dependencies/ConstDependency'
Require stack:
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/@prefresh/webpack/src/index.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/@prefresh/next/src/index.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/next-plugin-preact/index.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/next.config.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/next/dist/next-server/server/config.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/next/dist/server/next.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/next/dist/server/lib/start-server.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/next/dist/cli/next-dev.js
- /Users/lunelson/Git/sandboxes/nextjs-preactx-test/node_modules/next/dist/bin/next```
aralroca commented 3 years ago

I have the same issue with webpack 5

aralroca commented 3 years ago

Installing webpack to the project solve it... npm i webpack@latest --save-dev

laymonage commented 2 years ago

https://github.com/preactjs/prefresh/pull/361 and https://github.com/preactjs/prefresh/pull/362 have been merged and have solved the issue, but I had to manually upgrade @prefresh/webpack to fix it. Maybe @JoviDeCroock could bump the prefresh in this package again? Thanks!