-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Using an external import (react-hook-form is where I noticed the issue) which has a module export which internally uses imports from React leads to preact/compat to be re-imported as ESM. Since this is a completely separate import, errors such as not being able to use hooks occur.
This issue is not observed in vanilla React because it only contains a CJS export (afaik).
Setting experimental.esmExternals: false leads to the external being imported as CJS which leads to the same version of React as the base page being used, fixing the observed issues.
This of course won't work if a package only has a module export.
Should next-plugin-preact suggest experimental.esmExternals: false in next.config.js? Can we somehow tell webpack to always resolve imports from "react" to use CJS?