Skip to content

Commit

Permalink
Use built version os sockjs-client
Browse files Browse the repository at this point in the history
`webpack-dev-server` bundles `sockjs-client` from source. `sockjs-client` sources assume a node environment however, and will fail to run if `global` is not available.

By bundling `sockjs-client` from source, the node environment requirement from `sockjs-client` will also be required of the app being served and thus it is not possible to have `node.global = false` in the user app being bundled.

This fix uses the built `sockjs-client` instead of the sources.

Fix #1147
  • Loading branch information
filipesilva committed Oct 16, 2017
1 parent 32412bb commit fe5e48c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/socket.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const SockJS = require('sockjs-client');
const SockJS = require('sockjs-client/dist/sockjs');

let retries = 0;
let sock = null;
Expand Down
9 changes: 9 additions & 0 deletions examples/node-false/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CLI - node false

```shell
node ../../bin/webpack-dev-server.js --open
```

## What should happen

In the app you should see "It's working."
3 changes: 3 additions & 0 deletions examples/node-false/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

document.write("It's working.");
9 changes: 9 additions & 0 deletions examples/node-false/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<script src="bundle.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<h1>Example: CLI - node false</h1>
</body>
</html>
7 changes: 7 additions & 0 deletions examples/node-false/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
context: __dirname,
entry: './app.js',
node: false
};
3 changes: 2 additions & 1 deletion test/fixtures/simple-config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ module.exports = {
output: {
filename: 'bundle.js',
path: '/'
}
},
node: false
};

0 comments on commit fe5e48c

Please sign in to comment.