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

Upgrade to Vue v3 or move back to React.js #110

Open
rubys opened this issue Jan 7, 2021 · 3 comments
Open

Upgrade to Vue v3 or move back to React.js #110

rubys opened this issue Jan 7, 2021 · 3 comments

Comments

@rubys
Copy link
Member

rubys commented Jan 7, 2021

Not urgent, but this work should be planned for. Summary

  • Vue.js version 3 was released in September of 2020. It is not exaggerating much to say that pretty much every API we used has changed. Details below.
  • Previously the agenda, secretary workbench, and roster apps were built using React, but we moved away from that when React changed to a non-open source license. React changed their license back shortly after this work was completed. They were aware of our moving away due to licensing issues, and this may have contributed to their change of heart, but at that point it didn't seem worth spending the effort to migrate back.

In Ruby syntax, a minimal application looks like the following:

class C < Vue
  def render
     _span "hi"
  end
end

Vue.render '#greetings' do
  _C
end

The above currently compiles to the following JavaScript:

var C = Vue.component(
  "c-",
  {render: function($h) {return $h("span", "hi")}}
);

new Vue({el: "#foo", render: function($h) {return $h(C)}})

With V3:

  • component is no longer a method on Vue. Instead one needs to call createApp, and component is a method on the app.
  • render methods no longer are passed an argument. Instead, one is expected to call Vue.h.
  • new Vue no longer works; instead one needs to call mount on the app.

After a day's worth of effort, I've gotten close, but I still haven't found a combination of calls that is equivalent to the above. Once that is done, I don't know what else has changed.

To be fair, Vue discourages the use of these APIs; they recommend creating HTML templates and mounting data onto the templates instead.


During this same time, the React API has remained stable, mostly with some additions that don't much matter to us.

If the requires for ruby2js/filter/vue were replaced with requires for ruby2js/filter/react and each of the classes defined in .js.rb files were changed to inherit from React instead of Vue, the code would nearly work.

  • Vue lifecyle methods are a bit different than React lifecycle methods. Some of the mappings are straightforward Vue's created is roughly the same as React's componentDidMount. Others are subtly different and need to be investigated on a case by case basis.
  • React event handler names are a bit different. If you want to have a method called every time someone enters a character in an input field, you would define this with onChange instead of onInput.

I really don't think that there was much more to it than that. This would not be a particularly difficult task, but it does represent a non-trivial amount of effort given the number of source files involved.

In case it isn't obvious, my recommendation is to move back to React.

@sebbASF
Copy link
Contributor

sebbASF commented Jan 9, 2021

How does this compare with the proposal to rewrite in Node.js?

@sebbASF
Copy link
Contributor

sebbASF commented Jan 12, 2023

@rubys is it still your recommendation to move back to React?

@rubys
Copy link
Member Author

rubys commented Jan 13, 2023

yes

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

No branches or pull requests

2 participants