react-redux icon indicating copy to clipboard operation
react-redux copied to clipboard

use of Object.defineProperty breaks ie8

Open mattydoincode opened this issue 11 years ago • 11 comments

Hi all,

I understand completely that react-redux may not intend to support ie8 and that's totally fine. However, I'm curious if I could be given a little more insight into how the createProvider method works, especially regarding the call to _createClass so that I might find a workaround. As mentioned here calling Object.defineProperty breaks ie8. Perhaps there is a way to write some of the contents of createProvider in a more es6 heavy way? This might allow me to use my own ie8 compatible babel settings to avoid use of defineProperty. Any and all help is greatly appreciated!

mattydoincode avatar Oct 01 '15 19:10 mattydoincode

And i now see that you guys have written this with es6 and that i was simply reading the deployed compiled files

mattydoincode avatar Oct 01 '15 20:10 mattydoincode

This might allow me to use my own ie8 compatible babel settings to avoid use of defineProperty.

How can we do that? We don't actually use Object.defineProperty—it's just what Babel uses for class definitions. Can we avoid it with different Babel settings?

I'm curious if I could be given a little more insight into how the createProvider method works

Just a method that returns a class, see the source.

gaearon avatar Oct 01 '15 20:10 gaearon

Ya i was reading the source like an idiot of my local copy of the files. It's quite easy to follow thanks.

here is our babel loader: babel-loader?loose=es6.classes,es6.properties.computed&stage=1&optional=spec.protoToAssign&externalHelpers=true

I believe that es6.classes and es6.properties.computed both protect against object.defineProperty.

We're a company that sells software to police forces and hence has to support ie8 and it's the absolute worst :(.

mattydoincode avatar Oct 01 '15 20:10 mattydoincode

Actually i believe the specific babel loose mode for this case is es6.modules as explained here.

mattydoincode avatar Oct 01 '15 21:10 mattydoincode

Can you confirm that compiling React Redux with loose: 'all' fixes the issue? I don't mind compiling in this mode.

gaearon avatar Oct 01 '15 21:10 gaearon

yup! checkin now.

mattydoincode avatar Oct 01 '15 21:10 mattydoincode

Going to work more on this today. The .babelrc is already using loose mode all, the real kicker is uses of static class properties. Going to make a PR, but finding that a bunch of other libraries in the redux ecosystem also use similar stuff, so having trouble getting a full integration test on ie8. Will update as I find out more!

mattydoincode avatar Oct 02 '15 15:10 mattydoincode

I've forked and cloned the repo locally, have modified the code to protect against Object.defineProperty, but when attempting to test it using npm link am running into this issue. Essentially because react-redux has a (dev?) dependency on react 0.14-rc1, but my application still depends on react 0.13, both are loaded in. So my application is getting With React 0.14 and later versions, you no longer need to wrap <Provider> child into a function. I'm not sure how the build process of react-redux combined with npm link would end up including a second react version and i'm a little out of my element so I hope my test methodology isn't dumb. I might just drop in the shimmed compiled file for now...

mattydoincode avatar Oct 02 '15 18:10 mattydoincode

Out in 3.1.0.

gaearon avatar Oct 05 '15 08:10 gaearon

use of Object.defineProperty breaks ie8 again. https://github.com/rackt/react-redux/issues/227

xcatliu avatar Dec 23 '15 07:12 xcatliu

Fixed.

gaearon avatar Dec 23 '15 11:12 gaearon