Skip to content
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

Not pusing mini_racer in default install. Closes #1438 #1437

Closed
wants to merge 2 commits into from

Conversation

vtamara
Copy link

@vtamara vtamara commented Mar 31, 2022

node is used by default and usually it has less problems than mini_racer.

react_on_rails shouldn't push mini_racer in new installations. This patch removes such behavior.


This change is Reviewable

@vtamara vtamara force-pushed the no-miniracer branch 2 times, most recently from 8245fac to e10b3f5 Compare March 31, 2022 22:36
@vtamara vtamara changed the title mini_racer not needed by default. Not pusing mini_racer in default install. Closes #1438 Mar 31, 2022
@justin808
Copy link
Member

@alexeyr @tomdracz Please take a look at this.

  1. Is this a breaking change in any way?
  2. Recommended under what circumstances?
  3. Any downsides?

I don't quite understand why recently this change is needed.

@tomdracz
Copy link
Contributor

From my perspective:

  • agree that mini_racer creates some headaches. Had a lot of time spent debugging and swearing when CI wasn't playing ball with libv8 versions
  • Breaking change? Possibly, maybe. You might hit some implementation differences but considering Node itself is built on top of v8, I wouldn't expect much difference apart from some edge cases
  • Having mini_racer as dependency means sneakily changing ExecJS runtime from Node to mini_racer if it wasn't previously specified. Following principle of least surprise, I would rather have the app dictate what they use for the JS engine. If people want to use mini_racer for whatever circumstances, we should let them, but they should do it in the main app Gemfile.
  • Can't see downsides here really. Considering you will need Node either way and it's faster, I see no reason to rely on mini_racer
  • mini_racer is only useful if you want to use your app in an environment without existing JS engine. But you will need Node to compile assets so this point is moot for anyone using react_on_rails

I've ran a few tests on my app that is using mini_racer gem - yanking it out resulted in no visible changes, app still works, test suite still passes etc.

Happy for this one to go, will add some minor comments.

1 similar comment
@tomdracz
Copy link
Contributor

From my perspective:

  • agree that mini_racer creates some headaches. Had a lot of time spent debugging and swearing when CI wasn't playing ball with libv8 versions
  • Breaking change? Possibly, maybe. You might hit some implementation differences but considering Node itself is built on top of v8, I wouldn't expect much difference apart from some edge cases
  • Having mini_racer as dependency means sneakily changing ExecJS runtime from Node to mini_racer if it wasn't previously specified. Following principle of least surprise, I would rather have the app dictate what they use for the JS engine. If people want to use mini_racer for whatever circumstances, we should let them, but they should do it in the main app Gemfile.
  • Can't see downsides here really. Considering you will need Node either way and it's faster, I see no reason to rely on mini_racer
  • mini_racer is only useful if you want to use your app in an environment without existing JS engine. But you will need Node to compile assets so this point is moot for anyone using react_on_rails

I've ran a few tests on my app that is using mini_racer gem - yanking it out resulted in no visible changes, app still works, test suite still passes etc.

Happy for this one to go, will add some minor comments.

@@ -4,7 +4,7 @@

In most cases, you should use the `prerender: false` (default behavior) with the provided helper method to render the React component from your Rails views. In some cases, such as when SEO is vital, or many users will not have JavaScript enabled, you can enable server-rendering by passing `prerender: true` to your helper, or you can simply change the default in `config/initializers/react_on_rails`.

Now the server will interpret your JavaScript. The default is to use [ExecJS](https://github.com/rails/execjs) and pass the resulting HTML to the client. We recommend using [mini_racer](https://github.com/discourse/mini_racer) as ExecJS's runtime.
Now the server will interpret your JavaScript. The default is to use Node.js.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think ExecJS will still be used behind the scenes but with Node.js rather than mini_racer. Maybe change this to reflect this and tell people they've got choice of alternative runtimes, as documented in ExecJS readme?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be my suggestion too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can anything other than ExecJS be used? If not, the correct phrasing could be something like "Now the server will interpret your JavaScript using ExecJS. You can pick the engine as described in the documentation." If yes, this is a good place to explain how.

@@ -137,14 +137,14 @@ ReactOnRails.configure do |config|
################################################################################
# Server Renderer Configuration for ExecJS
################################################################################
# The default server rendering is ExecJS, probably using the mini_racer gem
# The default server rendering is Node.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, still will be ExecJS but with Node runtime

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but since it already says "for ExecJS" just 2 lines above I don't know if it needs to be said again.

@@ -137,14 +137,14 @@ ReactOnRails.configure do |config|
################################################################################
# Server Renderer Configuration for ExecJS
################################################################################
# The default server rendering is ExecJS, probably using the mini_racer gem
# The default server rendering is Node.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, still will be ExecJS but with Node runtime

# If you wish to use an alternative Node server rendering for higher performance,
# contact justin@shakacode.com for details.
#
# For ExecJS:
# You can configure your pool of JS virtual machines and specify where it should load code:
# On MRI, use `mini_racer` for the best performance
# (see [discussion](https://github.com/reactjs/react-rails/pull/290))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discussion there has shown that mini_racer performed better than Node. That was quite a few years back, would be good to link to any benchmarks supporting the fact that Node is more peformant

# If you wish to use an alternative Node server rendering for higher performance,
# contact justin@shakacode.com for details.
#
# For ExecJS:
# You can configure your pool of JS virtual machines and specify where it should load code:
# On MRI, use `mini_racer` for the best performance
# (see [discussion](https://github.com/reactjs/react-rails/pull/290))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discussion there has shown that mini_racer performed better than Node. That was quite a few years back, would be good to link to any benchmarks supporting the fact that Node is more peformant

@@ -73,7 +73,6 @@ def copy_webpacker_config
end

def add_base_gems_to_gemfile
gem "mini_racer", platforms: :ruby
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a changelog entry reflecting that. If users already have mini_racer in their Gemfiles, nothing will change. We should note that it's been removed and ask users to also remove and test their apps for any changes

@@ -73,7 +73,6 @@ def copy_webpacker_config
end

def add_base_gems_to_gemfile
gem "mini_racer", platforms: :ruby
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a changelog entry reflecting that. If users already have mini_racer in their Gemfiles, nothing will change. We should note that it's been removed and ask users to also remove and test their apps for any changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants