@umijs/bundler-webpack 4.0.0-canary.20220429.3 → 4.0.0-canary.20220506.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/dist/build.d.ts +20 -0
- package/dist/build.js +64 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +81 -0
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.js +245 -0
- package/dist/config/_sampleFeature.d.ts +10 -0
- package/dist/config/_sampleFeature.js +11 -0
- package/dist/config/assetRules.d.ts +11 -0
- package/dist/config/assetRules.js +50 -0
- package/dist/config/bundleAnalyzerPlugin.d.ts +10 -0
- package/dist/config/bundleAnalyzerPlugin.js +19 -0
- package/dist/config/compressPlugin.d.ts +10 -0
- package/dist/config/compressPlugin.js +83 -0
- package/dist/config/config.d.ts +27 -0
- package/dist/config/config.js +218 -0
- package/dist/config/copyPlugin.d.ts +10 -0
- package/dist/config/copyPlugin.js +38 -0
- package/dist/config/cssRules.d.ts +11 -0
- package/dist/config/cssRules.js +108 -0
- package/dist/config/definePlugin.d.ts +15 -0
- package/dist/config/definePlugin.js +37 -0
- 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.d.ts +12 -0
- package/dist/config/fastRefreshPlugin.js +23 -0
- 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.d.ts +10 -0
- package/dist/config/ignorePlugin.js +16 -0
- package/dist/config/javaScriptRules.d.ts +16 -0
- package/dist/config/javaScriptRules.js +177 -0
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +17 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +11 -0
- package/dist/config/miniCSSExtractPlugin.js +22 -0
- package/dist/config/nodePolyfill.d.ts +10 -0
- package/dist/config/nodePolyfill.js +28 -0
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.d.ts +11 -0
- package/dist/config/progressPlugin.js +16 -0
- package/dist/config/purgecssWebpackPlugin.d.ts +10 -0
- package/dist/config/purgecssWebpackPlugin.js +21 -0
- package/dist/config/speedMeasureWebpackPlugin.d.ts +6 -0
- package/dist/config/speedMeasureWebpackPlugin.js +23 -0
- package/dist/config/svgRules.d.ts +12 -0
- package/dist/config/svgRules.js +53 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +24 -0
- package/dist/dev.d.ts +25 -0
- package/dist/dev.js +134 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +20 -0
- 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.d.ts +11 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +52 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +73 -0
- package/dist/plugins/ProgressPlugin.d.ts +15 -0
- package/dist/plugins/ProgressPlugin.js +44 -0
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
- package/dist/plugins/_SamplePlugin.d.ts +9 -0
- package/dist/plugins/_SamplePlugin.js +14 -0
- package/dist/requireHook.d.ts +1 -0
- package/dist/requireHook.js +31 -0
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +84 -0
- package/dist/server/server.d.ts +17 -0
- package/dist/server/server.js +193 -0
- package/dist/server/ws.d.ts +11 -0
- package/dist/server/ws.js +42 -0
- package/dist/swcPlugins/autoCSSModules.d.ts +13 -0
- package/dist/swcPlugins/autoCSSModules.js +34 -0
- 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 +119 -0
- package/dist/types.js +30 -0
- package/dist/utils/browsersList.d.ts +5 -0
- package/dist/utils/browsersList.js +10 -0
- package/dist/utils/depMatch.d.ts +6 -0
- package/dist/utils/depMatch.js +46 -0
- package/dist/utils/formatWebpackMessages.d.ts +12 -0
- package/dist/utils/formatWebpackMessages.js +100 -0
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +5 -5
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function formatMessage(message: string | {
|
|
2
|
+
message: string;
|
|
3
|
+
} | {
|
|
4
|
+
message: string;
|
|
5
|
+
}[]): string;
|
|
6
|
+
export declare function formatWebpackMessages(json: {
|
|
7
|
+
errors: string[];
|
|
8
|
+
warnings: string[];
|
|
9
|
+
}): {
|
|
10
|
+
errors: string[];
|
|
11
|
+
warnings: string[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatWebpackMessages = exports.formatMessage = void 0;
|
|
7
|
+
const strip_ansi_1 = __importDefault(require("@umijs/utils/compiled/strip-ansi"));
|
|
8
|
+
const friendlySyntaxErrorLabel = 'Syntax error:';
|
|
9
|
+
function isLikelyASyntaxError(message) {
|
|
10
|
+
return (0, strip_ansi_1.default)(message).indexOf(friendlySyntaxErrorLabel) !== -1;
|
|
11
|
+
}
|
|
12
|
+
function formatMessage(message) {
|
|
13
|
+
let lines = [];
|
|
14
|
+
if (typeof message === 'string') {
|
|
15
|
+
lines = message.split('\n');
|
|
16
|
+
}
|
|
17
|
+
else if ('message' in message) {
|
|
18
|
+
lines = message['message'].split('\n');
|
|
19
|
+
}
|
|
20
|
+
else if (Array.isArray(message)) {
|
|
21
|
+
message.forEach((message) => {
|
|
22
|
+
if ('message' in message) {
|
|
23
|
+
lines = message['message'].split('\n');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// Strip webpack-added headers off errors/warnings
|
|
28
|
+
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
|
|
29
|
+
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
|
|
30
|
+
// Transform parsing error into syntax error
|
|
31
|
+
// TODO: move this to our ESLint formatter?
|
|
32
|
+
lines = lines.map((line) => {
|
|
33
|
+
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
|
|
34
|
+
if (!parsingError) {
|
|
35
|
+
return line;
|
|
36
|
+
}
|
|
37
|
+
const [, errorLine, errorColumn, errorMessage] = parsingError;
|
|
38
|
+
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
|
39
|
+
});
|
|
40
|
+
message = lines.join('\n');
|
|
41
|
+
// Smoosh syntax errors (commonly found in CSS)
|
|
42
|
+
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`);
|
|
43
|
+
// Clean up export errors
|
|
44
|
+
message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
|
|
45
|
+
message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
|
|
46
|
+
message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
|
|
47
|
+
lines = message.split('\n');
|
|
48
|
+
// Remove leading newline
|
|
49
|
+
if (lines.length > 2 && lines[1].trim() === '') {
|
|
50
|
+
lines.splice(1, 1);
|
|
51
|
+
}
|
|
52
|
+
// Clean up file name
|
|
53
|
+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
|
|
54
|
+
// Cleans up verbose "module not found" messages for files and packages.
|
|
55
|
+
if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
|
|
56
|
+
lines = [
|
|
57
|
+
lines[0],
|
|
58
|
+
lines[1]
|
|
59
|
+
.replace('Error: ', '')
|
|
60
|
+
.replace('Module not found: Cannot find file:', 'Cannot find file:'),
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
// Add helpful message for users trying to use Sass for the first time
|
|
64
|
+
if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
|
|
65
|
+
lines[1] = 'To import Sass files, you first need to install sass.\n';
|
|
66
|
+
lines[1] +=
|
|
67
|
+
'Run `npm install sass` or `yarn add sass` inside your workspace.';
|
|
68
|
+
}
|
|
69
|
+
message = lines.join('\n');
|
|
70
|
+
// Internal stacks are generally useless so we strip them... with the
|
|
71
|
+
// exception of stacks containing `webpack:` because they're normally
|
|
72
|
+
// from user code generated by webpack. For more information see
|
|
73
|
+
// https://github.com/facebook/create-react-app/pull/1050
|
|
74
|
+
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
|
|
75
|
+
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
|
|
76
|
+
lines = message.split('\n');
|
|
77
|
+
// Remove duplicated newlines
|
|
78
|
+
lines = lines.filter((line, index, arr) => index === 0 ||
|
|
79
|
+
line.trim() !== '' ||
|
|
80
|
+
line.trim() !== arr[index - 1].trim());
|
|
81
|
+
// Reassemble the message
|
|
82
|
+
message = lines.join('\n');
|
|
83
|
+
return message.trim();
|
|
84
|
+
}
|
|
85
|
+
exports.formatMessage = formatMessage;
|
|
86
|
+
function formatWebpackMessages(json) {
|
|
87
|
+
const formattedErrors = json.errors.map(function (message) {
|
|
88
|
+
return formatMessage(message);
|
|
89
|
+
});
|
|
90
|
+
const formattedWarnings = json.warnings.map(function (message) {
|
|
91
|
+
return formatMessage(message);
|
|
92
|
+
});
|
|
93
|
+
const result = { errors: formattedErrors, warnings: formattedWarnings };
|
|
94
|
+
if (result.errors.some(isLikelyASyntaxError)) {
|
|
95
|
+
// If there are any syntax errors, show just them.
|
|
96
|
+
result.errors = result.errors.filter(isLikelyASyntaxError);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
exports.formatWebpackMessages = formatWebpackMessages;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEsBuildTarget = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function getEsBuildTarget({ targets }) {
|
|
6
|
+
return Object.keys(targets)
|
|
7
|
+
.filter((key) => constants_1.DEFAULT_ESBUILD_TARGET_KEYS.includes(key))
|
|
8
|
+
.map((key) => {
|
|
9
|
+
return `${key}${targets[key] === true ? '0' : targets[key]}`;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.getEsBuildTarget = getEsBuildTarget;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220506.2",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@svgr/plugin-jsx": "^6.2.1",
|
|
36
36
|
"@svgr/plugin-svgo": "^6.2.0",
|
|
37
37
|
"@types/hapi__joi": "17.1.8",
|
|
38
|
-
"@umijs/babel-preset-umi": "4.0.0-canary.
|
|
39
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
40
|
-
"@umijs/mfsu": "4.0.0-canary.
|
|
41
|
-
"@umijs/utils": "4.0.0-canary.
|
|
38
|
+
"@umijs/babel-preset-umi": "4.0.0-canary.20220506.2",
|
|
39
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220506.2",
|
|
40
|
+
"@umijs/mfsu": "4.0.0-canary.20220506.2",
|
|
41
|
+
"@umijs/utils": "4.0.0-canary.20220506.2",
|
|
42
42
|
"css-loader": "6.7.1",
|
|
43
43
|
"es5-imcompatible-versions": "^0.1.73",
|
|
44
44
|
"jest-worker": "27.5.1",
|