@umijs/bundler-webpack 4.0.0-beta.7 → 4.0.0-canary.202200505.1
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 +65 -37
- package/client/constants.js +9 -0
- package/compiled/autoprefixer/browserslist/index.d.ts +13 -7
- 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/container.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
- package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +38 -4
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +5 -4
- package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
- 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/LICENSE +21 -0
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +42 -0
- package/compiled/fork-ts-checker-webpack-plugin/package.json +1 -0
- 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 +7970 -7445
- 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 +85 -24
- package/compiled/postcss-loader/index.js +1 -1
- 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/schema-utils/ajv/dist/ajv.d.ts +16 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
- package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
- package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
- package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
- package/compiled/schema-utils/declarations/validate.d.ts +4 -4
- package/compiled/schema-utils/index.js +8 -2
- package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/style-loader/index.js +1 -1
- package/compiled/terser/index.js +1 -1
- package/compiled/terser-webpack-plugin/index.js +393 -517
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
- package/compiled/terser-webpack-plugin/minify.js +10 -3
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +183 -149
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -15
- package/compiled/terser-webpack-plugin/utils.js +118 -25
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +6 -1
- package/compiled/webpack/index.js +13409 -5746
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-dev-middleware/index.js +11 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- 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 +6 -3
- package/dist/build.js +48 -56
- package/dist/cli.js +10 -22
- package/dist/client/client.js +57 -51
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -51
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +70 -64
- package/dist/config/config.d.ts +9 -2
- package/dist/config/config.js +184 -144
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +93 -83
- package/dist/config/definePlugin.js +11 -19
- 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 +70 -0
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +23 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +31 -0
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.d.ts +2 -0
- package/dist/config/javaScriptRules.js +153 -131
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +17 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +12 -24
- package/dist/config/nodePolyfill.js +14 -20
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.js +7 -18
- package/dist/config/purgecssWebpackPlugin.js +15 -26
- package/dist/config/speedMeasureWebpackPlugin.js +12 -23
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +45 -48
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +10 -1
- package/dist/dev.d.ts +8 -2
- package/dist/dev.js +117 -66
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -1
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +58 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +74 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +23 -36
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +73 -0
- package/dist/plugins/ProgressPlugin.js +2 -2
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
- package/dist/requireHook.js +1 -1
- package/dist/schema.js +23 -11
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +165 -130
- package/dist/server/ws.d.ts +6 -3
- package/dist/server/ws.js +1 -1
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +16 -17
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +24 -0
- package/dist/types.d.ts +19 -0
- 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 +68 -67
- package/compiled/@svgr/webpack/.svgo.yml +0 -75
- package/compiled/@svgr/webpack/LICENSE +0 -7
- package/compiled/@svgr/webpack/index.js +0 -343
- package/compiled/@svgr/webpack/package.json +0 -1
- 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/compiled/swc-loader/LICENSE +0 -25
- package/compiled/swc-loader/index.js +0 -1
- package/compiled/swc-loader/package.json +0 -1
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -22,7 +13,7 @@ const dev_1 = require("./dev");
|
|
|
22
13
|
const args = (0, utils_1.yParser)(process.argv.slice(2), {});
|
|
23
14
|
const command = args._[0];
|
|
24
15
|
const cwd = process.cwd();
|
|
25
|
-
const entry = tryPaths([
|
|
16
|
+
const entry = (0, utils_1.tryPaths)([
|
|
26
17
|
(0, path_1.join)(cwd, 'src/index.tsx'),
|
|
27
18
|
(0, path_1.join)(cwd, 'src/index.ts'),
|
|
28
19
|
(0, path_1.join)(cwd, 'index.tsx'),
|
|
@@ -40,11 +31,11 @@ if ((0, fs_1.existsSync)(configFile)) {
|
|
|
40
31
|
}
|
|
41
32
|
Object.assign(config, args);
|
|
42
33
|
if (command === 'build') {
|
|
43
|
-
(() =>
|
|
34
|
+
(async () => {
|
|
44
35
|
process.env.NODE_ENV = 'production';
|
|
45
36
|
(0, assert_1.default)(entry, `Build failed: entry not found.`);
|
|
46
37
|
try {
|
|
47
|
-
|
|
38
|
+
await (0, build_1.build)({
|
|
48
39
|
config,
|
|
49
40
|
cwd,
|
|
50
41
|
entry: {
|
|
@@ -55,26 +46,29 @@ if (command === 'build') {
|
|
|
55
46
|
catch (e) {
|
|
56
47
|
console.error(e);
|
|
57
48
|
}
|
|
58
|
-
})
|
|
49
|
+
})();
|
|
59
50
|
}
|
|
60
51
|
else if (command === 'dev') {
|
|
61
|
-
(() =>
|
|
52
|
+
(async () => {
|
|
62
53
|
process.env.NODE_ENV = 'development';
|
|
63
54
|
try {
|
|
64
55
|
(0, assert_1.default)(entry, `Build failed: entry not found.`);
|
|
65
|
-
|
|
56
|
+
await (0, dev_1.dev)({
|
|
66
57
|
config,
|
|
67
58
|
cwd,
|
|
68
59
|
port: process.env.PORT,
|
|
69
60
|
entry: {
|
|
70
61
|
[getEntryKey(entry)]: entry,
|
|
71
62
|
},
|
|
63
|
+
cache: {
|
|
64
|
+
buildDependencies: [].filter(Boolean),
|
|
65
|
+
},
|
|
72
66
|
});
|
|
73
67
|
}
|
|
74
68
|
catch (e) {
|
|
75
69
|
console.error(e);
|
|
76
70
|
}
|
|
77
|
-
})
|
|
71
|
+
})();
|
|
78
72
|
}
|
|
79
73
|
else {
|
|
80
74
|
error(`Unsupported command ${command}.`);
|
|
@@ -82,12 +76,6 @@ else {
|
|
|
82
76
|
function error(msg) {
|
|
83
77
|
console.error(utils_1.chalk.red(msg));
|
|
84
78
|
}
|
|
85
|
-
function tryPaths(paths) {
|
|
86
|
-
for (const path of paths) {
|
|
87
|
-
if ((0, fs_1.existsSync)(path))
|
|
88
|
-
return path;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
79
|
function getEntryKey(path) {
|
|
92
80
|
return (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
93
81
|
}
|
package/dist/client/client.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -18,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
27
|
};
|
|
@@ -37,15 +32,30 @@ const ErrorOverlay = __importStar(require("react-error-overlay"));
|
|
|
37
32
|
const constants_1 = require("../constants");
|
|
38
33
|
const formatWebpackMessages_1 = require("../utils/formatWebpackMessages");
|
|
39
34
|
console.log('[webpack] connecting...');
|
|
35
|
+
function getHost() {
|
|
36
|
+
if (process.env.SOCKET_SERVER) {
|
|
37
|
+
return new URL(process.env.SOCKET_SERVER);
|
|
38
|
+
}
|
|
39
|
+
return location;
|
|
40
|
+
}
|
|
41
|
+
function getSocketUrl() {
|
|
42
|
+
let h = getHost();
|
|
43
|
+
const host = h.host;
|
|
44
|
+
const isHttps = h.protocol === 'https:';
|
|
45
|
+
return `${isHttps ? 'wss' : 'ws'}://${host}`;
|
|
46
|
+
}
|
|
47
|
+
function getPingUrl() {
|
|
48
|
+
const h = getHost();
|
|
49
|
+
return `${h.protocol}//${h.host}/__umi_ping`;
|
|
50
|
+
}
|
|
40
51
|
let pingTimer = null;
|
|
41
|
-
const host = location.host;
|
|
42
|
-
const wsUrl = `ws://${host}`;
|
|
43
52
|
let isFirstCompilation = true;
|
|
44
53
|
let mostRecentCompilationHash = null;
|
|
45
54
|
let hasCompileErrors = false;
|
|
46
55
|
let hadRuntimeError = false;
|
|
47
|
-
const
|
|
48
|
-
socket
|
|
56
|
+
const pingUrl = getPingUrl();
|
|
57
|
+
const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
|
|
58
|
+
socket.addEventListener('message', async ({ data }) => {
|
|
49
59
|
data = JSON.parse(data);
|
|
50
60
|
if (data.type === 'connected') {
|
|
51
61
|
console.log(`[webpack] connected.`);
|
|
@@ -56,28 +66,26 @@ socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void
|
|
|
56
66
|
else {
|
|
57
67
|
handleMessage(data).catch(console.error);
|
|
58
68
|
}
|
|
59
|
-
})
|
|
60
|
-
function waitForSuccessfulPing(ms = 1000) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
yield new Promise((resolve) => setTimeout(resolve, ms));
|
|
70
|
-
}
|
|
69
|
+
});
|
|
70
|
+
async function waitForSuccessfulPing(ms = 1000) {
|
|
71
|
+
// eslint-disable-next-line no-constant-condition
|
|
72
|
+
while (true) {
|
|
73
|
+
try {
|
|
74
|
+
await fetch(pingUrl);
|
|
75
|
+
break;
|
|
71
76
|
}
|
|
72
|
-
|
|
77
|
+
catch (e) {
|
|
78
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
73
81
|
}
|
|
74
|
-
socket.addEventListener('close', () =>
|
|
82
|
+
socket.addEventListener('close', async () => {
|
|
75
83
|
if (pingTimer)
|
|
76
84
|
clearInterval(pingTimer);
|
|
77
85
|
console.info('[webpack] Dev server disconnected. Polling for restart...');
|
|
78
|
-
|
|
86
|
+
await waitForSuccessfulPing();
|
|
79
87
|
location.reload();
|
|
80
|
-
})
|
|
88
|
+
});
|
|
81
89
|
ErrorOverlay.startReportingRuntimeErrors({
|
|
82
90
|
onError: function () {
|
|
83
91
|
hadRuntimeError = true;
|
|
@@ -215,25 +223,23 @@ function tryApplyUpdates(onHotUpdateSuccess) {
|
|
|
215
223
|
handleApplyUpdates(err, null);
|
|
216
224
|
});
|
|
217
225
|
}
|
|
218
|
-
function handleMessage(payload) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
});
|
|
226
|
+
async function handleMessage(payload) {
|
|
227
|
+
// console.log('[payload]', payload);
|
|
228
|
+
switch (payload.type) {
|
|
229
|
+
case constants_1.MESSAGE_TYPE.hash:
|
|
230
|
+
handleAvailableHash(payload.data);
|
|
231
|
+
break;
|
|
232
|
+
case constants_1.MESSAGE_TYPE.stillOk:
|
|
233
|
+
case constants_1.MESSAGE_TYPE.ok:
|
|
234
|
+
handleSuccess();
|
|
235
|
+
break;
|
|
236
|
+
case constants_1.MESSAGE_TYPE.errors:
|
|
237
|
+
handleErrors(payload.data);
|
|
238
|
+
break;
|
|
239
|
+
case constants_1.MESSAGE_TYPE.warnings:
|
|
240
|
+
handleWarnings(payload.data);
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
// Do nothing
|
|
244
|
+
}
|
|
239
245
|
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addSampleFeature = void 0;
|
|
13
|
-
function addSampleFeature(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
env;
|
|
20
|
-
});
|
|
4
|
+
async function addSampleFeature(opts) {
|
|
5
|
+
const { config, userConfig, cwd, env } = opts;
|
|
6
|
+
config;
|
|
7
|
+
userConfig;
|
|
8
|
+
cwd;
|
|
9
|
+
env;
|
|
21
10
|
}
|
|
22
11
|
exports.addSampleFeature = addSampleFeature;
|
|
@@ -1,57 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addAssetRules = void 0;
|
|
13
|
-
function addAssetRules(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
4
|
+
async function addAssetRules(opts) {
|
|
5
|
+
const { config, userConfig } = opts;
|
|
6
|
+
const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
|
|
7
|
+
const rule = config.module.rule('asset');
|
|
8
|
+
rule
|
|
9
|
+
.oneOf('avif')
|
|
10
|
+
.test(/\.avif$/)
|
|
11
|
+
.type('asset')
|
|
12
|
+
.mimetype('image/avif')
|
|
13
|
+
.parser({
|
|
14
|
+
dataUrlCondition: {
|
|
15
|
+
maxSize: inlineLimit,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
.generator({
|
|
19
|
+
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
20
|
+
});
|
|
21
|
+
rule
|
|
22
|
+
.oneOf('image')
|
|
23
|
+
.test(/\.(bmp|gif|jpg|jpeg|png)$/)
|
|
24
|
+
.type('asset')
|
|
25
|
+
.parser({
|
|
26
|
+
dataUrlCondition: {
|
|
27
|
+
maxSize: inlineLimit,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
.generator({
|
|
31
|
+
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
32
|
+
});
|
|
33
|
+
const fallback = rule
|
|
34
|
+
.oneOf('fallback')
|
|
35
|
+
.exclude.add(/^$/) /* handle data: resources */
|
|
36
|
+
.add(/\.(js|mjs|jsx|ts|tsx)$/)
|
|
37
|
+
.add(/\.(css|less|sass|scss|stylus)$/)
|
|
38
|
+
.add(/\.html$/)
|
|
39
|
+
.add(/\.json$/);
|
|
40
|
+
if (userConfig.mdx) {
|
|
41
|
+
fallback.add(/\.mdx?$/);
|
|
42
|
+
}
|
|
43
|
+
fallback
|
|
44
|
+
.end()
|
|
45
|
+
.type('asset/resource')
|
|
46
|
+
.generator({
|
|
47
|
+
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
55
48
|
});
|
|
56
49
|
}
|
|
57
50
|
exports.addAssetRules = addAssetRules;
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addBundleAnalyzerPlugin = void 0;
|
|
13
4
|
// @ts-ignore
|
|
14
5
|
const webpack_bundle_analyzer_1 = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
|
|
15
|
-
function addBundleAnalyzerPlugin(opts) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]);
|
|
28
|
-
});
|
|
6
|
+
async function addBundleAnalyzerPlugin(opts) {
|
|
7
|
+
const { config } = opts;
|
|
8
|
+
config.plugin('webpack-bundle-analyzer').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin, [
|
|
9
|
+
// https://github.com/webpack-contrib/webpack-bundle-analyzer
|
|
10
|
+
{
|
|
11
|
+
analyzerMode: 'server',
|
|
12
|
+
analyzerPort: process.env.ANALYZE_PORT || 8888,
|
|
13
|
+
openAnalyzer: false,
|
|
14
|
+
logLevel: 'info',
|
|
15
|
+
defaultSizes: 'parsed',
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
29
18
|
}
|
|
30
19
|
exports.addBundleAnalyzerPlugin = addBundleAnalyzerPlugin;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,61 +8,76 @@ exports.addCompressPlugin = void 0;
|
|
|
17
8
|
const css_minimizer_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/css-minimizer-webpack-plugin"));
|
|
18
9
|
const terser_webpack_plugin_1 = __importDefault(require("../../compiled/terser-webpack-plugin"));
|
|
19
10
|
const ESBuildCSSMinifyPlugin_1 = __importDefault(require("../plugins/ESBuildCSSMinifyPlugin"));
|
|
11
|
+
const ParcelCSSMinifyPlugin_1 = require("../plugins/ParcelCSSMinifyPlugin");
|
|
20
12
|
const types_1 = require("../types");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
13
|
+
const getEsBuildTarget_1 = require("../utils/getEsBuildTarget");
|
|
14
|
+
async function addCompressPlugin(opts) {
|
|
15
|
+
const { config, userConfig, env } = opts;
|
|
16
|
+
const jsMinifier = userConfig.jsMinifier || types_1.JSMinifier.esbuild;
|
|
17
|
+
const cssMinifier = userConfig.cssMinifier || types_1.CSSMinifier.esbuild;
|
|
18
|
+
if (env === types_1.Env.development ||
|
|
19
|
+
process.env.COMPRESS === 'none' ||
|
|
20
|
+
(jsMinifier === types_1.JSMinifier.none && cssMinifier === types_1.CSSMinifier.none)) {
|
|
21
|
+
config.optimization.minimize(false);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
config.optimization.minimize(true);
|
|
25
|
+
let minify;
|
|
26
|
+
let terserOptions;
|
|
27
|
+
if (jsMinifier === types_1.JSMinifier.esbuild) {
|
|
28
|
+
minify = terser_webpack_plugin_1.default.esbuildMinify;
|
|
29
|
+
terserOptions = {
|
|
30
|
+
target: (0, getEsBuildTarget_1.getEsBuildTarget)({
|
|
31
|
+
targets: userConfig.targets || {},
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (jsMinifier === types_1.JSMinifier.terser) {
|
|
36
|
+
minify = terser_webpack_plugin_1.default.terserMinify;
|
|
37
|
+
}
|
|
38
|
+
else if (jsMinifier === types_1.JSMinifier.swc) {
|
|
39
|
+
minify = terser_webpack_plugin_1.default.swcMinify;
|
|
40
|
+
}
|
|
41
|
+
else if (jsMinifier === types_1.JSMinifier.uglifyJs) {
|
|
42
|
+
minify = terser_webpack_plugin_1.default.uglifyJsMinify;
|
|
43
|
+
}
|
|
44
|
+
else if (jsMinifier !== types_1.JSMinifier.none) {
|
|
45
|
+
throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
|
|
46
|
+
}
|
|
47
|
+
terserOptions = {
|
|
48
|
+
...terserOptions,
|
|
49
|
+
...userConfig.jsMinifierOptions,
|
|
50
|
+
};
|
|
51
|
+
if (jsMinifier !== types_1.JSMinifier.none) {
|
|
52
|
+
config.optimization.minimizer(`js-${jsMinifier}`).use(terser_webpack_plugin_1.default, [
|
|
53
|
+
{
|
|
54
|
+
minify,
|
|
55
|
+
terserOptions,
|
|
56
|
+
},
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
if (cssMinifier === types_1.CSSMinifier.esbuild) {
|
|
60
|
+
config.optimization
|
|
61
|
+
.minimizer(`css-${cssMinifier}`)
|
|
62
|
+
.use(ESBuildCSSMinifyPlugin_1.default, [userConfig.cssMinifierOptions]);
|
|
63
|
+
}
|
|
64
|
+
else if (cssMinifier === types_1.CSSMinifier.cssnano) {
|
|
65
|
+
config.optimization
|
|
66
|
+
.minimizer(`css-${cssMinifier}`)
|
|
67
|
+
.use(css_minimizer_webpack_plugin_1.default, [
|
|
68
|
+
{
|
|
69
|
+
minimizerOptions: userConfig.cssMinifierOptions,
|
|
70
|
+
parallel: true,
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
else if (cssMinifier === types_1.CSSMinifier.parcelCSS) {
|
|
75
|
+
config.optimization
|
|
76
|
+
.minimizer(`css-${cssMinifier}`)
|
|
77
|
+
.use(ParcelCSSMinifyPlugin_1.ParcelCSSMinifyPlugin);
|
|
78
|
+
}
|
|
79
|
+
else if (cssMinifier !== types_1.CSSMinifier.none) {
|
|
80
|
+
throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
exports.addCompressPlugin = addCompressPlugin;
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Configuration } from '../../compiled/webpack';
|
|
2
2
|
import { Env, IConfig } from '../types';
|
|
3
|
-
interface IOpts {
|
|
3
|
+
export interface IOpts {
|
|
4
4
|
cwd: string;
|
|
5
|
+
rootDir?: string;
|
|
5
6
|
env: Env;
|
|
6
7
|
entry: Record<string, string>;
|
|
7
8
|
extraBabelPresets?: any[];
|
|
8
9
|
extraBabelPlugins?: any[];
|
|
10
|
+
extraBabelIncludes?: string[];
|
|
11
|
+
extraEsbuildLoaderHandler?: any[];
|
|
9
12
|
babelPreset?: any;
|
|
10
13
|
chainWebpack?: Function;
|
|
11
14
|
modifyWebpackConfig?: Function;
|
|
@@ -15,6 +18,10 @@ interface IOpts {
|
|
|
15
18
|
userConfig: IConfig;
|
|
16
19
|
analyze?: any;
|
|
17
20
|
name?: string;
|
|
21
|
+
cache?: {
|
|
22
|
+
absNodeModulesPath?: string;
|
|
23
|
+
buildDependencies?: string[];
|
|
24
|
+
cacheDirectory?: string;
|
|
25
|
+
};
|
|
18
26
|
}
|
|
19
27
|
export declare function getConfig(opts: IOpts): Promise<Configuration>;
|
|
20
|
-
export {};
|