In a monorepo that is wired using Lerna and Yarn workspaces, one of the packages is a Next.js app, which depends on several packages internal to the monorepo.
All of the consumable packages in the monorepo are written in modern javascript, and have both a main field and a module field in their package.jsons. As per convention, the main field points to transpiled code, that uses CJS, while the main field points to code that is transplied except for for the conversion of ES modules to CJS.
As mentioned before, the package consuming the these packages is a Next.js app, which is build using Webpack 4. Strangely enough, one of the consumed packages is resolved to the main field, while all the rest are properly resolved to the module field.
I have even tried to manually set resolve.mainField to [ 'module', 'main', ], which had no effect.
I couldn't find anything in the documentation that could explain this behavior, and any hint would be greatly appreciated