@modern-js/utils 2.4.0 → 2.5.0

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 (102) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/FileSizeReporter.d.ts +5 -5
  3. package/dist/FileSizeReporter.js +143 -136
  4. package/dist/alias.d.ts +14 -12
  5. package/dist/alias.js +94 -54
  6. package/dist/analyzeProject.d.ts +1 -1
  7. package/dist/analyzeProject.js +58 -33
  8. package/dist/applyOptionsChain.d.ts +1 -1
  9. package/dist/applyOptionsChain.js +55 -27
  10. package/dist/chainId.d.ts +256 -184
  11. package/dist/chainId.js +132 -187
  12. package/dist/clearConsole.d.ts +1 -1
  13. package/dist/clearConsole.js +29 -7
  14. package/dist/commands.d.ts +1 -1
  15. package/dist/commands.js +33 -10
  16. package/dist/compatRequire.d.ts +3 -3
  17. package/dist/compatRequire.js +74 -38
  18. package/dist/compiled.d.ts +2 -1
  19. package/dist/compiled.js +137 -72
  20. package/dist/constants.d.ts +131 -105
  21. package/dist/constants.js +298 -277
  22. package/dist/debug.d.ts +1 -1
  23. package/dist/debug.js +28 -11
  24. package/dist/emptyDir.d.ts +1 -1
  25. package/dist/emptyDir.js +51 -9
  26. package/dist/ensureAbsolutePath.d.ts +1 -1
  27. package/dist/ensureAbsolutePath.js +33 -14
  28. package/dist/ensureArray.d.ts +1 -1
  29. package/dist/ensureArray.js +30 -8
  30. package/dist/findExists.d.ts +1 -1
  31. package/dist/findExists.js +37 -17
  32. package/dist/format.d.ts +3 -3
  33. package/dist/format.js +93 -81
  34. package/dist/generateMetaTags.d.ts +3 -3
  35. package/dist/generateMetaTags.js +56 -43
  36. package/dist/getBrowserslist.d.ts +1 -1
  37. package/dist/getBrowserslist.js +31 -7
  38. package/dist/getCoreJsVersion.d.ts +1 -1
  39. package/dist/getCoreJsVersion.js +39 -35
  40. package/dist/getEntryOptions.d.ts +1 -1
  41. package/dist/getEntryOptions.js +51 -24
  42. package/dist/getPackageManager.d.ts +1 -1
  43. package/dist/getPackageManager.js +75 -28
  44. package/dist/getPort.d.ts +7 -4
  45. package/dist/getPort.js +104 -58
  46. package/dist/getServerConfig.d.ts +1 -1
  47. package/dist/getServerConfig.js +61 -32
  48. package/dist/import.d.ts +2 -2
  49. package/dist/import.js +31 -8
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.js +59 -59
  52. package/dist/is/index.d.ts +12 -1
  53. package/dist/is/index.js +83 -82
  54. package/dist/is/node-env.d.ts +1 -1
  55. package/dist/is/node-env.js +39 -17
  56. package/dist/is/platform.d.ts +1 -1
  57. package/dist/is/platform.js +30 -10
  58. package/dist/is/type.d.ts +1 -1
  59. package/dist/is/type.js +48 -22
  60. package/dist/logger.d.ts +48 -48
  61. package/dist/logger.js +127 -95
  62. package/dist/monorepo.d.ts +3 -3
  63. package/dist/monorepo.js +117 -74
  64. package/dist/nodeEnv.d.ts +1 -1
  65. package/dist/nodeEnv.js +72 -25
  66. package/dist/path.d.ts +3 -1
  67. package/dist/path.js +76 -59
  68. package/dist/pathSerializer.d.ts +6 -6
  69. package/dist/pathSerializer.js +65 -43
  70. package/dist/plugin.d.ts +1 -1
  71. package/dist/plugin.js +45 -26
  72. package/dist/prettyInstructions.d.ts +4 -4
  73. package/dist/prettyInstructions.js +107 -65
  74. package/dist/printBuildError.d.ts +1 -1
  75. package/dist/printBuildError.js +54 -40
  76. package/dist/react.d.ts +1 -1
  77. package/dist/react.js +57 -21
  78. package/dist/readTsConfig.d.ts +1 -1
  79. package/dist/readTsConfig.js +38 -12
  80. package/dist/removeSlash.d.ts +1 -1
  81. package/dist/removeSlash.js +33 -9
  82. package/dist/routes.d.ts +1 -1
  83. package/dist/routes.js +49 -22
  84. package/dist/runtimeExports.d.ts +3 -3
  85. package/dist/runtimeExports.js +59 -39
  86. package/dist/ssr.d.ts +2 -1
  87. package/dist/ssr.js +30 -7
  88. package/dist/storage.d.ts +3 -3
  89. package/dist/storage.js +65 -59
  90. package/dist/test-utils.d.ts +1 -1
  91. package/dist/test-utils.js +30 -24
  92. package/dist/tryResolve.d.ts +2 -1
  93. package/dist/tryResolve.js +45 -33
  94. package/dist/types.d.ts +1 -1
  95. package/dist/types.js +15 -2
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +83 -24
  98. package/dist/wait.d.ts +1 -1
  99. package/dist/wait.js +28 -6
  100. package/dist/watch.d.ts +3 -3
  101. package/dist/watch.js +82 -55
  102. package/package.json +7 -8
