@umijs/bundler-webpack 4.0.0-rc.9 → 4.0.0
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/client/client/client.js +65 -37
- package/client/constants.js +9 -0
- package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
- package/compiled/cssnano/index.js +6 -6
- package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
- package/compiled/{tapable → react-refresh}/LICENSE +6 -6
- package/compiled/react-refresh/index.js +9 -7
- package/compiled/react-refresh/package.json +1 -0
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +6 -1
- package/compiled/webpack/index.js +3978 -3167
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-dev-middleware/index.js +8 -7
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.js +49 -56
- package/dist/cli.js +6 -15
- package/dist/client/client.js +52 -50
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -55
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +89 -70
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +181 -179
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +114 -83
- package/dist/config/definePlugin.js +11 -19
- package/dist/config/detectDeadCodePlugin.js +16 -21
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.js +11 -22
- package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.d.ts +1 -0
- package/dist/config/javaScriptRules.js +152 -136
- package/dist/config/manifestPlugin.d.ts +1 -1
- package/dist/config/manifestPlugin.js +10 -18
- package/dist/config/miniCSSExtractPlugin.js +15 -23
- package/dist/config/nodePolyfill.js +14 -20
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.js +7 -18
- package/dist/config/purgecssWebpackPlugin.js +15 -26
- package/dist/config/speedMeasureWebpackPlugin.js +12 -23
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +66 -0
- package/dist/config/svgRules.js +44 -47
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +7 -1
- package/dist/dev.d.ts +4 -0
- package/dist/dev.js +113 -93
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/loader/svgr.js +4 -13
- package/dist/loader/swc.js +9 -14
- package/dist/plugins/ProgressPlugin.js +3 -3
- package/dist/plugins/RuntimePublicPathPlugin.js +4 -1
- package/dist/schema.js +21 -6
- package/dist/server/server.d.ts +3 -1
- package/dist/server/server.js +165 -159
- package/dist/server/ws.d.ts +7 -2
- package/dist/types.d.ts +3 -0
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +22 -20
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -63
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +0 -10
- package/dist/plugins/ParcelCSSMinifyPlugin.js +0 -75
package/client/client/client.js
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import stripAnsi from '@umijs/utils/compiled/strip-ansi';
|
|
2
11
|
// @ts-ignore
|
|
3
12
|
import * as ErrorOverlay from 'react-error-overlay';
|
|
4
13
|
import { MESSAGE_TYPE } from '../constants';
|
|
5
14
|
import { formatWebpackMessages } from '../utils/formatWebpackMessages';
|
|
6
15
|
console.log('[webpack] connecting...');
|
|
16
|
+
function getHost() {
|
|
17
|
+
if (process.env.SOCKET_SERVER) {
|
|
18
|
+
return new URL(process.env.SOCKET_SERVER);
|
|
19
|
+
}
|
|
20
|
+
return location;
|
|
21
|
+
}
|
|
22
|
+
function getSocketUrl() {
|
|
23
|
+
let h = getHost();
|
|
24
|
+
const host = h.host;
|
|
25
|
+
const isHttps = h.protocol === 'https:';
|
|
26
|
+
return `${isHttps ? 'wss' : 'ws'}://${host}`;
|
|
27
|
+
}
|
|
28
|
+
function getPingUrl() {
|
|
29
|
+
const h = getHost();
|
|
30
|
+
return `${h.protocol}//${h.host}/__umi_ping`;
|
|
31
|
+
}
|
|
7
32
|
let pingTimer = null;
|
|
8
|
-
const host = location.host;
|
|
9
|
-
const wsUrl = `ws://${host}`;
|
|
10
33
|
let isFirstCompilation = true;
|
|
11
34
|
let mostRecentCompilationHash = null;
|
|
12
35
|
let hasCompileErrors = false;
|
|
13
36
|
let hadRuntimeError = false;
|
|
14
|
-
const
|
|
15
|
-
socket
|
|
37
|
+
const pingUrl = getPingUrl();
|
|
38
|
+
const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
|
|
39
|
+
socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
40
|
data = JSON.parse(data);
|
|
17
41
|
if (data.type === 'connected') {
|
|
18
42
|
console.log(`[webpack] connected.`);
|
|
@@ -23,26 +47,28 @@ socket.addEventListener('message', async ({ data }) => {
|
|
|
23
47
|
else {
|
|
24
48
|
handleMessage(data).catch(console.error);
|
|
25
49
|
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
}));
|
|
51
|
+
function waitForSuccessfulPing(ms = 1000) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
// eslint-disable-next-line no-constant-condition
|
|
54
|
+
while (true) {
|
|
55
|
+
try {
|
|
56
|
+
yield fetch(pingUrl);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
yield new Promise((resolve) => setTimeout(resolve, ms));
|
|
61
|
+
}
|
|
36
62
|
}
|
|
37
|
-
}
|
|
63
|
+
});
|
|
38
64
|
}
|
|
39
|
-
socket.addEventListener('close',
|
|
65
|
+
socket.addEventListener('close', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
66
|
if (pingTimer)
|
|
41
67
|
clearInterval(pingTimer);
|
|
42
68
|
console.info('[webpack] Dev server disconnected. Polling for restart...');
|
|
43
|
-
|
|
69
|
+
yield waitForSuccessfulPing();
|
|
44
70
|
location.reload();
|
|
45
|
-
});
|
|
71
|
+
}));
|
|
46
72
|
ErrorOverlay.startReportingRuntimeErrors({
|
|
47
73
|
onError: function () {
|
|
48
74
|
hadRuntimeError = true;
|
|
@@ -180,23 +206,25 @@ function tryApplyUpdates(onHotUpdateSuccess) {
|
|
|
180
206
|
handleApplyUpdates(err, null);
|
|
181
207
|
});
|
|
182
208
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
209
|
+
function handleMessage(payload) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
// console.log('[payload]', payload);
|
|
212
|
+
switch (payload.type) {
|
|
213
|
+
case MESSAGE_TYPE.hash:
|
|
214
|
+
handleAvailableHash(payload.data);
|
|
215
|
+
break;
|
|
216
|
+
case MESSAGE_TYPE.stillOk:
|
|
217
|
+
case MESSAGE_TYPE.ok:
|
|
218
|
+
handleSuccess();
|
|
219
|
+
break;
|
|
220
|
+
case MESSAGE_TYPE.errors:
|
|
221
|
+
handleErrors(payload.data);
|
|
222
|
+
break;
|
|
223
|
+
case MESSAGE_TYPE.warnings:
|
|
224
|
+
handleWarnings(payload.data);
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
// Do nothing
|
|
228
|
+
}
|
|
229
|
+
});
|
|
202
230
|
}
|
package/client/constants.js
CHANGED
|
@@ -10,3 +10,12 @@ export var MESSAGE_TYPE;
|
|
|
10
10
|
MESSAGE_TYPE["stillOk"] = "still-ok";
|
|
11
11
|
MESSAGE_TYPE["invalid"] = "invalid";
|
|
12
12
|
})(MESSAGE_TYPE || (MESSAGE_TYPE = {}));
|
|
13
|
+
export const DEFAULT_BROWSER_TARGETS = {
|
|
14
|
+
chrome: 80,
|
|
15
|
+
};
|
|
16
|
+
export const DEFAULT_ESBUILD_TARGET_KEYS = [
|
|
17
|
+
'chrome',
|
|
18
|
+
'firefox',
|
|
19
|
+
'edge',
|
|
20
|
+
'safari',
|
|
21
|
+
];
|