@umijs/bundler-webpack 4.0.0-rc.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.
Files changed (111) hide show
  1. package/client/client/client.js +49 -35
  2. package/client/constants.js +3 -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 +14 -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/sass-loader/index.js +1 -1
  33. package/compiled/terser/index.js +1 -1
  34. package/compiled/terser-webpack-plugin/index.js +296 -297
  35. package/compiled/terser-webpack-plugin/minify.js +4 -2
  36. package/compiled/terser-webpack-plugin/package.json +1 -1
  37. package/compiled/terser-webpack-plugin/types/index.d.ts +180 -146
  38. package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
  39. package/compiled/terser-webpack-plugin/types/utils.d.ts +1 -3
  40. package/compiled/terser-webpack-plugin/utils.js +9 -12
  41. package/compiled/webpack/index.js +9855 -4185
  42. package/compiled/webpack-dev-middleware/index.js +7 -7
  43. package/compiled/webpack-dev-middleware/package.json +1 -1
  44. package/compiled/webpack-manifest-plugin/index.js +1 -1
  45. package/compiled/webpack-sources/index.js +1 -1
  46. package/compiled/ws/index.d.ts +1 -2
  47. package/compiled/ws/index.js +1 -1
  48. package/dist/build.d.ts +2 -1
  49. package/dist/build.js +1 -1
  50. package/dist/client/client.js +7 -2
  51. package/dist/config/compressPlugin.js +6 -0
  52. package/dist/config/config.js +4 -3
  53. package/dist/config/cssRules.js +1 -1
  54. package/dist/config/detectDeadCode.d.ts +12 -0
  55. package/dist/config/detectDeadCode.js +120 -0
  56. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  57. package/dist/config/detectDeadCodePlugin.js +75 -0
  58. package/dist/config/javaScriptRules.js +7 -12
  59. package/dist/constants.d.ts +3 -0
  60. package/dist/constants.js +4 -1
  61. package/dist/dev.d.ts +1 -0
  62. package/dist/dev.js +13 -5
  63. package/dist/index.d.ts +4 -1
  64. package/dist/index.js +5 -1
  65. package/dist/loader/swc.js +14 -18
  66. package/dist/plugins/ESBuildCSSMinifyPlugin.js +1 -3
  67. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
  68. package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
  69. package/dist/plugins/ProgressPlugin.js +2 -2
  70. package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
  71. package/dist/requireHook.js +1 -1
  72. package/dist/schema.js +10 -6
  73. package/dist/server/server.d.ts +1 -2
  74. package/dist/server/server.js +27 -11
  75. package/dist/server/ws.d.ts +3 -2
  76. package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
  77. package/dist/swcPlugins/autoCSSModules.js +14 -17
  78. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  79. package/dist/swcPlugins/changeImportFromString.js +10 -0
  80. package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
  81. package/dist/swcPlugins/lockCoreJS.js +3 -2
  82. package/dist/types.d.ts +16 -12
  83. package/dist/types.js +1 -0
  84. package/dist/utils/depMatch.js +1 -1
  85. package/dist/utils/server.d.ts +5 -0
  86. package/dist/utils/server.js +93 -0
  87. package/package.json +38 -41
  88. package/compiled/css-loader/LICENSE +0 -20
  89. package/compiled/css-loader/api.js +0 -102
  90. package/compiled/css-loader/getUrl.js +0 -29
  91. package/compiled/css-loader/index.js +0 -2
  92. package/compiled/css-loader/noSourceMaps.js +0 -5
  93. package/compiled/css-loader/package.json +0 -1
  94. package/compiled/css-loader/sourceMaps.js +0 -22
  95. package/compiled/express/LICENSE +0 -24
  96. package/compiled/express/body-parser/index.d.ts +0 -104
  97. package/compiled/express/connect/index.d.ts +0 -93
  98. package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
  99. package/compiled/express/index.d.ts +0 -133
  100. package/compiled/express/index.js +0 -338
  101. package/compiled/express/mime/index.d.ts +0 -35
  102. package/compiled/express/package.json +0 -1
  103. package/compiled/express/qs/index.d.ts +0 -62
  104. package/compiled/express/range-parser/index.d.ts +0 -35
  105. package/compiled/express/serve-static/index.d.ts +0 -108
  106. package/compiled/less/index.js +0 -31
  107. package/compiled/less/package.json +0 -1
  108. package/dist/esbuildHandler/autoCssModules.d.ts +0 -2
  109. package/dist/esbuildHandler/autoCssModules.js +0 -23
  110. package/dist/loader/esbuild.d.ts +0 -5
  111. package/dist/loader/esbuild.js +0 -53
@@ -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 wsUrl = `ws://${host}`;
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', async ({ data }) => {
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
- 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));
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', async () => {
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
- await waitForSuccessfulPing();
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
- 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
- }
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
  }
@@ -10,3 +10,6 @@ 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
+ };
@@ -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
  }