@umijs/bundler-webpack 4.0.0-rc.1 → 4.0.0-rc.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.
- package/compiled/autoprefixer/browserslist/index.d.ts +4 -0
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/copy-webpack-plugin/576.index.js +1171 -0
- package/compiled/copy-webpack-plugin/index.js +16 -10
- package/compiled/copy-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
- package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
- package/compiled/cssnano/index.js +12 -11
- package/compiled/express/index.js +57 -74
- package/compiled/fork-ts-checker-webpack-plugin/index.js +14 -15
- package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
- package/compiled/http-proxy-middleware/index.js +10 -10
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
- package/compiled/mini-css-extract-plugin/index.js +4427 -3979
- package/compiled/mini-css-extract-plugin/loader.js +177 -54
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +77 -23
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/terser-webpack-plugin/index.js +296 -297
- package/compiled/terser-webpack-plugin/minify.js +4 -2
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +180 -146
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +1 -3
- package/compiled/terser-webpack-plugin/utils.js +9 -12
- package/compiled/webpack/index.js +8652 -3904
- package/compiled/webpack-dev-middleware/index.js +7 -7
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/compiled/webpack-sources/index.js +1 -1
- package/compiled/ws/index.d.ts +1 -2
- package/compiled/ws/index.js +1 -1
- package/dist/build.d.ts +2 -1
- package/dist/build.js +1 -1
- package/dist/config/config.js +4 -3
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +120 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +71 -0
- package/dist/config/javaScriptRules.js +3 -6
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +7 -5
- package/dist/loader/swc.js +14 -18
- package/dist/requireHook.js +1 -1
- package/dist/schema.js +2 -0
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +11 -16
- package/dist/types.d.ts +9 -12
- package/dist/utils/depMatch.js +1 -1
- package/package.json +31 -31
- package/dist/esbuildHandler/autoCssModules.d.ts +0 -2
- package/dist/esbuildHandler/autoCssModules.js +0 -23
- package/dist/loader/esbuild.d.ts +0 -5
- 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 =
|
|
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(
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
},
|
|
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();
|