package/dist/emptyDir.js CHANGED
@@ -1,10 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emptyDir = void 0;
4
- const compiled_1 = require("./compiled");
5
- const emptyDir = async (dir) => {
6
- if (await compiled_1.fs.pathExists(dir)) {
7
- await compiled_1.fs.emptyDir(dir);
8
- }
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
9
8
  };
10
- exports.emptyDir = emptyDir;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+ var emptyDir_exports = {};
39
+ __export(emptyDir_exports, {
40
+ emptyDir: () => emptyDir
41
+ });
42
+ module.exports = __toCommonJS(emptyDir_exports);
43
+ var import_compiled = require("./compiled");
44
+ const emptyDir = (dir) => __async(void 0, null, function* () {
45
+ if (yield import_compiled.fs.pathExists(dir)) {
46
+ yield import_compiled.fs.emptyDir(dir);
47
+ }
48
+ });
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ emptyDir
52
+ });
@@ -4,4 +4,4 @@
4
4
  * @param filePath - Absolute or relative file path.
5
5
  * @returns Resolved absolute file path.
6
6
  */
7
- export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
7
+ export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
@@ -1,15 +1,34 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ensureAbsolutePath = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- /**
9
- * ensure absolute file path.
10
- * @param base - Base path to resolve relative from.
11
- * @param filePath - Absolute or relative file path.
12
- * @returns Resolved absolute file path.
13
- */
14
- const ensureAbsolutePath = (base, filePath) => path_1.default.isAbsolute(filePath) ? filePath : path_1.default.resolve(base, filePath);
15
- exports.ensureAbsolutePath = ensureAbsolutePath;
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var ensureAbsolutePath_exports = {};
25
+ __export(ensureAbsolutePath_exports, {
26
+ ensureAbsolutePath: () => ensureAbsolutePath
27
+ });
28
+ module.exports = __toCommonJS(ensureAbsolutePath_exports);
29
+ var import_path = __toESM(require("path"));
30
+ const ensureAbsolutePath = (base, filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.resolve(base, filePath);
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ ensureAbsolutePath
34
+ });
@@ -1 +1 @@
1
- export declare const ensureArray: <T>(params: T | T[]) => T[];
1
+ export declare const ensureArray: <T>(params: T | T[]) => T[];
@@ -1,10 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureArray = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var ensureArray_exports = {};
19
+ __export(ensureArray_exports, {
20
+ ensureArray: () => ensureArray
21
+ });
22
+ module.exports = __toCommonJS(ensureArray_exports);
4
23
  const ensureArray = (params) => {
5
- if (Array.isArray(params)) {
6
- return params;
7
- }
8
- return [params];
24
+ if (Array.isArray(params)) {
25
+ return params;
26
+ }
27
+ return [params];
9
28
  };
10
- exports.ensureArray = ensureArray;
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ ensureArray
32
+ });
@@ -3,4 +3,4 @@
3
3
  * @param files - Absolute file paths with extension.
4
4
  * @returns The file path if exists, or false if no file exists.
5
5
  */
