What version of Next.js are you using?
10.1.3
What version of Node.js are you using?
14.15.3
What browser are you using?
Chrome
What operating system are you using?
Windows 10
How are you deploying your application?
Vercel
Describe the Bug
I have a project which have an API route which returns collection of data from markdowns using gray-matter. Works fine locally and when deployed to vercel. But problem occurs when I enable the webpack5 configuration in next.config.js, now the api route works fine locally, but it returns ISE (Internal Server Error) when deployed to vercel.
Expected Behavior
The api route should works fine locally and when being deployed to vercel with webpack5 enabled.
To Reproduce
Sample Repository to reproduce: https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error
https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error/blob/main/next.config.js
Expected (local dev screenshot):

Deployed (in vercel):
https://nextjs-webpack5-api-route-vercel-deployment-error.vercel.app/api/posts
