@umijs/bundler-webpack 4.0.0-beta.9 → 4.0.0-canary-20240513.3
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 +255 -167
- package/client/constants.d.ts +15 -0
- package/client/constants.js +30 -12
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +87 -86
- package/compiled/autoprefixer/browserslist/index.d.ts +33 -7
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/package.json +1 -1
- 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 +6 -5
- 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 +8 -2
- package/compiled/babel-loader/package.json +1 -1
- 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 +23 -22
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +305 -54
- package/compiled/cssnano/index.js +12 -11
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/file-loader/index.js +3 -0
- package/compiled/file-loader/package.json +1 -0
- package/compiled/less-loader/index.js +1 -1
- package/compiled/less-loader/package.json +1 -1
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -46
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +10 -6
- package/compiled/mini-css-extract-plugin/index.js +10669 -10348
- package/compiled/mini-css-extract-plugin/loader.js +159 -100
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +88 -44
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/sass-loader/sass.default.dart.js +4 -0
- 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/stylus-loader/LICENSE +20 -0
- package/compiled/stylus-loader/index.js +44 -0
- package/compiled/stylus-loader/package.json +1 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser/index.js +1 -1
- package/compiled/terser/package.json +1 -1
- package/compiled/terser/tools/terser.d.ts +6 -3
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser-webpack-plugin/index.js +1390 -3693
- 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 +186 -152
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +20 -24
- package/compiled/terser-webpack-plugin/utils.js +153 -34
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicEvaluatedExpression.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/ExternalsPlugin.js +1 -0
- package/compiled/webpack/FetchCompileAsyncWasmPlugin.js +1 -0
- package/compiled/webpack/FetchCompileWasmPlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/LimitChunkCountPlugin.js +1 -0
- package/compiled/webpack/NodeTargetPlugin.js +1 -0
- package/compiled/webpack/NodeTemplatePlugin.js +1 -0
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/StringXor.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/WebWorkerTemplatePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +15 -1
- package/compiled/webpack/index.js +26404 -10329
- package/compiled/webpack/json-schema/index.d.ts +8 -1
- package/compiled/webpack/lazy-compilation-node.js +10 -0
- package/compiled/webpack/lazy-compilation-web.js +9 -0
- package/compiled/webpack/types.d.ts +823 -287
- package/compiled/webpack-5-chain/index.js +1 -1
- package/compiled/webpack-5-chain/package.json +1 -1
- package/compiled/webpack-5-chain/types/index.d.ts +76 -20
- package/compiled/webpack-bundle-analyzer/index.js +7 -6
- package/compiled/webpack-bundle-analyzer/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
- package/compiled/webpack-dev-middleware/index.js +12 -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/{express → webpackbar}/LICENSE +1 -5
- package/compiled/webpackbar/dist/index.d.ts +121 -0
- package/compiled/webpackbar/index.js +7 -0
- package/compiled/webpackbar/package.json +1 -0
- package/compiled/ws/LICENSE +13 -12
- package/compiled/ws/index.d.ts +74 -35
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.d.ts +8 -3
- package/dist/build.js +147 -68
- package/dist/cli.js +84 -81
- package/dist/config/_sampleFeature.js +33 -20
- package/dist/config/assetRules.js +46 -67
- package/dist/config/bundleAnalyzerPlugin.js +41 -28
- package/dist/config/compressPlugin.js +125 -74
- package/dist/config/config.d.ts +11 -2
- package/dist/config/config.js +235 -172
- package/dist/config/copyPlugin.js +61 -47
- package/dist/config/cssRules.js +162 -95
- package/dist/config/definePlugin.d.ts +2 -0
- package/dist/config/definePlugin.js +59 -39
- package/dist/config/detectCssModulesInDependence.d.ts +10 -0
- package/dist/config/detectCssModulesInDependence.js +151 -0
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +191 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +82 -0
- package/dist/config/fastRefreshPlugin.js +46 -31
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +49 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
- package/dist/config/ignorePlugin.js +38 -25
- package/dist/config/javaScriptRules.d.ts +2 -0
- package/dist/config/javaScriptRules.js +186 -150
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +40 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +52 -31
- package/dist/config/nodePolyfill.js +49 -32
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +38 -0
- package/dist/config/progressPlugin.js +50 -24
- package/dist/config/purgecssWebpackPlugin.js +41 -30
- package/dist/config/speedMeasureWebpackPlugin.js +56 -31
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +98 -0
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +68 -41
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +59 -15
- package/dist/dev.d.ts +23 -2
- package/dist/dev.js +198 -81
- package/dist/index.d.ts +6 -1
- package/dist/index.js +31 -15
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +84 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +149 -0
- package/dist/parcelCSS.d.ts +2 -0
- package/dist/parcelCSS.js +39 -0
- package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
- package/dist/plugins/EsbuildMinifyFix.js +136 -0
- package/dist/plugins/ProgressPlugin.js +68 -43
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +37 -14
- package/dist/requireHook.js +44 -27
- package/dist/schema.d.ts +4 -3
- package/dist/schema.js +175 -69
- package/dist/server/server.d.ts +4 -3
- package/dist/server/server.js +219 -154
- package/dist/server/ws.d.ts +8 -3
- package/dist/server/ws.js +72 -38
- package/dist/swcPlugins/autoCSSModules.d.ts +11 -2
- package/dist/swcPlugins/autoCSSModules.js +60 -32
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +32 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +56 -0
- package/dist/types.d.ts +53 -9
- package/dist/types.js +61 -29
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +65 -39
- package/dist/utils/formatWebpackMessages.js +119 -91
- package/dist/utils/getEsBuildTarget.d.ts +7 -0
- package/dist/utils/getEsBuildTarget.js +46 -0
- package/dist/utils/pkgUpContainsName.d.ts +1 -0
- package/dist/utils/pkgUpContainsName.js +50 -0
- package/package.json +76 -68
- package/compiled/@svgr/webpack/LICENSE +0 -7
- package/compiled/@svgr/webpack/index.js +0 -266
- package/compiled/@svgr/webpack/package.json +0 -1
- 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/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/http-proxy-middleware/LICENSE +0 -22
- package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
- package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
- package/compiled/http-proxy-middleware/index.js +0 -66
- package/compiled/http-proxy-middleware/package.json +0 -1
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- package/compiled/react-refresh/index.js +0 -19
- 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/client/client.js +0 -239
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
- /package/{dist → client}/client/client.d.ts +0 -0
- /package/compiled/{css-loader → file-loader}/LICENSE +0 -0
|
@@ -1,92 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/utils/formatWebpackMessages.ts
|
|
2
|
+
import stripAnsi from "@umijs/utils/compiled/strip-ansi";
|
|
3
|
+
var friendlySyntaxErrorLabel = "Syntax error:";
|
|
3
4
|
function isLikelyASyntaxError(message) {
|
|
4
|
-
|
|
5
|
+
return stripAnsi(message).indexOf(friendlySyntaxErrorLabel) !== -1;
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
message.
|
|
16
|
-
|
|
17
|
-
lines = message['message'].split('\n');
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
// Strip webpack-added headers off errors/warnings
|
|
22
|
-
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
|
|
23
|
-
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
|
|
24
|
-
// Transform parsing error into syntax error
|
|
25
|
-
// TODO: move this to our ESLint formatter?
|
|
26
|
-
lines = lines.map((line) => {
|
|
27
|
-
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
|
|
28
|
-
if (!parsingError) {
|
|
29
|
-
return line;
|
|
30
|
-
}
|
|
31
|
-
const [, errorLine, errorColumn, errorMessage] = parsingError;
|
|
32
|
-
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
|
7
|
+
function formatMessage(message) {
|
|
8
|
+
let lines = [];
|
|
9
|
+
if (typeof message === "string") {
|
|
10
|
+
lines = message.split("\n");
|
|
11
|
+
} else if ("message" in message) {
|
|
12
|
+
lines = message["message"].split("\n");
|
|
13
|
+
} else if (Array.isArray(message)) {
|
|
14
|
+
message.forEach((message2) => {
|
|
15
|
+
if ("message" in message2) {
|
|
16
|
+
lines = message2["message"].split("\n");
|
|
17
|
+
}
|
|
33
18
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Remove leading newline
|
|
43
|
-
if (lines.length > 2 && lines[1].trim() === '') {
|
|
44
|
-
lines.splice(1, 1);
|
|
45
|
-
}
|
|
46
|
-
// Clean up file name
|
|
47
|
-
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
|
|
48
|
-
// Cleans up verbose "module not found" messages for files and packages.
|
|
49
|
-
if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
|
|
50
|
-
lines = [
|
|
51
|
-
lines[0],
|
|
52
|
-
lines[1]
|
|
53
|
-
.replace('Error: ', '')
|
|
54
|
-
.replace('Module not found: Cannot find file:', 'Cannot find file:'),
|
|
55
|
-
];
|
|
19
|
+
}
|
|
20
|
+
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
|
|
21
|
+
lines = lines.map((line) => {
|
|
22
|
+
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
|
23
|
+
line
|
|
24
|
+
);
|
|
25
|
+
if (!parsingError) {
|
|
26
|
+
return line;
|
|
56
27
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
28
|
+
const [, errorLine, errorColumn, errorMessage] = parsingError;
|
|
29
|
+
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
|
30
|
+
});
|
|
31
|
+
message = lines.join("\n");
|
|
32
|
+
message = message.replace(
|
|
33
|
+
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
|
34
|
+
`${friendlySyntaxErrorLabel} $3 ($1:$2)
|
|
35
|
+
`
|
|
36
|
+
);
|
|
37
|
+
message = message.replace(
|
|
38
|
+
/^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
|
|
39
|
+
`Attempted import error: '$1' is not exported from '$2'.`
|
|
40
|
+
);
|
|
41
|
+
message = message.replace(
|
|
42
|
+
/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
|
|
43
|
+
`Attempted import error: '$2' does not contain a default export (imported as '$1').`
|
|
44
|
+
);
|
|
45
|
+
message = message.replace(
|
|
46
|
+
/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
|
|
47
|
+
`Attempted import error: '$1' is not exported from '$3' (imported as '$2').`
|
|
48
|
+
);
|
|
49
|
+
lines = message.split("\n");
|
|
50
|
+
if (lines.length > 2 && lines[1].trim() === "") {
|
|
51
|
+
lines.splice(1, 1);
|
|
52
|
+
}
|
|
53
|
+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
|
54
|
+
if (lines[1] && lines[1].indexOf("Module not found: ") === 0) {
|
|
55
|
+
lines = [
|
|
56
|
+
lines[0],
|
|
57
|
+
lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:")
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
|
|
61
|
+
lines[1] = "To import Sass files, you first need to install sass.\n";
|
|
62
|
+
lines[1] += "Run `npm install sass` or `yarn add sass` inside your workspace.";
|
|
63
|
+
}
|
|
64
|
+
message = lines.join("\n");
|
|
65
|
+
message = message.replace(
|
|
66
|
+
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
|
|
67
|
+
""
|
|
68
|
+
);
|
|
69
|
+
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
|
|
70
|
+
lines = message.split("\n");
|
|
71
|
+
lines = lines.filter(
|
|
72
|
+
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
|
73
|
+
);
|
|
74
|
+
message = lines.join("\n");
|
|
75
|
+
return message.trim();
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return result;
|
|
77
|
+
function formatWebpackMessages(json) {
|
|
78
|
+
const formattedErrors = json.errors.map(function(message) {
|
|
79
|
+
return formatMessage(message);
|
|
80
|
+
});
|
|
81
|
+
const formattedWarnings = json.warnings.map(function(message) {
|
|
82
|
+
return formatMessage(message);
|
|
83
|
+
});
|
|
84
|
+
const result = { errors: formattedErrors, warnings: formattedWarnings };
|
|
85
|
+
if (result.errors.some(isLikelyASyntaxError)) {
|
|
86
|
+
result.errors = result.errors.filter(isLikelyASyntaxError);
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
92
89
|
}
|
|
90
|
+
export {
|
|
91
|
+
formatMessage,
|
|
92
|
+
formatWebpackMessages
|
|
93
|
+
};
|
|
@@ -6,14 +6,22 @@
|
|
|
6
6
|
* ```
|
|
7
7
|
*
|
|
8
8
|
* @param queries Browser queries.
|
|
9
|
+
* @param opts Options.
|
|
9
10
|
* @returns Array with browser names in Can I Use.
|
|
10
11
|
*/
|
|
11
|
-
declare function browserslist
|
|
12
|
+
declare function browserslist(
|
|
12
13
|
queries?: string | readonly string[] | null,
|
|
13
14
|
opts?: browserslist.Options
|
|
14
15
|
): string[]
|
|
15
16
|
|
|
16
17
|
declare namespace browserslist {
|
|
18
|
+
interface Query {
|
|
19
|
+
compose: 'or' | 'and'
|
|
20
|
+
type: string
|
|
21
|
+
query: string
|
|
22
|
+
not?: true
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
interface Options {
|
|
18
26
|
/**
|
|
19
27
|
* Path to processed file. It will be used to find config files.
|
|
@@ -36,6 +44,10 @@ declare namespace browserslist {
|
|
|
36
44
|
* Do not throw on unknown version in direct query.
|
|
37
45
|
*/
|
|
38
46
|
ignoreUnknownVersions?: boolean
|
|
47
|
+
/**
|
|
48
|
+
* Throw an error if env is not found.
|
|
49
|
+
*/
|
|
50
|
+
throwOnMissing?: boolean
|
|
39
51
|
/**
|
|
40
52
|
* Disable security checks for extend query.
|
|
41
53
|
*/
|
|
@@ -98,6 +110,8 @@ declare namespace browserslist {
|
|
|
98
110
|
| undefined
|
|
99
111
|
}
|
|
100
112
|
|
|
113
|
+
let nodeVersions: string[]
|
|
114
|
+
|
|
101
115
|
interface Usage {
|
|
102
116
|
[version: string]: number
|
|
103
117
|
}
|
|
@@ -136,15 +150,27 @@ declare namespace browserslist {
|
|
|
136
150
|
* @param stats Which statistics should be used.
|
|
137
151
|
* @returns Total market coverage for all selected browsers.
|
|
138
152
|
*/
|
|
139
|
-
function coverage
|
|
153
|
+
function coverage(browsers: readonly string[], stats?: StatsOptions): number
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get queries AST to analyze the config content.
|
|
157
|
+
*
|
|
158
|
+
* @param queries Browser queries.
|
|
159
|
+
* @param opts Options.
|
|
160
|
+
* @returns An array of the data of each query in the config.
|
|
161
|
+
*/
|
|
162
|
+
function parse(
|
|
163
|
+
queries?: string | readonly string[] | null,
|
|
164
|
+
opts?: browserslist.Options
|
|
165
|
+
): Query[]
|
|
140
166
|
|
|
141
|
-
function clearCaches
|
|
167
|
+
function clearCaches(): void
|
|
142
168
|
|
|
143
|
-
function parseConfig
|
|
169
|
+
function parseConfig(string: string): Config
|
|
144
170
|
|
|
145
|
-
function readConfig
|
|
171
|
+
function readConfig(file: string): Config
|
|
146
172
|
|
|
147
|
-
function findConfig
|
|
173
|
+
function findConfig(...pathSegments: string[]): Config | undefined
|
|
148
174
|
|
|
149
175
|
interface LoadConfigOptions {
|
|
150
176
|
config?: string
|
|
@@ -152,7 +178,7 @@ declare namespace browserslist {
|
|
|
152
178
|
env?: string
|
|
153
179
|
}
|
|
154
180
|
|
|
155
|
-
function loadConfig
|
|
181
|
+
function loadConfig(options: LoadConfigOptions): string[] | undefined
|
|
156
182
|
}
|
|
157
183
|
|
|
158
184
|
declare global {
|