-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compability with Preact #1230
Comments
Actually, there is only one difference: Preact requires different So I tried to add the following
and
The only problem is that |
I think it’s great many projects can run on Preact without significant changes but I don’t think we’ll be spending effort supporting this as a built-in configuration (just like we don’t support, for example, Relay out of the box). The best course of action for those interested in it would be to fork |
Well, forking may be a solution. I will try to create a fork and use it. Actually, there already was an attempt to do this: https://github.com/alexkuz/create-preact-app @alexkuz, is there any chance that you will update your create-preact-app fork? |
@just-boris I am working on putting this in my fork. Will get back to you when I am done. I need someone to test complete compatibility, as i don't have a lot experience with preact. |
@just-boris I could, but tbh I'm not really using preact (at least for now), so I have no big interest to keep it up to date. Just fork it and update. Or I could transfer this fork to you if you want to take care of it from here. |
Oh hi @alexkuz |
Hello again, So far, I have been working on this solution and have finally published my fork. So, if you want to create a Preact app without any setup, you may run
and it will give you a Preact-based application. @alexkuz that was not possible to pick up your fork, because the structure of main repo was changed a lot since that time (now this is a monorepo with Lerna). But it would be helpful if you will put a note about my newer fork in your Readme. Also, I have opened "Issues" section in my repo, any further suggestions are welcome |
For those, who wants to check out, what was changed, you may look at this diff |
@just-boris For a complete react compatibility wouldn't one need preact-compat too ? |
Yes, just added this feature per request in just-boris#1. |
Closing this as no any further action from the upstream side. |
Nice, thank you for sharing this! |
Well, if anyone still need this, I created a process.env.NODE_ENV = "production"
const config = require("react-scripts/config/webpack.config.prod")
config.resolve.alias["react"] = "preact-compat"
config.resolve.alias["react-dom"] = "preact-compat"
require("react-scripts/scripts/build") It's not ideal, but it's very simple and easy to maintain |
This doesn't work in tests. It gives an error "Cannot find module 'react' from 'App.test.js'". Can't jest read aliases? Is there any way to configure jest to use preact for react? |
Not without ejecting. (Just like you can’t configure any other alias.) |
It worked when I added to preact-compat to ModuleNameMapper in package.json. However, enzyme didn't work. It would be great if we have a full implementation with preact-compat from someone. |
@prasadmsvs Have you tried https://github.com/timarney/react-app-rewired ? |
@prasadmsvs I am still maintaining my fork supporting Preact. In version 1.1.0 I have also added a mapping into Jest config. Also, look at the official Preact documentation: https://preactjs.com/guide/unit-testing-with-enzyme |
I couldn't find an issue about this topic, so I'd like to create this one to discussion.
Surprisingly, Preact is pretty compatible with React, so this project can also support project based on Preact without big changes.
Any chances for any move toward this?
The text was updated successfully, but these errors were encountered: