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

Version advice for starting with webpacker #2879

Closed
diesl opened this issue Jan 13, 2021 · 6 comments
Closed

Version advice for starting with webpacker #2879

diesl opened this issue Jan 13, 2021 · 6 comments

Comments

@diesl
Copy link

diesl commented Jan 13, 2021

We have a dockerized Rails 5.2 web app and we are planning to start using webpacker.

However, after having read quite a few tickets around here, I am not sure what is the best way to begin this journey. I see that the new versions of webpack and yarn have quite big (breaking) changes in code and philosophy. Because of that I wonder whether I should start with the brand new versions or stick to the "old" stable versions where I have to upgrade to new versions with possibly lots of work again at some point of time.

Let's make it more concrete:
Would it be clever to start using webpacker with

  • Rails 5.2
  • webpacker 6.x
  • yarn 2.x

Or should I stick to the stable version:

  • Rails 5.2
  • webpacker 5.x
  • yarn 1.x

Some more questions are:

  • Can I even use yarn 2.x with Rails 5.2? In some issues concerning yarn 2.x, I mostly read about Rails 6.x making me unsure. If this is the case, would you recommend to update to Rails 6.x first and then go with the new webpacker?
  • In case you recommend the new solution, do you know some docs explaining the installation with Docker (especially the yarn part)?

Thanks for your advice!

@rossta
Copy link
Member

rossta commented Jan 13, 2021

My advice would depend on your familiarity with webpack. If you're comfortable, start with Webpacker v6. If this is your first time using webpack, stick with the latest stable Webpacker v5. Docs should help with the upgrade.

I've been using yarn v1 for awhile now without any issues. I can't speak to how well yarn v2 works with Webpacker yet.

@gauravtiwari
Copy link
Member

Thanks @rossta that sounds like a great advice ^^

There are some more upcoming changes to Webpacker 6.0 to smoothen switch from sprockets and make defaults simpler like Sprockets. I will share more updates later in the week.

@diesl
Copy link
Author

diesl commented Jan 14, 2021

Thank you for your comments so far.

My advice would depend on your familiarity with webpack. If you're comfortable, start with Webpacker v6. If this is your first time using webpack, stick with the latest stable Webpacker v5.

Funny enough, my thought was the other way round: If I am familiar with webpack (v5) then start with what I know. But as I am mostly unfamiliar with webpack, why start learning something that will be outdated soon? But I will surely reconsider

There are some more upcoming changes to Webpacker 6.0 to smoothen switch from sprockets and make defaults simpler like Sprockets. I will share more updates later in the week.

Sounds great! I am looking forward to see your updates. Maybe this will already help me.

Does anyone know if yarn 2 is supported by webpacker on Rails 5.2?

@pedrofurtado
Copy link
Member

pedrofurtado commented Jan 21, 2021

Hey, @diesl ! 👋

A important note: The webpacker 6.x is not stable yet, but the 5.x is stable and ready for use in production environments 👍

I will try to answer your question about compatibility of yarn v2 in Rails and in webpacker, separately.

Yarn 2 is supported by Rails itself only in 6.x version (6.0 and 6.1). For more details, you can check the discussion in PR related to it: rails/rails#40722

Yarn 2 is supported by Webpacker in 6.x version (#2799).

Recently, few days ago, we also added support in 5.x version of webpacker (#2889). In next release of 5.x version (maybe v5.2.2 or v5.3.0), yarn 2 support will be available! 🎉

@diesl
Copy link
Author

diesl commented Feb 1, 2021

Thanks @pedrofurtado for your additional comments and links for further reading 👍

I did some further research and came to conclusion that we will update to Rails 6.x first, as the migration seems to work fine and without big problems in our dev environment.

As yarn 2 will be available in both webpacker 5 (soon) and 6, we will likely go with yarn 2 then.

Last but not least, when it comes to decide which webpacker version we will choose, I think we will likely pick the new 6.x branch. Since I started this ticket, already 2 new beta versions have been released, so I think a stable version is not half a year away and we are not in a big hurry.

There are some more upcoming changes to Webpacker 6.0 to smoothen switch from sprockets and make defaults simpler like Sprockets. I will share more updates later in the week.

@gauravtiwari Do you have any news here?

@dhh dhh closed this as completed Aug 20, 2021
@mariuspopaadrian
Copy link

@pedrofurtado Just a Question with Rails patches for yarn2 backported to 5.2 i guess yarn 2 can work with webpacker 5.x (already merged) ?

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

6 participants