@umijs/bundler-webpack 4.0.0-rc.1 → 4.0.0-rc.12

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 (121) hide show
  1. package/client/client/client.js +57 -37
  2. package/client/constants.js +9 -0
  3. package/compiled/autoprefixer/browserslist/index.d.ts +6 -0
  4. package/compiled/autoprefixer/index.js +3 -3
  5. package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
  6. package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
  7. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
  8. package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
  9. package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
  10. package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
  11. package/compiled/babel-loader/index.js +2 -2
  12. package/compiled/copy-webpack-plugin/939.index.js +1171 -0
  13. package/compiled/copy-webpack-plugin/index.js +16 -10
  14. package/compiled/copy-webpack-plugin/package.json +1 -1
  15. package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
  16. package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
  17. package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
  18. package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
  19. package/compiled/cssnano/index.js +12 -11
  20. package/compiled/cssnano/package.json +1 -1
  21. package/compiled/express.d.ts +2 -0
  22. package/compiled/fork-ts-checker-webpack-plugin/index.js +8 -15
  23. package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
  24. package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
  25. package/compiled/http-proxy-middleware/index.js +10 -10
  26. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
  27. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
  28. package/compiled/mini-css-extract-plugin/index.js +4523 -4036
  29. package/compiled/mini-css-extract-plugin/loader.js +179 -54
  30. package/compiled/mini-css-extract-plugin/package.json +1 -1
  31. package/compiled/mini-css-extract-plugin/utils.js +79 -23
  32. package/compiled/react-refresh/LICENSE +21 -0
  33. package/compiled/react-refresh/index.js +9 -7
  34. package/compiled/react-refresh/package.json +1 -0
  35. package/compiled/sass-loader/index.js +1 -1
  36. package/compiled/terser/index.js +1 -1
  37. package/compiled/terser-webpack-plugin/index.js +296 -297
  38. package/compiled/terser-webpack-plugin/minify.js +4 -2
  39. package/compiled/terser-webpack-plugin/package.json +1 -1
  40. package/compiled/terser-webpack-plugin/types/index.d.ts +180 -146
  41. package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
  42. package/compiled/terser-webpack-plugin/types/utils.d.ts +1 -3
  43. package/compiled/terser-webpack-plugin/utils.js +9 -12
  44. package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
  45. package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
  46. package/compiled/webpack/index.js +11589 -4372
  47. package/compiled/webpack-dev-middleware/index.js +7 -7
  48. package/compiled/webpack-dev-middleware/package.json +1 -1
  49. package/compiled/webpack-manifest-plugin/index.js +1 -1
  50. package/compiled/webpack-sources/index.js +1 -1
  51. package/compiled/ws/index.d.ts +1 -2
  52. package/compiled/ws/index.js +1 -1
  53. package/dist/build.d.ts +2 -1
  54. package/dist/build.js +1 -1
  55. package/dist/client/client.js +15 -4
  56. package/dist/config/compressPlugin.js +15 -1
  57. package/dist/config/config.js +7 -3
  58. package/dist/config/cssRules.js +1 -1
  59. package/dist/config/detectDeadCode.d.ts +12 -0
  60. package/dist/config/detectDeadCode.js +120 -0
  61. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  62. package/dist/config/detectDeadCodePlugin.js +75 -0
  63. package/dist/config/javaScriptRules.js +7 -12
  64. package/dist/config/nodePolyfill.js +1 -1
  65. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  66. package/dist/config/nodePrefixPlugin.js +25 -0
  67. package/dist/constants.d.ts +4 -0
  68. package/dist/constants.js +10 -1
  69. package/dist/dev.d.ts +4 -0
  70. package/dist/dev.js +27 -8
  71. package/dist/index.d.ts +4 -1
  72. package/dist/index.js +5 -1
  73. package/dist/loader/swc.js +14 -18
  74. package/dist/plugins/ESBuildCSSMinifyPlugin.js +1 -3
  75. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
  76. package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
  77. package/dist/plugins/ProgressPlugin.js +2 -2
  78. package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
  79. package/dist/requireHook.js +1 -1
  80. package/dist/schema.js +10 -6
  81. package/dist/server/https.d.ts +5 -0
  82. package/dist/server/https.js +73 -0
  83. package/dist/server/server.d.ts +2 -1
  84. package/dist/server/server.js +48 -11
  85. package/dist/server/ws.d.ts +3 -2
  86. package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
  87. package/dist/swcPlugins/autoCSSModules.js +14 -17
  88. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  89. package/dist/swcPlugins/changeImportFromString.js +10 -0
  90. package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
  91. package/dist/swcPlugins/lockCoreJS.js +3 -2
  92. package/dist/types.d.ts +16 -12
  93. package/dist/types.js +1 -0
  94. package/dist/utils/depMatch.js +1 -1
  95. package/dist/utils/getEsBuildTarget.d.ts +5 -0
  96. package/dist/utils/getEsBuildTarget.js +12 -0
  97. package/package.json +40 -42
  98. package/compiled/css-loader/LICENSE +0 -20
  99. package/compiled/css-loader/api.js +0 -102
  100. package/compiled/css-loader/getUrl.js +0 -29
  101. package/compiled/css-loader/index.js +0 -2
  102. package/compiled/css-loader/noSourceMaps.js +0 -5
  103. package/compiled/css-loader/package.json +0 -1
  104. package/compiled/css-loader/sourceMaps.js +0 -22
  105. package/compiled/express/LICENSE +0 -24
  106. package/compiled/express/body-parser/index.d.ts +0 -104
  107. package/compiled/express/connect/index.d.ts +0 -93
  108. package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
  109. package/compiled/express/index.d.ts +0 -133
  110. package/compiled/express/index.js +0 -338
  111. package/compiled/express/mime/index.d.ts +0 -35
  112. package/compiled/express/package.json +0 -1
  113. package/compiled/express/qs/index.d.ts +0 -62
  114. package/compiled/express/range-parser/index.d.ts +0 -35
  115. package/compiled/express/serve-static/index.d.ts +0 -108
  116. package/compiled/less/index.js +0 -31
  117. package/compiled/less/package.json +0 -1
  118. package/dist/esbuildHandler/autoCssModules.d.ts +0 -2
  119. package/dist/esbuildHandler/autoCssModules.js +0 -23
  120. package/dist/loader/esbuild.d.ts +0 -5
  121. package/dist/loader/esbuild.js +0 -53
@@ -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
+ ];
@@ -36,6 +36,10 @@ declare namespace browserslist {
36
36
  * Do not throw on unknown version in direct query.
37
37
  */
38
38
  ignoreUnknownVersions?: boolean
39
+ /**
40
+ * Throw a error if env is not found.
41
+ */
42
+ throwOnMissing?: boolean
39
43
  /**
40
44
  * Disable security checks for extend query.
41
45
  */
@@ -98,6 +102,8 @@ declare namespace browserslist {
98
102
  | undefined
99
103
  }
100
104
 
105
+ let nodeVersions: string[]
106
+
101
107
  interface Usage {
102
108
  [version: string]: number
103
109
  }