Socket
Socket
Sign inDemoInstall

webpack-dev-middleware

Package Overview
Dependencies
85
Maintainers
6
Versions
113
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.2 to 4.0.3

10

CHANGELOG.md

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

### [4.0.3](https://github.com/webpack/webpack-dev-middleware/compare/v4.0.1...v4.0.3) (2021-01-12)
### Bug Fixes
* output `stats` to `stdout` instead `stderr`, how does `webpack-cli`, if you need hide `stats` from output please use `{ stats: false }` or `{ stats: 'none' }` ([4de0f97](https://github.com/webpack/webpack-dev-middleware/commit/4de0f97596d52a7182ac108a9b9865462fca54fe))
* colors are working for `stats` ([4de0f97](https://github.com/webpack/webpack-dev-middleware/commit/4de0f97596d52a7182ac108a9b9865462fca54fe))
* schema description ([#783](https://github.com/webpack/webpack-dev-middleware/issues/783)) ([f9ce2b2](https://github.com/webpack/webpack-dev-middleware/commit/f9ce2b2537c331901e230c5a8452f4b91d45c713))
* skip `Content-type header` on unknown types ([#809](https://github.com/webpack/webpack-dev-middleware/issues/809)) ([5c9eee5](https://github.com/webpack/webpack-dev-middleware/commit/5c9eee549be264f6df202d960b7cd10bfff7f97d))
### [4.0.2](https://github.com/webpack/webpack-dev-middleware/compare/v4.0.1...v4.0.2) (2020-11-10)

@@ -7,0 +17,0 @@

18

dist/middleware.js

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

// content-type name(like application/javascript; charset=utf-8) or false
const contentType = _mimeTypes.default.contentType(_path.default.extname(filename)); // Express API
const contentType = _mimeTypes.default.contentType(_path.default.extname(filename)); // Only set content-type header if media type is known
// https://tools.ietf.org/html/rfc7231#section-3.1.1.5
if (res.set && contentType) {
res.set('Content-Type', contentType);
} // Node.js API
else {
res.setHeader('Content-Type', contentType || 'application/octet-stream');
}
if (contentType) {
// Express API
if (res.set) {
res.set('Content-Type', contentType);
} // Node.js API
else {
res.setHeader('Content-Type', contentType);
}
}
}

@@ -84,0 +88,0 @@

@@ -5,5 +5,7 @@ {

"mimeTypes": {
"description": "Allows a user to register custom mime types or extension mappings.",
"type": "object"
},
"writeToDisk": {
"description": "Allows to write generated files on disk.",
"anyOf": [

@@ -19,5 +21,7 @@ {

"methods": {
"description": "Allows to pass the list of HTTP request methods accepted by the middleware.",
"type": "array",
"items": {
"type": "string"
"type": "string",
"minlength": "1"
}

@@ -29,11 +33,25 @@ },

"publicPath": {
"type": "string"
"description": "The `publicPath` specifies the public URL address of the output files when referenced in a browser.",
"anyOf": [
{
"enum": ["auto"]
},
{
"type": "string"
},
{
"instanceof": "Function"
}
]
},
"serverSideRender": {
"description": "Instructs the module to enable or disable the server-side rendering mode.",
"type": "boolean"
},
"outputFileSystem": {
"description": "Set the default file system which will be used by webpack as primary destination of generated files.",
"type": "object"
},
"index": {
"description": "Allows to serve an index of the directory.",
"anyOf": [

@@ -44,3 +62,4 @@ {

{
"type": "string"
"type": "string",
"minlength": "1"
}

@@ -47,0 +66,0 @@ ]

@@ -8,6 +8,12 @@ "use strict";

var _webpack = _interopRequireDefault(require("webpack"));
var _colorette = _interopRequireDefault(require("colorette"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function setupHooks(context) {
function invalid() {
if (context.state) {
context.logger.info('Compiling...');
context.logger.log('Compilation starting...');
} // We are now in invalid state

@@ -31,6 +37,6 @@ // eslint-disable-next-line no-param-reassign

const {
compiler,
logger,
state,
compiler,
callbacks,
logger
callbacks
} = context; // Check if still in valid state

@@ -40,36 +46,44 @@

return;
} // Print webpack output
}
logger.log('Compilation finished');
let statsOptions = compiler.compilers ? {
children: compiler.compilers.map(child => // eslint-disable-next-line no-undefined
child.options ? child.options.stats : undefined)
} : compiler.options ? compiler.options.stats : // eslint-disable-next-line no-undefined
undefined;
const statsForWebpack4 = _webpack.default.Stats && _webpack.default.Stats.presetToOptions;
const printStats = (childCompiler, childStats) => {
const statsString = childStats.toString(childCompiler.options.stats);
const name = childCompiler.options.name ? `Child "${childCompiler.options.name}": ` : '';
if (compiler.compilers) {
statsOptions.children = statsOptions.children.map(childStatsOptions => {
if (statsForWebpack4) {
// eslint-disable-next-line no-param-reassign
childStatsOptions = _webpack.default.Stats.presetToOptions(childStatsOptions);
}
if (statsString.length) {
if (childStats.hasErrors()) {
logger.error(`${name}${statsString}`);
} else if (childStats.hasWarnings()) {
logger.warn(`${name}${statsString}`);
} else {
logger.info(`${name}${statsString}`);
if (typeof childStatsOptions.colors === 'undefined') {
// eslint-disable-next-line no-param-reassign
childStatsOptions.colors = Boolean(_colorette.default.options.enabled);
}
return childStatsOptions;
});
} else if (typeof statsOptions.colors === 'undefined' || typeof statsOptions === 'string') {
if (statsForWebpack4) {
statsOptions = _webpack.default.Stats.presetToOptions(statsOptions);
}
let message = `${name}Compiled successfully.`;
statsOptions.colors = Boolean(_colorette.default.options.enabled);
} // TODO webpack@4 doesn't support `{ children: [{ colors: true }, { colors: true }] }` for stats
if (childStats.hasErrors()) {
message = `${name}Failed to compile.`;
} else if (childStats.hasWarnings()) {
message = `${name}Compiled with warnings.`;
}
logger.info(message);
};
if (compiler.compilers && statsForWebpack4) {
statsOptions.colors = statsOptions.children.some(child => child.colors);
}
if (compiler.compilers) {
compiler.compilers.forEach((compilerFromMultiCompileMode, index) => {
printStats(compilerFromMultiCompileMode, stats.stats[index]);
});
} else {
printStats(compiler, stats);
const printedStats = stats.toString(statsOptions); // Avoid extra empty line when `stats: 'none'`
if (printedStats) {
// eslint-disable-next-line no-console
console.log(printedStats);
} // eslint-disable-next-line no-param-reassign

@@ -86,5 +100,5 @@

context.compiler.hooks.watchRun.tap('DevMiddleware', invalid);
context.compiler.hooks.invalid.tap('DevMiddleware', invalid);
context.compiler.hooks.done.tap('DevMiddleware', done);
context.compiler.hooks.watchRun.tap('webpack-dev-middleware', invalid);
context.compiler.hooks.invalid.tap('webpack-dev-middleware', invalid);
(context.compiler.webpack ? context.compiler.hooks.afterDone : context.compiler.hooks.done).tap('webpack-dev-middleware', done);
}
{
"name": "webpack-dev-middleware",
"version": "4.0.2",
"version": "4.0.3",
"description": "A development middleware for webpack",

@@ -41,5 +41,6 @@ "license": "MIT",

"dependencies": {
"colorette": "^1.2.1",
"mem": "^8.0.0",
"memfs": "^3.2.0",
"mime-types": "^2.1.27",
"mime-types": "^2.1.28",
"range-parser": "^1.2.1",

@@ -49,5 +50,5 @@ "schema-utils": "^3.0.0"

"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@commitlint/cli": "^11.0.0",

@@ -58,21 +59,24 @@ "@commitlint/config-conventional": "^11.0.0",

"babel-jest": "^26.6.3",
"chokidar": "^3.4.3",
"chokidar": "^3.5.0",
"connect": "^3.7.0",
"cross-env": "^7.0.2",
"cross-env": "^7.0.3",
"deepmerge": "^4.2.2",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^3.3.0",
"execa": "^5.0.0",
"express": "^4.17.1",
"file-loader": "^6.2.0",
"husky": "^4.3.0",
"husky": "^4.3.7",
"jest": "^26.6.3",
"lint-staged": "^10.5.1",
"lint-staged": "^10.5.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"standard-version": "^9.0.0",
"prettier": "^2.2.1",
"standard-version": "^9.1.0",
"strip-ansi": "^6.0.0",
"supertest": "^6.0.1",
"webpack": "^5.4.0"
"webpack": "^5.13.0"
},

@@ -79,0 +83,0 @@ "keywords": [

@@ -69,3 +69,3 @@ <div align="center">

This property allows a user to pass the list of HTTP request methods accepted by the server.
This property allows a user to pass the list of HTTP request methods accepted by the middleware\*\*.

@@ -111,4 +111,4 @@ ### headers

Instructs the module to enable or disable the server-side rendering mode. Please
see [Server-Side Rendering](#server-side-rendering) for more information.
Instructs the module to enable or disable the server-side rendering mode.
Please see [Server-Side Rendering](#server-side-rendering) for more information.

@@ -120,14 +120,8 @@ ### writeToDisk

If `true`, the option will instruct the module to write files to the configured
location on disk as specified in your `webpack` config file. _Setting
`writeToDisk: true` won't change the behavior of the `webpack-dev-middleware`,
and bundle files accessed through the browser will still be served from memory._
This option provides the same capabilities as the
[`WriteFilePlugin`](https://github.com/gajus/write-file-webpack-plugin/pulls).
If `true`, the option will instruct the module to write files to the configured location on disk as specified in your `webpack` config file.
_Setting `writeToDisk: true` won't change the behavior of the `webpack-dev-middleware`, and bundle files accessed through the browser will still be served from memory._
This option provides the same capabilities as the [`WriteFilePlugin`](https://github.com/gajus/write-file-webpack-plugin/pulls).
This option also accepts a `Function` value, which can be used to filter which
files are written to disk. The function follows the same premise as
[`Array#filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
in which a return value of `false` _will not_ write the file, and a return value
of `true` _will_ write the file to disk. eg.
This option also accepts a `Function` value, which can be used to filter which files are written to disk.
The function follows the same premise as [`Array#filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) in which a return value of `false` _will not_ write the file, and a return value of `true` _will_ write the file to disk. eg.

@@ -209,3 +203,3 @@ ```js

// to the config
compiler.apply(new webpack.BannerPlugin('A new banner'));
new webpack.BannerPlugin('A new banner').apply(compiler);

@@ -212,0 +206,0 @@ // Recompile the bundle with the banner plugin:

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