facebookarchive / flux

Application Architecture for Building User Interfaces
https://facebookarchive.github.io/flux/
Other
17.47k stars 3.46k forks source link

Dispatcher fails in Chrome #45

Closed balanceiskey closed 10 years ago

balanceiskey commented 10 years ago

_prefix is not defined

I'm actually experiencing this issue because we're using react-router which in turn uses Flux. It's been referenced over in Webpack's issues, but it doesn't appear to be a Webpack issue:

https://github.com/webpack/webpack/issues/417 http://jsfiddle.net/rokkkjcs/1/

balanceiskey commented 10 years ago

Does it makes sense to remove the "use strict' requirement there? Is that the issue?

gaearon commented 10 years ago

I'm working around this by using jsx?harmony Webpack loader and original ES6 Dispatcher.js file with my own 'use strict' added at the very top.

KyleAMathews commented 10 years ago

Just ran into this as well...

fisherwebdev commented 10 years ago

The dispatcher does work in Chrome. But it does not work while you're using source maps, correct? I believe the issue is the "use strict" declaration that is getting inserted by gulp-react during the transformation from ES6 with the harmony: true option. https://github.com/facebook/flux/blob/master/Gulpfile.js#L19

Fastclick was dealing with a similar issue: https://github.com/ftlabs/fastclick/pull/270 https://github.com/ftlabs/fastclick/pull/288

This might be an issue for Chrome devtools, or maybe for gulp-react? Not sure Flux is the correct place to correct it, but I'm totally open to suggestions on what band-aid we should provide in the mean time.

gaearon commented 10 years ago

@fisherwebdev For me, putting 'use strict' at the top of Dispatcher.js helps: it no longer generates 'use strict' inside functions, and thus doesn't break eval in Chrome.

zpao commented 10 years ago

We're not going to be changing the class transforms which is adding the inner 'use strict's (in jstransform via react-tools) so I think doing what @gaearon says and putting 'use strict' at the top of the file is the right move.

gaearon commented 10 years ago

:+1: Thanks!