preactjs / next-plugin-preact

Next.js plugin for preact X

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error building with latest preact, next.js: Cannot find module 'webpack'

srdjan opened this issue · comments

Reproduction

https://github.com/srdjan/next-repros

Steps to reproduce

npm run build

Expected Behavior

successful build

Actual Behavior

Build error occurred
{ Error: Cannot find module 'webpack'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._resolveFilename (/Users/srdjans/Code/next-repros/node_modules/module-alias/index.js:49:29)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/Users/srdjans/Code/next-repros/node_modules/@prefresh/webpack/src/index.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/Users/srdjans/Code/next-repros/node_modules/@prefresh/next/src/index.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) code: 'MODULE_NOT_FOUND' }

Looks like the canary builds of nextjs inline webpack as a dependency. Therefore it won't show up in node_modules anymore.

Downgrading next to the latest stable build works fine.

@JoviDeCroock can you transfer this issue to the prefresh repo?

yeah, thanks.
alternatively installing webpack (at least while this gets sorted) works ...

Re-opening because it should work by default without additional user interactions.

commented

@JoviDeCroock do you already have a plan how to mitigate this in @prefresh/next? I think we should check whether the required webpack utils are part of nextjs' bundled webpack distro and use them instead of importing webpack (if available)

Hmm, does next export the utils?

This seems to be fixed with the recently released next@10.0.8, can someone else verify?

confirming that next@10.0.8 fixes this issue

since I opened it - I'll close it :)

Cool, however mind that Next 10.0.8 has trouble with .env files: vercel/next.js#22879 – if you need that, it should be fixed in canary.