@umijs/bundler-webpack 4.0.0-canary.20220323.1 → 4.0.0-rc.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/client/client/client.js +49 -35
- package/client/constants.js +3 -0
- package/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
- package/compiled/copy-webpack-plugin/index.js +12 -12
- package/dist/client/client.js +2 -1
- package/dist/dev.js +5 -0
- package/dist/schema.js +1 -0
- package/dist/server/server.d.ts +1 -2
- package/dist/server/server.js +11 -8
- package/dist/server/ws.d.ts +3 -2
- package/dist/swcPlugins/autoCSSModules.js +3 -1
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.js +3 -2
- package/dist/types.d.ts +6 -0
- package/dist/utils/server.d.ts +5 -0
- package/dist/utils/server.js +93 -0
- package/package.json +6 -5
package/client/client/client.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
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';
|
|
@@ -6,13 +15,14 @@ import { formatWebpackMessages } from '../utils/formatWebpackMessages';
|
|
|
6
15
|
console.log('[webpack] connecting...');
|
|
7
16
|
let pingTimer = null;
|
|
8
17
|
const host = location.host;
|
|
9
|
-
const
|
|
18
|
+
const isHttps = location.protocol === 'https:';
|
|
19
|
+
const wsUrl = `${isHttps ? 'wss' : 'ws'}://${host}`;
|
|
10
20
|
let isFirstCompilation = true;
|
|
11
21
|
let mostRecentCompilationHash = null;
|
|
12
22
|
let hasCompileErrors = false;
|
|
13
23
|
let hadRuntimeError = false;
|
|
14
24
|
const socket = new WebSocket(wsUrl, 'webpack-hmr');
|
|
15
|
-
socket.addEventListener('message',
|
|
25
|
+
socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
26
|
data = JSON.parse(data);
|
|
17
27
|
if (data.type === 'connected') {
|
|
18
28
|
console.log(`[webpack] connected.`);
|
|
@@ -23,26 +33,28 @@ socket.addEventListener('message', async ({ data }) => {
|
|
|
23
33
|
else {
|
|
24
34
|
handleMessage(data).catch(console.error);
|
|
25
35
|
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
}));
|
|
37
|
+
function waitForSuccessfulPing(ms = 1000) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
// eslint-disable-next-line no-constant-condition
|
|
40
|
+
while (true) {
|
|
41
|
+
try {
|
|
42
|
+
yield fetch(`/__umi_ping`);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
yield new Promise((resolve) => setTimeout(resolve, ms));
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
|
-
}
|
|
49
|
+
});
|
|
38
50
|
}
|
|
39
|
-
socket.addEventListener('close',
|
|
51
|
+
socket.addEventListener('close', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
52
|
if (pingTimer)
|
|
41
53
|
clearInterval(pingTimer);
|
|
42
54
|
console.info('[webpack] Dev server disconnected. Polling for restart...');
|
|
43
|
-
|
|
55
|
+
yield waitForSuccessfulPing();
|
|
44
56
|
location.reload();
|
|
45
|
-
});
|
|
57
|
+
}));
|
|
46
58
|
ErrorOverlay.startReportingRuntimeErrors({
|
|
47
59
|
onError: function () {
|
|
48
60
|
hadRuntimeError = true;
|
|
@@ -180,23 +192,25 @@ function tryApplyUpdates(onHotUpdateSuccess) {
|
|
|
180
192
|
handleApplyUpdates(err, null);
|
|
181
193
|
});
|
|
182
194
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
function handleMessage(payload) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
// console.log('[payload]', payload);
|
|
198
|
+
switch (payload.type) {
|
|
199
|
+
case MESSAGE_TYPE.hash:
|
|
200
|
+
handleAvailableHash(payload.data);
|
|
201
|
+
break;
|
|
202
|
+
case MESSAGE_TYPE.stillOk:
|
|
203
|
+
case MESSAGE_TYPE.ok:
|
|
204
|
+
handleSuccess();
|
|
205
|
+
break;
|
|
206
|
+
case MESSAGE_TYPE.errors:
|
|
207
|
+
handleErrors(payload.data);
|
|
208
|
+
break;
|
|
209
|
+
case MESSAGE_TYPE.warnings:
|
|
210
|
+
handleWarnings(payload.data);
|
|
211
|
+
break;
|
|
212
|
+
default:
|
|
213
|
+
// Do nothing
|
|
214
|
+
}
|
|
215
|
+
});
|
|
202
216
|
}
|
package/client/constants.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
exports.id =
|
|
2
|
-
exports.ids = [
|
|
1
|
+
exports.id = 939;
|
|
2
|
+
exports.ids = [939];
|
|
3
3
|
exports.modules = {
|
|
4
4
|
|
|
5
|
-
/***/
|
|
5
|
+
/***/ 5352:
|
|
6
6
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
7
7
|
|
|
8
8
|
"use strict";
|
|
9
9
|
|
|
10
10
|
const path = __webpack_require__(1017);
|
|
11
|
-
const pathType = __webpack_require__(
|
|
11
|
+
const pathType = __webpack_require__(9223);
|
|
12
12
|
|
|
13
13
|
const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
|
|
14
14
|
|
|
@@ -85,7 +85,7 @@ module.exports.sync = (input, options) => {
|
|
|
85
85
|
|
|
86
86
|
/***/ }),
|
|
87
87
|
|
|
88
|
-
/***/
|
|
88
|
+
/***/ 6302:
|
|
89
89
|
/***/ (function(module) {
|
|
90
90
|
|
|
91
91
|
// A simple implementation of make-array
|
|
@@ -695,7 +695,7 @@ if (
|
|
|
695
695
|
|
|
696
696
|
/***/ }),
|
|
697
697
|
|
|
698
|
-
/***/
|
|
698
|
+
/***/ 9223:
|
|
699
699
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
700
700
|
|
|
701
701
|
"use strict";
|
|
@@ -746,7 +746,7 @@ exports.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
|
|
|
746
746
|
|
|
747
747
|
/***/ }),
|
|
748
748
|
|
|
749
|
-
/***/
|
|
749
|
+
/***/ 1939:
|
|
750
750
|
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
751
751
|
|
|
752
752
|
"use strict";
|
|
@@ -772,11 +772,11 @@ const arrayUnion = (...arguments_) => [...new Set(arguments_.flat())];
|
|
|
772
772
|
/* harmony default export */ var array_union = (arrayUnion);
|
|
773
773
|
|
|
774
774
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/merge2@1.4.1/node_modules/merge2/index.js
|
|
775
|
-
var merge2 = __webpack_require__(
|
|
775
|
+
var merge2 = __webpack_require__(1382);
|
|
776
776
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/fast-glob@3.2.11/node_modules/fast-glob/out/index.js
|
|
777
|
-
var out = __webpack_require__(
|
|
777
|
+
var out = __webpack_require__(3924);
|
|
778
778
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/dir-glob@3.0.1/node_modules/dir-glob/index.js
|
|
779
|
-
var dir_glob = __webpack_require__(
|
|
779
|
+
var dir_glob = __webpack_require__(5352);
|
|
780
780
|
// EXTERNAL MODULE: external "node:url"
|
|
781
781
|
var external_node_url_ = __webpack_require__(1041);
|
|
782
782
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/globby@12.2.0/node_modules/globby/to-path.js
|
|
@@ -801,7 +801,7 @@ var external_node_process_ = __webpack_require__(7742);
|
|
|
801
801
|
// EXTERNAL MODULE: external "node:path"
|
|
802
802
|
var external_node_path_ = __webpack_require__(9411);
|
|
803
803
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/ignore@5.2.0/node_modules/ignore/index.js
|
|
804
|
-
var ignore = __webpack_require__(
|
|
804
|
+
var ignore = __webpack_require__(6302);
|
|
805
805
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/slash@4.0.0/node_modules/slash/index.js
|
|
806
806
|
function slash(path) {
|
|
807
807
|
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|