@umijs/bundler-webpack 4.0.7 → 4.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist → client}/client/client.d.ts +0 -0
- package/client/client/client.js +295 -194
- package/client/constants.d.ts +15 -0
- package/client/constants.js +28 -19
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +68 -86
- package/dist/build.d.ts +1 -1
- package/dist/build.js +105 -68
- package/dist/cli.js +77 -69
- package/dist/config/_sampleFeature.js +33 -9
- package/dist/config/assetRules.js +45 -36
- package/dist/config/bundleAnalyzerPlugin.js +39 -17
- package/dist/config/compressPlugin.js +114 -95
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +204 -215
- package/dist/config/copyPlugin.js +59 -40
- package/dist/config/cssRules.js +136 -131
- package/dist/config/definePlugin.js +71 -35
- package/dist/config/detectDeadCode.js +120 -108
- package/dist/config/detectDeadCodePlugin.js +78 -63
- package/dist/config/fastRefreshPlugin.js +39 -20
- package/dist/config/forkTSCheckerPlugin.js +38 -19
- package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
- package/dist/config/ignorePlugin.js +38 -14
- package/dist/config/javaScriptRules.js +147 -173
- package/dist/config/manifestPlugin.js +51 -15
- package/dist/config/miniCSSExtractPlugin.js +42 -22
- package/dist/config/nodePolyfill.js +65 -26
- package/dist/config/nodePrefixPlugin.js +36 -12
- package/dist/config/progressPlugin.js +37 -13
- package/dist/config/purgecssWebpackPlugin.js +41 -19
- package/dist/config/speedMeasureWebpackPlugin.js +41 -20
- package/dist/config/ssrPlugin.js +83 -63
- package/dist/config/svgRules.js +74 -46
- package/dist/constants.js +57 -22
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +174 -134
- package/dist/index.js +22 -20
- package/dist/loader/svgr.js +73 -54
- package/dist/loader/swc.js +110 -69
- package/dist/parcelCSS.js +31 -27
- package/dist/plugins/ProgressPlugin.js +66 -43
- package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
- package/dist/plugins/_SamplePlugin.js +39 -14
- package/dist/requireHook.js +37 -27
- package/dist/schema.js +123 -96
- package/dist/server/server.d.ts +0 -1
- package/dist/server/server.js +214 -184
- package/dist/server/ws.d.ts +0 -2
- package/dist/server/ws.js +63 -38
- package/dist/swcPlugins/autoCSSModules.js +50 -31
- package/dist/swcPlugins/changeImportFromString.js +31 -9
- package/dist/swcPlugins/lockCoreJS.js +44 -20
- package/dist/types.d.ts +2 -1
- package/dist/types.js +61 -30
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +63 -39
- package/dist/utils/formatWebpackMessages.js +93 -91
- package/dist/utils/getEsBuildTarget.d.ts +3 -1
- package/dist/utils/getEsBuildTarget.js +39 -11
- package/package.json +12 -16
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
- package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
- package/compiled/react-refresh/LICENSE +0 -21
- package/compiled/react-refresh/index.js +0 -21
- package/compiled/react-refresh/package.json +0 -1
- package/dist/client/client.js +0 -245
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"fork-ts-checker-webpack-plugin","author":"Piotr Oleś <piotrek.oles@gmail.com>","license":"MIT","types":"lib/index.d.ts"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";var e={653:function(e,t){
|
|
2
|
-
/**
|
|
3
|
-
* @license React
|
|
4
|
-
* react-refresh-runtime.development.js
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the MIT license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/
|
|
11
|
-
if(process.env.NODE_ENV!=="production"){(function(){"use strict";var e=Symbol.for("react.forward_ref");var r=Symbol.for("react.memo");var n=typeof WeakMap==="function"?WeakMap:Map;var o=new Map;var i=new n;var a=new n;var u=new n;var f=[];var s=new Map;var c=new Map;var l=new Set;var d=new Set;var p=typeof WeakMap==="function"?new WeakMap:null;var y=false;function computeFullKey(e){if(e.fullKey!==null){return e.fullKey}var t=e.ownKey;var r;try{r=e.getCustomHooks()}catch(r){e.forceReset=true;e.fullKey=t;return t}for(var n=0;n<r.length;n++){var o=r[n];if(typeof o!=="function"){e.forceReset=true;e.fullKey=t;return t}var i=a.get(o);if(i===undefined){continue}var u=computeFullKey(i);if(i.forceReset){e.forceReset=true}t+="\n---\n"+u}e.fullKey=t;return t}function haveEqualSignatures(e,t){var r=a.get(e);var n=a.get(t);if(r===undefined&&n===undefined){return true}if(r===undefined||n===undefined){return false}if(computeFullKey(r)!==computeFullKey(n)){return false}if(n.forceReset){return false}return true}function isReactClass(e){return e.prototype&&e.prototype.isReactComponent}function canPreserveStateBetween(e,t){if(isReactClass(e)||isReactClass(t)){return false}if(haveEqualSignatures(e,t)){return true}return false}function resolveFamily(e){return u.get(e)}function cloneMap(e){var t=new Map;e.forEach((function(e,r){t.set(r,e)}));return t}function cloneSet(e){var t=new Set;e.forEach((function(e){t.add(e)}));return t}function getProperty(e,t){try{return e[t]}catch(e){return undefined}}function performReactRefresh(){if(f.length===0){return null}if(y){return null}y=true;try{var e=new Set;var t=new Set;var r=f;f=[];r.forEach((function(r){var n=r[0],o=r[1];var i=n.current;u.set(i,n);u.set(o,n);n.current=o;if(canPreserveStateBetween(i,o)){t.add(n)}else{e.add(n)}}));var n={updatedFamilies:t,staleFamilies:e};s.forEach((function(e){e.setRefreshHandler(resolveFamily)}));var o=false;var i=null;var a=cloneSet(d);var h=cloneSet(l);var v=cloneMap(c);a.forEach((function(e){var t=v.get(e);if(t===undefined){throw new Error("Could not find helpers for a root. This is a bug in React Refresh.")}if(!d.has(e)){}if(p===null){return}if(!p.has(e)){return}var r=p.get(e);try{t.scheduleRoot(e,r)}catch(e){if(!o){o=true;i=e}}}));h.forEach((function(e){var t=v.get(e);if(t===undefined){throw new Error("Could not find helpers for a root. This is a bug in React Refresh.")}if(!l.has(e)){}try{t.scheduleRefresh(e,n)}catch(e){if(!o){o=true;i=e}}}));if(o){throw i}return n}finally{y=false}}function register(t,n){{if(t===null){return}if(typeof t!=="function"&&typeof t!=="object"){return}if(i.has(t)){return}var a=o.get(n);if(a===undefined){a={current:t};o.set(n,a)}else{f.push([a,t])}i.set(t,a);if(typeof t==="object"&&t!==null){switch(getProperty(t,"$$typeof")){case e:register(t.render,n+"$render");break;case r:register(t.type,n+"$type");break}}}}function setSignature(t,n){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var i=arguments.length>3?arguments[3]:undefined;{if(!a.has(t)){a.set(t,{forceReset:o,ownKey:n,fullKey:null,getCustomHooks:i||function(){return[]}})}if(typeof t==="object"&&t!==null){switch(getProperty(t,"$$typeof")){case e:setSignature(t.render,n,o,i);break;case r:setSignature(t.type,n,o,i);break}}}}function collectCustomHooksForSignature(e){{var t=a.get(e);if(t!==undefined){computeFullKey(t)}}}function getFamilyByID(e){{return o.get(e)}}function getFamilyByType(e){{return i.get(e)}}function findAffectedHostInstances(e){{var t=new Set;l.forEach((function(r){var n=c.get(r);if(n===undefined){throw new Error("Could not find helpers for a root. This is a bug in React Refresh.")}var o=n.findHostInstancesForRefresh(r,e);o.forEach((function(e){t.add(e)}))}));return t}}function injectIntoGlobalHook(e){{var t=e.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t===undefined){var r=0;e.__REACT_DEVTOOLS_GLOBAL_HOOK__=t={renderers:new Map,supportsFiber:true,inject:function(e){return r++},onScheduleFiberRoot:function(e,t,r){},onCommitFiberRoot:function(e,t,r,n){},onCommitFiberUnmount:function(){}}}if(t.isDisabled){console["warn"]("Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). "+"Fast Refresh is not compatible with this shim and will be disabled.");return}var n=t.inject;t.inject=function(e){var t=n.apply(this,arguments);if(typeof e.scheduleRefresh==="function"&&typeof e.setRefreshHandler==="function"){s.set(t,e)}return t};t.renderers.forEach((function(e,t){if(typeof e.scheduleRefresh==="function"&&typeof e.setRefreshHandler==="function"){s.set(t,e)}}));var o=t.onCommitFiberRoot;var i=t.onScheduleFiberRoot||function(){};t.onScheduleFiberRoot=function(e,t,r){if(!y){d.delete(t);if(p!==null){p.set(t,r)}}return i.apply(this,arguments)};t.onCommitFiberRoot=function(e,t,r,n){var i=s.get(e);if(i!==undefined){c.set(t,i);var a=t.current;var u=a.alternate;if(u!==null){var f=u.memoizedState!=null&&u.memoizedState.element!=null&&l.has(t);var p=a.memoizedState!=null&&a.memoizedState.element!=null;if(!f&&p){l.add(t);d.delete(t)}else if(f&&p);else if(f&&!p){l.delete(t);if(n){d.add(t)}else{c.delete(t)}}else if(!f&&!p){if(n){d.add(t)}}}else{l.add(t)}}return o.apply(this,arguments)}}}function hasUnrecoverableErrors(){return false}function _getMountedRootCount(){{return l.size}}function createSignatureFunctionForTransform(){{var e;var t;var r=false;return function(n,o,i,a){if(typeof o==="string"){if(!e){e=n;t=typeof a==="function"}if(n!=null&&(typeof n==="function"||typeof n==="object")){setSignature(n,o,i,a)}return n}else{if(!r&&t){r=true;collectCustomHooksForSignature(e)}}}}}function isLikelyComponentType(t){{switch(typeof t){case"function":{if(t.prototype!=null){if(t.prototype.isReactComponent){return true}var n=Object.getOwnPropertyNames(t.prototype);if(n.length>1||n[0]!=="constructor"){return false}if(t.prototype.__proto__!==Object.prototype){return false}}var o=t.name||t.displayName;return typeof o==="string"&&/^[A-Z]/.test(o)}case"object":{if(t!=null){switch(getProperty(t,"$$typeof")){case e:case r:return true;default:return false}}return false}default:{return false}}}}t._getMountedRootCount=_getMountedRootCount;t.collectCustomHooksForSignature=collectCustomHooksForSignature;t.createSignatureFunctionForTransform=createSignatureFunctionForTransform;t.findAffectedHostInstances=findAffectedHostInstances;t.getFamilyByID=getFamilyByID;t.getFamilyByType=getFamilyByType;t.hasUnrecoverableErrors=hasUnrecoverableErrors;t.injectIntoGlobalHook=injectIntoGlobalHook;t.isLikelyComponentType=isLikelyComponentType;t.performReactRefresh=performReactRefresh;t.register=register;t.setSignature=setSignature})()}},665:function(){
|
|
12
|
-
/**
|
|
13
|
-
* @license React
|
|
14
|
-
* react-refresh-runtime.production.min.js
|
|
15
|
-
*
|
|
16
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/
|
|
21
|
-
throw Error("React Refresh runtime should not be included in the production bundle.")},999:function(e,t,r){if(process.env.NODE_ENV==="production"){e.exports=r(665)}else{e.exports=r(653)}}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var o=t[r]={exports:{}};var i=true;try{e[r](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[r]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(999);module.exports=r})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"react-refresh","license":"MIT"}
|
package/dist/client/client.js
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const strip_ansi_1 = __importDefault(require("@umijs/utils/compiled/strip-ansi"));
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
const ErrorOverlay = __importStar(require("react-error-overlay"));
|
|
32
|
-
const constants_1 = require("../constants");
|
|
33
|
-
const formatWebpackMessages_1 = require("../utils/formatWebpackMessages");
|
|
34
|
-
console.log('[webpack] connecting...');
|
|
35
|
-
function getHost() {
|
|
36
|
-
if (process.env.SOCKET_SERVER) {
|
|
37
|
-
return new URL(process.env.SOCKET_SERVER);
|
|
38
|
-
}
|
|
39
|
-
return location;
|
|
40
|
-
}
|
|
41
|
-
function getSocketUrl() {
|
|
42
|
-
let h = getHost();
|
|
43
|
-
const host = h.host;
|
|
44
|
-
const isHttps = h.protocol === 'https:';
|
|
45
|
-
return `${isHttps ? 'wss' : 'ws'}://${host}`;
|
|
46
|
-
}
|
|
47
|
-
function getPingUrl() {
|
|
48
|
-
const h = getHost();
|
|
49
|
-
return `${h.protocol}//${h.host}/__umi_ping`;
|
|
50
|
-
}
|
|
51
|
-
let pingTimer = null;
|
|
52
|
-
let isFirstCompilation = true;
|
|
53
|
-
let mostRecentCompilationHash = null;
|
|
54
|
-
let hasCompileErrors = false;
|
|
55
|
-
let hadRuntimeError = false;
|
|
56
|
-
const pingUrl = getPingUrl();
|
|
57
|
-
const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
|
|
58
|
-
socket.addEventListener('message', async ({ data }) => {
|
|
59
|
-
data = JSON.parse(data);
|
|
60
|
-
if (data.type === 'connected') {
|
|
61
|
-
console.log(`[webpack] connected.`);
|
|
62
|
-
// proxy(nginx, docker) hmr ws maybe caused timeout,
|
|
63
|
-
// so send ping package let ws keep alive.
|
|
64
|
-
pingTimer = setInterval(() => socket.send('ping'), 30000);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
handleMessage(data).catch(console.error);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
async function waitForSuccessfulPing(ms = 1000) {
|
|
71
|
-
// eslint-disable-next-line no-constant-condition
|
|
72
|
-
while (true) {
|
|
73
|
-
try {
|
|
74
|
-
await fetch(pingUrl);
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
socket.addEventListener('close', async () => {
|
|
83
|
-
if (pingTimer)
|
|
84
|
-
clearInterval(pingTimer);
|
|
85
|
-
console.info('[webpack] Dev server disconnected. Polling for restart...');
|
|
86
|
-
await waitForSuccessfulPing();
|
|
87
|
-
location.reload();
|
|
88
|
-
});
|
|
89
|
-
ErrorOverlay.startReportingRuntimeErrors({
|
|
90
|
-
onError: function () {
|
|
91
|
-
hadRuntimeError = true;
|
|
92
|
-
},
|
|
93
|
-
filename: '/static/js/bundle.js',
|
|
94
|
-
});
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
if (module.hot && typeof module.hot.dispose === 'function') {
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
module.hot.dispose(function () {
|
|
99
|
-
// TODO: why do we need this?
|
|
100
|
-
ErrorOverlay.stopReportingRuntimeErrors();
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
// There is a newer version of the code available.
|
|
104
|
-
function handleAvailableHash(hash) {
|
|
105
|
-
// Update last known compilation hash.
|
|
106
|
-
mostRecentCompilationHash = hash;
|
|
107
|
-
}
|
|
108
|
-
function handleSuccess() {
|
|
109
|
-
const isHotUpdate = !isFirstCompilation;
|
|
110
|
-
isFirstCompilation = false;
|
|
111
|
-
hasCompileErrors = false;
|
|
112
|
-
// Attempt to apply hot updates or reload.
|
|
113
|
-
if (isHotUpdate) {
|
|
114
|
-
tryApplyUpdates(function onHotUpdateSuccess() {
|
|
115
|
-
// Only dismiss it when we're sure it's a hot update.
|
|
116
|
-
// Otherwise it would flicker right before the reload.
|
|
117
|
-
tryDismissErrorOverlay();
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function handleWarnings(warnings) {
|
|
122
|
-
const isHotUpdate = !isFirstCompilation;
|
|
123
|
-
isFirstCompilation = false;
|
|
124
|
-
hasCompileErrors = false;
|
|
125
|
-
const formatted = (0, formatWebpackMessages_1.formatWebpackMessages)({
|
|
126
|
-
warnings,
|
|
127
|
-
errors: [],
|
|
128
|
-
});
|
|
129
|
-
// print warnings
|
|
130
|
-
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
|
131
|
-
for (let i = 0; i < formatted.warnings.length; i++) {
|
|
132
|
-
if (i === 5) {
|
|
133
|
-
console.warn('There were more warnings in other files.\n' +
|
|
134
|
-
'You can find a complete log in the terminal.');
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
console.warn((0, strip_ansi_1.default)(formatted.warnings[i]));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// Attempt to apply hot updates or reload.
|
|
141
|
-
if (isHotUpdate) {
|
|
142
|
-
tryApplyUpdates(function onSuccessfulHotUpdate() {
|
|
143
|
-
// Only dismiss it when we're sure it's a hot update.
|
|
144
|
-
// Otherwise it would flicker right before the reload.
|
|
145
|
-
tryDismissErrorOverlay();
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function handleErrors(errors) {
|
|
150
|
-
isFirstCompilation = false;
|
|
151
|
-
hasCompileErrors = true;
|
|
152
|
-
const formatted = (0, formatWebpackMessages_1.formatWebpackMessages)({
|
|
153
|
-
warnings: [],
|
|
154
|
-
errors,
|
|
155
|
-
});
|
|
156
|
-
// Only show the first error.
|
|
157
|
-
ErrorOverlay.reportBuildError(formatted.errors[0]);
|
|
158
|
-
// Also log them to the console.
|
|
159
|
-
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
160
|
-
for (let i = 0; i < formatted.errors.length; i++) {
|
|
161
|
-
console.error((0, strip_ansi_1.default)(formatted.errors[i]));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function tryDismissErrorOverlay() {
|
|
166
|
-
if (!hasCompileErrors) {
|
|
167
|
-
ErrorOverlay.dismissBuildError();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// Is there a newer version of this code available?
|
|
171
|
-
function isUpdateAvailable() {
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
return mostRecentCompilationHash !== __webpack_hash__;
|
|
174
|
-
}
|
|
175
|
-
function canApplyUpdates() {
|
|
176
|
-
// @ts-ignore
|
|
177
|
-
return module.hot.status() === 'idle';
|
|
178
|
-
}
|
|
179
|
-
function canAcceptErrors() {
|
|
180
|
-
// NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.
|
|
181
|
-
const hasReactRefresh = process.env.FAST_REFRESH;
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
const status = module.hot.status();
|
|
184
|
-
// React refresh can handle hot-reloading over errors.
|
|
185
|
-
// However, when hot-reload status is abort or fail,
|
|
186
|
-
// it indicates the current update cannot be applied safely,
|
|
187
|
-
// and thus we should bail out to a forced reload for consistency.
|
|
188
|
-
return hasReactRefresh && ['abort', 'fail'].indexOf(status) === -1;
|
|
189
|
-
}
|
|
190
|
-
function tryApplyUpdates(onHotUpdateSuccess) {
|
|
191
|
-
// @ts-ignore
|
|
192
|
-
if (!module.hot) {
|
|
193
|
-
window.location.reload();
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
function handleApplyUpdates(err, updatedModules) {
|
|
200
|
-
const haveErrors = err || hadRuntimeError;
|
|
201
|
-
// When there is no error but updatedModules is unavailable,
|
|
202
|
-
// it indicates a critical failure in hot-reloading,
|
|
203
|
-
// e.g. server is not ready to serve new bundle,
|
|
204
|
-
// and hence we need to do a forced reload.
|
|
205
|
-
const needsForcedReload = !err && !updatedModules;
|
|
206
|
-
if ((haveErrors && !canAcceptErrors()) || needsForcedReload) {
|
|
207
|
-
window.location.reload();
|
|
208
|
-
}
|
|
209
|
-
if (onHotUpdateSuccess)
|
|
210
|
-
onHotUpdateSuccess();
|
|
211
|
-
// While we were updating, there was a new update! Do it again.
|
|
212
|
-
if (isUpdateAvailable()) {
|
|
213
|
-
tryApplyUpdates();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// @ts-ignore
|
|
217
|
-
module.hot
|
|
218
|
-
.check(/* autoApply */ true)
|
|
219
|
-
.then((updatedModules) => {
|
|
220
|
-
handleApplyUpdates(null, updatedModules);
|
|
221
|
-
})
|
|
222
|
-
.catch((err) => {
|
|
223
|
-
handleApplyUpdates(err, null);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
async function handleMessage(payload) {
|
|
227
|
-
// console.log('[payload]', payload);
|
|
228
|
-
switch (payload.type) {
|
|
229
|
-
case constants_1.MESSAGE_TYPE.hash:
|
|
230
|
-
handleAvailableHash(payload.data);
|
|
231
|
-
break;
|
|
232
|
-
case constants_1.MESSAGE_TYPE.stillOk:
|
|
233
|
-
case constants_1.MESSAGE_TYPE.ok:
|
|
234
|
-
handleSuccess();
|
|
235
|
-
break;
|
|
236
|
-
case constants_1.MESSAGE_TYPE.errors:
|
|
237
|
-
handleErrors(payload.data);
|
|
238
|
-
break;
|
|
239
|
-
case constants_1.MESSAGE_TYPE.warnings:
|
|
240
|
-
handleWarnings(payload.data);
|
|
241
|
-
break;
|
|
242
|
-
default:
|
|
243
|
-
// Do nothing
|
|
244
|
-
}
|
|
245
|
-
}
|