the conclusion from the meeting was to use module patching wherever possible
JavaScript has two major standards of organizing modules:
ESM is supposed to supersede CJS over time, right now we work with projects that contain dependencies supporting either of them or both.
The interoperability problem is a question on how to ensure that we can use different ESM and CJS dependencies at the same time without compability issues.
If a Next.js project uses the app directory, Next.js will change the SWC loader options for code within the API routes, as explained here: https://github.com/vercel/next.js/blob/2af1e784c290eba505b2de76ab0e83eb110cf30e/packages/next/src/build/webpack-config.ts#L669
We found a problem with one library called libphonenumber-js
that, depending on the running environment, is either imported as a CJS module or an ESM one.
The problems seems to be manyfold.
package.json
file available for this library on NPM contains both main
and exports
definitions