flux icon indicating copy to clipboard operation
flux copied to clipboard

Dispatcher fails in Chrome

Open balanceiskey opened this issue 12 years ago • 7 comments

_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 avatar Sep 03 '14 13:09 balanceiskey

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

balanceiskey avatar Sep 03 '14 13:09 balanceiskey

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.

gaearon avatar Sep 03 '14 14:09 gaearon

Just ran into this as well...

KyleAMathews avatar Sep 04 '14 18:09 KyleAMathews

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.

fisherwebdev avatar Sep 04 '14 22:09 fisherwebdev

@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.

gaearon avatar Sep 04 '14 22:09 gaearon

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.

zpao avatar Sep 07 '14 21:09 zpao

:+1: Thanks!

gaearon avatar Sep 10 '14 21:09 gaearon