Proposal to create @undux npm scope
I'd like to propose creating an @undux npm scope in order to remove the current hard dependency of Undux on React.
Instead of making a hard dependency we could split undux up like this:
@undux/core
@undux/react
I already have a working PoC of using Undux in Angular. You can check it out here: https://github.com/sandervalstar/undux-angular-test Currently I run a shell script on a postinstall hook which removes the React dependencies from Undux.
I think it should not be too hard to split Undux up into a Core package and a React package, especially in the latest version of Undux (5.0.0-alpha.15) the react dependency already seems pretty well isolated to me. We'll probably have to create an organization account for Undux on npm to get an @undux scope. Organization accounts on npm are free if you only have public packages. https://www.npmjs.com/docs/orgs/
Do you think this is a good idea? Will it really be as simple as I think or are there some obstructions that I missed?
By the way, if we agree that this is a good idea I would love to help with splitting up Undux.
Hey @sandervalstar, that's an interesting idea! Which parts of Undux were you able to reuse for your Angular implementation - was it just StoreDefinition?
Hi @bcherny I tried some things out tonight to see if the plugins and snapshots are working too. I added a factory which allows for enabling redux dev tools and the logger by setting environment variables. And they're both fully working as far as I can tell. I also added a component that takes snapshots. Just pushed the changes to my test project.
Are there any other parts of Undux that I missed?
Really neat work @sandervalstar! Using Undux at facebook, I’m actually moving in the other direction, towards less dependencies and a mono-package. That’s because the module bundling system we use for web is pretty strict, and it can be a little painful to bundle projects that have deep dependency graphs (today it’s Undux -> typed-exactly-emitter -> rxjs, but we actually use what’s in the bundled-rx2 branch - note the inlined dependencies).
So if you don’t mind, let’s keep everything as-is for now. You can still use Undux to power undux-Angular right? The only downside is it pulls in a kB or so of extra dependencies if you’re not using a tree-shaking bundler.
Thanks, glad you like it @bcherny! I'm not sure I'm following, are you talking about minimizing required peer dependencies for Undux? I see your bundled-rx2 branch includes a hard copy of the emitter package and the branch does not require rxjs as peer dependency whereas master does. Following this model wouldn't it be possible to bundle undux/core in undux/react but still maintain undux/core separately without a React peer dependency?
I am able to use Undux in Angular only after removing the React dependencies from Undux manually (or with a hacky shell script like in my test project's post-install hook). If I don't remove those dependencies from Undux I would have to install React as a dependency in my Angular project which is kind of an abomination. So I don't think that my solution is very desirable for real projects, it's just a proof of concept that we would only have to extract a small number of things out of the core package for Undux to become usable outside of React.
Alternatively I could publish an undux-angular package which takes care of removing the React dependencies from Undux so people using Angular can directly install the undux-angular package. But that still seems a little backwards.
Thanks for taking the time to look at this by the way!