@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.
- package/client/client/client.js +57 -37
- package/client/constants.js +9 -0
- package/compiled/autoprefixer/browserslist/index.d.ts +6 -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 +2 -2
- package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/babel-loader/index.js +2 -2
- package/compiled/copy-webpack-plugin/939.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/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +8 -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 +4523 -4036
- package/compiled/mini-css-extract-plugin/loader.js +179 -54
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +79 -23
- package/compiled/react-refresh/LICENSE +21 -0
- package/compiled/react-refresh/index.js +9 -7
- package/compiled/react-refresh/package.json +1 -0
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/terser/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/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/index.js +11589 -4372
- 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/client/client.js +15 -4
- package/dist/config/compressPlugin.js +15 -1
- package/dist/config/config.js +7 -3
- package/dist/config/cssRules.js +1 -1
- 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 +75 -0
- package/dist/config/javaScriptRules.js +7 -12
- package/dist/config/nodePolyfill.js +1 -1
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +25 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +10 -1
- package/dist/dev.d.ts +4 -0
- package/dist/dev.js +27 -8
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -1
- package/dist/loader/swc.js +14 -18
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +1 -3
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
- package/dist/plugins/ProgressPlugin.js +2 -2
- package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
- package/dist/requireHook.js +1 -1
- package/dist/schema.js +10 -6
- package/dist/server/https.d.ts +5 -0
- package/dist/server/https.js +73 -0
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +48 -11
- package/dist/server/ws.d.ts +3 -2
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +14 -17
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
- package/dist/swcPlugins/lockCoreJS.js +3 -2
- package/dist/types.d.ts +16 -12
- package/dist/types.js +1 -0
- package/dist/utils/depMatch.js +1 -1
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +40 -42
- package/compiled/css-loader/LICENSE +0 -20
- package/compiled/css-loader/api.js +0 -102
- package/compiled/css-loader/getUrl.js +0 -29
- package/compiled/css-loader/index.js +0 -2
- package/compiled/css-loader/noSourceMaps.js +0 -5
- package/compiled/css-loader/package.json +0 -1
- package/compiled/css-loader/sourceMaps.js +0 -22
- package/compiled/express/LICENSE +0 -24
- package/compiled/express/body-parser/index.d.ts +0 -104
- package/compiled/express/connect/index.d.ts +0 -93
- package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
- package/compiled/express/index.d.ts +0 -133
- package/compiled/express/index.js +0 -338
- package/compiled/express/mime/index.d.ts +0 -35
- package/compiled/express/package.json +0 -1
- package/compiled/express/qs/index.d.ts +0 -62
- package/compiled/express/range-parser/index.d.ts +0 -35
- package/compiled/express/serve-static/index.d.ts +0 -108
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- 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
package/client/client/client.js
CHANGED
|
@@ -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(
|
|
15
|
-
socket.addEventListener('message',
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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',
|
|
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
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
}
|
package/client/constants.js
CHANGED
|
@@ -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
|
}
|