@umijs/bundler-webpack 4.0.0-canary.20220429.3 → 4.0.0-canary.20220429.4

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.
Files changed (97) hide show
  1. package/dist/build.d.ts +20 -0
  2. package/dist/build.js +75 -0
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +90 -0
  5. package/dist/client/client.d.ts +1 -0
  6. package/dist/client/client.js +258 -0
  7. package/dist/config/_sampleFeature.d.ts +10 -0
  8. package/dist/config/_sampleFeature.js +22 -0
  9. package/dist/config/assetRules.d.ts +11 -0
  10. package/dist/config/assetRules.js +61 -0
  11. package/dist/config/bundleAnalyzerPlugin.d.ts +10 -0
  12. package/dist/config/bundleAnalyzerPlugin.js +30 -0
  13. package/dist/config/compressPlugin.d.ts +10 -0
  14. package/dist/config/compressPlugin.js +91 -0
  15. package/dist/config/config.d.ts +27 -0
  16. package/dist/config/config.js +226 -0
  17. package/dist/config/copyPlugin.d.ts +10 -0
  18. package/dist/config/copyPlugin.js +49 -0
  19. package/dist/config/cssRules.d.ts +11 -0
  20. package/dist/config/cssRules.js +98 -0
  21. package/dist/config/definePlugin.d.ts +15 -0
  22. package/dist/config/definePlugin.js +45 -0
  23. package/dist/config/detectDeadCode.d.ts +12 -0
  24. package/dist/config/detectDeadCode.js +120 -0
  25. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  26. package/dist/config/detectDeadCodePlugin.js +75 -0
  27. package/dist/config/fastRefreshPlugin.d.ts +12 -0
  28. package/dist/config/fastRefreshPlugin.js +34 -0
  29. package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
  30. package/dist/config/forkTSCheckerPlugin.js +34 -0
  31. package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
  32. package/dist/config/harmonyLinkingErrorPlugin.js +42 -0
  33. package/dist/config/ignorePlugin.d.ts +10 -0
  34. package/dist/config/ignorePlugin.js +27 -0
  35. package/dist/config/javaScriptRules.d.ts +16 -0
  36. package/dist/config/javaScriptRules.js +188 -0
  37. package/dist/config/manifestPlugin.d.ts +11 -0
  38. package/dist/config/manifestPlugin.js +25 -0
  39. package/dist/config/miniCSSExtractPlugin.d.ts +11 -0
  40. package/dist/config/miniCSSExtractPlugin.js +33 -0
  41. package/dist/config/nodePolyfill.d.ts +10 -0
  42. package/dist/config/nodePolyfill.js +35 -0
  43. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  44. package/dist/config/nodePrefixPlugin.js +25 -0
  45. package/dist/config/progressPlugin.d.ts +11 -0
  46. package/dist/config/progressPlugin.js +27 -0
  47. package/dist/config/purgecssWebpackPlugin.d.ts +10 -0
  48. package/dist/config/purgecssWebpackPlugin.js +32 -0
  49. package/dist/config/speedMeasureWebpackPlugin.d.ts +6 -0
  50. package/dist/config/speedMeasureWebpackPlugin.js +34 -0
  51. package/dist/config/svgRules.d.ts +12 -0
  52. package/dist/config/svgRules.js +57 -0
  53. package/dist/constants.d.ts +15 -0
  54. package/dist/constants.js +24 -0
  55. package/dist/dev.d.ts +25 -0
  56. package/dist/dev.js +145 -0
  57. package/dist/index.d.ts +8 -0
  58. package/dist/index.js +20 -0
  59. package/dist/loader/svgr.d.ts +4 -0
  60. package/dist/loader/svgr.js +67 -0
  61. package/dist/loader/swc.d.ts +4 -0
  62. package/dist/loader/swc.js +79 -0
  63. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +11 -0
  64. package/dist/plugins/ESBuildCSSMinifyPlugin.js +63 -0
  65. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
  66. package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
  67. package/dist/plugins/ProgressPlugin.d.ts +15 -0
  68. package/dist/plugins/ProgressPlugin.js +44 -0
  69. package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
  70. package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
  71. package/dist/plugins/_SamplePlugin.d.ts +9 -0
  72. package/dist/plugins/_SamplePlugin.js +14 -0
  73. package/dist/requireHook.d.ts +1 -0
  74. package/dist/requireHook.js +31 -0
  75. package/dist/schema.d.ts +3 -0
  76. package/dist/schema.js +84 -0
  77. package/dist/server/server.d.ts +17 -0
  78. package/dist/server/server.js +202 -0
  79. package/dist/server/ws.d.ts +11 -0
  80. package/dist/server/ws.js +42 -0
  81. package/dist/swcPlugins/autoCSSModules.d.ts +13 -0
  82. package/dist/swcPlugins/autoCSSModules.js +34 -0
  83. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  84. package/dist/swcPlugins/changeImportFromString.js +10 -0
  85. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  86. package/dist/swcPlugins/lockCoreJS.js +24 -0
  87. package/dist/types.d.ts +119 -0
  88. package/dist/types.js +30 -0
  89. package/dist/utils/browsersList.d.ts +5 -0
  90. package/dist/utils/browsersList.js +10 -0
  91. package/dist/utils/depMatch.d.ts +6 -0
  92. package/dist/utils/depMatch.js +46 -0
  93. package/dist/utils/formatWebpackMessages.d.ts +12 -0
  94. package/dist/utils/formatWebpackMessages.js +100 -0
  95. package/dist/utils/getEsBuildTarget.d.ts +5 -0
  96. package/dist/utils/getEsBuildTarget.js +12 -0
  97. package/package.json +5 -5
@@ -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,5 @@
1
+ interface IOpts {
2
+ targets: Record<string, any>;
3
+ }
4
+ export declare function getEsBuildTarget({ targets }: IOpts): string[];
5
+ export {};
@@ -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.20220429.3",
3
+ "version": "4.0.0-canary.20220429.4",
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.20220429.3",
39
- "@umijs/bundler-utils": "4.0.0-canary.20220429.3",
40
- "@umijs/mfsu": "4.0.0-canary.20220429.3",
41
- "@umijs/utils": "4.0.0-canary.20220429.3",
38
+ "@umijs/babel-preset-umi": "4.0.0-canary.20220429.4",
39
+ "@umijs/bundler-utils": "4.0.0-canary.20220429.4",
40
+ "@umijs/mfsu": "4.0.0-canary.20220429.4",
41
+ "@umijs/utils": "4.0.0-canary.20220429.4",
42
42
  "css-loader": "6.7.1",
43
43
  "es5-imcompatible-versions": "^0.1.73",
44
44
  "jest-worker": "27.5.1",