opennextjs / opennextjs-cloudflare

Open Next.js adapter for Cloudflare
https://opennext.js.org/cloudflare
MIT License
378 stars 8 forks source link

adjust wrangler patching logic to use the correct `node_modules/next/dist` directory #52

Closed dario-piotrowicz closed 1 month ago

dario-piotrowicz commented 1 month ago

Next.js saves the node_modules/next/dist directory for the app in either the normal standalone dir or in the standalone root path, this depends on where the next dependency is actually saved (https://github.com/vercel/next.js/blob/39e06c75/packages/next/src/build/webpack-config.ts#L103-L104) and can depend on the package manager used, if it is using workspaces, etc...

Currently we're always using the normal standalone dir but this is incorrect and causes the package not to work in certain projects, this PR fixes such issue.


[!NOTE] I would have liked to add an e2e test for this, but since this is quite dependent on the package manager being used and the project structure I think that adding an e2e would be tricky (e.g. I'd have to force pnpm to put some dependecies in some locations somehow) and not too valuable (e.g. can I replicate what npm does in pnpm? what about yarn, etc...)


fixes #42