Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devtool: 'eval' causes ReferenceError #417

Closed
gaearon opened this issue Aug 21, 2014 · 9 comments
Closed

devtool: 'eval' causes ReferenceError #417

gaearon opened this issue Aug 21, 2014 · 9 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Aug 21, 2014

I tried switching to devtool: 'eval' but I keep getting ReferenceErrors in one of the files.
The code is perfectly legit though and works fine with devtool: 'source-map'.

Offending code is from Facebook Flux Dispatcher:

  Dispatcher.prototype.register=function(callback) {"use strict";
    var id = _prefix + _lastID++; // <- Uncaught ReferenceError: _prefix is not defined 
    this.$Dispatcher_callbacks[id] = callback;
    return id;
  };

This variable is declared on top of that file:

var _prefix = 'ID_';

Dispatcher.js

@gaearon
Copy link
Contributor Author

gaearon commented Aug 21, 2014

Weirder, this seems to only affect Chrome and doesn't happen when "use strict" is removed from function.

@gaearon
Copy link
Contributor Author

gaearon commented Aug 21, 2014

This may actually be a Chrome bug.

This fiddle alerts OK in all browsers except Chrome.

@jhnns
Copy link
Member

jhnns commented Aug 21, 2014

It's not a webpack problem, it's caused by the scoped use of "use strict". I've described the problem at a pull-request for FastClick.

@jhnns jhnns closed this as completed Aug 21, 2014
@gaearon
Copy link
Contributor Author

gaearon commented Aug 21, 2014

I'm curious: why does this work in other browsers? Do they implement the spec incorrectly?

@jhnns
Copy link
Member

jhnns commented Aug 21, 2014

Yes ... you're right, it's strange. I don't know.

@balanceiskey
Copy link

I've opened a PR with the Flux folks that references this: facebookarchive/flux#45

@sophiebits
Copy link

This behavior may match the spec for eval, but it's still unintuitive (and IMO, a bug) that the recommended devtool setting for source maps causes code to behave differently than it does without the source map.

@aaronjensen
Copy link

@gaearon were you able to get this working? Even w/ flux 2.0.1 I still see the error when using eval

@aaronjensen
Copy link

@gaearon I got it fixed by using "react-router": "rackt/react-router" because remix-run/react-router#280 has not been released yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants