Skip to content

Commit 27d21aa

Browse files
authored
Merge branch 'master' into universal-inline
2 parents e454169 + 11e5db5 commit 27d21aa

14 files changed

+739
-117
lines changed

CHANGELOG.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [3.3.1](https://github.com/webpack/webpack-dev-server/compare/v3.3.0...v3.3.1) (2019-04-09)
6+
7+
8+
### Bug Fixes
9+
10+
* **regression:** always get necessary stats for hmr ([#1780](https://github.com/webpack/webpack-dev-server/issues/1780)) ([66b04a9](https://github.com/webpack/webpack-dev-server/commit/66b04a9))
11+
* **regression:** host and port can be undefined or null ([#1779](https://github.com/webpack/webpack-dev-server/issues/1779)) ([028ceee](https://github.com/webpack/webpack-dev-server/commit/028ceee))
12+
* only add entries after compilers have been created ([#1774](https://github.com/webpack/webpack-dev-server/issues/1774)) ([b31cbaa](https://github.com/webpack/webpack-dev-server/commit/b31cbaa))
13+
14+
15+
516
# [3.3.0](https://github.com/webpack/webpack-dev-server/compare/v3.2.1...v3.3.0) (2019-04-08)
617

718

819
### Bug Fixes
920

10-
* **deps:** update dependency yargs to v12.0.5 ([#1707](https://github.com/webpack/webpack-dev-server/issues/1707)) ([fa17131](https://github.com/webpack/webpack-dev-server/commit/fa17131))
11-
* **example/util:** use path.resolve ([#1678](https://github.com/webpack/webpack-dev-server/issues/1678)) ([5d1476e](https://github.com/webpack/webpack-dev-server/commit/5d1476e)), closes [#1428](https://github.com/webpack/webpack-dev-server/issues/1428)
1221
* compatibility with [email protected] ([#1754](https://github.com/webpack/webpack-dev-server/issues/1754)) ([fd7cb0d](https://github.com/webpack/webpack-dev-server/commit/fd7cb0d))
1322
* ignore proxy when bypass return false ([#1696](https://github.com/webpack/webpack-dev-server/issues/1696)) ([aa7de77](https://github.com/webpack/webpack-dev-server/commit/aa7de77))
1423
* respect stats option from webpack config ([#1665](https://github.com/webpack/webpack-dev-server/issues/1665)) ([efaa740](https://github.com/webpack/webpack-dev-server/commit/efaa740))
1524
* use location.port when location.hostname is used to infer HMR socket URL ([#1664](https://github.com/webpack/webpack-dev-server/issues/1664)) ([2f7f052](https://github.com/webpack/webpack-dev-server/commit/2f7f052))
16-
* **Server:** validate express.static.mime.types ([#1765](https://github.com/webpack/webpack-dev-server/issues/1765)) ([919ff77](https://github.com/webpack/webpack-dev-server/commit/919ff77))
25+
* don't crash with express.static.mime.types ([#1765](https://github.com/webpack/webpack-dev-server/issues/1765)) ([919ff77](https://github.com/webpack/webpack-dev-server/commit/919ff77))
1726

1827

1928
### Features

CONTRIBUTING.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ Pull requests often need some real-world testing.
3939

4040
1. In your `package.json`, change the line with `webpack-dev-server` to:
4141

42-
```json
43-
"webpack-dev-server": "github:webpack/webpack-dev-server#pull/<ID>/head"
44-
```
42+
```json
43+
"webpack-dev-server": "<PATH>"
44+
```
4545

46-
`<ID>` is the ID of the pull request.
46+
`<PATH>`:
47+
48+
- `github:webpack/webpack-dev-server#pull/<ID>/head`
49+
where `<ID>` is the ID of the pull request.
50+
51+
- `file:../path/to/local/webapck-dev-server/fork` is the path to your local repo, just make sure you hit the correct path
4752

4853
2. Run `npm install`.
4954

bin/webpack-dev-server.js

-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const webpack = require('webpack');
2020
const options = require('./options');
2121
const Server = require('../lib/Server');
2222

23-
const addEntries = require('../lib/utils/addEntries');
2423
const colors = require('../lib/utils/colors');
2524
const createConfig = require('../lib/utils/createConfig');
2625
const createDomain = require('../lib/utils/createDomain');
@@ -140,8 +139,6 @@ function processOptions(config) {
140139
function startDevServer(config, options) {
141140
const log = createLogger(options);
142141

143-
addEntries(config, options);
144-
145142
let compiler;
146143

147144
try {

lib/Server.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ class Server {
9797

9898
updateCompiler(compiler, options);
9999

100-
this.stats =
101-
options.stats && Object.keys(options.stats).length
102-
? options.stats
103-
: Server.DEFAULT_STATS;
100+
this.originalStats =
101+
options.stats && Object.keys(options.stats).length ? options.stats : {};
104102

105103
this.hot = options.hot || options.hotOnly;
106104
this.headers = options.headers;
@@ -724,7 +722,13 @@ class Server {
724722
}
725723

726724
getStats(statsObj) {
727-
return statsObj.toJson(this.stats);
725+
const stats = Server.DEFAULT_STATS;
726+
727+
if (this.originalStats.warningsFilter) {
728+
stats.warningsFilter = this.originalStats.warningsFilter;
729+
}
730+
731+
return statsObj.toJson(stats);
728732
}
729733

730734
use() {

lib/options.json

+21-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,27 @@
1717
"type": "boolean"
1818
},
1919
"host": {
20-
"type": "string"
20+
"anyOf": [
21+
{
22+
"type": "string"
23+
},
24+
{
25+
"type": "null"
26+
}
27+
]
28+
},
29+
"port": {
30+
"anyOf": [
31+
{
32+
"type": "number"
33+
},
34+
{
35+
"type": "string"
36+
},
37+
{
38+
"type": "null"
39+
}
40+
]
2141
},
2242
"allowedHosts": {
2343
"type": "array",
@@ -41,16 +61,6 @@
4161
"publicPath": {
4262
"type": "string"
4363
},
44-
"port": {
45-
"anyOf": [
46-
{
47-
"type": "number"
48-
},
49-
{
50-
"type": "string"
51-
}
52-
]
53-
},
5464
"socket": {
5565
"type": "string"
5666
},

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-dev-server",
3-
"version": "3.3.0",
3+
"version": "3.3.1",
44
"description": "Serves a webpack app. Updates the browser on changes.",
55
"bin": "bin/webpack-dev-server.js",
66
"main": "lib/Server.js",

test/BeforeAndAfter.test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ describe('Before And After options', () => {
1212
server = helper.start(
1313
config,
1414
{
15-
before: (app, server, compiler) => {
16-
if (!app) {
15+
before: (appArg, serverArg, compilerArg) => {
16+
if (!appArg) {
1717
throw new Error('app is not defined');
1818
}
1919

20-
if (!server) {
20+
if (!serverArg) {
2121
throw new Error('server is not defined');
2222
}
2323

24-
if (!compiler) {
24+
if (!compilerArg) {
2525
throw new Error('compiler is not defined');
2626
}
2727

28-
app.get('/before/some/path', (req, res) => {
29-
res.send('before');
28+
appArg.get('/before/some/path', (_, response) => {
29+
response.send('before');
3030
});
3131
},
32-
after: (app, server, compiler) => {
33-
if (!app) {
32+
after: (appArg, serverArg, compilerArg) => {
33+
if (!appArg) {
3434
throw new Error('app is not defined');
3535
}
3636

37-
if (!server) {
37+
if (!serverArg) {
3838
throw new Error('server is not defined');
3939
}
4040

41-
if (!compiler) {
41+
if (!compilerArg) {
4242
throw new Error('compiler is not defined');
4343
}
4444

45-
app.get('/after/some/path', (req, res) => {
46-
res.send('after');
45+
appArg.get('/after/some/path', (_, response) => {
46+
response.send('after');
4747
});
4848
},
4949
},

test/CreateConfig.test.js

+58
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,32 @@ describe('createConfig', () => {
6868
expect(config).toMatchSnapshot();
6969
});
7070

71+
it('host option (undefined)', () => {
72+
const config = createConfig(
73+
webpackConfig,
74+
Object.assign({}, argv, {
75+
// eslint-disable-next-line no-undefined
76+
host: undefined,
77+
}),
78+
{ port: 8080 }
79+
);
80+
81+
expect(config).toMatchSnapshot();
82+
});
83+
84+
it('host option (null)', () => {
85+
const config = createConfig(
86+
webpackConfig,
87+
Object.assign({}, argv, {
88+
// eslint-disable-next-line no-undefined
89+
host: null,
90+
}),
91+
{ port: 8080 }
92+
);
93+
94+
expect(config).toMatchSnapshot();
95+
});
96+
7197
it('host option (devServer config)', () => {
7298
const config = createConfig(
7399
Object.assign({}, webpackConfig, { devServer: { host: 'example.dev' } }),
@@ -893,6 +919,38 @@ describe('createConfig', () => {
893919
expect(config).toMatchSnapshot();
894920
});
895921

922+
it('port option (same) (string)', () => {
923+
const config = createConfig(
924+
webpackConfig,
925+
Object.assign({}, argv, { port: '9090' }),
926+
{ port: '9090' }
927+
);
928+
929+
expect(config).toMatchSnapshot();
930+
});
931+
932+
it('port option (same) (null)', () => {
933+
const config = createConfig(
934+
webpackConfig,
935+
Object.assign({}, argv, { port: null }),
936+
{ port: null }
937+
);
938+
939+
expect(config).toMatchSnapshot();
940+
});
941+
942+
it('port option (same) (undefined)', () => {
943+
const config = createConfig(
944+
webpackConfig,
945+
// eslint-disable-next-line no-undefined
946+
Object.assign({}, argv, { port: undefined }),
947+
// eslint-disable-next-line no-undefined
948+
{ port: undefined }
949+
);
950+
951+
expect(config).toMatchSnapshot();
952+
});
953+
896954
it('port option (difference)', () => {
897955
const config = createConfig(
898956
webpackConfig,

0 commit comments

Comments
 (0)