reflux / refluxjs

A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
BSD 3-Clause "New" or "Revised" License
5.36k stars 330 forks source link

Import Reflux from 'reflux' no longer working #492

Closed eek closed 7 years ago

eek commented 7 years ago

@BryanGrezeszak unfortunately the last change in reflux-core made our website no longer usable.

We're doing:

import Reflux from 'reflux';

const UserActions = Reflux.createActions(['blab', 'blabla']);

export default UserActions;

I get Cannot read property 'createActions' of undefined, that's because Webpack compiles the import Reflux from 'reflux' into reflux.default where default does not exists, so createActions no longer exists.

It's probably from the change in reflux-core, because of the removal of export default Reflux. Can we do anything about it? :D Like put it back? :))

BryanGrezeszak commented 7 years ago

Aye! This is a crappy issue because reflux and reflux-core got out of sync with each other over time, and when it happened nobody realized it was breaking changes happening. So now we've got conflicts that have no good resolution.

In the past reflux-core exported in a way where what was being exported was an object which basically was Reflux...containing the reflux properties/methods.

Then some pushes where made that changed it exporting it as default, without realizing that this changes how it exports itself to something more like an object that contains a default property which then contains the actual Reflux properties/methods.

I'll look at solutions that might benefit both camps and see if we can resolve it. Give me a couple hours.

eek commented 7 years ago

The easiest fix I could find, so that "both camps" are happy is actually explicitly create the default export as well...

So at the end of the Reflux index file, below module.exports = Reflux; to also add module.exports.default = Reflux; I know it's messy, but it works 😀

BryanGrezeszak commented 7 years ago

That's the general path of where I'm going, but I'm doing it inside reflux-core (which is where the issue began) and doing it as a non-iterable property so that there's a little less messiness.

Working on getting it pushed into reflux-core right now, then once its tests/build are all good will update reflux itself to use that version of the core.

eek commented 7 years ago

Awesome!

eek commented 7 years ago

I tried the new version, it works! 😀 Great job! 😀

BryanGrezeszak commented 7 years ago

@eek - v5.0.3 should be good to go to work with either var Reflux = require('reflux'); style importing or import Reflux from 'reflux'; style importing.

BryanGrezeszak commented 7 years ago

Thanks, and thanks for finding/bringing up the issue.