6
- export declare const findExists: (files: string[]) => string | false;
6
+ export declare const findExists: (files: string[]) => string | false;
@@ -1,21 +1,41 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.findExists = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- /**
9
- * Find first already exists file.
10
- * @param files - Absolute file paths with extension.
11
- * @returns The file path if exists, or false if no file exists.
12
- */
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var findExists_exports = {};
25
+ __export(findExists_exports, {
26
+ findExists: () => findExists
27
+ });
28
+ module.exports = __toCommonJS(findExists_exports);
29
+ var import_fs = __toESM(require("fs"));
13
30
  const findExists = (files) => {
14
- for (const file of files) {
15
- if (fs_1.default.existsSync(file) && fs_1.default.statSync(file).isFile()) {
16
- return file;
17
- }
31
+ for (const file of files) {
32
+ if (import_fs.default.existsSync(file) && import_fs.default.statSync(file).isFile()) {
33
+ return file;
18
34
  }
19
- return false;
35
+ }
36
+ return false;
20
37
  };
21
- exports.findExists = findExists;
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ findExists
41
+ });
package/dist/format.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { StatsCompilation } from 'webpack';
9
9
  declare function formatWebpackMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>): {
10
- errors: string[];
11
- warnings: string[];
10
+ errors: string[];
11
+ warnings: string[];
12
12
  };
13
- export { formatWebpackMessages };
13
+ export { formatWebpackMessages };
package/dist/format.js CHANGED
@@ -1,88 +1,100 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) 2015-present, Facebook, Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file at
7
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.formatWebpackMessages = void 0;
11
- const friendlySyntaxErrorLabel = 'SyntaxError:';
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var format_exports = {};
19
+ __export(format_exports, {
20
+ formatWebpackMessages: () => formatWebpackMessages
21
+ });
22
+ module.exports = __toCommonJS(format_exports);
23
+ const friendlySyntaxErrorLabel = "SyntaxError:";
12
24
  function isLikelyASyntaxError(message) {
13
- return message.includes(friendlySyntaxErrorLabel);
25
+ return message.includes(friendlySyntaxErrorLabel);
14
26
  }
15
- // Cleans up webpack error messages.
16
27
  function formatMessage(stats) {
17
- let lines = [];
18
- let message;
19
- // webpack 5 stats error object
20
- if (typeof stats === 'object') {
21
- const fileName = stats.moduleName ? `File: ${stats.moduleName}\n` : '';
22
- const mainMessage = stats.message;
23
- const details = stats.details ? `\nDetails: ${stats.details}\n` : '';
24
- const stack = stats.stack ? `\n${stats.stack}` : '';
25
- message = `${fileName}${mainMessage}${details}${stack}`;
28
+ let lines = [];
29
+ let message;
30
+ if (typeof stats === "object") {
31
+ const fileName = stats.moduleName ? `File: ${stats.moduleName}
32
+ ` : "";
33
+ const mainMessage = stats.message;
34
+ const details = stats.details ? `
35
+ Details: ${stats.details}
36
+ ` : "";
37
+ const stack = stats.stack ? `
38
+ ${stats.stack}` : "";
39
+ message = `${fileName}${mainMessage}${details}${stack}`;
40
+ } else {
41
+ message = stats;
42
+ }
43
+ lines = message.split("\n");
44
+ lines = lines.map((line) => {
45
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
46
+ line
47
+ );
48
+ if (!parsingError) {
49
+ return line;
26
50
  }
27
- else {
28
- message = stats;
29
- }
30
- lines = message.split('\n');
31
- // Transform parsing error into syntax error
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
- lines = message.split('\n');
44
- // Remove leading newline
45
- if (lines.length > 2 && lines[1].trim() === '') {
46
- lines.splice(1, 1);
47
- }
48
- // Clean up file name
49
- lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
50
- // Cleans up verbose "module not found" messages for files and packages.
51
- if (lines[1] && lines[1].indexOf('Module not found:') !== -1) {
52
- lines[1] = lines[1].replace('Error: ', '');
53
- }
54
- message = lines.join('\n');
55
- // Internal stacks are generally useless so we strip them... with the
56
- // exception of stacks containing `webpack:` because they're normally
57
- // from user code generated by webpack. For more information see
58
- // https://github.com/facebook/create-react-app/pull/1050
59
- message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
60
- message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
61
- lines = message.split('\n');
62
- // Remove duplicated newlines
63
- lines = lines.filter((line, index, arr) => index === 0 ||
64
- line.trim() !== '' ||
65
- line.trim() !== arr[index - 1].trim());
66
- // Reassemble the message
67
- message = lines.join('\n');
68
- return message.trim();
51
+ const [, errorLine, errorColumn, errorMessage] = parsingError;
52
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
53
+ });
54
+ message = lines.join("\n");
55
+ message = message.replace(
56
+ /SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
57
+ `${friendlySyntaxErrorLabel} $3 ($1:$2)
58
+ `
59
+ );
60
+ lines = message.split("\n");
61
+ if (lines.length > 2 && lines[1].trim() === "") {
62
+ lines.splice(1, 1);
63
+ }
64
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
65
+ if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
66
+ lines[1] = lines[1].replace("Error: ", "");
67
+ }
68
+ message = lines.join("\n");
69
+ message = message.replace(
70
+ /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
71
+ ""
72
+ );
73
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
74
+ lines = message.split("\n");
75
+ lines = lines.filter(
76
+ (line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
77
+ );
78
+ message = lines.join("\n");
79
+ return message.trim();
69
80
  }
