Skip to content

Commit 41222a3

Browse files
committed
Merge branch 'master' of https://github.com/rlamana/webpack-dev-server into hmr-use-location-port
# Conflicts: # package-lock.json
2 parents a50b5ab + cb10f83 commit 41222a3

33 files changed

+2650
-446
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @evilebottnawi @michael-ciniawsky
1+
* @evilebottnawi @hiroppy

.travis.yml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1+
sudo: false
2+
3+
git:
4+
depth: 10
5+
6+
branches:
7+
only:
8+
- master
9+
- next
10+
111
language: node_js
212

313
cache:
414
directories:
515
- node_modules
16+
- $HOME/.npm
617

7-
jobs:
18+
matrix:
819
fast_finish: true
920
include:
10-
- stage: Lint
11-
env: SCRIPT=lint
12-
node_js: 'stable'
21+
- env: JOB_PART=lint
22+
node_js: 11
1323
- &linux
14-
stage: Test (Linux)
15-
env: SCRIPT=test
16-
node_js: 'stable'
17-
- <<: *linux
24+
env: JOB_PART=test
1825
node_js: 11
1926
- <<: *linux
2027
node_js: 10
@@ -23,9 +30,8 @@ jobs:
2330
- <<: *linux
2431
node_js: 6
2532
- &osx
26-
stage: Test (MacOS)
2733
os: 'osx'
28-
env: SCRIPT=test
34+
env: JOB_PART=test
2935
node_js: 11
3036
- <<: *osx
3137
node_js: 10
@@ -34,15 +40,19 @@ jobs:
3440
- <<: *osx
3541
node_js: 6
3642

37-
install:
43+
before_install:
3844
- npm i -g npm@latest
39-
- npm i
4045

41-
script: npm run $SCRIPT
46+
install:
47+
- npm ci
48+
49+
before_script:
50+
- node --version
51+
- npm --version
52+
53+
script:
54+
- npm run $JOB_PART
4255

