-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
eval-source-map
results in "Can't find variable: SockJS" in Safari on Mac and iOS with v2.8.x
#1090
Comments
If you haven't already, give I can certainly understand the frustration that 2.8.x introduced a regression and this has ceased to work correctly for you. There seems to be a never ending number of edge cases in the webpack world that surfaces with each release. For this particular one bugbear, we'll happily welcome a PR from the community to resolve it. In the meantime, you might choose to use |
It occurs on the not only 2.8.x, but also ~ 2.2.0. (or maybe lower version too.) I changed code to below (with helping by @shai, my colleague at work), It works well. // webpack-dev-server/client/socket.js
var SockJS = require('sockjs-client');
var retries = 0;
var sock = null;
function socket(url, handlers) {
sock = new SockJS(url);
... I don't know why scope is recognized weirdly, but it works! |
It seems that Safari has trouble in understanding |
@deedubbu do either of the two solutions here work for your setup? |
tried this with |
@karneaud You need to include webpack-dev-server's js files in the babel-loader.
|
Seems like the issue has been fixed in Safari 11.0. Can anyone else confirm that? |
I was facing the same issue, then I updated iOS (and Safari) to version 11.0.whatever and it´s working fine. |
closing this one citing the workarounds listed in the issue and confirmations the issue has been cleared up in the latest Safari version |
this means being unable to hit dev URLs on iOS10. not optimal? |
I want this to be fixed on Safari 10 . |
Please fix this in recent version for safari 10. Its urgent. |
@lakinmohapatra please do not post successive comments on an issue within seconds of each other, it's considered bad form. instead, edit your previous comment. workarounds for this issue have been posted by other users, we recommend trying those. |
Okay got it . |
For me I edited web-pack-dev-server/client/socket.js as follows:
|
@cheerun 's solution helped me figure out what I hope is a nicer solution #1090 (comment) I wanted to add something that wasn't immediately clear for others. The file to edit is located at /node_modules/webpack-dev-server/client/socket.js What I changed was one line, from this
to this
@shellscape I will create a PR for this. |
Fixes iOS Safari 10 bug. At the root, this works around a bug where Safari's eval's scope was getting confused. Something to do with [this issue](https://stackoverflow.com/questions/46036960/evaluated-expression-const-variable-scope-in-safari) [bug reference](webpack#1090 (comment))
* iOS Safari 10 bug where SockJS couldn't be found Fixes iOS Safari 10 bug. At the root, this works around a bug where Safari's eval's scope was getting confused. Something to do with [this issue](https://stackoverflow.com/questions/46036960/evaluated-expression-const-variable-scope-in-safari) [bug reference](#1090 (comment)) * named function to satisfy linter
After working through this and a related issue, and not wanting to rely on Safari 11 upgrades, I found a different work-around... in the project folder, i forced the local CLI up to the latest version...
my app ran fine in Safari 10.x after that. Granted, some of my npm dependencies will now probably need to be updated, but fortunately all of them appeared to work even with some warnings upon ng serve. |
Code
Sample code here
Expected Behavior
Using the
eval-source-map
option fordevtool
should not affect the ability to render the page.Actual Behavior
With version
2.8.x
it seems like specifyingeval-source-map
fordevtool
is causing an error that is preventing rendering on Safari on Mac and iOS. Rendering seems fine on Chrome/Firefox, but when loading the page in Safari I'm getting:ReferenceError: Can't find variable: SockJS
I suspect something in the "Cleanup Effort" commit might have broke this but haven't identified what. Maybe something to do with uglifyJS plugin being added
How can we reproduce the behavior?
The gist has a complete code sample that exhibits the issue:
npm install
npm start
localhost:8000
in Safari and open dev tools console to see error. Notice the page doesn't render either.npm start
webpack.config.js
and removedevtool: 'eval-source-map'
.npm start
localhost:8000
in Safari and notice it now renders and the dev tools console is clean.The text was updated successfully, but these errors were encountered: