@modern-js/app-tools 2.58.1-alpha.6 → 2.58.2

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 (285) hide show
  1. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
  2. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  3. package/dist/cjs/builder/generator/index.js +2 -2
  4. package/dist/cjs/builder/index.js +2 -2
  5. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +13 -4
  6. package/dist/cjs/commands/build.js +19 -0
  7. package/dist/cjs/commands/dev.js +9 -0
  8. package/dist/cjs/commands/index.js +8 -8
  9. package/dist/cjs/commands/inspect.js +1 -1
  10. package/dist/cjs/config/initialize/inits.js +4 -4
  11. package/dist/cjs/esm/esbuild-loader.mjs +20 -0
  12. package/dist/cjs/esm/register-esm.mjs +67 -0
  13. package/dist/cjs/esm/ts-node-loader.mjs +21 -0
  14. package/dist/cjs/esm/utils.mjs +43 -0
  15. package/dist/cjs/index.js +1 -1
  16. package/dist/cjs/plugins/analyze/index.js +3 -3
  17. package/dist/cjs/plugins/deploy/dependencies/index.js +2 -15
  18. package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -78
  19. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
  20. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  21. package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
  22. package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
  23. package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
  24. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
  25. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  26. package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
  27. package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
  28. package/dist/cjs/utils/config.js +1 -1
  29. package/dist/cjs/utils/loadPlugins.js +1 -1
  30. package/dist/cjs/utils/register.js +50 -23
  31. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
  32. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  33. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
  34. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  35. package/dist/types/builder/generator/index.d.ts +2 -2
  36. package/dist/types/builder/index.d.ts +1 -1
  37. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  38. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  39. package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
  40. package/dist/types/commands/build.d.ts +1 -1
  41. package/dist/types/commands/dev.d.ts +3 -3
  42. package/dist/types/commands/index.d.ts +3 -3
  43. package/dist/types/config/default.d.ts +1 -1
  44. package/dist/types/config/initialize/inits.d.ts +1 -1
  45. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  46. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  47. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  48. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  49. package/dist/types/esm/esbuild-loader.d.mts +6 -0
  50. package/dist/types/esm/register-esm.d.mts +5 -0
  51. package/dist/types/esm/ts-node-loader.d.mts +6 -0
  52. package/dist/types/esm/utils.d.mts +6 -0
  53. package/dist/types/exports/server.d.ts +1 -1
  54. package/dist/types/hooks.d.ts +1 -1
  55. package/dist/types/index.d.ts +2 -2
  56. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  57. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  58. package/dist/types/plugins/analyze/index.d.ts +1 -1
  59. package/dist/types/plugins/deploy/dependencies/index.d.ts +3 -5
  60. package/dist/types/plugins/deploy/dependencies/utils.d.ts +2 -9
  61. package/dist/types/plugins/deploy/index.d.ts +2 -2
  62. package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
  63. package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
  64. package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
  65. package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
  66. package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
  67. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  68. package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
  69. package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
  70. package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
  71. package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
  72. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  73. package/dist/types/plugins/serverBuild.d.ts +1 -1
  74. package/dist/types/types/hooks.d.ts +1 -1
  75. package/dist/types/types/index.d.ts +1 -1
  76. package/dist/types/utils/createServer.d.ts +1 -1
  77. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  78. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  79. package/dist/types/utils/loadPlugins.d.ts +3 -3
  80. package/dist/types/utils/register.d.ts +2 -2
  81. package/dist/types/utils/restart.d.ts +2 -2
  82. package/lib/types.d.ts +15 -0
  83. package/package.json +20 -21
  84. package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
  85. package/dist/esm/builder/builder-rspack/index.js +0 -34
  86. package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
  87. package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
  88. package/dist/esm/builder/builder-webpack/index.js +0 -52
  89. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
  90. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
  91. package/dist/esm/builder/generator/index.js +0 -94
  92. package/dist/esm/builder/index.js +0 -45
  93. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
  94. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  95. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
  96. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
  97. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  98. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  99. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  100. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -288
  101. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  102. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  103. package/dist/esm/builder/shared/index.js +0 -3
  104. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  105. package/dist/esm/builder/shared/types.js +0 -0
  106. package/dist/esm/commands/build.js +0 -117
  107. package/dist/esm/commands/deploy.js +0 -48
  108. package/dist/esm/commands/dev.js +0 -169
  109. package/dist/esm/commands/index.js +0 -411
  110. package/dist/esm/commands/inspect.js +0 -28
  111. package/dist/esm/commands/serve.js +0 -93
  112. package/dist/esm/config/default.js +0 -190
  113. package/dist/esm/config/index.js +0 -3
  114. package/dist/esm/config/initialize/index.js +0 -9
  115. package/dist/esm/config/initialize/inits.js +0 -85
  116. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  117. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  118. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  119. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  120. package/dist/esm/config/legacy/index.js +0 -43
  121. package/dist/esm/defineConfig.js +0 -16
  122. package/dist/esm/exports/server.js +0 -4
  123. package/dist/esm/hooks.js +0 -34
  124. package/dist/esm/index.js +0 -239
  125. package/dist/esm/locale/en.js +0 -43
  126. package/dist/esm/locale/index.js +0 -12
  127. package/dist/esm/locale/zh.js +0 -43
  128. package/dist/esm/plugins/analyze/constants.js +0 -14
  129. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
  130. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
  131. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
  132. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
  133. package/dist/esm/plugins/analyze/index.js +0 -380
  134. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  135. package/dist/esm/plugins/analyze/templates.js +0 -6
  136. package/dist/esm/plugins/analyze/utils.js +0 -101
  137. package/dist/esm/plugins/deploy/dependencies/index.js +0 -629
  138. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -643
  139. package/dist/esm/plugins/deploy/exports.js +0 -4
  140. package/dist/esm/plugins/deploy/index.js +0 -135
  141. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
  142. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
  143. package/dist/esm/plugins/deploy/platforms/node.js +0 -133
  144. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
  145. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  146. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
  147. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
  148. package/dist/esm/plugins/deploy/utils.js +0 -47
  149. package/dist/esm/plugins/initialize/index.js +0 -119
  150. package/dist/esm/plugins/serverBuild.js +0 -87
  151. package/dist/esm/types/config/deploy.js +0 -0
  152. package/dist/esm/types/config/dev.js +0 -0
  153. package/dist/esm/types/config/experiments.js +0 -0
  154. package/dist/esm/types/config/html.js +0 -0
  155. package/dist/esm/types/config/index.js +0 -1
  156. package/dist/esm/types/config/output.js +0 -0
  157. package/dist/esm/types/config/performance.js +0 -0
  158. package/dist/esm/types/config/security.js +0 -0
  159. package/dist/esm/types/config/source.js +0 -0
  160. package/dist/esm/types/config/testing.js +0 -0
  161. package/dist/esm/types/config/tools.js +0 -0
  162. package/dist/esm/types/hooks.js +0 -0
  163. package/dist/esm/types/index.js +0 -3
  164. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  165. package/dist/esm/types/legacyConfig/dev.js +0 -0
  166. package/dist/esm/types/legacyConfig/index.js +0 -0
  167. package/dist/esm/types/legacyConfig/output.js +0 -0
  168. package/dist/esm/types/legacyConfig/source.js +0 -0
  169. package/dist/esm/types/legacyConfig/testing.js +0 -0
  170. package/dist/esm/types/legacyConfig/tools.js +0 -0
  171. package/dist/esm/types/utils.js +0 -0
  172. package/dist/esm/utils/config.js +0 -122
  173. package/dist/esm/utils/createServer.js +0 -58
  174. package/dist/esm/utils/env.js +0 -16
  175. package/dist/esm/utils/generateWatchFiles.js +0 -71
  176. package/dist/esm/utils/getSelectedEntries.js +0 -67
  177. package/dist/esm/utils/loadPlugins.js +0 -69
  178. package/dist/esm/utils/printInstructions.js +0 -32
  179. package/dist/esm/utils/register.js +0 -129
  180. package/dist/esm/utils/restart.js +0 -67
  181. package/dist/esm/utils/routes.js +0 -42
  182. package/dist/esm/utils/types.js +0 -0
  183. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
  184. package/dist/esm-node/builder/builder-rspack/index.js +0 -12
  185. package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
  186. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
  187. package/dist/esm-node/builder/builder-webpack/index.js +0 -20
  188. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
  189. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
  190. package/dist/esm-node/builder/generator/index.js +0 -37
  191. package/dist/esm-node/builder/index.js +0 -11
  192. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
  193. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  194. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
  195. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
  196. package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
  197. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  198. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  199. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -219
  200. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
  201. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  202. package/dist/esm-node/builder/shared/index.js +0 -3
  203. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  204. package/dist/esm-node/builder/shared/types.js +0 -0
  205. package/dist/esm-node/commands/build.js +0 -55
  206. package/dist/esm-node/commands/deploy.js +0 -12
  207. package/dist/esm-node/commands/dev.js +0 -95
  208. package/dist/esm-node/commands/index.js +0 -92
  209. package/dist/esm-node/commands/inspect.js +0 -15
  210. package/dist/esm-node/commands/serve.js +0 -51
  211. package/dist/esm-node/config/default.js +0 -197
  212. package/dist/esm-node/config/index.js +0 -3
  213. package/dist/esm-node/config/initialize/index.js +0 -9
  214. package/dist/esm-node/config/initialize/inits.js +0 -79
  215. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  216. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  217. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  218. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  219. package/dist/esm-node/config/legacy/index.js +0 -43
  220. package/dist/esm-node/defineConfig.js +0 -13
  221. package/dist/esm-node/exports/server.js +0 -4
  222. package/dist/esm-node/hooks.js +0 -34
  223. package/dist/esm-node/index.js +0 -124
  224. package/dist/esm-node/locale/en.js +0 -43
  225. package/dist/esm-node/locale/index.js +0 -12
  226. package/dist/esm-node/locale/zh.js +0 -43
  227. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  228. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
  229. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
  230. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
  231. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
  232. package/dist/esm-node/plugins/analyze/index.js +0 -166
  233. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  234. package/dist/esm-node/plugins/analyze/templates.js +0 -24
  235. package/dist/esm-node/plugins/analyze/utils.js +0 -68
  236. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -215
  237. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -202
  238. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  239. package/dist/esm-node/plugins/deploy/index.js +0 -44
  240. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
  241. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
  242. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
  243. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
  244. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  245. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
  246. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
  247. package/dist/esm-node/plugins/deploy/utils.js +0 -44
  248. package/dist/esm-node/plugins/initialize/index.js +0 -84
  249. package/dist/esm-node/plugins/serverBuild.js +0 -58
  250. package/dist/esm-node/types/config/deploy.js +0 -0
  251. package/dist/esm-node/types/config/dev.js +0 -0
  252. package/dist/esm-node/types/config/experiments.js +0 -0
  253. package/dist/esm-node/types/config/html.js +0 -0
  254. package/dist/esm-node/types/config/index.js +0 -1
  255. package/dist/esm-node/types/config/output.js +0 -0
  256. package/dist/esm-node/types/config/performance.js +0 -0
  257. package/dist/esm-node/types/config/security.js +0 -0
  258. package/dist/esm-node/types/config/source.js +0 -0
  259. package/dist/esm-node/types/config/testing.js +0 -0
  260. package/dist/esm-node/types/config/tools.js +0 -0
  261. package/dist/esm-node/types/hooks.js +0 -0
  262. package/dist/esm-node/types/index.js +0 -3
  263. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  264. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  265. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  266. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  267. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  268. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  269. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  270. package/dist/esm-node/types/utils.js +0 -0
  271. package/dist/esm-node/utils/config.js +0 -49
  272. package/dist/esm-node/utils/createServer.js +0 -26
  273. package/dist/esm-node/utils/env.js +0 -16
  274. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  275. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  276. package/dist/esm-node/utils/loadPlugins.js +0 -22
  277. package/dist/esm-node/utils/printInstructions.js +0 -11
  278. package/dist/esm-node/utils/register.js +0 -69
  279. package/dist/esm-node/utils/restart.js +0 -22
  280. package/dist/esm-node/utils/routes.js +0 -21
  281. package/dist/esm-node/utils/types.js +0 -0
  282. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
  283. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  284. /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
  285. /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,643 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
5
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
6
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
7
- import path from "path";
8
- import os from "node:os";
9
- import { fs as fse } from "@modern-js/utils";
10
- import { parseNodeModulePath } from "mlly";
11
- import { nodeFileTrace } from "@vercel/nft";
12
- function applyPublicCondition(pkg) {
13
- var _pkg_publishConfig;
14
- if (pkg === null || pkg === void 0 ? void 0 : (_pkg_publishConfig = pkg.publishConfig) === null || _pkg_publishConfig === void 0 ? void 0 : _pkg_publishConfig.exports) {
15
- var _pkg_publishConfig1;
16
- pkg.exports = pkg === null || pkg === void 0 ? void 0 : (_pkg_publishConfig1 = pkg.publishConfig) === null || _pkg_publishConfig1 === void 0 ? void 0 : _pkg_publishConfig1.exports;
17
- }
18
- }
19
- var writePackage = function() {
20
- var _ref = _async_to_generator(function(options) {
21
- var pkg, version, projectDir, _pkgPath, pkgPath, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, src, subpath, dest, dirname, subpath1, dest1, dirname1, err, pkgJSON, packageJsonPath;
22
- return _ts_generator(this, function(_state) {
23
- switch (_state.label) {
24
- case 0:
25
- pkg = options.pkg, version = options.version, projectDir = options.projectDir, _pkgPath = options._pkgPath;
26
- pkgPath = _pkgPath || pkg.name;
27
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
28
- _state.label = 1;
29
- case 1:
30
- _state.trys.push([
31
- 1,
32
- 10,
33
- 11,
34
- 12
35
- ]);
36
- _iterator = pkg.versions[version].files[Symbol.iterator]();
37
- _state.label = 2;
38
- case 2:
39
- if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
40
- return [
41
- 3,
42
- 9
43
- ];
44
- src = _step.value;
45
- if (!src.includes("node_modules"))
46
- return [
47
- 3,
48
- 5
49
- ];
50
- subpath = parseNodeModulePath(src).subpath;
51
- dest = path.join(projectDir, "node_modules", pkgPath, subpath);
52
- dirname = path.dirname(dest);
53
- return [
54
- 4,
55
- fse.ensureDir(dirname)
56
- ];
57
- case 3:
58
- _state.sent();
59
- return [
60
- 4,
61
- fse.copyFile(src, dest)
62
- ];
63
- case 4:
64
- _state.sent();
65
- return [
66
- 3,
67
- 8
68
- ];
69
- case 5:
70
- subpath1 = path.relative(pkg.versions[version].path, src);
71
- dest1 = path.join(projectDir, "node_modules", pkgPath, subpath1);
72
- dirname1 = path.dirname(dest1);
73
- return [
74
- 4,
75
- fse.ensureDir(dirname1)
76
- ];
77
- case 6:
78
- _state.sent();
79
- return [
80
- 4,
81
- fse.copyFile(src, dest1)
82
- ];
83
- case 7:
84
- _state.sent();
85
- _state.label = 8;
86
- case 8:
87
- _iteratorNormalCompletion = true;
88
- return [
89
- 3,
90
- 2
91
- ];
92
- case 9:
93
- return [
94
- 3,
95
- 12
96
- ];
97
- case 10:
98
- err = _state.sent();
99
- _didIteratorError = true;
100
- _iteratorError = err;
101
- return [
102
- 3,
103
- 12
104
- ];
105
- case 11:
106
- try {
107
- if (!_iteratorNormalCompletion && _iterator.return != null) {
108
- _iterator.return();
109
- }
110
- } finally {
111
- if (_didIteratorError) {
112
- throw _iteratorError;
113
- }
114
- }
115
- return [
116
- 7
117
- ];
118
- case 12:
119
- pkgJSON = pkg.versions[version].pkgJSON;
120
- applyPublicCondition(pkgJSON);
121
- packageJsonPath = path.join(projectDir, "node_modules", pkgPath, "package.json");
122
- return [
123
- 4,
124
- fse.ensureDir(path.dirname(packageJsonPath))
125
- ];
126
- case 13:
127
- _state.sent();
128
- return [
129
- 4,
130
- fse.writeFile(packageJsonPath, JSON.stringify(pkgJSON, null, 2))
131
- ];
132
- case 14:
133
- _state.sent();
134
- return [
135
- 2
136
- ];
137
- }
138
- });
139
- });
140
- return function writePackage2(options) {
141
- return _ref.apply(this, arguments);
142
- };
143
- }();
144
- var isWindows = os.platform() === "win32";
145
- var linkPackage = function() {
146
- var _ref = _async_to_generator(function(from, to, projectRootDir) {
147
- var src, dest, dstStat, exists;
148
- return _ts_generator(this, function(_state) {
149
- switch (_state.label) {
150
- case 0:
151
- src = path.join(projectRootDir, "node_modules", from);
152
- dest = path.join(projectRootDir, "node_modules", to);
153
- return [
154
- 4,
155
- fse.lstat(dest).catch(function() {
156
- return null;
157
- })
158
- ];
159
- case 1:
160
- dstStat = _state.sent();
161
- exists = dstStat === null || dstStat === void 0 ? void 0 : dstStat.isSymbolicLink();
162
- if (exists) {
163
- return [
164
- 2
165
- ];
166
- }
167
- return [
168
- 4,
169
- fse.mkdir(path.dirname(dest), {
170
- recursive: true
171
- })
172
- ];
173
- case 2:
174
- _state.sent();
175
- return [
176
- 4,
177
- fse.symlink(path.relative(path.dirname(dest), src), dest, isWindows ? "junction" : "dir").catch(function(error) {
178
- console.error("Cannot link", from, "to", to, error);
179
- })
180
- ];
181
- case 3:
182
- _state.sent();
183
- return [
184
- 2
185
- ];
186
- }
187
- });
188
- });
189
- return function linkPackage2(from, to, projectRootDir) {
190
- return _ref.apply(this, arguments);
191
- };
192
- }();
193
- var readDirRecursive = function() {
194
- var _ref = _async_to_generator(function(dir) {
195
- var options, filter, files, filesAndDirs;
196
- var _arguments = arguments;
197
- return _ts_generator(this, function(_state) {
198
- switch (_state.label) {
199
- case 0:
200
- options = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
201
- filter = options.filter;
202
- return [
203
- 4,
204
- fse.readdir(dir, {
205
- withFileTypes: true
206
- })
207
- ];
208
- case 1:
209
- files = _state.sent();
210
- return [
211
- 4,
212
- Promise.all(files.map(function() {
213
- var _ref2 = _async_to_generator(function(file) {
214
- var resolvedPath;
215
- return _ts_generator(this, function(_state2) {
216
- resolvedPath = path.resolve(dir, file.name);
217
- if (file.isDirectory()) {
218
- return [
219
- 2,
220
- readDirRecursive(resolvedPath, options)
221
- ];
222
- } else {
223
- return [
224
- 2,
225
- filter && !filter(resolvedPath) ? [] : resolvedPath
226
- ];
227
- }
228
- return [
229
- 2
230
- ];
231
- });
232
- });
233
- return function(file) {
234
- return _ref2.apply(this, arguments);
235
- };
236
- }()))
237
- ];
238
- case 2:
239
- filesAndDirs = _state.sent();
240
- return [
241
- 2,
242
- filesAndDirs.flat()
243
- ];
244
- }
245
- });
246
- });
247
- return function readDirRecursive2(dir) {
248
- return _ref.apply(this, arguments);
249
- };
250
- }();
251
- var isFile = function() {
252
- var _ref = _async_to_generator(function(file) {
253
- var stat, error;
254
- return _ts_generator(this, function(_state) {
255
- switch (_state.label) {
256
- case 0:
257
- _state.trys.push([
258
- 0,
259
- 2,
260
- ,
261
- 3
262
- ]);
263
- return [
264
- 4,
265
- fse.stat(file)
266
- ];
267
- case 1:
268
- stat = _state.sent();
269
- return [
270
- 2,
271
- stat.isFile()
272
- ];
273
- case 2:
274
- error = _state.sent();
275
- if (error.code === "ENOENT") {
276
- return [
277
- 2,
278
- false
279
- ];
280
- }
281
- throw error;
282
- case 3:
283
- return [
284
- 2
285
- ];
286
- }
287
- });
288
- });
289
- return function isFile2(file) {
290
- return _ref.apply(this, arguments);
291
- };
292
- }();
293
- var findEntryFiles = function() {
294
- var _ref = _async_to_generator(function(rootDir, entryFilter) {
295
- var files;
296
- return _ts_generator(this, function(_state) {
297
- switch (_state.label) {
298
- case 0:
299
- return [
300
- 4,
301
- readDirRecursive(rootDir, {
302
- filter: entryFilter
303
- })
304
- ];
305
- case 1:
306
- files = _state.sent();
307
- return [
308
- 2,
309
- files.filter(function(file) {
310
- return file.endsWith(".mjs") || file.endsWith(".cjs") || file.endsWith(".js");
311
- })
312
- ];
313
- }
314
- });
315
- });
316
- return function findEntryFiles2(rootDir, entryFilter) {
317
- return _ref.apply(this, arguments);
318
- };
319
- }();
320
- var findPackageParents = function(pkg, version, tracedFiles) {
321
- var versionFiles = pkg.versions[version].files.map(function(path2) {
322
- return tracedFiles[path2];
323
- });
324
- var parentPkgs = _to_consumable_array(new Set(versionFiles.flatMap(function(file) {
325
- return (
326
- // Because it supports copyWholePackage configuration, not all files exist.
327
- file === null || file === void 0 ? void 0 : file.parents.map(function(parentPath) {
328
- var parentFile = tracedFiles[parentPath];
329
- if (!parentFile || parentFile.pkgName === pkg.name) {
330
- return null;
331
- }
332
- return "".concat(parentFile.pkgName, "@").concat(parentFile.pkgVersion);
333
- }).filter(Boolean)
334
- );
335
- })));
336
- return parentPkgs.filter(function(parentPkg) {
337
- return parentPkg;
338
- });
339
- };
340
- function serializeMap(map) {
341
- return _serializeMap.apply(this, arguments);
342
- }
343
- function _serializeMap() {
344
- _serializeMap = _async_to_generator(function(map) {
345
- var resolvedMap;
346
- return _ts_generator(this, function(_state) {
347
- switch (_state.label) {
348
- case 0:
349
- resolvedMap = /* @__PURE__ */ new Map();
350
- return [
351
- 4,
352
- Promise.all(Array.from(map.entries()).map(function() {
353
- var _ref = _async_to_generator(function(param) {
354
- var _param, key, value, _, _tmp, _tmp1;
355
- return _ts_generator(this, function(_state2) {
356
- switch (_state2.label) {
357
- case 0:
358
- _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
359
- _ = resolvedMap.set;
360
- _tmp = [
361
- key
362
- ];
363
- if (!_instanceof(value, Promise))
364
- return [
365
- 3,
366
- 2
367
- ];
368
- return [
369
- 4,
370
- Promise.resolve(value)
371
- ];
372
- case 1:
373
- _tmp1 = _state2.sent();
374
- return [
375
- 3,
376
- 3
377
- ];
378
- case 2:
379
- _tmp1 = value;
380
- _state2.label = 3;
381
- case 3:
382
- _.apply(resolvedMap, _tmp.concat([
383
- _tmp1
384
- ]));
385
- return [
386
- 2
387
- ];
388
- }
389
- });
390
- });
391
- return function(_) {
392
- return _ref.apply(this, arguments);
393
- };
394
- }()))
395
- ];
396
- case 1:
397
- _state.sent();
398
- return [
399
- 2,
400
- JSON.stringify(resolvedMap, function(key, value) {
401
- if (value === null) {
402
- return void 0;
403
- }
404
- if (_instanceof(value, Map)) {
405
- return {
406
- dataType: "Map",
407
- value: Array.from(value.entries())
408
- };
409
- }
410
- if (_instanceof(value, Set)) {
411
- return {
412
- dataType: "Set",
413
- value: Array.from(value)
414
- };
415
- }
416
- return value;
417
- })
418
- ];
419
- }
420
- });
421
- });
422
- return _serializeMap.apply(this, arguments);
423
- }
424
- function deserializeMap(serializedData) {
425
- return JSON.parse(serializedData, function(key, value) {
426
- if (value && value.dataType === "Map") {
427
- return new Map(value.value);
428
- }
429
- if (value && value.dataType === "Set") {
430
- return new Set(value.value);
431
- }
432
- return value;
433
- });
434
- }
435
- var loadCache = function() {
436
- var _ref = _async_to_generator(function(filePath, enabled) {
437
- var _tmp, data;
438
- return _ts_generator(this, function(_state) {
439
- switch (_state.label) {
440
- case 0:
441
- _tmp = enabled;
442
- if (!_tmp)
443
- return [
444
- 3,
445
- 2
446
- ];
447
- return [
448
- 4,
449
- fse.pathExists(filePath)
450
- ];
451
- case 1:
452
- _tmp = _state.sent();
453
- _state.label = 2;
454
- case 2:
455
- if (!_tmp)
456
- return [
457
- 3,
458
- 4
459
- ];
460
- console.log("load cache:", filePath);
461
- return [
462
- 4,
463
- fse.readFile(filePath)
464
- ];
465
- case 3:
466
- data = _state.sent().toString();
467
- return [
468
- 2,
469
- deserializeMap(data)
470
- ];
471
- case 4:
472
- return [
473
- 2,
474
- void 0
475
- ];
476
- }
477
- });
478
- });
479
- return function loadCache2(filePath, enabled) {
480
- return _ref.apply(this, arguments);
481
- };
482
- }();
483
- var writeCache = function() {
484
- var _ref = _async_to_generator(function(filePath, cacheMap) {
485
- var newCacheMap, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, key, value, _, _tmp;
486
- return _ts_generator(this, function(_state) {
487
- switch (_state.label) {
488
- case 0:
489
- newCacheMap = /* @__PURE__ */ new Map();
490
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
491
- try {
492
- for (_iterator = cacheMap.entries()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
493
- _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
494
- if (key.includes("node_modules/")) {
495
- newCacheMap.set(key, value);
496
- }
497
- }
498
- } catch (err) {
499
- _didIteratorError = true;
500
- _iteratorError = err;
501
- } finally {
502
- try {
503
- if (!_iteratorNormalCompletion && _iterator.return != null) {
504
- _iterator.return();
505
- }
506
- } finally {
507
- if (_didIteratorError) {
508
- throw _iteratorError;
509
- }
510
- }
511
- }
512
- _ = fse.writeFile;
513
- _tmp = [
514
- filePath
515
- ];
516
- return [
517
- 4,
518
- serializeMap(newCacheMap)
519
- ];
520
- case 1:
521
- return [
522
- 4,
523
- _.apply(fse, _tmp.concat([
524
- _state.sent()
525
- ]))
526
- ];
527
- case 2:
528
- _state.sent();
529
- console.log("write ".concat(path.basename(filePath), " finish"));
530
- return [
531
- 2
532
- ];
533
- }
534
- });
535
- });
536
- return function writeCache2(filePath, cacheMap) {
537
- return _ref.apply(this, arguments);
538
- };
539
- }();
540
- var traceFiles = function() {
541
- var _ref = _async_to_generator(function(param) {
542
- var entryFiles, serverRootDir, _param_base, base, cacheOptions, traceOptions, cacheDir, fileCache, analysisCache, symlinkCache, analysisCacheFile, fileCacheFile, symlinkCacheFile, cache, _tmp, res;
543
- return _ts_generator(this, function(_state) {
544
- switch (_state.label) {
545
- case 0:
546
- entryFiles = param.entryFiles, serverRootDir = param.serverRootDir, _param_base = param.base, base = _param_base === void 0 ? "/" : _param_base, cacheOptions = param.cacheOptions, traceOptions = param.traceOptions;
547
- cacheDir = cacheOptions.cacheDir, fileCache = cacheOptions.fileCache, analysisCache = cacheOptions.analysisCache, symlinkCache = cacheOptions.symlinkCache;
548
- analysisCacheFile = path.join(cacheDir, "analysis-cache.json");
549
- fileCacheFile = path.join(cacheDir, "file-cache.json");
550
- symlinkCacheFile = path.join(cacheDir, "symlink-cache.json");
551
- _tmp = {};
552
- return [
553
- 4,
554
- loadCache(analysisCacheFile, analysisCache)
555
- ];
556
- case 1:
557
- _tmp.analysisCache = _state.sent();
558
- return [
559
- 4,
560
- loadCache(fileCacheFile, fileCache)
561
- ];
562
- case 2:
563
- _tmp.fileCache = _state.sent();
564
- return [
565
- 4,
566
- loadCache(symlinkCacheFile, symlinkCache)
567
- ];
568
- case 3:
569
- cache = (_tmp.symlinkCache = _state.sent(), _tmp);
570
- return [
571
- 4,
572
- nodeFileTrace(entryFiles, _object_spread({
573
- base,
574
- processCwd: serverRootDir,
575
- cache
576
- }, traceOptions))
577
- ];
578
- case 4:
579
- res = _state.sent();
580
- if (!(analysisCache || fileCache || symlinkCache))
581
- return [
582
- 3,
583
- 6
584
- ];
585
- return [
586
- 4,
587
- fse.ensureDir(cacheDir)
588
- ];
589
- case 5:
590
- _state.sent();
591
- if (cache.analysisCache && analysisCache) {
592
- writeCache(analysisCacheFile, cache.analysisCache);
593
- }
594
- if (cache.fileCache && fileCache) {
595
- writeCache(fileCacheFile, cache.fileCache);
596
- }
597
- if (cache.symlinkCache && symlinkCache) {
598
- writeCache(symlinkCacheFile, cache.symlinkCache);
599
- }
600
- _state.label = 6;
601
- case 6:
602
- return [
603
- 2,
604
- res
605
- ];
606
- }
607
- });
608
- });
609
- return function traceFiles2(_) {
610
- return _ref.apply(this, arguments);
611
- };
612
- }();
613
- var resolveTracedPath = function() {
614
- var _ref = _async_to_generator(function(base, p) {
615
- return _ts_generator(this, function(_state) {
616
- return [
617
- 2,
618
- fse.realpath(path.resolve(base, p))
619
- ];
620
- });
621
- });
622
- return function resolveTracedPath2(base, p) {
623
- return _ref.apply(this, arguments);
624
- };
625
- }();
626
- var isSubPath = function(parentPath, childPath) {
627
- if (!parentPath || !childPath) {
628
- return false;
629
- }
630
- var relative = path.relative(parentPath, childPath);
631
- return relative && !relative.startsWith("..");
632
- };
633
- export {
634
- findEntryFiles,
635
- findPackageParents,
636
- isFile,
637
- isSubPath,
638
- linkPackage,
639
- readDirRecursive,
640
- resolveTracedPath,
641
- traceFiles,
642
- writePackage
643
- };
@@ -1,4 +0,0 @@
1
- import { handleDependencies } from "./dependencies";
2
- export {
3
- handleDependencies
4
- };