Closed manuschillerdev closed 4 years ago
This isn't the preact-compat you normally know from npm, this is a github dependency. The name might be confusing yes
@JoviDeCroock thanks.
Not sure I am understanding this yet.
When I use preact compact, I alias react to compat from the regular preact/compat
package like so:
"resolve": {
"alias": {
"react": "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
},
}
The package github.com/preact-compat/react
used here in nextjs-preact-demo
seems to be rather outdated:
So to me it remains unclear why this github dependency was used for such a "bleeding edge" nextjs example. Just curious! :)
Thanks!
@manuschillerdev the package used as an alias here is itself just an alias. It is a "proxy package" that just imports preact/compat
and re-exports it:
This is necessary because npm aliases (the aliasing technique in use here) don't support subpackages (paths within packages). That meant I couldn't alias react
directly to preact/compat
(the compat directory inside the preact package). Instead, I aliased it to the preact-compat/react
package, which just re-exports preact/compat
.
It's convoluted and may be unnecessary if you copy this change.
Closing for now since this might mislead folks, but I think ultimately the "fix" here is to not use npm aliases. They're nice and minimal in terms of setup, but probably confusing for updates. They also don't apply to transient dependencies, which has been causing issues for folks.
thanks! that cleared things up for me @developit Sorry for the confusion @JoviDeCroock 😄
Hey!
I noticed, that you explicitly use a rather outdated preact-compat version. Is there any reason, why you didn't chose a current preact x version?
https://github.com/developit/nextjs-preact-demo/blob/master/package.json#L13
Thanks! :)