70
81
  function formatWebpackMessages(json) {
71
- var _a, _b, _c;
72
- const formattedErrors = (_a = json === null || json === void 0 ? void 0 : json.errors) === null || _a === void 0 ? void 0 : _a.map(formatMessage);
73
- const formattedWarnings = (_b = json === null || json === void 0 ? void 0 : json.warnings) === null || _b === void 0 ? void 0 : _b.map(formatMessage);
74
- const result = {
75
- errors: formattedErrors || [],
76
- warnings: formattedWarnings || [],
77
- };
78
- if ((_c = result.errors) === null || _c === void 0 ? void 0 : _c.some(isLikelyASyntaxError)) {
79
- // If there are any syntax errors, show just them.
80
- result.errors = result.errors.filter(isLikelyASyntaxError);
81
- }
82
- // First error is usually it.
83
- if (result.errors.length > 1) {
84
- result.errors.length = 1;
85
- }
86
- return result;
82
+ var _a, _b, _c;
83
+ const formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
84
+ const formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
85
+ const result = {
86
+ errors: formattedErrors || [],
87
+ warnings: formattedWarnings || []
88
+ };
89
+ if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
90
+ result.errors = result.errors.filter(isLikelyASyntaxError);
91
+ }
92
+ if (result.errors.length > 1) {
93
+ result.errors.length = 1;
94
+ }
95
+ return result;
87
96
  }
88
- exports.formatWebpackMessages = formatWebpackMessages;
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ formatWebpackMessages
100
+ });
@@ -8,9 +8,9 @@
8
8
  * Modified from https://github.com/jantimon/html-webpack-plugin/blob/2f5de7ab9e8bca60e9e200f2e4b4cfab90db28d4/index.js#L800
9
9
  */
10
10
  export type MetaAttributes = {
11
- [attributeName: string]: string | boolean;
11
+ [attributeName: string]: string | boolean;
12
12
  };
13
13
  export interface MetaOptions {
14
- [name: string]: string | false | MetaAttributes;
14
+ [name: string]: string | false | MetaAttributes;
15
15
  }
