Socket
Socket
Sign inDemoInstall

webpack-dev-middleware

Package Overview
Dependencies
84
Maintainers
6
Versions
113
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-rc.3 to 4.0.0

dist/cjs.js

13

CHANGELOG.md

@@ -5,2 +5,15 @@ # Changelog

## [4.0.0](https://github.com/webpack/webpack-dev-middleware/compare/v4.0.0-rc.3...v4.0.0) (2020-10-28)
### ⚠ BREAKING CHANGES
* export in CommonJS format
### Bug Fixes
* compatibility with new webpack@5 API ([#737](https://github.com/webpack/webpack-dev-middleware/issues/737)) ([f6054a0](https://github.com/webpack/webpack-dev-middleware/commit/f6054a00e0e804a9d9ef0f4b3075e6116fae6c99))
* handle the `auto` value of the `publicPath` option ([9b4c5ec](https://github.com/webpack/webpack-dev-middleware/commit/9b4c5ec924d8b25d374b95433191d549f9d3717f))
* support webpack@5 ([#702](https://github.com/webpack/webpack-dev-middleware/issues/702)) ([9ccc327](https://github.com/webpack/webpack-dev-middleware/commit/9ccc3276466754bb10e7f5d0b76f63de2a913e92))
## [4.0.0-rc.3](https://github.com/webpack/webpack-dev-middleware/compare/v4.0.0-rc.2...v4.0.0-rc.3) (2020-07-14)

@@ -7,0 +20,0 @@

72

dist/index.js

@@ -8,3 +8,3 @@ "use strict";

var _schemaUtils = _interopRequireDefault(require("schema-utils"));
var _schemaUtils = require("schema-utils");

@@ -30,3 +30,3 @@ var _mimeTypes = _interopRequireDefault(require("mime-types"));

function wdm(compiler, options = {}) {
(0, _schemaUtils.default)(_options.default, options, {
(0, _schemaUtils.validate)(_options.default, options, {
name: 'Dev Middleware',

@@ -66,43 +66,43 @@ baseDataPath: 'options'

(0, _setupOutputFileSystem.default)(context);
let watchOptions;
(0, _setupOutputFileSystem.default)(context); // Start watching
if (Array.isArray(context.compiler.compilers)) {
watchOptions = context.compiler.compilers.map(childCompiler => childCompiler.options.watchOptions || {});
if (context.compiler.watching) {
context.watching = context.compiler.watching;
} else {
watchOptions = context.compiler.options.watchOptions || {};
} // Start watching
let watchOptions;
context.watching = context.compiler.watch(watchOptions, error => {
if (error) {
// TODO: improve that in future
// For example - `writeToDisk` can throw an error and right now it is ends watching.
// We can improve that and keep watching active, but it is require API on webpack side.
// Let's implement that in webpack@5 because it is rare case.
context.logger.error(error);
if (Array.isArray(context.compiler.compilers)) {
watchOptions = context.compiler.compilers.map(childCompiler => childCompiler.options.watchOptions || {});
} else {
watchOptions = context.compiler.options.watchOptions || {};
}
});
return Object.assign((0, _middleware.default)(context), {
waitUntilValid(callback) {
// eslint-disable-next-line no-param-reassign
callback = callback || noop;
(0, _ready.default)(context, callback);
},
invalidate(callback) {
// eslint-disable-next-line no-param-reassign
callback = callback || noop;
(0, _ready.default)(context, callback);
context.watching.invalidate();
},
context.watching = context.compiler.watch(watchOptions, error => {
if (error) {
// TODO: improve that in future
// For example - `writeToDisk` can throw an error and right now it is ends watching.
// We can improve that and keep watching active, but it is require API on webpack side.
// Let's implement that in webpack@5 because it is rare case.
context.logger.error(error);
}
});
}
close(callback) {
// eslint-disable-next-line no-param-reassign
callback = callback || noop;
context.watching.close(callback);
},
const instance = (0, _middleware.default)(context); // API
context
});
instance.waitUntilValid = (callback = noop) => {
(0, _ready.default)(context, callback);
};
instance.invalidate = (callback = noop) => {
(0, _ready.default)(context, callback);
context.watching.invalidate();
};
instance.close = (callback = noop) => {
context.watching.close(callback);
};
instance.context = context;
return instance;
}

@@ -44,3 +44,3 @@ "use strict";

try {
publicPathObject = memoizedParse(publicPath || '/', false, true);
publicPathObject = memoizedParse(publicPath !== 'auto' && publicPath ? publicPath : '/', false, true);
} catch (_ignoreError) {

@@ -47,0 +47,0 @@ // eslint-disable-next-line no-continue

@@ -15,11 +15,12 @@ "use strict";

// alternative header APIs
res.setHeader('Accept-Ranges', 'bytes');
res.set('Accept-Ranges', 'bytes');
const range = req.get('range');
if (req.headers.range) {
const ranges = (0, _rangeParser.default)(content.length, req.headers.range); // unsatisfiable
if (range) {
const ranges = (0, _rangeParser.default)(content.length, range); // unsatisfiable
if (ranges === -1) {
res.setHeader('Content-Range', `bytes */${content.length}`); // eslint-disable-next-line no-param-reassign
res.set('Content-Range', `bytes */${content.length}`); // eslint-disable-next-line no-param-reassign
res.statusCode = 416;
res.status(416);
} else if (ranges === -2) {

@@ -38,4 +39,4 @@ // malformed header treated as regular response

res.statusCode = 206;
res.setHeader('Content-Range', `bytes ${ranges[0].start}-${ranges[0].end}/${length}`); // eslint-disable-next-line no-param-reassign
res.status(206);
res.set('Content-Range', `bytes ${ranges[0].start}-${ranges[0].end}/${length}`); // eslint-disable-next-line no-param-reassign

@@ -42,0 +43,0 @@ content = content.slice(ranges[0].start, ranges[0].end + 1);

{
"name": "webpack-dev-middleware",
"version": "4.0.0-rc.3",
"version": "4.0.0",
"description": "A development middleware for webpack",

@@ -10,3 +10,3 @@ "license": "MIT",

"bugs": "https://github.com/webpack/webpack-dev-middleware/issues",
"main": "dist/index.js",
"main": "dist/cjs.js",
"funding": {

@@ -17,3 +17,3 @@ "type": "opencollective",

"engines": {
"node": ">= 10.13"
"node": ">= 10.13.0"
},

@@ -40,38 +40,38 @@ "scripts": {

"peerDependencies": {
"webpack": "^4.0.0"
"webpack": "^4.0.0 || ^5.0.0"
},
"dependencies": {
"mem": "^6.1.0",
"mem": "^8.0.0",
"memfs": "^3.2.0",
"mime-types": "^2.1.27",
"range-parser": "^1.2.1",
"schema-utils": "^2.7.0"
"schema-utils": "^3.0.0"
},
"devDependencies": {
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webpack-contrib/defaults": "^6.3.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^26.1.0",
"chokidar": "^3.4.0",
"babel-jest": "^26.6.1",
"chokidar": "^3.4.3",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.4",
"express": "^4.17.1",
"file-loader": "^6.0.0",
"husky": "^4.2.5",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"file-loader": "^6.2.0",
"husky": "^4.3.0",
"jest": "^26.6.1",
"lint-staged": "^10.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"standard-version": "^8.0.2",
"supertest": "^4.0.2",
"webpack": "^4.43.0"
"prettier": "^2.1.2",
"standard-version": "^9.0.0",
"supertest": "^5.0.0",
"webpack": "^5.3.0"
},

@@ -78,0 +78,0 @@ "keywords": [

@@ -58,2 +58,4 @@ <div align="center">

See [below](#other-servers) for an example of use with fastify.
## Options

@@ -344,2 +346,26 @@

## Other servers
Examples of use with other servers will follow here.
### Fastify
Fastify interop will require the use of `fastify-express` instead of `middie` for providing middleware support. As the authors of `fastify-express` recommend, this should only be used as a stopgap while full Fastify support is worked on.
```js
const fastify = require('fastify')();
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const devMiddleware = require('webpack-dev-middleware');
const compiler = webpack(webpackConfig);
const { publicPath } = webpackConfig.output;
(async () => {
await fastify.register(require('fastify-express'));
await fastify.use(devMiddleware(compiler, { publicPath }));
await fastify.listen(3000);
})();
```
## Contributing

@@ -367,4 +393,4 @@

[chat-url]: https://gitter.im/webpack/webpack
[size]: https://packagephobia.now.sh/badge?p=webpack-dev-middleware
[size-url]: https://packagephobia.now.sh/result?p=webpack-dev-middleware
[size]: https://packagephobia.com/badge?p=webpack-dev-middleware
[size-url]: https://packagephobia.com/result?p=webpack-dev-middleware
[docs-url]: https://webpack.js.org/guides/development/#using-webpack-dev-middleware

@@ -371,0 +397,0 @@ [hash-url]: https://twitter.com/search?q=webpack

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc