@modern-js/utils 2.18.0 → 2.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/cjs/{alias.js → cli/alias.js} +3 -3
  3. package/dist/cjs/{applyOptionsChain.js → cli/applyOptionsChain.js} +6 -5
  4. package/dist/cjs/{babel.js → cli/babel.js} +3 -3
  5. package/dist/cjs/cli/common.js +26 -0
  6. package/dist/cjs/{constants.js → cli/constants/index.js} +14 -2
  7. package/dist/cjs/{readTsConfig.js → cli/ensure.js} +10 -9
  8. package/dist/cjs/cli/fs.js +29 -0
  9. package/dist/cjs/{getEntryOptions.js → cli/get/config.js} +2 -2
  10. package/dist/cjs/cli/get/data.js +112 -0
  11. package/dist/cjs/cli/get/index.js +46 -0
  12. package/dist/cjs/cli/index.js +41 -0
  13. package/dist/cjs/{is/index.js → cli/is/config.js} +2 -43
  14. package/dist/cjs/{is/nodeEnv.js → cli/is/env.js} +3 -1
  15. package/dist/cjs/cli/is/index.js +22 -0
  16. package/dist/cjs/cli/is/project.js +92 -0
  17. package/dist/cjs/{is → cli/is}/type.js +3 -1
  18. package/dist/cjs/{logger.js → cli/logger.js} +1 -1
  19. package/dist/cjs/{monorepo.js → cli/monorepo.js} +1 -1
  20. package/dist/cjs/{nodeEnv.js → cli/package.js} +8 -1
  21. package/dist/cjs/{path.js → cli/path.js} +8 -2
  22. package/dist/cjs/{pathSerializer.js → cli/pathSerializer.js} +1 -1
  23. package/dist/cjs/{getPort.js → cli/port.js} +1 -1
  24. package/dist/cjs/{prettyInstructions.js → cli/prettyInstructions.js} +1 -2
  25. package/dist/cjs/{printBuildError.js → cli/print.js} +1 -1
  26. package/dist/cjs/{compatRequire.js → cli/require.js} +21 -3
  27. package/dist/cjs/{routes.js → cli/routes.js} +4 -11
  28. package/dist/cjs/{runtimeExports.js → cli/runtimeExports.js} +1 -1
  29. package/dist/cjs/cli/watch.js +61 -0
  30. package/dist/cjs/index.js +1 -42
  31. package/dist/cjs/runtime/router.js +19 -0
  32. package/dist/cjs/{ssr.js → runtime-node/index.js} +3 -1
  33. package/dist/esm/{alias.js → cli/alias.js} +2 -2
  34. package/dist/esm/{applyOptionsChain.js → cli/applyOptionsChain.js} +2 -1
  35. package/dist/esm/{babel.js → cli/babel.js} +1 -1
  36. package/dist/esm/cli/common.js +10 -0
  37. package/dist/esm/{constants.js → cli/constants/index.js} +1 -1
  38. package/dist/esm/{ensureAbsolutePath.js → cli/ensure.js} +8 -0
  39. package/dist/esm/{findExists.js → cli/fs.js} +6 -1
  40. package/dist/esm/{getEntryOptions.js → cli/get/config.js} +2 -2
  41. package/dist/esm/cli/get/data.js +86 -0
  42. package/dist/esm/cli/get/index.js +13 -0
  43. package/dist/esm/cli/index.js +24 -0
  44. package/dist/esm/{is/index.js → cli/is/config.js} +1 -21
  45. package/dist/esm/{is/nodeEnv.js → cli/is/env.js} +1 -0
  46. package/dist/esm/cli/is/index.js +5 -0
  47. package/dist/esm/cli/is/project.js +67 -0
  48. package/dist/esm/{is → cli/is}/type.js +1 -0
  49. package/dist/esm/{logger.js → cli/logger.js} +1 -1
  50. package/dist/esm/{monorepo.js → cli/monorepo.js} +1 -1
  51. package/dist/esm/{nodeEnv.js → cli/package.js} +7 -1
  52. package/dist/esm/{path.js → cli/path.js} +4 -1
  53. package/dist/esm/{pathSerializer.js → cli/pathSerializer.js} +1 -1
  54. package/dist/esm/{getPort.js → cli/port.js} +1 -1
  55. package/dist/esm/{prettyInstructions.js → cli/prettyInstructions.js} +2 -2
  56. package/dist/esm/{printBuildError.js → cli/print.js} +1 -1
  57. package/dist/esm/{compatRequire.js → cli/require.js} +18 -1
  58. package/dist/esm/{routes.js → cli/routes.js} +2 -2
  59. package/dist/esm/{runtimeExports.js → cli/runtimeExports.js} +1 -1
  60. package/dist/esm/{watch.js → cli/watch.js} +2 -2
  61. package/dist/esm/index.js +1 -42
  62. package/dist/esm/runtime/router.js +2 -0
  63. package/dist/esm/{ssr.js → runtime-node/index.js} +1 -0
  64. package/dist/types/{applyOptionsChain.d.ts → cli/applyOptionsChain.d.ts} +1 -1
  65. package/dist/types/{debug.d.ts → cli/common.d.ts} +3 -1
  66. package/dist/types/{constants.d.ts → cli/constants/index.d.ts} +2 -6
  67. package/dist/types/{ensureAbsolutePath.d.ts → cli/ensure.d.ts} +2 -1
  68. package/dist/types/{findExists.d.ts → cli/fs.d.ts} +2 -1
  69. package/dist/types/cli/get/data.d.ts +9 -0
  70. package/dist/types/cli/get/index.d.ts +4 -0
  71. package/dist/types/cli/index.d.ts +24 -0
  72. package/dist/types/cli/is/config.d.ts +30 -0
  73. package/dist/types/{is/nodeEnv.d.ts → cli/is/env.d.ts} +2 -1
  74. package/dist/types/cli/is/index.d.ts +5 -0
  75. package/dist/types/cli/is/project.d.ts +25 -0
  76. package/dist/types/{is → cli/is}/type.d.ts +9 -1
  77. package/dist/types/{logger.d.ts → cli/logger.d.ts} +1 -1
  78. package/dist/types/cli/package.d.ts +4 -0
  79. package/dist/types/{path.d.ts → cli/path.d.ts} +5 -2
  80. package/dist/types/{prettyInstructions.d.ts → cli/prettyInstructions.d.ts} +0 -3
  81. package/dist/types/{compatRequire.d.ts → cli/require.d.ts} +9 -1
  82. package/dist/types/cli/routes.d.ts +1 -0
  83. package/dist/types/{watch.d.ts → cli/watch.d.ts} +1 -1
  84. package/dist/types/index.d.ts +2 -43
  85. package/dist/types/runtime/router.d.ts +2 -0
  86. package/dist/types/{ssr.d.ts → runtime-node/index.d.ts} +2 -1
  87. package/package.json +55 -92
  88. package/dist/cjs/FileSizeReporter.js +0 -139
  89. package/dist/cjs/analyzeProject.js +0 -68
  90. package/dist/cjs/clearConsole.js +0 -13
  91. package/dist/cjs/debug.js +0 -10
  92. package/dist/cjs/emptyDir.js +0 -14
  93. package/dist/cjs/ensureAbsolutePath.js +0 -15
  94. package/dist/cjs/ensureArray.js +0 -16
  95. package/dist/cjs/findExists.js +0 -22
  96. package/dist/cjs/getBrowserslist.js +0 -24
  97. package/dist/cjs/getCoreJsVersion.js +0 -58
  98. package/dist/cjs/getPackageManager.js +0 -42
  99. package/dist/cjs/getServerConfig.js +0 -55
  100. package/dist/cjs/getTargetDir.js +0 -53
  101. package/dist/cjs/plugin.js +0 -28
  102. package/dist/cjs/react.js +0 -30
  103. package/dist/cjs/removeSlash.js +0 -19
  104. package/dist/cjs/resolve.js +0 -57
  105. package/dist/cjs/types.js +0 -4
  106. package/dist/cjs/version.js +0 -43
  107. package/dist/cjs/wait.js +0 -11
  108. package/dist/cjs/watch.js +0 -96
  109. package/dist/esm/FileSizeReporter.js +0 -121
  110. package/dist/esm/analyzeProject.js +0 -13
  111. package/dist/esm/clearConsole.js +0 -5
  112. package/dist/esm/debug.js +0 -2
  113. package/dist/esm/emptyDir.js +0 -6
  114. package/dist/esm/ensureArray.js +0 -8
  115. package/dist/esm/getBrowserslist.js +0 -9
  116. package/dist/esm/getCoreJsVersion.js +0 -10
  117. package/dist/esm/getPackageManager.js +0 -29
  118. package/dist/esm/getServerConfig.js +0 -7
  119. package/dist/esm/getTargetDir.js +0 -5
  120. package/dist/esm/plugin.js +0 -20
  121. package/dist/esm/react.js +0 -17
  122. package/dist/esm/readTsConfig.js +0 -9
  123. package/dist/esm/removeSlash.js +0 -3
  124. package/dist/esm/resolve.js +0 -41
  125. package/dist/esm/types.js +0 -1
  126. package/dist/esm/version.js +0 -23
  127. package/dist/esm/wait.js +0 -4
  128. package/dist/types/FileSizeReporter.d.ts +0 -16
  129. package/dist/types/analyzeProject.d.ts +0 -2
  130. package/dist/types/clearConsole.d.ts +0 -1
  131. package/dist/types/emptyDir.d.ts +0 -1
  132. package/dist/types/ensureArray.d.ts +0 -1
  133. package/dist/types/getBrowserslist.d.ts +0 -2
  134. package/dist/types/getCoreJsVersion.d.ts +0 -1
  135. package/dist/types/getPackageManager.d.ts +0 -1
  136. package/dist/types/getServerConfig.d.ts +0 -1
  137. package/dist/types/getTargetDir.d.ts +0 -1
  138. package/dist/types/is/index.d.ts +0 -58
  139. package/dist/types/nodeEnv.d.ts +0 -3
  140. package/dist/types/plugin.d.ts +0 -2
  141. package/dist/types/react.d.ts +0 -1
  142. package/dist/types/readTsConfig.d.ts +0 -2
  143. package/dist/types/removeSlash.d.ts +0 -3
  144. package/dist/types/resolve.d.ts +0 -13
  145. package/dist/types/routes.d.ts +0 -2
  146. package/dist/types/types.d.ts +0 -1
  147. package/dist/types/version.d.ts +0 -2
  148. package/dist/types/wait.d.ts +0 -2
  149. /package/dist/cjs/{commands.js → cli/commands.js} +0 -0
  150. /package/dist/cjs/{chainId.js → cli/constants/chainId.js} +0 -0
  151. /package/dist/cjs/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
  152. /package/dist/cjs/{is → cli/is}/platform.js +0 -0
  153. /package/dist/cjs/{testUtils.js → cli/test.js} +0 -0
  154. /package/dist/cjs/{universal → runtime}/nestedRoutes.js +0 -0
  155. /package/dist/cjs/{universal → runtime}/remixRouter.js +0 -0
  156. /package/dist/cjs/{runtime → runtime-browser}/index.js +0 -0
  157. /package/dist/cjs/{runtime → runtime-browser}/parsed.js +0 -0
  158. /package/dist/cjs/{universal → runtime-node}/serialize.js +0 -0
  159. /package/dist/cjs/{storage.js → runtime-node/storage.js} +0 -0
  160. /package/dist/esm/{commands.js → cli/commands.js} +0 -0
  161. /package/dist/esm/{chainId.js → cli/constants/chainId.js} +0 -0
  162. /package/dist/esm/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
  163. /package/dist/esm/{is → cli/is}/platform.js +0 -0
  164. /package/dist/esm/{testUtils.js → cli/test.js} +0 -0
  165. /package/dist/esm/{universal → runtime}/nestedRoutes.js +0 -0
  166. /package/dist/esm/{universal → runtime}/remixRouter.js +0 -0
  167. /package/dist/esm/{runtime → runtime-browser}/index.js +0 -0
  168. /package/dist/esm/{runtime → runtime-browser}/parsed.js +0 -0
  169. /package/dist/esm/{universal → runtime-node}/serialize.js +0 -0
  170. /package/dist/esm/{storage.js → runtime-node/storage.js} +0 -0
  171. /package/dist/types/{alias.d.ts → cli/alias.d.ts} +0 -0
  172. /package/dist/types/{babel.d.ts → cli/babel.d.ts} +0 -0
  173. /package/dist/types/{commands.d.ts → cli/commands.d.ts} +0 -0
  174. /package/dist/types/{chainId.d.ts → cli/constants/chainId.d.ts} +0 -0
  175. /package/dist/types/{generateMetaTags.d.ts → cli/generateMetaTags.d.ts} +0 -0
  176. /package/dist/types/{getEntryOptions.d.ts → cli/get/config.d.ts} +0 -0
  177. /package/dist/types/{is → cli/is}/platform.d.ts +0 -0
  178. /package/dist/types/{monorepo.d.ts → cli/monorepo.d.ts} +0 -0
  179. /package/dist/types/{pathSerializer.d.ts → cli/pathSerializer.d.ts} +0 -0
  180. /package/dist/types/{getPort.d.ts → cli/port.d.ts} +0 -0
  181. /package/dist/types/{printBuildError.d.ts → cli/print.d.ts} +0 -0
  182. /package/dist/types/{runtimeExports.d.ts → cli/runtimeExports.d.ts} +0 -0
  183. /package/dist/types/{testUtils.d.ts → cli/test.d.ts} +0 -0
  184. /package/dist/types/{universal → runtime}/nestedRoutes.d.ts +0 -0
  185. /package/dist/types/{universal → runtime}/remixRouter.d.ts +0 -0
  186. /package/dist/types/{runtime → runtime-browser}/index.d.ts +0 -0
  187. /package/dist/types/{runtime → runtime-browser}/parsed.d.ts +0 -0
  188. /package/dist/types/{universal → runtime-node}/serialize.d.ts +0 -0
  189. /package/dist/types/{storage.d.ts → runtime-node/storage.d.ts} +0 -0