16
- export declare const generateMetaTags: (metaOptions?: MetaOptions) => string;
16
+ export declare const generateMetaTags: (metaOptions?: MetaOptions) => string;
@@ -1,48 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateMetaTags = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var generateMetaTags_exports = {};
19
+ __export(generateMetaTags_exports, {
20
+ generateMetaTags: () => generateMetaTags
21
+ });
22
+ module.exports = __toCommonJS(generateMetaTags_exports);
4
23
  const tagObjectToString = (tagDefinition) => {
5
- const attributes = Object.keys(tagDefinition.attributes || {})
6
- .filter(attributeName => tagDefinition.attributes[attributeName] !== false)
7
- .map(attributeName => {
8
- if (tagDefinition.attributes[attributeName] === true) {
9
- return attributeName;
10
- }
11
- return `${attributeName}="${tagDefinition.attributes[attributeName]}"`;
12
- });
13
- return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${tagDefinition.innerHTML || ''}${tagDefinition.voidTag ? '' : `</${tagDefinition.tagName}>`}`;
24
+ const attributes = Object.keys(tagDefinition.attributes || {}).filter((attributeName) => tagDefinition.attributes[attributeName] !== false).map((attributeName) => {
25
+ if (tagDefinition.attributes[attributeName] === true) {
26
+ return attributeName;
27
+ }
28
+ return `${attributeName}="${tagDefinition.attributes[attributeName]}"`;
29
+ });
30
+ return `<${[tagDefinition.tagName].concat(attributes).join(" ")}>${tagDefinition.innerHTML || ""}${tagDefinition.voidTag ? "" : `</${tagDefinition.tagName}>`}`;
14
31
  };
15
32
  const generateMetaTags = (metaOptions) => {
16
- if (!metaOptions) {
17
- return '';
33
+ if (!metaOptions) {
34
+ return "";
35
+ }
36
+ const metaTagAttributeObjects = Object.keys(metaOptions).map((metaName) => {
37
+ const metaTagContent = metaOptions[metaName];
38
+ return typeof metaTagContent === "string" ? {
39
+ name: metaName,
40
+ content: metaTagContent
41
+ } : metaTagContent;
42
+ }).filter((attribute) => attribute !== false);
43
+ return metaTagAttributeObjects.map((metaTagAttributes) => {
44
+ if (metaTagAttributes === false) {
45
+ throw new Error("Invalid meta tag");
18
46
  }
19
- // Make tags self-closing in case of xhtml
20
- // Turn { "viewport" : "width=500, initial-scale=1" } into
21
- // [{ name:"viewport" content:"width=500, initial-scale=1" }]
22
- const metaTagAttributeObjects = Object.keys(metaOptions)
23
- .map(metaName => {
24
- const metaTagContent = metaOptions[metaName];
25
- return typeof metaTagContent === 'string'
26
- ? {
27
- name: metaName,
28
- content: metaTagContent,
29
- }
30
- : metaTagContent;
31
- })
32
- .filter(attribute => attribute !== false);
33
- // Turn [{ name:"viewport" content:"width=500, initial-scale=1" }] into
34
- // the html-webpack-plugin tag structure
35
- return metaTagAttributeObjects
36
- .map(metaTagAttributes => {
37
- if (metaTagAttributes === false) {
38
- throw new Error('Invalid meta tag');
39
- }
40
- return {
41
- tagName: 'meta',
42
- voidTag: true,
43
- attributes: metaTagAttributes,
44
- };
45
- })
46
- .reduce((memo, tagObject) => `${memo}\n${tagObjectToString(tagObject)}`, '');
47
+ return {
48
+ tagName: "meta",
49
+ voidTag: true,
50
+ attributes: metaTagAttributes
51
+ };
52
+ }).reduce(
53
+ (memo, tagObject) => `${memo}
54
+ ${tagObjectToString(tagObject)}`,
55
+ ""
56
+ );
47
57
  };
48
- exports.generateMetaTags = generateMetaTags;
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ generateMetaTags
61
+ });
@@ -1,2 +1,2 @@
1
1
  export declare const defaults: string[];
2
- export declare const getBrowserslist: (appDirectory: string) => string[];
2
+ export declare const getBrowserslist: (appDirectory: string) => string[];
@@ -1,7 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBrowserslist = exports.defaults = void 0;
4
- const compiled_1 = require("./compiled");
5
- exports.defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
6
- const getBrowserslist = (appDirectory) => compiled_1.browserslist.loadConfig({ path: appDirectory }) || exports.defaults;
7
- exports.getBrowserslist = getBrowserslist;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var getBrowserslist_exports = {};
19
+ __export(getBrowserslist_exports, {
20
+ defaults: () => defaults,
21
+ getBrowserslist: () => getBrowserslist
22
+ });
23
+ module.exports = __toCommonJS(getBrowserslist_exports);
24
+ var import_compiled = require("./compiled");
25
+ const defaults = ["> 0.01%", "not dead", "not op_mini all"];
26
+ const getBrowserslist = (appDirectory) => import_compiled.browserslist.loadConfig({ path: appDirectory }) || defaults;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ defaults,
30
+ getBrowserslist
31
+ });
@@ -1 +1 @@
1
- export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
1
+ export declare const getCoreJsVersion: (corejsPkgPath: string) => string;