-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Add new Gatsby plugin for Inferno support #9138
Conversation
yes for me i should to trick a bit because in development react hot load give some problem: in webpack.config i use a test case to remove react hot load. Before to be able to publish a working plugin we should to have a possibility to disable the react hot load from gatsby , because it's not supported by inferno. function getResolve() {
i used a other case for a build in test mode development;
and in babel-helper need it's what i added:
pragma is needed to have a correct output in dom in test dev "inferno" mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some initial comments. I think @simonjoom have much more context here :)
@@ -0,0 +1,2 @@ | |||
/gatsby-node.js | |||
/gatsby-browser.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be something like:
/*.js
!index.js
yarn.lock
We don't want any gatsby-
built file in git (including gatsby-node
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to get to this tonight - thanks :)
@@ -0,0 +1,15 @@ | |||
exports.onCreateWebpackConfig = ({ stage, actions }) => { | |||
// Requiring the server version of React-dom is hardcoded right now | |||
// in the development server. So we'll just avoid loading Inferno there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this copied from preact
plugin or this is something new? I'm not sure what's the problem this check is workarounding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was. There are some problems in development with hot reloading on Inferno. This seems to fix it by excluding Inferno in dev and, I assumed, this was probably the same explanation for Preact so I left it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
develop-html
is only for generating things for basic index.html
used in develop mode. There is separate develop
stage that actually produce js bundle, so not sure if this changes anything for hot-reload
@simonjoom I'm getting around the hot reloading issue by just excluding Inferno during development like the Preact plugin does. It's definitely not an ideal solution, but I'd prefer to maintain consistency with how other plugins do things unless strictly necessary. This was all I personally needed to do in order to switch to Inferno and seems pretty consistent with how their docs tell you to migrate - unless I'm missing something, we shouldn't have to do anything else. For instance, switching the pragma isn't needed because Inferno provides Edit: Maybe I'm not actually fixing the hot reloading issue. I'll verify tonight and get back |
Just a heads up - |
Allows hot module reloading locally for me and revamps the comment stating explicitly what we're doing here
@pieh noted. Everything you've mentioned should be resolved at this point :) |
Hello First because it's avoid you to deploy everytime your project to be able to reduce bug involving from inferno. so for me it's why i create a new variable process.env.NODE_ENV=="inferno" In my case i use "npm run inferno" give me my test production case so process.env.NODE_ENV=="inferno" here (hot reloaded avoided with this boolean) HMR working and no minifyjs "npm run build" produce output with inferno + minifyjs inside without react for who is motivated to create a full plugin Pragma is needed to turn around a bug in development mode with inferno. this bug come with preact as well in development nota: there is lot of alias no needed for the plugin (i use a react-native-web structure it's why) i use doting to setup the process env: so the gatsby.config need:
IN PACKAGE.JSON: IN gatsby-browser-entry: Something interesting to do remove the alias: as inferno need the polyfill and not the react versius of context!
too->
|
@simonjoom as mentioned, I agree it's not the ideal situation. This at least serves my personal use case and I don't think the loss of HMR is worth it in development I'll let someone else (preferably from the Gatsby team) decide which route to go so we're not at a standstill here Edit: Clarification |
What is the problem with inferno and HMR - it straight doesn't work or it's buggy? |
With inferno: But it's the react-hot-loader who cannot work with. because react-hot-loader was done for react and still they did not release a inferno-hot-loader to replace it Gatsby use the both. react-hot-loader allow to have fully refresh component without page refresh And again i think an inferno development is not to be on the side it's a very well feature. I created a starter repo the gatsby in last release is boiled in If i missed some hack code in this thread, look in https://github.com/simonjoom/gatsby-starter-inferno-master/tree/master/gatsbyhack/gatsby i did a little video for what you get after deploy: for curious |
Ah, that makes sense - yeah then we should just refresh page in there is no equiavalent to |
@simonjoom @pieh sounds good then. I'll release the code here as my own package since this is all I need and let @simonjoom take this effort from here :) |
@DonnieWest @simonjoom I'll close this one as if I read correct @DonnieWest is not going to pursuit this on the gatsby repo. @simonjoom feel free to create a new PR with your own code. You can also just publish it on your own and add it to our lovely plugin directory. |
Created as a proof of concept for #8858
You can see others who have had success with getting Inferno V6 running on Gatsby and I've also had some luck. Figured I'd essentially fork the Preact plugin and open this as a place for discussion. I'm willing to make any edits requested :)