@umijs/bundler-webpack 4.0.0-rc.2 → 4.0.0-rc.20

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 (112) hide show
  1. package/client/client/client.js +65 -37
  2. package/client/constants.js +9 -0
  3. package/compiled/autoprefixer/browserslist/index.d.ts +2 -0
  4. package/compiled/autoprefixer/index.js +3 -3
  5. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
  6. package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
  7. package/compiled/babel-loader/index.js +2 -2
  8. package/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
  9. package/compiled/copy-webpack-plugin/index.js +12 -12
  10. package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
  11. package/compiled/cssnano/index.js +6 -6
  12. package/compiled/cssnano/package.json +1 -1
  13. package/compiled/express.d.ts +2 -0
  14. package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
  15. package/compiled/http-proxy-middleware/index.js +10 -10
  16. package/compiled/mini-css-extract-plugin/index.js +440 -401
  17. package/compiled/mini-css-extract-plugin/loader.js +3 -1
  18. package/compiled/mini-css-extract-plugin/utils.js +2 -0
  19. package/compiled/{tapable → react-refresh}/LICENSE +6 -6
  20. package/compiled/react-refresh/index.js +9 -7
  21. package/compiled/react-refresh/package.json +1 -0
  22. package/compiled/terser/index.js +1 -1
  23. package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
  24. package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
  25. package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
  26. package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
  27. package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
  28. package/compiled/webpack/RuleSetCompiler.js +1 -0
  29. package/compiled/webpack/UseEffectRulePlugin.js +1 -0
  30. package/compiled/webpack/deepImports.json +6 -1
  31. package/compiled/webpack/index.js +5760 -3275
  32. package/compiled/webpack/types.d.ts +606 -171
  33. package/compiled/webpack-manifest-plugin/index.js +1 -1
  34. package/dist/build.d.ts +1 -0
  35. package/dist/build.js +48 -57
  36. package/dist/cli.js +6 -15
  37. package/dist/client/client.js +57 -51
  38. package/dist/config/_sampleFeature.js +6 -17
  39. package/dist/config/assetRules.js +44 -55
  40. package/dist/config/bundleAnalyzerPlugin.js +12 -23
  41. package/dist/config/compressPlugin.js +89 -64
  42. package/dist/config/config.d.ts +2 -0
  43. package/dist/config/config.js +177 -179
  44. package/dist/config/copyPlugin.js +29 -40
  45. package/dist/config/cssRules.js +93 -83
  46. package/dist/config/definePlugin.js +11 -19
  47. package/dist/config/detectDeadCode.js +1 -1
  48. package/dist/config/detectDeadCodePlugin.js +21 -22
  49. package/dist/config/fastRefreshPlugin.js +11 -22
  50. package/dist/config/forkTSCheckerPlugin.js +11 -22
  51. package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
  52. package/dist/config/ignorePlugin.js +10 -21
  53. package/dist/config/javaScriptRules.d.ts +1 -0
  54. package/dist/config/javaScriptRules.js +152 -138
  55. package/dist/config/manifestPlugin.js +10 -18
  56. package/dist/config/miniCSSExtractPlugin.js +12 -23
  57. package/dist/config/nodePolyfill.js +14 -20
  58. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  59. package/dist/config/nodePrefixPlugin.js +14 -0
  60. package/dist/config/progressPlugin.js +7 -18
  61. package/dist/config/purgecssWebpackPlugin.js +15 -26
  62. package/dist/config/speedMeasureWebpackPlugin.js +12 -23
  63. package/dist/config/svgRules.js +44 -47
  64. package/dist/constants.d.ts +1 -0
  65. package/dist/constants.js +7 -1
  66. package/dist/dev.d.ts +4 -0
  67. package/dist/dev.js +115 -94
  68. package/dist/index.d.ts +4 -1
  69. package/dist/index.js +5 -1
  70. package/dist/loader/svgr.js +4 -13
  71. package/dist/loader/swc.js +9 -14
  72. package/dist/plugins/ProgressPlugin.js +2 -2
  73. package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
  74. package/dist/schema.js +29 -13
  75. package/dist/server/server.d.ts +2 -1
  76. package/dist/server/server.js +164 -148
  77. package/dist/server/ws.d.ts +5 -2
  78. package/dist/swcPlugins/autoCSSModules.js +3 -1
  79. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  80. package/dist/swcPlugins/changeImportFromString.js +10 -0
  81. package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
  82. package/dist/swcPlugins/lockCoreJS.js +3 -2
  83. package/dist/types.d.ts +4 -0
  84. package/dist/types.js +1 -0
  85. package/dist/utils/getEsBuildTarget.d.ts +5 -0
  86. package/dist/utils/getEsBuildTarget.js +12 -0
  87. package/package.json +32 -34
  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 -321
  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/compiled/tapable/index.js +0 -1
  109. package/compiled/tapable/package.json +0 -1
  110. package/compiled/tapable/tapable.d.ts +0 -116
  111. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
  112. package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
@@ -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 socket = new WebSocket(wsUrl, 'webpack-hmr');
15
- socket.addEventListener('message', async ({ data }) => {
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
- 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));
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', async () => {
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
- await waitForSuccessfulPing();
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
- 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
- }
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
  }
@@ -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
+ ];
@@ -102,6 +102,8 @@ declare namespace browserslist {
102
102
  | undefined
103
103
  }
104
104
 
105
+ let nodeVersions: string[]
106
+
105
107
  interface Usage {
106
108
  [version: string]: number
107
109
  }