AltSchool / ember-cli-react

Use React component hierarchies in your Ember app
MIT License
68 stars 24 forks source link

Use webpack for building => hot loading + imports #47

Open wmertens opened 5 years ago

wmertens commented 5 years ago

I'm thinking that it would be possible to build the react component(s) with webpack, and have webpack include all the dependencies.

This way, the dependencies for React are tree-shaken and work like normally in the React ecosystem, and any shared dependencies can be marked as external globals in the webpack configuration. Furthermore, it can use the hot reload capabilities of webpack and react-hot-loader.

Disadvantage would be having to run 2 processes to develop.

Does that sound reasonable or am I missing something?

pswai commented 5 years ago

@wmertens That's actually an interesting idea. If we can do that it will be awesome and highly valuable :)

There are two major potential issues that we need to solve:

I'll try to experiment with the idea. If you have already started some research, please feel free to share your findings. PR is very welcomed!

wmertens commented 5 years ago

I got things working like this, but I'm not at liberty to release the code yet:

end result: ember dev also starts a webpack compiler that serves the react components and handles hot reloading.

It works very well, hot reload is pretty instant and doesn't cause Ember to reload. If there are overlapping dependencies between react and ember, they can be grabbed by telling webpack to get the dependency from its global (injected by Ember).

Still to figure out:

I'll ask about releasing the code again.