@modern-js/utils 2.4.1-beta.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/CHANGELOG.md +7 -1
  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 +127 -105
  21. package/dist/constants.js +298 -281
  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 +5 -1
  53. package/dist/is/index.js +81 -94
  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/watch.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
2
2
  export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
3
3
  type RunTaskType = (option: {
4
- changedFilePath: string;
5
- changeType: WatchChangeTypeValueT;
4
+ changedFilePath: string;
5
+ changeType: WatchChangeTypeValueT;
6
6
  }) => void | Promise<void>;
7
7
  export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
8
- export {};
8
+ export {};
package/dist/watch.js CHANGED
@@ -1,59 +1,86 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
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);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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 });
24
10
  };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.watch = exports.WatchChangeType = void 0;
27
- const path = __importStar(require("path"));
28
- const compiled_1 = require("./compiled");
29
- exports.WatchChangeType = {
30
- ADD: 'add',
31
- UNLINK: 'unlink',
32
- CHANGE: 'change',
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 __async = (__this, __arguments, generator) => {
25
+ return new Promise((resolve, reject) => {
26
+ var fulfilled = (value) => {
27
+ try {
28
+ step(generator.next(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var rejected = (value) => {
34
+ try {
35
+ step(generator.throw(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
+ step((generator = generator.apply(__this, __arguments)).next());
42
+ });
43
+ };
44
+ var watch_exports = {};
45
+ __export(watch_exports, {
46
+ WatchChangeType: () => WatchChangeType,
47
+ watch: () => watch
48
+ });
49
+ module.exports = __toCommonJS(watch_exports);
50
+ var path = __toESM(require("path"));
51
+ var import_compiled = require("./compiled");
52
+ const WatchChangeType = {
53
+ ADD: "add",
54
+ UNLINK: "unlink",
55
+ CHANGE: "change"
33
56
  };
34
57
  const watch = (watchDir, runTask, ignored = []) => {
35
- let ready = false;
36
- const watcher = compiled_1.chokidar.watch(watchDir, {
37
- ignored,
38
- });
39
- watcher.on('ready', () => (ready = true));
40
- watcher.on('change', async (filePath) => {
41
- const changedFilePath = path.resolve(filePath);
42
- await runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
43
- });
44
- watcher.on('add', async (filePath) => {
45
- const changedFilePath = path.resolve(filePath);
46
- if (ready) {
47
- await runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
48
- }
49
- });
50
- watcher.on('unlink', async (filePath) => {
51
- const changedFilePath = path.resolve(filePath);
52
- await runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
53
- });
54
- watcher.on('error', err => {
55
- throw err;
56
- });
57
- return watcher;
58
+ let ready = false;
59
+ const watcher = import_compiled.chokidar.watch(watchDir, {
60
+ ignored
61
+ });
62
+ watcher.on("ready", () => ready = true);
63
+ watcher.on("change", (filePath) => __async(void 0, null, function* () {
64
+ const changedFilePath = path.resolve(filePath);
65
+ yield runTask({ changedFilePath, changeType: WatchChangeType.CHANGE });
66
+ }));
67
+ watcher.on("add", (filePath) => __async(void 0, null, function* () {
68
+ const changedFilePath = path.resolve(filePath);
69
+ if (ready) {
70
+ yield runTask({ changedFilePath, changeType: WatchChangeType.ADD });
71
+ }
72
+ }));
73
+ watcher.on("unlink", (filePath) => __async(void 0, null, function* () {
74
+ const changedFilePath = path.resolve(filePath);
75
+ yield runTask({ changedFilePath, changeType: WatchChangeType.UNLINK });
76
+ }));
77
+ watcher.on("error", (err) => {
78
+ throw err;
79
+ });
80
+ return watcher;
58
81
  };
59
- exports.watch = watch;
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ WatchChangeType,
85
+ watch
86
+ });
package/package.json CHANGED
@@ -11,12 +11,11 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.4.1-beta.0",
14
+ "version": "2.5.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
18
18
  "module": "./dist/index.js",
19
- "jsnext:modern": "./dist/index.js",
20
19
  "_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
21
20
  "exports": {
22
21
  ".": "./dist/index.js",
@@ -125,7 +124,7 @@
125
124
  }
126
125
  },
127
126
  "dependencies": {
128
- "caniuse-lite": "^1.0.30001332",
127
+ "caniuse-lite": "^1.0.30001451",
129
128
  "lodash": "^4.17.21"
130
129
  },
131
130
  "devDependencies": {
@@ -134,15 +133,15 @@
134
133
  "jest": "^27",
135
134
  "typescript": "^4",
136
135
  "webpack": "^5.75.0",
137
- "@modern-js/types": "2.4.0",
138
- "@scripts/jest-config": "2.4.0",
139
- "@scripts/build": "2.4.0"
136
+ "@modern-js/types": "2.5.0",
137
+ "@scripts/jest-config": "2.5.0",
138
+ "@scripts/build": "2.5.0"
140
139
  },
141
140
  "sideEffects": false,
142
141
  "scripts": {
143
142
  "new": "modern-lib new",
144
- "dev": "tsc --watch",
145
- "build": "tsc",
143
+ "dev": "modern-lib build --watch",
144
+ "build": "modern-lib build",
146
145
  "test": "jest --passWithNoTests"
147
146
  }
148
147
  }