preactjs / next-plugin-preact

Next.js plugin for preact X
394 stars 9 forks source link

Plugin dependency requirements break testing abilities #43

Open Paratron opened 2 years ago

Paratron commented 2 years ago

When I try to install the plugin into our Next.js 11.1 project, I run into serious problems because of the dependency requirements of the plugin.

When I start up my next dev server, I get this message:

[preact] Missing/incorrect dependencies.
Please run:
  npm i react@npm:@preact/compat react-dom@npm:@preact/compat

or:

  yarn add react@npm:@preact/compat react-dom@npm:@preact/compat

So far so good - the problem is, when I completely override the react and react-dom dependencies in npm, the next.js build itself works just fine, but it breaks all unit tests in jest either using react-test-renderer or enzyme-adapter-react-16. The problem is that those testing libs try to access features inside the libaries which are not contained in preact/compat (for example react-dom/test-utils).

Is it really necessary to alias the react and react-dom modules "globally" for the whole project?

rschristian commented 2 years ago

Any chance you have a reproduction? I think we're just missing an alias here, though I'm not a Next or Jest user myself.