Socket
Socket
Sign inDemoInstall

webpack-dev-middleware

Package Overview
Dependencies
318
Maintainers
4
Versions
113
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.6 to 3.0.0

lib/DevMiddlewareError.js

1

index.js

@@ -21,3 +21,2 @@ 'use strict';

},
watchOffset: 11000,
watchOptions: {

@@ -24,0 +23,0 @@ aggregateTimeout: 200

@@ -63,3 +63,3 @@ 'use strict';

function invalid(...args) {
function invalid(callback) {
if (context.state) {

@@ -74,5 +74,3 @@ context.options.reporter(context.options, {

context.state = false;
// resolve async
if (args.length === 2 && typeof args[1] === 'function') {
const [, callback] = args;
if (callback && typeof callback === 'function') {
callback();

@@ -99,25 +97,10 @@ }

context.rebuild = rebuild;
context.compiler.plugin('invalid', invalid);
context.compiler.plugin('run', invalid);
context.compiler.plugin('done', (stats) => {
// clean up the time offset
if (options.watchOffset > 0) {
stats.startTime -= options.watchOffset;
}
done(stats);
context.compiler.hooks.invalid.tap('WebpackDevMiddleware', invalid);
context.compiler.hooks.run.tap('WebpackDevMiddleware', invalid);
context.compiler.hooks.done.tap('WebpackDevMiddleware', done);
context.compiler.hooks.watchRun.tap('WebpackDevMiddleware', (comp, callback) => {
invalid(callback);
});
context.compiler.plugin('watch-run', (watcher, callback) => {
// apply a fix for compiler.watch, if watchOffset is greater than 0:
// ff0000-ad-tech/wp-plugin-watch-offset
// offset start-time
if (options.watchOffset > 0) {
watcher.startTime += options.watchOffset;
}
invalid(watcher, callback);
});
return context;
};

@@ -5,2 +5,3 @@ 'use strict';

const urlJoin = require('url-join');
const DevMiddlewareError = require('./DevMiddlewareError');
const { getFilenameFromUrl, handleRangeHeaders, handleRequest, ready } = require('./util');

@@ -38,2 +39,3 @@

let stat = context.fs.statSync(filename);
if (!stat.isFile()) {

@@ -46,4 +48,3 @@ if (stat.isDirectory()) {

} else if (!index) {
// TODO throw a proper error
throw new Error('next');
throw new DevMiddlewareError('next');
}

@@ -54,8 +55,6 @@

if (!stat.isFile()) {
// TODO throw a proper error
throw new Error('next');
throw new DevMiddlewareError('next');
}
} else {
// TODO throw a proper error
throw new Error('next');
throw new DevMiddlewareError('next');
}

@@ -70,3 +69,5 @@ }

content = handleRangeHeaders(content, req, res);
let contentType = mime.getType(filename);
// do not add charset to WebAssembly files, otherwise compileStreaming will fail in the client

@@ -73,0 +74,0 @@ if (!/\.wasm$/.test(filename)) {

@@ -9,2 +9,3 @@ 'use strict';

const urlJoin = require('url-join');
const DevMiddlewareError = require('./DevMiddlewareError');

@@ -94,3 +95,7 @@ const HASH_REGEXP = /[0-9a-f]{10,}/;

if (filename) {
uri = urlJoin((outputPath || '').replace(/\/$/, ''), filename);
uri = urlJoin((outputPath || ''), filename);
if (!uri.startsWith('/')) {
uri = `/${uri}`;
}
}

@@ -161,3 +166,3 @@

if (typeof compiler.outputPath === 'string' && !pathabs.posix(compiler.outputPath) && !pathabs.win32(compiler.outputPath)) {
throw new Error('`output.path` needs to be an absolute path or `/`.');
throw new DevMiddlewareError('`output.path` needs to be an absolute path or `/`.');
}

@@ -164,0 +169,0 @@

{
"name": "webpack-dev-middleware",
"version": "2.0.6",
"version": "3.0.0",
"description": "A development middleware for webpack",

@@ -21,9 +21,8 @@ "license": "MIT",

"scripts": {
"ci": "npm run cover -- --report lcovonly && npm run test",
"lint": "eslint index.js lib",
"mocha": "mocha --full-trace --check-leaks",
"test": "npm run lint && npm run mocha",
"beautify": "npm run lint -- --fix",
"cover": "istanbul cover node_modules/mocha/bin/_mocha",
"travis": "npm run cover -- --report lcovonly && npm run lint"
"ci": "npm run lint && npm run test",
"cover": "nyc report --reporter=text-lcov > coverage.lcov && codecov --token=$WDM_CODECOV_TOKEN",
"lint": "eslint index.js cli.js bin lib test examples",
"mocha": "mocha test/test.js --full-trace --check-leaks --exit",
"test": "nyc npm run mocha"
},

@@ -35,3 +34,3 @@ "files": [

"peerDependencies": {
"webpack": "^2.2.0 || ^3.0.0 || ^4.0.0-alpha || ^4.0.0-beta || ^4.0.0"
"webpack": "^4.0.0"
},

@@ -44,3 +43,3 @@ "dependencies": {

"range-parser": "^1.0.3",
"url-join": "^2.0.2",
"url-join": "^4.0.0",
"webpack-log": "^1.0.1"

@@ -50,3 +49,3 @@ },

"assert": "^1.4.1",
"codecov.io": "^0.1.6",
"codecov": "^3.0.0",
"eslint": "^4.0.0",

@@ -56,9 +55,9 @@ "eslint-config-webpack": "^1.2.5",

"express": "^4.14.0",
"file-loader": "^1.1.5",
"istanbul": "^0.4.5",
"mocha": "^4.0.1",
"file-loader": "^1.1.10",
"mocha": "^5.0.1",
"nyc": "^11.4.1",
"sinon": "^4.1.3",
"supertest": "^3.0.0",
"webpack": "^3.0.0"
"webpack": "^4.0.1"
}
}

@@ -183,17 +183,2 @@ <div align="center">

### watchOffset
Type: `Number`
Default: `11000`
Watching (by means of `lazy: false`) will frequently cause multiple compilations
as the bundle changes during compilation. This is due in part to cross-platform
differences in file watchers, so that webpack doesn't loose file changes when
watched files change rapidly. Since that scenario is more an edge case than not,
this option serves as a means to prevent multiple needless, identical compilations
by advancing start-time of a watcher by a number of seconds, which keeps generated
files from triggering the watch cycle.
_To disable this prevention, set this option to a value of `0`._
### watchOptions

@@ -274,3 +259,12 @@

```
## Known Issues
### Multiple Successive Builds
Watching (by means of `lazy: false`) will frequently cause multiple compilations
as the bundle changes during compilation. This is due in part to cross-platform
differences in file watchers, so that webpack doesn't loose file changes when
watched files change rapidly. If you run into this situation, please make use of
the [`TimeFixPlugin`](https://github.com/egoist/time-fix-plugin).
## Server-Side Rendering

@@ -410,2 +404,2 @@

[uglify-url]: https://github.com/webpack-contrib/uglifyjs-webpack-plugin
[wjo-url]: https://github.com/webpack/webpack.js.org
[wjo-url]: https://github.com/webpack/webpack.js.org
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc