Skip to content

A conversation about using require() #284

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

Closed
watzon opened this issue May 27, 2015 · 4 comments
Closed

A conversation about using require() #284

watzon opened this issue May 27, 2015 · 4 comments

Comments

@watzon
Copy link

watzon commented May 27, 2015

I know that this has been brought up before, but I figured I'd reach out and see if any new solutions have popped up since then. So let's hear it. Has anyone found a fairly easy-to-implement solution for requiring external component libraries in react-rails?

@krzysiek1507
Copy link
Contributor

In application.js

//= library

In component.js if namespaced

var OtherComponent = Namespace.OtherComponent

class Blah extends OtherComponent {
 ...
}

@danott
Copy link
Contributor

danott commented May 27, 2015

Using https://rails-assets.org/ for external libs has worked well in my practice. The caveat being, those packages have to be on bower.

The approach I've started taking for things that are not on bower is to build my own browserify'd or webpack'd version of the other component. A readme for how to do that could be a interim solution.

Others' mileage may very, but overall, sticking with Sprockets has been the happiest path I've taken. I've tried browserify-rails, and also built my own webpack_rails solution, but at the end of day, embracing Sprockets with all it's warts works wonderfully if I accept the trade-offs.

@AndrewRayCode
Copy link

this project is fundamentally incompatible with a require() workflow #129 as the authors have stated they are sticking with the rails asset pipeline. The mentioned #120 gives a hairy hack that might work for commonjs.

@rmosolgo
Copy link
Member

rmosolgo commented Dec 9, 2016

As mentioned, there's nothing in this gem to especially support require. I'll be keeping an eye out for asset changes in 5.1, where webpack may come in the mix!

@rmosolgo rmosolgo closed this as completed Dec 9, 2016
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

5 participants