@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
@@ -7,15 +7,23 @@
7
7
  no-console,
8
8
  func-names
9
9
  */
10
+
11
+ /** @typedef {any} TODO */
10
12
  var normalizeUrl = require("./normalize-url");
11
13
 
12
14
  var srcByModuleId = Object.create(null);
13
15
  var noDocument = typeof document === "undefined";
14
16
  var forEach = Array.prototype.forEach;
17
+ /**
18
+ * @param {function} fn
19
+ * @param {number} time
20
+ * @returns {(function(): void)|*}
21
+ */
15
22
 
16
23
  function debounce(fn, time) {
17
24
  var timeout = 0;
18
25
  return function () {
26
+ // @ts-ignore
19
27
  var self = this; // eslint-disable-next-line prefer-rest-params
20
28
 
21
29
  var args = arguments;
@@ -24,19 +32,27 @@ function debounce(fn, time) {
24
32
  return fn.apply(self, args);
25
33
  };
26
34
 
27
- clearTimeout(timeout);
35
+ clearTimeout(timeout); // @ts-ignore
36
+
28
37
  timeout = setTimeout(functionCall, time);
29
38
  };
30
39
  }
31
40
 
32
41
  function noop() {}
42
+ /**
43
+ * @param {TODO} moduleId
44
+ * @returns {TODO}
45
+ */
46
+
33
47
 
34
48
  function getCurrentScriptUrl(moduleId) {
35
49
  var src = srcByModuleId[moduleId];
36
50
 
37
51
  if (!src) {
38
52
  if (document.currentScript) {
39
- src = document.currentScript.src;
53
+ src =
54
+ /** @type {HTMLScriptElement} */
55
+ document.currentScript.src;
40
56
  } else {
41
57
  var scripts = document.getElementsByTagName("script");
42
58
  var lastScriptTag = scripts[scripts.length - 1];
@@ -48,6 +64,11 @@ function getCurrentScriptUrl(moduleId) {
48
64
 
49
65
  srcByModuleId[moduleId] = src;
50
66
  }
67
+ /**
68
+ * @param {string} fileMap
69
+ * @returns {null | string[]}
70
+ */
71
+
51
72
 
52
73
  return function (fileMap) {
53
74
  if (!src) {
@@ -71,6 +92,11 @@ function getCurrentScriptUrl(moduleId) {
71
92
  });
72
93
  };
73
94
  }
95
+ /**
96
+ * @param {TODO} el
97
+ * @param {string} [url]
98
+ */
99
+
74
100
 
75
101
  function updateCss(el, url) {
76
102
  if (!url) {
@@ -82,7 +108,9 @@ function updateCss(el, url) {
82
108
  url = el.href.split("?")[0];
83
109
  }
84
110
 
85
- if (!isUrlRequest(url)) {
111
+ if (!isUrlRequest(
112
+ /** @type {string} */
113
+ url)) {
86
114
  return;
87
115
  }
88
116
 
@@ -124,21 +152,34 @@ function updateCss(el, url) {
124
152
  el.parentNode.appendChild(newEl);
125
153
  }
126
154
  }
155
+ /**
156
+ * @param {string} href
157
+ * @param {TODO} src
158
+ * @returns {TODO}
159
+ */
160
+
127
161
 
128
162
  function getReloadUrl(href, src) {
129
163
  var ret; // eslint-disable-next-line no-param-reassign
130
164
 
131
- href = normalizeUrl(href, {
132
- stripWWW: false
133
- }); // eslint-disable-next-line array-callback-return
134
-
135
- src.some(function (url) {
165
+ href = normalizeUrl(href);
166
+ src.some(
167
+ /**
168
+ * @param {string} url
169
+ */
170
+ // eslint-disable-next-line array-callback-return
171
+ function (url) {
136
172
  if (href.indexOf(src) > -1) {
137
173
  ret = url;
138
174
  }
139
175
  });
140
176
  return ret;
141
177
  }
178
+ /**
179
+ * @param {string} [src]
180
+ * @returns {boolean}
181
+ */
182
+
142
183
 
143
184
  function reloadStyle(src) {
144
185
  if (!src) {
@@ -180,6 +221,11 @@ function reloadAll() {
180
221
  updateCss(el);
181
222
  });
182
223
  }
224
+ /**
225
+ * @param {string} url
226
+ * @returns {boolean}
227
+ */
228
+
183
229
 
184
230
  function isUrlRequest(url) {
185
231
  // An URL is not an request if
@@ -190,6 +236,12 @@ function isUrlRequest(url) {
190
236
 
191
237
  return true;
192
238
  }
239
+ /**
240
+ * @param {TODO} moduleId
241
+ * @param {TODO} options
242
+ * @returns {TODO}
243
+ */
244
+
193
245
 
194
246
  module.exports = function (moduleId, options) {
195
247
  if (noDocument) {
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable */
4
+
5
+ /**
6
+ * @param {string[]} pathComponents
7
+ * @returns {string}
8
+ */
4
9
  function normalizeUrl(pathComponents) {
5
10
  return pathComponents.reduce(function (accumulator, item) {
6
11
  switch (item) {
@@ -16,8 +21,15 @@ function normalizeUrl(pathComponents) {
16
21
  }
17
22
 
18
23
  return accumulator;
19
- }, []).join("/");
24
+ },
25
+ /** @type {string[]} */
26
+ []).join("/");
20
27
  }
28
+ /**
29
+ * @param {string} urlString
30
+ * @returns {string}
31
+ */
32
+
21
33
 
22
34
  module.exports = function (urlString) {
23
35
  urlString = urlString.trim();