-
Notifications
You must be signed in to change notification settings - Fork 752
Description
I'm working on a very big legacy Rails app where we recently started migrating React components from the Asset Pipeline to Webpacker. We started doing this because sourcemaps weren't working correctly and we figured out it had something to do with the Asset Pipeline. As we started on this, we really wanted a way to migrate components selectively so that we didn't have to do everything in one fell swoop and run the risk of introducing a lot of bugs in the process (the automated testing is a work in progress). After reading this issue and a little bit of tinkering, I was able to get things setup so that we're able to migrate components over selectively rather than in one fell swoop. The approach that I used was to allow the Asset Pipeline to continue loading React, but to switch over to the UJS loader for Webpacker. This allows you to avoid including React twice. I tried to do it vice-versa using Webpack's Provide Plugin, but I wasn't able to get this to work. Could just be because of some old dependencies in the app. At any rate, I'd be happy to highlight both approaches so that people can try both and use what works for them.
I think it would be great to add this information to the docs so that other people are aware of this option as I believe more people will be migrating to Webpacker in the near future. Would it be alright for me to open a PR with updates to the README on how to do this?