Skip to content

Commit 06df2f4

Browse files
filipesilvashellscape
authored andcommitted
Use built version os sockjs-client (#1148)
`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
1 parent 32412bb commit 06df2f4

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

client/socket.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

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

55
let retries = 0;
66
let sock = null;

examples/node-false/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# CLI - node false
2+
3+
```shell
4+
node ../../bin/webpack-dev-server.js --open
5+
```
6+
7+
## What should happen
8+
9+
In the app you should see "It's working."

examples/node-false/app.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
document.write("It's working.");

examples/node-false/index.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="bundle.js" type="text/javascript" charset="utf-8"></script>
5+
</head>
6+
<body>
7+
<h1>Example: CLI - node false</h1>
8+
</body>
9+
</html>

examples/node-false/webpack.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = {
4+
context: __dirname,
5+
entry: './app.js',
6+
node: false
7+
};

test/fixtures/simple-config/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ module.exports = {
66
output: {
77
filename: 'bundle.js',
88
path: '/'
9-
}
9+
},
10+
node: false
1011
};

0 commit comments

Comments
 (0)