preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
950 stars 148 forks source link

npm alias #542

Closed zsolt-dev closed 3 years ago

zsolt-dev commented 4 years ago

Hi,

When I alias preact-compat in webpack config, I get warnings in VS code and it does not work without webpack...

Now, there is new way to alias packages directly in npm: https://github.com/npm/rfcs/blob/latest/implemented/0001-package-aliases.md

Could this work for aliasing preact-compat as react and react-dom?

If yes, maybe this should be the preferred way in the documentation.

EDIT: the webpack alias does not work for me, since I do SSR and do not have webpack on the server side.

Thank you

developit commented 3 years ago

Package aliases can end up failing to apply to dependencies that specify specific react versions. The recommended solution is to use both techniques - alias using npm aliases, then also alias in your bundler config.

For SSR, you can use module-alias, which works directly in Node.