4356
after_success:
4457
- npm i codecov
4558
- $(npm bin)/codecov
46-
47-
notifications:
48-
email: false

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
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.2.1](https://github.com/webpack/webpack-dev-server/compare/v3.2.0...v3.2.1) (2019-02-25)
6+
7+
8+
### Bug Fixes
9+
10+
* deprecation message about `setup` now warning about `v4` ([#1684](https://github.com/webpack/webpack-dev-server/issues/1684)) ([523a6ec](https://github.com/webpack/webpack-dev-server/commit/523a6ec))
11+
* **regression:** allow `ca`, `key` and `cert` will be string ([#1676](https://github.com/webpack/webpack-dev-server/issues/1676)) ([b8d5c1e](https://github.com/webpack/webpack-dev-server/commit/b8d5c1e))
12+
* **regression:** handle `key`, `cert`, `cacert` and `pfx` in CLI ([#1688](https://github.com/webpack/webpack-dev-server/issues/1688)) ([4b2076c](https://github.com/webpack/webpack-dev-server/commit/4b2076c))
13+
* **regression:** problem with `idb-connector` after update `internal-ip` ([#1691](https://github.com/webpack/webpack-dev-server/issues/1691)) ([eb48691](https://github.com/webpack/webpack-dev-server/commit/eb48691))
14+
15+
16+
517
<a name="3.1.14"></a>
618
## [3.1.14](https://github.com/webpack/webpack-dev-server/compare/v3.1.13...v3.1.14) (2018-12-24)
719

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ state, the project only officially supports the _last two versions of major
9595
browsers_. We simply don't have the resources to support every whacky
9696
browser out there.
9797

98-
If you find an bug with an obscure / old browser, we would actively welcome a
98+
If you find a bug with an obscure / old browser, we would actively welcome a
9999
Pull Request to resolve the bug.
100100

101101
## Support
@@ -128,25 +128,6 @@ out completely._
128128

129129
We welcome your contributions! Please have a read of [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved.
130130

131-
## Maintainers
132-
133-
<table>
134-
<tbody>
135-
<tr>
136-
<td align="center">
137-
<img src="https://avatars.githubusercontent.com/SpaceK33z?v=4&s=150">
138-
<br />
139-
<a href="https://github.com/SpaceK33z">Kees Kluskens</a>
140-
</td>
141-
<td align="center">
142-
<img src="https://i.imgur.com/4v6pgxh.png">
143-
<br />
144-
<a href="https://github.com/shellscape">Andrew Powell</a>
145-
</td>
146-
</tr>
147-
</tbody>
148-
</table>
149-
150131
## Attribution
151132

152133
This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).

appveyor.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
build: 'off'
22

3-
cache:
4-
- node_modules
3+
branches:
4+
only:
5+
- master
6+
- next
57

68
init:
79
- git config --global core.autocrlf input
810

11+
cache:
12+
- node_modules
13+
- '%APPDATA%\npm-cache'
14+
915
environment:
1016
matrix:
1117
- nodejs_version: '11'
@@ -23,10 +29,12 @@ matrix:
2329
install:
2430
- ps: Install-Product node $env:nodejs_version x64
2531
- npm i -g npm@latest
26-
- npm i
32+
- npm ci
2733

2834
before_test:
2935
- cmd: npm i webpack@%webpack_version%
3036

3137
test_script:
32-
- cmd: npm t
38+
- node --version
39+
- npm --version
40+
- cmd: npm test

bin/webpack-dev-server.js

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,33 @@
44

55
/* eslint-disable
66
import/order,
7-
import/no-extraneous-dependencies,
8-
global-require,
97
no-shadow,
10-
no-console,
11-
multiline-ternary,
12-
arrow-parens,
13-
array-bracket-spacing,
14-
space-before-function-paren
8+
no-console
159
*/
1610
const debug = require('debug')('webpack-dev-server');
1711

1812
const fs = require('fs');
1913
const net = require('net');
2014

21-
const portfinder = require('portfinder');
2215
const importLocal = require('import-local');
2316

2417
const yargs = require('yargs');
2518
const webpack = require('webpack');
2619

2720
const options = require('./options');
28-
29-
const { colors, status, version, bonjour } = require('./utils');
30-
3121
const Server = require('../lib/Server');
3222

3323
const addEntries = require('../lib/utils/addEntries');
24+
const colors = require('../lib/utils/colors');
25+
const createConfig = require('../lib/utils/createConfig');
3426
const createDomain = require('../lib/utils/createDomain');
3527
const createLogger = require('../lib/utils/createLogger');
36-
const createConfig = require('../lib/utils/createConfig');
28+
const defaultTo = require('../lib/utils/defaultTo');
29+
const findPort = require('../lib/utils/findPort');
30+
const getVersions = require('../lib/utils/getVersions');
31+
const runBonjour = require('../lib/utils/runBonjour');
32+
const status = require('../lib/utils/status');
33+
const tryParseInt = require('../lib/utils/tryParseInt');
3734

3835
let server;
3936

@@ -74,17 +71,20 @@ try {
7471
}
7572

7673
yargs.usage(
77-
`${version()}\nUsage: https://webpack.js.org/configuration/dev-server/`
74+
`${getVersions()}\nUsage: https://webpack.js.org/configuration/dev-server/`
7875
);
7976

77+
// eslint-disable-next-line import/no-extraneous-dependencies
8078
require('webpack-cli/bin/config-yargs')(yargs);
79+
8180
// It is important that this is done after the webpack yargs config,
8281
// so it overrides webpack's version info.
83-
yargs.version(version());
82+
yargs.version(getVersions());
8483
yargs.options(options);
8584

8685
const argv = yargs.argv;
8786

87+
// eslint-disable-next-line import/no-extraneous-dependencies
8888
const config = require('webpack-cli/bin/convert-argv')(yargs, argv, {
8989
outputFilename: '/bundle.js',
9090
});
@@ -94,6 +94,15 @@ const config = require('webpack-cli/bin/convert-argv')(yargs, argv, {
9494
// we should use portfinder.
9595
const DEFAULT_PORT = 8080;
9696

97+
// Try to find unused port and listen on it for 3 times,
98+
// if port is not specified in options.
99+
// Because NaN == null is false, defaultTo fails if parseInt returns NaN
100+
// so the tryParseInt function is introduced to handle NaN
101+
const defaultPortRetry = defaultTo(
102+
tryParseInt(process.env.DEFAULT_PORT_RETRY),
103+
3
104+
);
105+
97106
function processOptions(config) {
98107
// processOptions {Promise}
99108
if (typeof config.then === 'function') {
@@ -107,24 +116,7 @@ function processOptions(config) {
107116
}
108117

109118
const options = createConfig(config, argv, { port: DEFAULT_PORT });
110-
111-
portfinder.basePort = DEFAULT_PORT;
112-
113-
if (options.port != null) {
114-
startDevServer(config, options);
115-
116-
return;
117-
}
118-
119-
portfinder.getPort((err, port) => {
120-
if (err) {
121-
throw err;
122-
}
123-
124-
options.port = port;
125-
126-
startDevServer(config, options);
127-
});
119+
startDevServer(config, options);
128120
}
129121

130122
function startDevServer(config, options) {
@@ -210,21 +202,35 @@ function startDevServer(config, options) {
210202
status(uri, options, log, argv.color);
211203
});
212204
});
213-
} else {
205+
return;
206+
}
207+
208+
const startServer = () => {
214209
server.listen(options.port, options.host, (err) => {
215210
if (err) {
216211
throw err;
217212
}
218-
219213
if (options.bonjour) {
220-
bonjour(options);
214+
runBonjour(options);
221215
}
222-
223216
const uri = createDomain(options, server.listeningApp) + suffix;
224-
225217
status(uri, options, log, argv.color);
226218
});
219+
};
220+
221+
if (options.port) {
222+
startServer();
223+
return;
227224
}
225+
226+
// only run port finder if no port as been specified
227+
findPort(server, DEFAULT_PORT, defaultPortRetry, (err, port) => {
228+
if (err) {
229+
throw err;
230+
}
231+
options.port = port;
232+
startServer();
233+
});
228234
}
229235

230236
processOptions(config);

examples/util.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ const webpack = require('webpack');
1111
module.exports = {
1212
setup(config) {
1313
const defaults = { mode: 'development', plugins: [], devServer: {} };
14+
15+
if (config.entry) {
16+
if (typeof config.entry === 'string') {
17+
config.entry = path.resolve(config.entry);
18+
} else if (Array.isArray(config.entry)) {
19+
config.entry = config.entry.map((entry) => path.resolve(entry));
20+
} else if (typeof config.entry === 'object') {
21+
Object.entries(config.entry).forEach(([key, value]) => {
22+
config.entry[key] = path.resolve(value);
23+
});
24+
}
25+
}
26+
1427
const result = Object.assign(defaults, config);
1528
const before = function before(app) {
1629
app.get('/.assets/*', (req, res) => {
@@ -40,12 +53,12 @@ module.exports = {
4053

4154
let exampleTitle = '';
4255

43-
renderer.heading = function headingProxy(text, level, raw) {
56+
renderer.heading = function headingProxy(text, level, raw, slugger) {
4457
if (level === 1 && !exampleTitle) {
4558
exampleTitle = text;
4659
}
4760

48-
return heading.call(this, text, level, raw);
61+
return heading.call(this, text, level, raw, slugger);
4962
};
5063

5164
marked.setOptions(markedOptions);

jest.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"testURL": "http://localhost/",
33
"collectCoverage": true,
4+
"coveragePathIgnorePatterns": ["test"],
45
"moduleFileExtensions": ["js", "json"],
56
"testMatch": ["**/test/**/*.test.js"],
67
"setupFilesAfterEnv": ["<rootDir>/setupTest.js"]

0 commit comments

Comments
 (0)