Bug report[?]
Describe the bug
Webpack's default resolve.mainFields are:
https://webpack.js.org/configuration/resolve/#resolvemainfields
server = ['module', 'main']
browser = ['browser', 'module', 'main']
But next's:
mainFields: isServer ? ['main', 'module'] : ['browser', 'module', 'main'],
https://github.com/zeit/next.js/blob/8e62c9b688aa7a92e339b728237e8c63ec31f1b5/packages/next/build/webpack-config.ts#L219
The server build prefers main over module which may lead to unexpected results (for example, when having a package whose main points to ES5+CJS source but module points to ESNext+ESM).
To Reproduce
Have a package with module field that points to a different source than main, in server build it prefers the main.
Expected behavior
Prefer module over main in server build. Or, remove this setting completely and use webpack's default.