package/package.json CHANGED
@@ -15,42 +15,51 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.18.0",
18
+ "version": "2.18.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
- "main": "./dist/index.js",
21
+ "main": "./dist/cjs/index.js",
22
22
  "module": "./dist/index.js",
23
23
  "_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
24
24
  "exports": {
25
25
  ".": {
26
- "import": "./dist/esm/index.js",
27
26
  "types": "./dist/types/index.d.ts",
28
27
  "default": "./dist/cjs/index.js"
29
28
  },
30
- "./runtime": {
31
- "import": "./dist/esm/runtime/index.js",
32
- "types": "./dist/types/runtime/index.d.ts",
33
- "default": "./dist/cjs/runtime/index.js"
29
+ "./logger": {
30
+ "types": "./dist/types/cli/logger.d.ts",
31
+ "default": "./dist/cjs/cli/logger.js"
32
+ },
33
+ "./chain-id": {
34
+ "types": "./dist/types/cli/constants/chainId.d.ts",
35
+ "default": "./dist/cjs/cli/constants/chainId.js"
34
36
  },
35
- "./ssr": {
36
- "import": "./dist/esm/ssr.js",
37
- "types": "./dist/types/ssr.d.ts",
38
- "default": "./dist/cjs/ssr.js"
37
+ "./runtime/router": {
38
+ "types": "./dist/types/runtime/router.d.ts",
39
+ "default": "./dist/esm/runtime/router.js"
39
40
  },
40
- "./logger": {
41
- "import": "./dist/esm/logger.js",
42
- "types": "./dist/types/logger.d.ts",
43
- "default": "./dist/cjs/logger.js"
41
+ "./runtime-browser": {
42
+ "jsnext:source": "./src/runtime-browser/index.d.ts",
43
+ "default": "./dist/esm/runtime-browser/index.js"
44
44
  },
45
- "./constants": {
46
- "import": "./dist/esm/constants.js",
47
- "types": "./dist/types/constants.d.ts",
48
- "default": "./dist/cjs/constants.js"
45
+ "./runtime-node": {
46
+ "types": "./dist/types/runtime-node/index.d.ts",
47
+ "default": "./dist/esm/runtime-node/index.js"
49
48
  },
50
- "./babel": {
51
- "import": "./dist/esm/babel.js",
52
- "types": "./dist/types/babel.d.ts",
53
- "default": "./dist/cjs/babel.js"
49
+ "./universal/constants": {
50
+ "types": "./dist/types/universal/constants.d.ts",
51
+ "import": "./dist/esm/universal/constants.js",
52
+ "default": "./dist/cjs/universal/constants.js"
53
+ },
54
+ "./universal/format-webpack": {
55
+ "types": "./dist/types/universal/format-webpack.d.ts",
56
+ "import": "./dist/esm/universal/formatWebpack.js",
57
+ "default": "./dist/cjs/universal/formatWebpack.js"
58
+ },
59
+ "./universal/plugin-dag-sort": {
60
+ "types": "./dist/types/universal/pluginDagSort.d.ts",
61
+ "import": "./dist/esm/universal/pluginDagSort.js",
62
+ "default": "./dist/cjs/universal/pluginDagSort.js"
54
63
  },
55
64
  "./ajv": "./dist/compiled/ajv/index.js",
56
65
  "./glob": "./dist/compiled/glob/index.js",
@@ -70,41 +79,7 @@
70
79
  "./webpack-chain": "./dist/compiled/webpack-chain/index.js",
71
80
  "./tsconfig-paths": "./dist/compiled/tsconfig-paths/index.js",
72
81
  "./better-ajv-errors": "./dist/compiled/better-ajv-errors/index.js",
73
- "./webpack-dev-middleware": "./dist/compiled/webpack-dev-middleware/index.js",
74
- "./chain-id": {
75
- "types": "./dist/types/chainId.d.ts",
76
- "default": "./dist/cjs/chainId.js"
77
- },
78
- "./universal/constants": {
79
- "import": "./dist/esm/universal/constants.js",
80
- "types": "./dist/types/universal/constants.d.ts",
81
- "default": "./dist/cjs/universal/constants.js"
82
- },
83
- "./universal/serialize": {
84
- "import": "./dist/esm/universal/serialize.js",
85
- "types": "./dist/types/universal/serialize.d.ts",
86
- "default": "./dist/cjs/universal/serialize.js"
87
- },
88
- "./universal/remix-router": {
89
- "import": "./dist/esm/universal/remixRouter.js",
90
- "types": "./dist/types/universal/remix-router.d.ts",
91
- "default": "./dist/cjs/universal/remixRouter.js"
92
- },
93
- "./universal/format-webpack": {
94
- "import": "./dist/esm/universal/formatWebpack.js",
95
- "types": "./dist/types/universal/format-webpack.d.ts",
96
- "default": "./dist/cjs/universal/formatWebpack.js"
97
- },
98
- "./universal/nestedRoutes": {
99
- "import": "./dist/esm/universal/nestedRoutes.js",
100
- "types": "./dist/types/universal/nestedRoutes.d.ts",
101
- "default": "./dist/cjs/universal/nestedRoutes.js"
102
- },
103
- "./universal/pluginDagSort": {
104
- "import": "./dist/esm/universal/pluginDagSort.js",
105
- "types": "./dist/types/universal/pluginDagSort.d.ts",
106
- "default": "./dist/cjs/universal/pluginDagSort.js"
107
- }
82
+ "./webpack-dev-middleware": "./dist/compiled/webpack-dev-middleware/index.js"
108
83
  },
109
84
  "publishConfig": {
110
85
  "registry": "https://registry.npmjs.org/",
@@ -112,20 +87,29 @@
112
87
  },
113
88
  "typesVersions": {
114
89
  "*": {
115
- "runtime": [
116
- "./dist/types/runtime/index.d.ts"
90
+ "logger": [
91
+ "./dist/types/cli/logger.d.ts"
117
92
  ],
118
- "ssr": [
119
- "./dist/types/ssr.d.ts"
93
+ "chain-id": [
94
+ "./dist/types/cli/constants/chainId.d.ts"
120
95
  ],
121
- "logger": [
122
- "./dist/types/logger.d.ts"
96
+ "runtime/router": [
97
+ "./dist/types/runtime/router.d.ts"
98
+ ],
99
+ "runtime-browser": [
100
+ "./dist/types/runtime-browser/index.d.ts"
123
101
  ],
124
- "constants": [
125
- "./dist/types/constants.d.ts"
102
+ "runtime-node": [
103
+ "./dist/types/runtime-node/index.d.ts"
104
+ ],
105
+ "universal/constants": [
106
+ "./dist/types/universal/constants.d.ts"
107
+ ],
108
+ "universal/format-webpack": [
109
+ "./dist/types/universal/formatWebpack.d.ts"
126
110
  ],
127
- "babel": [
128
- "./dist/types/babel.d.ts"
111
+ "universal/plugin-dag-sort": [
112
+ "./dist/types/universal/pluginDagSort.d.ts"
129
113
  ],
130
114
  "ajv": [
131
115
  "./dist/compiled/ajv/types/ajv.d.ts"
@@ -145,9 +129,6 @@
145
129
  "json5": [
146
130
  "./dist/compiled/json5/index.d.ts"
147
131
  ],
148
- "chain-id": [
149
- "./dist/types/chainId.d.ts"
150
- ],
151
132
  "semver": [
152
133
  "./dist/compiled/semver/index.d.ts"
153
134
  ],
@@ -189,24 +170,6 @@
189
170
  ],
190
171
  "webpack-dev-middleware": [
191
172
  "./dist/compiled/webpack-dev-middleware/types/index.d.ts"
192
- ],
193
- "universal/constants": [
194
- "./dist/types/universal/constants.d.ts"
195
- ],
196
- "universal/serialize": [
197
- "./dist/types/universal/serialize.d.ts"
198
- ],
199
- "universal/remix-router": [
200
- "./dist/types/universal/remixRouter.d.ts"
201
- ],
202
- "universal/format-webpack": [
203
- "./dist/types/universal/formatWebpack.d.ts"
204
- ],
205
- "universal/nestedRoutes": [
206
- "./dist/types/universal/nestedRoutes.d.ts"
207
- ],
208
- "universal/pluginDagSort": [
209
- "./dist/types/universal/pluginDagSort.d.ts"
210
173
  ]
211
174
  }
212
175
  },
@@ -242,9 +205,9 @@
242
205
  "typescript": "^4",
243
206
  "webpack": "^5.76.2",
244
207
  "@types/serialize-javascript": "^5.0.1",
245
- "@modern-js/types": "2.18.0",
246
- "@scripts/build": "2.18.0",
247
- "@scripts/jest-config": "2.18.0"
208
+ "@modern-js/types": "2.18.1",
209
+ "@scripts/jest-config": "2.18.1",
210
+ "@scripts/build": "2.18.1"
248
211
  },
249
212
  "sideEffects": false,
250
213
  "scripts": {
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- measureFileSizesBeforeBuild: () => measureFileSizesBeforeBuild,
14
- printFileSizesAfterBuild: () => printFileSizesAfterBuild
15
- });
16
- const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
17
- const _path = /* @__PURE__ */ _interop_require_default(require("path"));
18
- const _compiled = require("./compiled");
19
- const _logger = require("./logger");
20
- function _interop_require_default(obj) {
21
- return obj && obj.__esModule ? obj : {
22
- default: obj
23
- };
24
- }
25
- function canReadAsset(asset) {
26
- return /\.(js|css)$/.test(asset) && !/service-worker\.js/.test(asset) && !/precache-manifest\.[0-9a-f]+\.js/.test(asset);
27
- }
28
- function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
29
- var root = previousSizeMap.root;
30
- var sizes = previousSizeMap.sizes;
31
- var assets = (webpackStats.stats || [
32
- webpackStats
33
- ]).map((stats) => stats.toJson({
34
- all: false,
35
- assets: true
36
- }).assets.filter((asset) => canReadAsset(asset.name)).map((asset) => {
37
- var fileContents = _fs.default.readFileSync(_path.default.join(root, asset.name));
38
- var size = fileContents.length;
39
- var gzippedSize = _compiled.gzipSize.sync(fileContents);
40
- var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
41
- var sizeDifference = getDifferenceLabel(size, previousSize);
42
- var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
43
- return {
44
- folder: _path.default.join(_path.default.basename(buildFolder), _path.default.dirname(asset.name)),
45
- name: _path.default.basename(asset.name),
46
- gzippedSize,
47
- sizeLabel: (0, _compiled.filesize)(size) + (sizeDifference ? " (" + sizeDifference + ")" : ""),
48
- gzipSizeLabel: (0, _compiled.filesize)(gzippedSize) + (gzipSizeDifference ? " (" + gzipSizeDifference + ")" : "")
49
- };
50
- })).reduce((single, all) => all.concat(single), []);
51
- assets.sort((a, b) => b.size - a.size);
52
- var longestSizeLabelLength = Math.max.apply(null, assets.map((a) => (0, _compiled.stripAnsi)(a.sizeLabel).length));
53
- var longestFileNameLength = Math.max.apply(null, assets.map((a) => (0, _compiled.stripAnsi)(a.folder + _path.default.sep + a.name).length));
54
- printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
55
- var suggestBundleSplitting = false;
56
- assets.forEach((asset) => {
57
- var { folder, name, sizeLabel, gzipSizeLabel, gzippedSize } = asset;
58
- var fileNameLength = (0, _compiled.stripAnsi)(folder + _path.default.sep + name).length;
59
- var sizeLength = (0, _compiled.stripAnsi)(sizeLabel).length;
60
- if (sizeLength < longestSizeLabelLength) {
61
- var rightPadding = " ".repeat(longestSizeLabelLength - sizeLength);
62
- sizeLabel += rightPadding;
63
- }
64
- var fileNameLabel = _compiled.chalk.dim(asset.folder + _path.default.sep) + _compiled.chalk.cyan(asset.name);
65
- if (fileNameLength < longestFileNameLength) {
66
- var rightPadding = " ".repeat(longestFileNameLength - fileNameLength);
67
- fileNameLabel += rightPadding;
68
- }
69
- var isMainBundle = asset.name.indexOf("main.") === 0;
70
- var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
71
- var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
72
- if (isLarge && _path.default.extname(asset.name) === ".js") {
73
- suggestBundleSplitting = true;
74
- }
75
- _logger.logger.log(" " + fileNameLabel + " " + sizeLabel + " " + (isLarge ? _compiled.chalk.yellow(gzipSizeLabel) : gzipSizeLabel));
76
- });
77
- if (suggestBundleSplitting) {
78
- _logger.logger.log();
79
- _logger.logger.warn("The bundle size is significantly larger than recommended.");
80
- }
81
- }
82
- function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
83
- const longestLengths = [
84
- longestFileNameLength,
85
- longestSizeLabelLength
86
- ];
87
- const headerRow = [
88
- "File",
89
- "Size",
90
- "Gzipped"
91
- ].reduce((prev, cur, index) => {
92
- const length = longestLengths[index];
93
- let curLabel = cur;
94
- if (length) {
95
- curLabel = cur.length < length ? cur + " ".repeat(length - cur.length) : cur;
96
- }
97
- return prev + curLabel + " ";
98
- }, " ");
99
- _logger.logger.log(_compiled.chalk.bold(_compiled.chalk.blue(headerRow)));
100
- }
101
- function removeFileNameHash(buildFolder, fileName) {
102
- return fileName.replace(buildFolder, "").replace(/\\/g, "/").replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
103
- }
104
- function getDifferenceLabel(currentSize, previousSize) {
105
- var FIFTY_KILOBYTES = 1024 * 50;
106
- var difference = currentSize - previousSize;
107
- var fileSize = !Number.isNaN(difference) ? (0, _compiled.filesize)(difference) : 0;
108
- if (difference >= FIFTY_KILOBYTES) {
109
- return _compiled.chalk.red("+" + fileSize);
110
- } else if (difference < FIFTY_KILOBYTES && difference > 0) {
111
- return _compiled.chalk.yellow("+" + fileSize);
112
- } else if (difference < 0) {
113
- return _compiled.chalk.green(fileSize);
114
- } else {
115
- return "";
116
- }
117
- }
118
- function measureFileSizesBeforeBuild(buildFolder) {
119
- return new Promise((resolve) => {
120
- (0, _compiled.recursiveReaddir)(buildFolder, (err, fileNames) => {
121
- var sizes;
122
- if (!err && fileNames) {
123
- sizes = fileNames.filter(canReadAsset).reduce((memo, fileName) => {
124
- var contents = _fs.default.readFileSync(fileName);
125
- var key = removeFileNameHash(buildFolder, fileName);
126
- memo[key] = [
127
- contents.length,
128
- _compiled.gzipSize.sync(contents)
129
- ];
130
- return memo;
131
- }, {});
132
- }
133
- resolve({
134
- root: buildFolder,
135
- sizes: sizes || {}
136
- });
137
- });
138
- });
139
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- isApiOnly: () => isApiOnly,
14
- isWebOnly: () => isWebOnly
15
- });
16
- const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
17
- const _commands = require("./commands");
18
- const _compiled = require("./compiled");
19
- function _getRequireWildcardCache(nodeInterop) {
20
- if (typeof WeakMap !== "function")
21
- return null;
22
- var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
23
- var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
24
- return (_getRequireWildcardCache = function(nodeInterop2) {
25
- return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
26
- })(nodeInterop);
27
- }
28
- function _interop_require_wildcard(obj, nodeInterop) {
29
- if (!nodeInterop && obj && obj.__esModule) {
30
- return obj;
31
- }
32
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
33
- return {
34
- default: obj
35
- };
36
- }
37
- var cache = _getRequireWildcardCache(nodeInterop);
38
- if (cache && cache.has(obj)) {
39
- return cache.get(obj);
40
- }
41
- var newObj = {};
42
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
43
- for (var key in obj) {
44
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
45
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
46
- if (desc && (desc.get || desc.set)) {
47
- Object.defineProperty(newObj, key, desc);
48
- } else {
49
- newObj[key] = obj[key];
50
- }
51
- }
52
- }
53
- newObj.default = obj;
54
- if (cache) {
55
- cache.set(obj, newObj);
56
- }
57
- return newObj;
58
- }
59
- const isApiOnly = async (appDirectory, entryDir) => {
60
- const srcDir = _path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
61
- const existSrc = await _compiled.fs.pathExists(srcDir);
62
- const options = (0, _compiled.minimist)((0, _commands.getArgv)());
63
- return !existSrc || Boolean(options["api-only"]);
64
- };
65
- const isWebOnly = async () => {
66
- const options = (0, _compiled.minimist)((0, _commands.getArgv)());
67
- return Boolean(options["web-only"]);
68
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "clearConsole", {
6
- enumerable: true,
7
- get: () => clearConsole
8
- });
9
- const clearConsole = () => {
10
- if (process.stdout.isTTY && !process.env.DEBUG) {
11
- process.stdout.write("\x1B[H\x1B[2J");
12
- }
13
- };
package/dist/cjs/debug.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "createDebugger", {
6
- enumerable: true,
7
- get: () => createDebugger
8
- });
9
- const _debug = require("../compiled/debug");
10
- const createDebugger = (scope) => (0, _debug.debug)(`modern-js:${scope}`);
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "emptyDir", {
6
- enumerable: true,
7
- get: () => emptyDir
8
- });
9
- const _compiled = require("./compiled");
10
- const emptyDir = async (dir) => {
11
- if (await _compiled.fs.pathExists(dir)) {
12
- await _compiled.fs.emptyDir(dir);
13
- }
14
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ensureAbsolutePath", {
6
- enumerable: true,
7
- get: () => ensureAbsolutePath
8
- });
9
- const _path = /* @__PURE__ */ _interop_require_default(require("path"));
10
- function _interop_require_default(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- const ensureAbsolutePath = (base, filePath) => _path.default.isAbsolute(filePath) ? filePath : _path.default.resolve(base, filePath);
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ensureArray", {
6
- enumerable: true,
7
- get: () => ensureArray
8
- });
9
- const ensureArray = (params) => {
10
- if (Array.isArray(params)) {
11
- return params;
12
- }
13
- return [
14
- params
15
- ];
16
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "findExists", {
6
- enumerable: true,
7
- get: () => findExists
8
- });
9
- const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
10
- function _interop_require_default(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- const findExists = (files) => {
16
- for (const file of files) {
17
- if (_fs.default.existsSync(file) && _fs.default.statSync(file).isFile()) {
18
- return file;
19
- }
20
- }
21
- return false;
22
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- defaults: () => defaults,
14
- getBrowserslist: () => getBrowserslist
15
- });
16
- const _compiled = require("./compiled");
17
- const defaults = [
18
- "> 0.01%",
19
- "not dead",
20
- "not op_mini all"
21
- ];
22
- const getBrowserslist = (appDirectory) => _compiled.browserslist.loadConfig({
23
- path: appDirectory
24
- }) || defaults;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getCoreJsVersion", {
6
- enumerable: true,
7
- get: () => getCoreJsVersion
8
- });
9
- const _fsextra = /* @__PURE__ */ _interop_require_wildcard(require("../compiled/fs-extra"));
10
- function _getRequireWildcardCache(nodeInterop) {
11
- if (typeof WeakMap !== "function")
12
- return null;
13
- var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
14
- var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
15
- return (_getRequireWildcardCache = function(nodeInterop2) {
16
- return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
17
- })(nodeInterop);
18
- }
19
- function _interop_require_wildcard(obj, nodeInterop) {
20
- if (!nodeInterop && obj && obj.__esModule) {
21
- return obj;
22
- }
23
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
24
- return {
25
- default: obj
26
- };
27
- }
28
- var cache = _getRequireWildcardCache(nodeInterop);
29
- if (cache && cache.has(obj)) {
30
- return cache.get(obj);
31
- }
32
- var newObj = {};
33
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
34
- for (var key in obj) {
35
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
36
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
37
- if (desc && (desc.get || desc.set)) {
38
- Object.defineProperty(newObj, key, desc);
39
- } else {
40
- newObj[key] = obj[key];
41
- }
42
- }
43
- }
44
- newObj.default = obj;
45
- if (cache) {
46
- cache.set(obj, newObj);
47
- }
48
- return newObj;
49
- }
50
- const getCoreJsVersion = (corejsPkgPath) => {
51
- try {
52
- const { version } = _fsextra.readJSONSync(corejsPkgPath);
53
- const [major, minor] = version.split(".");
54
- return `${major}.${minor}`;
55
- } catch (err) {
56
- return "3";
57
- }
58
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getPackageManager", {
6
- enumerable: true,
7
- get: () => getPackageManager
8
- });
9
- const _os = /* @__PURE__ */ _interop_require_default(require("os"));
10
- const _path = /* @__PURE__ */ _interop_require_default(require("path"));
11
- const _compiled = require("./compiled");
12
- const _nodeEnv = require("./nodeEnv");
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- const MAX_TIMES = 5;
19
- async function getPackageManager(cwd = process.cwd()) {
20
- let appDirectory = cwd;
21
- let times = 0;
22
- while (_os.default.homedir() !== appDirectory && times < MAX_TIMES) {
23
- times++;
24
- if (_compiled.fs.existsSync(_path.default.resolve(appDirectory, "pnpm-lock.yaml"))) {
25
- return "pnpm";
26
- }
27
- if (_compiled.fs.existsSync(_path.default.resolve(appDirectory, "yarn.lock"))) {
28
- return "yarn";
29
- }
30
- if (_compiled.fs.existsSync(_path.default.resolve(appDirectory, "package-lock.json"))) {
31
- return "npm";
32
- }
33
- appDirectory = _path.default.join(appDirectory, "..");
34
- }
35
- if (await (0, _nodeEnv.canUsePnpm)()) {
36
- return "pnpm";
37
- }
38
- if (await (0, _nodeEnv.canUseYarn)()) {
39
- return "yarn";
40
- }
41
- return "npm";
42
- }