-
-
Notifications
You must be signed in to change notification settings - Fork 633
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
Adding a forced generator option #1131
Conversation
@Garethp I'm not totally convinced. Did you try this? Also, if we were to do such a change, I'd like to see if the change could be only done here: https://github.com/shakacode/react_on_rails/blob/master/node_package/src/generatorFunction.js If you can provide me exact steps to repro this on MacOS, I'll take a look. Additionally, I'd need tests, docs, etc. to merge. Thanks for helping out. |
@justin808 Initially I did have The problem is that the fix that is to tell webpack to use built ins. Telling webpack to use built ins without telling including The goal of this PR is to make an alternative than to #1097 than to use webpack's To be honest I'm not sure how I'd fix it solely in |
We started off with having an explicit flag for this. We spent a ton of
time trying to make the error messages super clear when you mess up. And a
super long time documenting this.
Ideally, the idea of the "generator function" should be renamed to "HOC"
Higher Order Function.
So I'm really open to getting this properly handled. And we need to be
careful about adding an API and then wanting to change 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.
Thanks @Garethp for your efforts!
Please provide:
- tests
- compelling examples I can run that confirm this is necessary.
Reviewed 1 of 1 files at r1, 2 of 2 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Garethp)
package.json, line 56 at r2 (raw file):
"test": "babel-tape-runner -r node_package/tests/helpers/test_helper.js node_package/tests/*.js | tap-spec", "clean": "rm -rf node_package/lib", "prepare": "npm run babel",
why is this changing?
Any update on this? Anybody else seeing this issue? |
Sorry for the delay. I haven't found the time to package it up in to a simple and self contained example. Here's something you can clone and reproduce. The docker container will take care of the php stuff, the js just needs to be built outside of the docker container. If you run the docker as is, you should see a fatal error with a stack track. I've already reported the stack error to Google, as mentioned in the description for this ticket. You can change the entry point of the Now, the cause for this specific stack trace is
This is 'caused by async doesThing() {
} I put it in there as a way to show this error, because we actually have quite a few
Because the generator function isn't being detected as a generator function. Hence my fix. As for the changing of the build, that was for my workplace. Since you want to tackle this bug in a different method than how I did it, I ended up changing the master branch of my fork to suit our build environment, assuming that my PR would be rejected for another approach. Is there any more information you need? |
@Garethp can you update your repo to the current version of React on Rails? |
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Garethp)
node_package/src/ComponentRegistry.js, line 22 at r2 (raw file):
} const isGeneratorFunction = generatorFunction(component);
@Garethp have you exhausted all possibilities to fix the function generatorFunction(component)
?
If we go with your fix, we need to document this.
Hi I didn't explore all possibilities because to be quite honest I had already spent quite a bit of time investigating this issue and reporting it to the various vendors, and didn't want to spend further time in an area had evidently had quite a bit of research put in to it by you. I had planned to come back to it later on to investigate further, but that time never came. At the moment, I'm not longer working for the company that I implemented this for, so I probably won't be following this bug much further unless I end up using ReactOnRails in my next position. I hope you can end up finding a more elegant solution though. |
@Garethp I'd definitely merge something if others also report this issue. |
What is this?
This allows someone to force
ReactOnRails.register
to treat what they registered as a generator function(s).Why is this needed?
It seems like webpack somehow transforms generator functions in such a way that React no longer recognizes them. I'm not the only person, someone has already logged #1097 to ask for help. For that person, the solution was to use Webpacks
useBuiltIns
and then includebabel-polyfil
. Unfortunately, we're rendering our code using Googles V8 Engine.babel-polyfil
currently causes a fatal error if the V8 engine tries to create a snapshot ofbabel-polyfil
. Here's someone else reporting an issue with php-v8js. I've already logged a ticket with Google about this, but they might take time to fix and release. And then it might take a while for the release to propagate and so on.On the other hand, a simple flag to force the registry to accept that it's being given a generator function would be much easier to implement and distribute, and would give another option other than to include
babel-polyfil
This change is