WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

20
node_modules/webpack-hot-middleware/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

200
node_modules/webpack-hot-middleware/README.md generated vendored Normal file
View File

@ -0,0 +1,200 @@
# Webpack Hot Middleware
Webpack hot reloading using only [webpack-dev-middleware](https://webpack.js.org/guides/development/#webpack-dev-middleware). This allows you to add hot reloading into an existing server without [webpack-dev-server](https://webpack.js.org/configuration/dev-server/).
This module is **only** concerned with the mechanisms to connect a browser client to a webpack server & receive updates. It will subscribe to changes from the server and execute those changes using [webpack's HMR API](https://webpack.js.org/concepts/hot-module-replacement/). Actually making your application capable of using hot reloading to make seamless changes is out of scope, and usually handled by another library.
If you're using React then some common options are [react-transform-hmr](https://github.com/gaearon/react-transform-hmr/) and [react-hot-loader](https://github.com/gaearon/react-hot-loader).
[![npm version](https://img.shields.io/npm/v/webpack-hot-middleware.svg)](https://www.npmjs.com/package/webpack-hot-middleware) [![CircleCI](https://circleci.com/gh/webpack-contrib/webpack-hot-middleware/tree/master.svg?style=svg)](https://circleci.com/gh/webpack-contrib/webpack-hot-middleware/tree/master)[![codecov](https://codecov.io/gh/webpack-contrib/webpack-hot-middleware/branch/master/graph/badge.svg)](https://codecov.io/gh/webpack-contrib/webpack-hot-middleware)![MIT Licensed](https://img.shields.io/npm/l/webpack-hot-middleware.svg)
## Installation & Usage
See [example/](./example/) for an example of usage.
First, install the npm module.
```sh
npm install --save-dev webpack-hot-middleware
```
Next, enable hot reloading in your webpack config:
1. Add the following plugins to the `plugins` array:
```js
plugins: [
// OccurrenceOrderPlugin is needed for webpack 1.x only
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
// Use NoErrorsPlugin for webpack 1.x
new webpack.NoEmitOnErrorsPlugin()
]
```
Occurence ensures consistent build hashes, hot module replacement is
somewhat self-explanatory, no errors is used to handle errors more cleanly.
3. Add `'webpack-hot-middleware/client'` into the `entry` array.
This connects to the server to receive notifications when the bundle
rebuilds and then updates your client bundle accordingly.
Now add the middleware into your server:
1. Add `webpack-dev-middleware` the usual way
```js
var webpack = require('webpack');
var webpackConfig = require('./webpack.config');
var compiler = webpack(webpackConfig);
app.use(require("webpack-dev-middleware")(compiler, {
noInfo: true, publicPath: webpackConfig.output.publicPath
}));
```
2. Add `webpack-hot-middleware` attached to the same compiler instance
```js
app.use(require("webpack-hot-middleware")(compiler));
```
And you're all set!
## Changelog
### 2.0.0
**Breaking Change**
As of version 2.0.0, all client functionality has been rolled into this module. This means that you should remove any reference to `webpack/hot/dev-server` or `webpack/hot/only-dev-server` from your webpack config. Instead, use the `reload` config option to control this behaviour.
This was done to allow full control over the client receiving updates, which is now able to output full module names in the console when applying changes.
## Documentation
More to come soon, you'll have to mostly rely on the example for now.
### Config
#### Client
Configuration options can be passed to the client by adding querystring parameters to the path in the webpack config.
```js
'webpack-hot-middleware/client?path=/__what&timeout=2000&overlay=false'
```
* **path** - The path which the middleware is serving the event stream on
* **name** - Bundle name, specifically for multi-compiler mode
* **timeout** - The time to wait after a disconnection before attempting to reconnect
* **overlay** - Set to `false` to disable the DOM-based client-side overlay.
* **reload** - Set to `true` to auto-reload the page when webpack gets stuck.
* **noInfo** - Set to `true` to disable informational console logging.
* **quiet** - Set to `true` to disable all console logging.
* **dynamicPublicPath** - Set to `true` to use webpack `publicPath` as prefix of `path`. (We can set `__webpack_public_path__` dynamically at runtime in the entry point, see note of [output.publicPath](https://webpack.js.org/configuration/output/#output-publicpath))
* **autoConnect** - Set to `false` to use to prevent a connection being automatically opened from the client to the webpack back-end - ideal if you need to modify the options using the `setOptionsAndConnect` function
* **ansiColors** - An object to customize the client overlay colors as mentioned in the [ansi-html](https://github.com/Tjatse/ansi-html/blob/99ec49e431c70af6275b3c4e00c7be34be51753c/README.md#set-colors) package.
* **overlayStyles** - An object to let you override or add new inline styles to the client overlay div.
* **overlayWarnings** - Set to `true` to enable client overlay on warnings in addition to errors.
> Note:
> Since the `ansiColors` and `overlayStyles` options are passed via query string, you'll need to uri encode your stringified options like below:
```js
var ansiColors = {
red: '00FF00' // note the lack of "#"
};
var overlayStyles = {
color: '#FF0000' // note the inclusion of "#" (these options would be the equivalent of div.style[option] = value)
};
var hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true&ansiColors=' + encodeURIComponent(JSON.stringify(ansiColors)) + '&overlayStyles=' + encodeURIComponent(JSON.stringify(overlayStyles));
```
#### Middleware
Configuration options can be passed to the middleware by passing a second argument.
```js
app.use(require("webpack-hot-middleware")(compiler, {
log: false,
path: "/__what",
heartbeat: 2000
}));
```
* **log** - A function used to log lines, pass `false` to disable. Defaults to `console.log`
* **path** - The path which the middleware will serve the event stream on, must match the client setting
* **heartbeat** - How often to send heartbeat updates to the client to keep the connection alive. Should be less than the client's `timeout` setting - usually set to half its value.
## How it Works
The middleware installs itself as a webpack plugin, and listens for compiler events.
Each connected client gets a [Server Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/) connection, the server will publish notifications to connected clients on compiler events.
When the client receives a message, it will check to see if the local code is up to date. If it isn't up to date, it will trigger webpack hot module reloading.
### Multi-compiler mode
If you're using multi-compiler mode (exporting an array of config in `webpack.config.js`), set `name` parameters to make sure bundles don't process each other's updates. For example:
```
// webpack.config.js
module.exports = [
{
name: 'mobile',
entry: {
vendor: 'vendor.js',
main: ['webpack-hot-middleware/client?name=mobile', 'mobile.js']
}
},
{
name: 'desktop',
entry: {
vendor: 'vendor.js',
main: ['webpack-hot-middleware/client?name=desktop', 'desktop.js']
}
}
]
```
## Other Frameworks
### Hapi
Use the [hapi-webpack-plugin](https://www.npmjs.com/package/hapi-webpack-plugin).
### Koa
[koa-webpack-middleware](https://www.npmjs.com/package/koa-webpack-middleware)
wraps this module for use with Koa 1.x
[koa-webpack](https://www.npmjs.com/package/koa-webpack)
can be used for Koa 2.x
## Troubleshooting
### Use on browsers without EventSource
If you want to use this module with browsers that don't support eventsource, you'll need to use a [polyfill](https://libraries.io/search?platforms=NPM&q=eventsource+polyfill). See [issue #11](https://github.com/webpack-contrib/webpack-hot-middleware/issues/11)
### Not receiving updates in client when using Gzip
This is because gzip generally buffers the response, but the Server Sent Events event-stream expects to be able to send data to the client immediately. You should make sure gzipping isn't being applied to the event-stream. See [issue #10](https://github.com/webpack-contrib/webpack-hot-middleware/issues/10).
### Use with auto-restarting servers
This module expects to remain running while you make changes to your webpack bundle, if you use a process manager like nodemon then you will likely see very slow changes on the client side. If you want to reload the server component, either use a separate process, or find a way to reload your server routes without restarting the whole process. See https://github.com/glenjamin/ultimate-hot-reloading-example for an example of one way to do this.
### Use with multiple entry points in webpack
If you want to use [multiple entry points in your webpack config](https://webpack.js.org/concepts/output/#multiple-entry-points) you need to include the hot middleware client in each entry point. This ensures that each entry point file knows how to handle hot updates. See the [examples folder README](example/README.md) for an example.
```js
entry: {
vendor: ['jquery', 'webpack-hot-middleware/client'],
index: ['./src/index', 'webpack-hot-middleware/client']
}
```
## License
See [LICENSE file](LICENSE).

99
node_modules/webpack-hot-middleware/client-overlay.js generated vendored Normal file
View File

@ -0,0 +1,99 @@
/*eslint-env browser*/
var clientOverlay = document.createElement('div');
clientOverlay.id = 'webpack-hot-middleware-clientOverlay';
var styles = {
background: 'rgba(0,0,0,0.85)',
color: '#e8e8e8',
lineHeight: '1.6',
whiteSpace: 'pre',
fontFamily: 'Menlo, Consolas, monospace',
fontSize: '13px',
position: 'fixed',
zIndex: 9999,
padding: '10px',
left: 0,
right: 0,
top: 0,
bottom: 0,
overflow: 'auto',
dir: 'ltr',
textAlign: 'left',
};
var ansiHTML = require('ansi-html');
var colors = {
reset: ['transparent', 'transparent'],
black: '181818',
red: 'ff3348',
green: '3fff4f',
yellow: 'ffd30e',
blue: '169be0',
magenta: 'f840b7',
cyan: '0ad8e9',
lightgrey: 'ebe7e3',
darkgrey: '6d7891',
};
var Entities = require('html-entities').AllHtmlEntities;
var entities = new Entities();
function showProblems(type, lines) {
clientOverlay.innerHTML = '';
lines.forEach(function(msg) {
msg = ansiHTML(entities.encode(msg));
var div = document.createElement('div');
div.style.marginBottom = '26px';
div.innerHTML = problemType(type) + ' in ' + msg;
clientOverlay.appendChild(div);
});
if (document.body) {
document.body.appendChild(clientOverlay);
}
}
function clear() {
if (document.body && clientOverlay.parentNode) {
document.body.removeChild(clientOverlay);
}
}
function problemType(type) {
var problemColors = {
errors: colors.red,
warnings: colors.yellow,
};
var color = problemColors[type] || colors.red;
return (
'<span style="background-color:#' +
color +
'; color:#000000; padding:3px 6px; border-radius: 4px;">' +
type.slice(0, -1).toUpperCase() +
'</span>'
);
}
module.exports = function(options) {
for (var color in options.ansiColors) {
if (color in colors) {
colors[color] = options.ansiColors[color];
}
ansiHTML.setColors(colors);
}
for (var style in options.overlayStyles) {
styles[style] = options.overlayStyles[style];
}
for (var key in styles) {
clientOverlay.style[key] = styles[key];
}
return {
showProblems: showProblems,
clear: clear,
};
};
module.exports.clear = clear;
module.exports.showProblems = showProblems;

306
node_modules/webpack-hot-middleware/client.js generated vendored Normal file
View File

@ -0,0 +1,306 @@
/*eslint-env browser*/
/*global __resourceQuery __webpack_public_path__*/
var options = {
path: '/__webpack_hmr',
timeout: 20 * 1000,
overlay: true,
reload: false,
log: true,
warn: true,
name: '',
autoConnect: true,
overlayStyles: {},
overlayWarnings: false,
ansiColors: {},
};
if (__resourceQuery) {
var querystring = require('querystring');
var overrides = querystring.parse(__resourceQuery.slice(1));
setOverrides(overrides);
}
if (typeof window === 'undefined') {
// do nothing
} else if (typeof window.EventSource === 'undefined') {
console.warn(
"webpack-hot-middleware's client requires EventSource to work. " +
'You should include a polyfill if you want to support this browser: ' +
'https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools'
);
} else {
if (options.autoConnect) {
connect();
}
}
/* istanbul ignore next */
function setOptionsAndConnect(overrides) {
setOverrides(overrides);
connect();
}
function setOverrides(overrides) {
if (overrides.autoConnect)
options.autoConnect = overrides.autoConnect == 'true';
if (overrides.path) options.path = overrides.path;
if (overrides.timeout) options.timeout = overrides.timeout;
if (overrides.overlay) options.overlay = overrides.overlay !== 'false';
if (overrides.reload) options.reload = overrides.reload !== 'false';
if (overrides.noInfo && overrides.noInfo !== 'false') {
options.log = false;
}
if (overrides.name) {
options.name = overrides.name;
}
if (overrides.quiet && overrides.quiet !== 'false') {
options.log = false;
options.warn = false;
}
if (overrides.dynamicPublicPath) {
options.path = __webpack_public_path__ + options.path;
}
if (overrides.ansiColors)
options.ansiColors = JSON.parse(overrides.ansiColors);
if (overrides.overlayStyles)
options.overlayStyles = JSON.parse(overrides.overlayStyles);
if (overrides.overlayWarnings) {
options.overlayWarnings = overrides.overlayWarnings == 'true';
}
}
function EventSourceWrapper() {
var source;
var lastActivity = new Date();
var listeners = [];
init();
var timer = setInterval(function() {
if (new Date() - lastActivity > options.timeout) {
handleDisconnect();
}
}, options.timeout / 2);
function init() {
source = new window.EventSource(options.path);
source.onopen = handleOnline;
source.onerror = handleDisconnect;
source.onmessage = handleMessage;
}
function handleOnline() {
if (options.log) console.log('[HMR] connected');
lastActivity = new Date();
}
function handleMessage(event) {
lastActivity = new Date();
for (var i = 0; i < listeners.length; i++) {
listeners[i](event);
}
}
function handleDisconnect() {
clearInterval(timer);
source.close();
setTimeout(init, options.timeout);
}
return {
addMessageListener: function(fn) {
listeners.push(fn);
},
};
}
function getEventSourceWrapper() {
if (!window.__whmEventSourceWrapper) {
window.__whmEventSourceWrapper = {};
}
if (!window.__whmEventSourceWrapper[options.path]) {
// cache the wrapper for other entries loaded on
// the same page with the same options.path
window.__whmEventSourceWrapper[options.path] = EventSourceWrapper();
}
return window.__whmEventSourceWrapper[options.path];
}
function connect() {
getEventSourceWrapper().addMessageListener(handleMessage);
function handleMessage(event) {
if (event.data == '\uD83D\uDC93') {
return;
}
try {
processMessage(JSON.parse(event.data));
} catch (ex) {
if (options.warn) {
console.warn('Invalid HMR message: ' + event.data + '\n' + ex);
}
}
}
}
// the reporter needs to be a singleton on the page
// in case the client is being used by multiple bundles
// we only want to report once.
// all the errors will go to all clients
var singletonKey = '__webpack_hot_middleware_reporter__';
var reporter;
if (typeof window !== 'undefined') {
if (!window[singletonKey]) {
window[singletonKey] = createReporter();
}
reporter = window[singletonKey];
}
function createReporter() {
var strip = require('strip-ansi');
var overlay;
if (typeof document !== 'undefined' && options.overlay) {
overlay = require('./client-overlay')({
ansiColors: options.ansiColors,
overlayStyles: options.overlayStyles,
});
}
var styles = {
errors: 'color: #ff0000;',
warnings: 'color: #999933;',
};
var previousProblems = null;
function log(type, obj) {
var newProblems = obj[type]
.map(function(msg) {
return strip(msg);
})
.join('\n');
if (previousProblems == newProblems) {
return;
} else {
previousProblems = newProblems;
}
var style = styles[type];
var name = obj.name ? "'" + obj.name + "' " : '';
var title = '[HMR] bundle ' + name + 'has ' + obj[type].length + ' ' + type;
// NOTE: console.warn or console.error will print the stack trace
// which isn't helpful here, so using console.log to escape it.
if (console.group && console.groupEnd) {
console.group('%c' + title, style);
console.log('%c' + newProblems, style);
console.groupEnd();
} else {
console.log(
'%c' + title + '\n\t%c' + newProblems.replace(/\n/g, '\n\t'),
style + 'font-weight: bold;',
style + 'font-weight: normal;'
);
}
}
return {
cleanProblemsCache: function() {
previousProblems = null;
},
problems: function(type, obj) {
if (options.warn) {
log(type, obj);
}
if (overlay) {
if (options.overlayWarnings || type === 'errors') {
overlay.showProblems(type, obj[type]);
return false;
}
overlay.clear();
}
return true;
},
success: function() {
if (overlay) overlay.clear();
},
useCustomOverlay: function(customOverlay) {
overlay = customOverlay;
},
};
}
var processUpdate = require('./process-update');
var customHandler;
var subscribeAllHandler;
function processMessage(obj) {
switch (obj.action) {
case 'building':
if (options.log) {
console.log(
'[HMR] bundle ' +
(obj.name ? "'" + obj.name + "' " : '') +
'rebuilding'
);
}
break;
case 'built':
if (options.log) {
console.log(
'[HMR] bundle ' +
(obj.name ? "'" + obj.name + "' " : '') +
'rebuilt in ' +
obj.time +
'ms'
);
}
// fall through
case 'sync':
if (obj.name && options.name && obj.name !== options.name) {
return;
}
var applyUpdate = true;
if (obj.errors.length > 0) {
if (reporter) reporter.problems('errors', obj);
applyUpdate = false;
} else if (obj.warnings.length > 0) {
if (reporter) {
var overlayShown = reporter.problems('warnings', obj);
applyUpdate = overlayShown;
}
} else {
if (reporter) {
reporter.cleanProblemsCache();
reporter.success();
}
}
if (applyUpdate) {
processUpdate(obj.hash, obj.modules, options);
}
break;
default:
if (customHandler) {
customHandler(obj);
}
}
if (subscribeAllHandler) {
subscribeAllHandler(obj);
}
}
if (module) {
module.exports = {
subscribeAll: function subscribeAll(handler) {
subscribeAllHandler = handler;
},
subscribe: function subscribe(handler) {
customHandler = handler;
},
useCustomOverlay: function useCustomOverlay(customOverlay) {
if (reporter) reporter.useCustomOverlay(customOverlay);
},
setOptionsAndConnect: setOptionsAndConnect,
};
}

9
node_modules/webpack-hot-middleware/helpers.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
var parse = require('url').parse;
exports.pathMatch = function(url, path) {
try {
return parse(url).pathname === path;
} catch (e) {
return false;
}
};

175
node_modules/webpack-hot-middleware/middleware.js generated vendored Normal file
View File

@ -0,0 +1,175 @@
module.exports = webpackHotMiddleware;
var helpers = require('./helpers');
var pathMatch = helpers.pathMatch;
function webpackHotMiddleware(compiler, opts) {
opts = opts || {};
opts.log =
typeof opts.log == 'undefined' ? console.log.bind(console) : opts.log;
opts.path = opts.path || '/__webpack_hmr';
opts.heartbeat = opts.heartbeat || 10 * 1000;
var eventStream = createEventStream(opts.heartbeat);
var latestStats = null;
var closed = false;
if (compiler.hooks) {
compiler.hooks.invalid.tap('webpack-hot-middleware', onInvalid);
compiler.hooks.done.tap('webpack-hot-middleware', onDone);
} else {
compiler.plugin('invalid', onInvalid);
compiler.plugin('done', onDone);
}
function onInvalid() {
if (closed) return;
latestStats = null;
if (opts.log) opts.log('webpack building...');
eventStream.publish({ action: 'building' });
}
function onDone(statsResult) {
if (closed) return;
// Keep hold of latest stats so they can be propagated to new clients
latestStats = statsResult;
publishStats('built', latestStats, eventStream, opts.log);
}
var middleware = function(req, res, next) {
if (closed) return next();
if (!pathMatch(req.url, opts.path)) return next();
eventStream.handler(req, res);
if (latestStats) {
// Explicitly not passing in `log` fn as we don't want to log again on
// the server
publishStats('sync', latestStats, eventStream);
}
};
middleware.publish = function(payload) {
if (closed) return;
eventStream.publish(payload);
};
middleware.close = function() {
if (closed) return;
// Can't remove compiler plugins, so we just set a flag and noop if closed
// https://github.com/webpack/tapable/issues/32#issuecomment-350644466
closed = true;
eventStream.close();
eventStream = null;
};
return middleware;
}
function createEventStream(heartbeat) {
var clientId = 0;
var clients = {};
function everyClient(fn) {
Object.keys(clients).forEach(function(id) {
fn(clients[id]);
});
}
var interval = setInterval(function heartbeatTick() {
everyClient(function(client) {
client.write('data: \uD83D\uDC93\n\n');
});
}, heartbeat).unref();
return {
close: function() {
clearInterval(interval);
everyClient(function(client) {
if (!client.finished) client.end();
});
clients = {};
},
handler: function(req, res) {
var headers = {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'text/event-stream;charset=utf-8',
'Cache-Control': 'no-cache, no-transform',
// While behind nginx, event stream should not be buffered:
// http://nginx.org/docs/http/ngx_http_proxy_module.html#proxy_buffering
'X-Accel-Buffering': 'no',
};
var isHttp1 = !(parseInt(req.httpVersion) >= 2);
if (isHttp1) {
req.socket.setKeepAlive(true);
Object.assign(headers, {
Connection: 'keep-alive',
});
}
res.writeHead(200, headers);
res.write('\n');
var id = clientId++;
clients[id] = res;
req.on('close', function() {
if (!res.finished) res.end();
delete clients[id];
});
},
publish: function(payload) {
everyClient(function(client) {
client.write('data: ' + JSON.stringify(payload) + '\n\n');
});
},
};
}
function publishStats(action, statsResult, eventStream, log) {
var stats = statsResult.toJson({
all: false,
cached: true,
children: true,
modules: true,
timings: true,
hash: true,
});
// For multi-compiler, stats will be an object with a 'children' array of stats
var bundles = extractBundles(stats);
bundles.forEach(function(stats) {
var name = stats.name || '';
// Fallback to compilation name in case of 1 bundle (if it exists)
if (bundles.length === 1 && !name && statsResult.compilation) {
name = statsResult.compilation.name || '';
}
if (log) {
log(
'webpack built ' +
(name ? name + ' ' : '') +
stats.hash +
' in ' +
stats.time +
'ms'
);
}
eventStream.publish({
name: name,
action: action,
time: stats.time,
hash: stats.hash,
warnings: stats.warnings || [],
errors: stats.errors || [],
modules: buildModuleMap(stats.modules),
});
});
}
function extractBundles(stats) {
// Stats has modules, single bundle
if (stats.modules) return [stats];
// Stats has children, multiple bundles
if (stats.children && stats.children.length) return stats.children;
// Not sure, assume single
return [stats];
}
function buildModuleMap(modules) {
var map = {};
modules.forEach(function(module) {
map[module.id] = module.name;
});
return map;
}

86
node_modules/webpack-hot-middleware/package.json generated vendored Normal file
View File

@ -0,0 +1,86 @@
{
"_from": "webpack-hot-middleware@^2.21.0",
"_id": "webpack-hot-middleware@2.25.0",
"_inBundle": false,
"_integrity": "sha512-xs5dPOrGPCzuRXNi8F6rwhawWvQQkeli5Ro48PRuQh8pYPCPmNnltP9itiUPT4xI8oW+y0m59lyyeQk54s5VgA==",
"_location": "/webpack-hot-middleware",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "webpack-hot-middleware@^2.21.0",
"name": "webpack-hot-middleware",
"escapedName": "webpack-hot-middleware",
"rawSpec": "^2.21.0",
"saveSpec": null,
"fetchSpec": "^2.21.0"
},
"_requiredBy": [
"/gatsby"
],
"_resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.25.0.tgz",
"_shasum": "4528a0a63ec37f8f8ef565cf9e534d57d09fe706",
"_spec": "webpack-hot-middleware@^2.21.0",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby",
"author": {
"name": "Glen Mailer",
"email": "glen@stainlessed.co.uk"
},
"bugs": {
"url": "https://github.com/webpack-contrib/webpack-hot-middleware/issues"
},
"bundleDependencies": false,
"dependencies": {
"ansi-html": "0.0.7",
"html-entities": "^1.2.0",
"querystring": "^0.2.0",
"strip-ansi": "^3.0.0"
},
"deprecated": false,
"description": "Webpack hot reloading you can attach to your own server",
"devDependencies": {
"eslint": "^5.14.1",
"eslint-plugin-prettier": "^3.0.1",
"express": "^4.13.3",
"istanbul": "^0.4.2",
"mocha": "^5.2.0",
"prettier": "^1.16.4",
"sinon": "^1.12.2",
"supertest": "^3.1.0",
"webpack": "^4.20.2",
"webpack-dev-middleware": "^3.4.0"
},
"homepage": "https://github.com/webpack-contrib/webpack-hot-middleware#readme",
"keywords": [
"webpack",
"hmr",
"hot",
"module",
"reloading",
"hot-reloading",
"middleware",
"express"
],
"license": "MIT",
"main": "middleware.js",
"name": "webpack-hot-middleware",
"prettier": {
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
},
"repository": {
"type": "git",
"url": "git+https://github.com/webpack-contrib/webpack-hot-middleware.git"
},
"scripts": {
"ci:coverage": "npm run test:coverage",
"ci:lint": "npm run lint && npm run security",
"ci:test": "npm run test",
"lint": "eslint . --max-warnings 0",
"security": "npm audit",
"test": "mocha",
"test:coverage": "istanbul cover _mocha --"
},
"version": "2.25.0"
}

157
node_modules/webpack-hot-middleware/process-update.js generated vendored Normal file
View File

@ -0,0 +1,157 @@
/**
* Based heavily on https://github.com/webpack/webpack/blob/
* c0afdf9c6abc1dd70707c594e473802a566f7b6e/hot/only-dev-server.js
* Original copyright Tobias Koppers @sokra (MIT license)
*/
/* global window __webpack_hash__ */
if (!module.hot) {
throw new Error('[HMR] Hot Module Replacement is disabled.');
}
var hmrDocsUrl = 'https://webpack.js.org/concepts/hot-module-replacement/'; // eslint-disable-line max-len
var lastHash;
var failureStatuses = { abort: 1, fail: 1 };
var applyOptions = {
ignoreUnaccepted: true,
ignoreDeclined: true,
ignoreErrored: true,
onUnaccepted: function(data) {
console.warn(
'Ignored an update to unaccepted module ' + data.chain.join(' -> ')
);
},
onDeclined: function(data) {
console.warn(
'Ignored an update to declined module ' + data.chain.join(' -> ')
);
},
onErrored: function(data) {
console.error(data.error);
console.warn(
'Ignored an error while updating module ' +
data.moduleId +
' (' +
data.type +
')'
);
},
};
function upToDate(hash) {
if (hash) lastHash = hash;
return lastHash == __webpack_hash__;
}
module.exports = function(hash, moduleMap, options) {
var reload = options.reload;
if (!upToDate(hash) && module.hot.status() == 'idle') {
if (options.log) console.log('[HMR] Checking for updates on the server...');
check();
}
function check() {
var cb = function(err, updatedModules) {
if (err) return handleError(err);
if (!updatedModules) {
if (options.warn) {
console.warn('[HMR] Cannot find update (Full reload needed)');
console.warn('[HMR] (Probably because of restarting the server)');
}
performReload();
return null;
}
var applyCallback = function(applyErr, renewedModules) {
if (applyErr) return handleError(applyErr);
if (!upToDate()) check();
logUpdates(updatedModules, renewedModules);
};
var applyResult = module.hot.apply(applyOptions, applyCallback);
// webpack 2 promise
if (applyResult && applyResult.then) {
// HotModuleReplacement.runtime.js refers to the result as `outdatedModules`
applyResult.then(function(outdatedModules) {
applyCallback(null, outdatedModules);
});
applyResult.catch(applyCallback);
}
};
var result = module.hot.check(false, cb);
// webpack 2 promise
if (result && result.then) {
result.then(function(updatedModules) {
cb(null, updatedModules);
});
result.catch(cb);
}
}
function logUpdates(updatedModules, renewedModules) {
var unacceptedModules = updatedModules.filter(function(moduleId) {
return renewedModules && renewedModules.indexOf(moduleId) < 0;
});
if (unacceptedModules.length > 0) {
if (options.warn) {
console.warn(
"[HMR] The following modules couldn't be hot updated: " +
'(Full reload needed)\n' +
'This is usually because the modules which have changed ' +
'(and their parents) do not know how to hot reload themselves. ' +
'See ' +
hmrDocsUrl +
' for more details.'
);
unacceptedModules.forEach(function(moduleId) {
console.warn('[HMR] - ' + (moduleMap[moduleId] || moduleId));
});
}
performReload();
return;
}
if (options.log) {
if (!renewedModules || renewedModules.length === 0) {
console.log('[HMR] Nothing hot updated.');
} else {
console.log('[HMR] Updated modules:');
renewedModules.forEach(function(moduleId) {
console.log('[HMR] - ' + (moduleMap[moduleId] || moduleId));
});
}
if (upToDate()) {
console.log('[HMR] App is up to date.');
}
}
}
function handleError(err) {
if (module.hot.status() in failureStatuses) {
if (options.warn) {
console.warn('[HMR] Cannot check for update (Full reload needed)');
console.warn('[HMR] ' + (err.stack || err.message));
}
performReload();
return;
}
if (options.warn) {
console.warn('[HMR] Update check failed: ' + (err.stack || err.message));
}
}
function performReload() {
if (reload) {
if (options.warn) console.warn('[HMR] Reloading page');
window.location.reload();
}
}
};