@umijs/bundler-webpack 4.0.0-canary.20220323.1 → 4.0.0-canary.20220412.2

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.
Files changed (36) hide show
  1. package/client/client/client.js +57 -37
  2. package/client/constants.js +9 -0
  3. package/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
  4. package/compiled/copy-webpack-plugin/index.js +12 -12
  5. package/compiled/cssnano/index.js +6 -6
  6. package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
  7. package/compiled/react-refresh/LICENSE +21 -0
  8. package/compiled/react-refresh/index.js +9 -7
  9. package/compiled/react-refresh/package.json +1 -0
  10. package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
  11. package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
  12. package/compiled/webpack/index.js +4430 -2883
  13. package/dist/client/client.js +10 -3
  14. package/dist/config/compressPlugin.js +9 -1
  15. package/dist/config/config.js +3 -0
  16. package/dist/config/nodePolyfill.js +1 -1
  17. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  18. package/dist/config/nodePrefixPlugin.js +25 -0
  19. package/dist/constants.d.ts +1 -0
  20. package/dist/constants.js +7 -1
  21. package/dist/dev.d.ts +2 -0
  22. package/dist/dev.js +7 -0
  23. package/dist/schema.js +1 -0
  24. package/dist/server/https.d.ts +5 -0
  25. package/dist/server/https.js +73 -0
  26. package/dist/server/server.d.ts +2 -1
  27. package/dist/server/server.js +32 -8
  28. package/dist/server/ws.d.ts +3 -2
  29. package/dist/swcPlugins/autoCSSModules.js +3 -1
  30. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  31. package/dist/swcPlugins/changeImportFromString.js +10 -0
  32. package/dist/swcPlugins/lockCoreJS.js +3 -2
  33. package/dist/types.d.ts +6 -0
  34. package/dist/utils/getEsBuildTarget.d.ts +5 -0
  35. package/dist/utils/getEsBuildTarget.js +12 -0
  36. package/package.json +13 -11
@@ -1,18 +1,34 @@
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 getSocketHost() {
17
+ let l = location;
18
+ if (process.env.SOCKET_SERVER) {
19
+ l = new URL(process.env.SOCKET_SERVER);
20
+ }
21
+ const host = l.host;
22
+ const isHttps = l.protocol === 'https:';
23
+ return `${isHttps ? 'wss' : 'ws'}://${host}`;
24
+ }
7
25
  let pingTimer = null;
8
- const host = location.host;
9
- const wsUrl = `ws://${host}`;
10
26
  let isFirstCompilation = true;
11
27
  let mostRecentCompilationHash = null;
12
28
  let hasCompileErrors = false;
13
29
  let hadRuntimeError = false;
14
- const socket = new WebSocket(wsUrl, 'webpack-hmr');
15
- socket.addEventListener('message', async ({ data }) => {
30
+ const socket = new WebSocket(getSocketHost(), 'webpack-hmr');
31
+ socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void 0, function* () {
16
32
  data = JSON.parse(data);
17
33
  if (data.type === 'connected') {
18
34
  console.log(`[webpack] connected.`);
@@ -23,26 +39,28 @@ socket.addEventListener('message', async ({ data }) => {
23
39
  else {
24
40
  handleMessage(data).catch(console.error);
25
41
  }
26
- });
27
- async function waitForSuccessfulPing(ms = 1000) {
28
- // eslint-disable-next-line no-constant-condition
29
- while (true) {
30
- try {
31
- await fetch(`/__umi_ping`);
32
- break;
33
- }
34
- catch (e) {
35
- await new Promise((resolve) => setTimeout(resolve, ms));
42
+ }));
43
+ function waitForSuccessfulPing(ms = 1000) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ // eslint-disable-next-line no-constant-condition
46
+ while (true) {
47
+ try {
48
+ yield fetch(`/__umi_ping`);
49
+ break;
50
+ }
51
+ catch (e) {
52
+ yield new Promise((resolve) => setTimeout(resolve, ms));
53
+ }
36
54
  }
37
- }
55
+ });
38
56
  }
39
- socket.addEventListener('close', async () => {
57
+ socket.addEventListener('close', () => __awaiter(void 0, void 0, void 0, function* () {
40
58
  if (pingTimer)
41
59
  clearInterval(pingTimer);
42
60
  console.info('[webpack] Dev server disconnected. Polling for restart...');
43
- await waitForSuccessfulPing();
61
+ yield waitForSuccessfulPing();
44
62
  location.reload();
45
- });
63
+ }));
46
64
  ErrorOverlay.startReportingRuntimeErrors({
47
65
  onError: function () {
48
66
  hadRuntimeError = true;
@@ -180,23 +198,25 @@ function tryApplyUpdates(onHotUpdateSuccess) {
180
198
  handleApplyUpdates(err, null);
181
199
  });
182
200
  }
183
- async function handleMessage(payload) {
184
- // console.log('[payload]', payload);
185
- switch (payload.type) {
186
- case MESSAGE_TYPE.hash:
187
- handleAvailableHash(payload.data);
188
- break;
189
- case MESSAGE_TYPE.stillOk:
190
- case MESSAGE_TYPE.ok:
191
- handleSuccess();
192
- break;
193
- case MESSAGE_TYPE.errors:
194
- handleErrors(payload.data);
195
- break;
196
- case MESSAGE_TYPE.warnings:
197
- handleWarnings(payload.data);
198
- break;
199
- default:
200
- // Do nothing
201
- }
201
+ function handleMessage(payload) {
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ // console.log('[payload]', payload);
204
+ switch (payload.type) {
205
+ case MESSAGE_TYPE.hash:
206
+ handleAvailableHash(payload.data);
207
+ break;
208
+ case MESSAGE_TYPE.stillOk:
209
+ case MESSAGE_TYPE.ok:
210
+ handleSuccess();
211
+ break;
212
+ case MESSAGE_TYPE.errors:
213
+ handleErrors(payload.data);
214
+ break;
215
+ case MESSAGE_TYPE.warnings:
216
+ handleWarnings(payload.data);
217
+ break;
218
+ default:
219
+ // Do nothing
220
+ }
221
+ });
202
222
  }
@@ -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
+ ];
@@ -1,14 +1,14 @@
1
- exports.id = 576;
2
- exports.ids = [576];
1
+ exports.id = 939;
2
+ exports.ids = [939];
3
3
  exports.modules = {
4
4
 
5
- /***/ 1199:
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__(6163);
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
- /***/ 6339:
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
- /***/ 6163:
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
- /***/ 3576:
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__(3891);
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__(9918);
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__(1199);
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__(6339);
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);