@modern-js/module-tools 2.0.0-beta.3 → 2.0.0-beta.6

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 (463) hide show
  1. package/CHANGELOG.md +331 -211
  2. package/bin/modern.js +1 -0
  3. package/compiled/@babel/code-frame/index.d.ts +1 -0
  4. package/compiled/@babel/code-frame/index.js +1 -0
  5. package/compiled/@babel/code-frame/license +22 -0
  6. package/compiled/@babel/code-frame/package.json +1 -0
  7. package/compiled/@babel/generator/index.d.ts +1 -0
  8. package/compiled/@babel/generator/index.js +1 -0
  9. package/compiled/@babel/generator/license +22 -0
  10. package/compiled/@babel/generator/package.json +1 -0
  11. package/compiled/@babel/helper-validator-identifier/index.d.ts +1 -0
  12. package/compiled/@babel/helper-validator-identifier/index.js +1 -0
  13. package/compiled/@babel/helper-validator-identifier/license +22 -0
  14. package/compiled/@babel/helper-validator-identifier/package.json +1 -0
  15. package/compiled/@babel/highlight/index.d.ts +1 -0
  16. package/compiled/@babel/highlight/index.js +1 -0
  17. package/compiled/@babel/highlight/license +22 -0
  18. package/compiled/@babel/highlight/package.json +1 -0
  19. package/compiled/@babel/parser/@babel/types/lib/index-legacy.d.ts +2742 -0
  20. package/compiled/@babel/parser/index.js +1 -0
  21. package/compiled/@babel/parser/license +19 -0
  22. package/compiled/@babel/parser/package.json +1 -0
  23. package/compiled/@babel/parser/typings/babel-parser.d.ts +214 -0
  24. package/compiled/@babel/template/index.d.ts +1 -0
  25. package/compiled/@babel/template/index.js +1 -0
  26. package/compiled/@babel/template/license +22 -0
  27. package/compiled/@babel/template/package.json +1 -0
  28. package/compiled/@babel/traverse/index.d.ts +1199 -0
  29. package/compiled/@babel/traverse/index.js +1 -0
  30. package/compiled/@babel/traverse/license +22 -0
  31. package/compiled/@babel/traverse/package.json +1 -0
  32. package/compiled/@babel/types/index.js +1 -0
  33. package/compiled/@babel/types/lib/index-legacy.d.ts +2732 -0
  34. package/compiled/@babel/types/license +22 -0
  35. package/compiled/@babel/types/package.json +1 -0
  36. package/compiled/@rollup/plugin-json/@rollup/pluginutils/types/index.d.ts +86 -0
  37. package/compiled/@rollup/plugin-json/estree/index.d.ts +548 -0
  38. package/compiled/@rollup/plugin-json/index.js +1 -0
  39. package/compiled/@rollup/plugin-json/license +21 -0
  40. package/compiled/@rollup/plugin-json/package.json +1 -0
  41. package/compiled/@rollup/plugin-json/rollup/dist/rollup.d.ts +948 -0
  42. package/compiled/@rollup/plugin-json/types/index.d.ts +41 -0
  43. package/compiled/find-up/index.d.ts +138 -0
  44. package/compiled/find-up/index.js +1 -0
  45. package/compiled/find-up/license +9 -0
  46. package/compiled/find-up/locate-path/index.d.ts +83 -0
  47. package/compiled/find-up/package.json +1 -0
  48. package/compiled/less/index.d.ts +282 -0
  49. package/compiled/less/index.js +1 -0
  50. package/compiled/less/package.json +1 -0
  51. package/compiled/normalize-path/index.d.ts +8 -0
  52. package/compiled/normalize-path/index.js +8 -0
  53. package/compiled/normalize-path/license +21 -0
  54. package/compiled/normalize-path/package.json +1 -0
  55. package/compiled/p-map/@szmarczak/http-timer/dist/source/index.d.ts +32 -0
  56. package/compiled/p-map/cacheable-lookup/index.d.ts +139 -0
  57. package/compiled/p-map/cacheable-request/index.d.ts +137 -0
  58. package/compiled/p-map/got/dist/source/as-promise/index.d.ts +3 -0
  59. package/compiled/p-map/got/dist/source/as-promise/types.d.ts +256 -0
  60. package/compiled/p-map/got/dist/source/core/index.d.ts +1124 -0
  61. package/compiled/p-map/got/dist/source/core/utils/dns-ip-version.d.ts +5 -0
  62. package/compiled/p-map/got/dist/source/core/utils/options-to-url.d.ts +14 -0
  63. package/compiled/p-map/got/dist/source/core/utils/timed-out.d.ts +29 -0
  64. package/compiled/p-map/got/dist/source/index.d.ts +4 -0
  65. package/compiled/p-map/got/dist/source/types.d.ts +344 -0
  66. package/compiled/p-map/http-cache-semantics/index.d.ts +170 -0
  67. package/compiled/p-map/index.d.ts +67 -0
  68. package/compiled/p-map/index.js +1 -0
  69. package/compiled/p-map/keyv/src/index.d.ts +104 -0
  70. package/compiled/p-map/license +9 -0
  71. package/compiled/p-map/p-cancelable/index.d.ts +176 -0
  72. package/compiled/p-map/package.json +1 -0
  73. package/compiled/p-map/responselike/index.d.ts +34 -0
  74. package/compiled/postcss-custom-properties/index.d.ts +1 -0
  75. package/compiled/postcss-custom-properties/index.js +1 -0
  76. package/compiled/postcss-custom-properties/package.json +1 -0
  77. package/compiled/postcss-flexbugs-fixes/index.d.ts +1 -0
  78. package/compiled/postcss-flexbugs-fixes/index.js +1 -0
  79. package/compiled/postcss-flexbugs-fixes/license +20 -0
  80. package/compiled/postcss-flexbugs-fixes/package.json +1 -0
  81. package/compiled/postcss-font-variant/index.d.ts +1 -0
  82. package/compiled/postcss-font-variant/index.js +1 -0
  83. package/compiled/postcss-font-variant/license +20 -0
  84. package/compiled/postcss-font-variant/package.json +1 -0
  85. package/compiled/postcss-initial/index.d.ts +1 -0
  86. package/compiled/postcss-initial/index.js +1 -0
  87. package/compiled/postcss-initial/license +20 -0
  88. package/compiled/postcss-initial/package.json +1 -0
  89. package/compiled/postcss-media-minmax/index.d.ts +1 -0
  90. package/compiled/postcss-media-minmax/index.js +1 -0
  91. package/compiled/postcss-media-minmax/license +22 -0
  92. package/compiled/postcss-media-minmax/package.json +1 -0
  93. package/compiled/postcss-nesting/index.d.ts +1 -0
  94. package/compiled/postcss-nesting/index.js +2 -0
  95. package/compiled/postcss-nesting/package.json +1 -0
  96. package/compiled/postcss-page-break/index.d.ts +1 -0
  97. package/compiled/postcss-page-break/index.js +1 -0
  98. package/compiled/postcss-page-break/license +20 -0
  99. package/compiled/postcss-page-break/package.json +1 -0
  100. package/compiled/postcss-value-parser/index.d.ts +1 -0
  101. package/compiled/postcss-value-parser/index.js +1 -0
  102. package/compiled/postcss-value-parser/license +22 -0
  103. package/compiled/postcss-value-parser/package.json +1 -0
  104. package/compiled/rollup/fsevents.node +0 -0
  105. package/compiled/rollup/index.js +82 -0
  106. package/compiled/rollup/package.json +1 -0
  107. package/compiled/rollup/types/rollup.d.ts +948 -0
  108. package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +21 -0
  109. package/compiled/rollup-plugin-dts/index.js +1 -0
  110. package/compiled/rollup-plugin-dts/package.json +1 -0
  111. package/compiled/rollup-plugin-dts/rollup/dist/rollup.d.ts +948 -0
  112. package/compiled/sass/index.js +1 -0
  113. package/compiled/sass/license +1619 -0
  114. package/compiled/sass/package.json +1 -0
  115. package/compiled/sass/types/compile.d.ts +152 -0
  116. package/compiled/sass/types/exception.d.ts +41 -0
  117. package/compiled/sass/types/importer.d.ts +294 -0
  118. package/compiled/sass/types/index.d.ts +80 -0
  119. package/compiled/sass/types/legacy/exception.d.ts +54 -0
  120. package/compiled/sass/types/legacy/function.d.ts +756 -0
  121. package/compiled/sass/types/legacy/importer.d.ts +168 -0
  122. package/compiled/sass/types/legacy/options.d.ts +642 -0
  123. package/compiled/sass/types/legacy/plugin_this.d.ts +73 -0
  124. package/compiled/sass/types/legacy/render.d.ts +139 -0
  125. package/compiled/sass/types/logger/index.d.ts +94 -0
  126. package/compiled/sass/types/logger/source_location.d.ts +21 -0
  127. package/compiled/sass/types/logger/source_span.d.ts +34 -0
  128. package/compiled/sass/types/options.d.ts +435 -0
  129. package/compiled/sass/types/util/promise_or.d.ts +17 -0
  130. package/compiled/sass/types/value/argument_list.d.ts +47 -0
  131. package/compiled/sass/types/value/boolean.d.ts +29 -0
  132. package/compiled/sass/types/value/color.d.ts +107 -0
  133. package/compiled/sass/types/value/function.d.ts +22 -0
  134. package/compiled/sass/types/value/index.d.ts +173 -0
  135. package/compiled/sass/types/value/list.d.ts +54 -0
  136. package/compiled/sass/types/value/map.d.ts +41 -0
  137. package/compiled/sass/types/value/number.d.ts +305 -0
  138. package/compiled/sass/types/value/string.d.ts +84 -0
  139. package/compiled/signal-exit/index.d.ts +24 -0
  140. package/compiled/signal-exit/index.js +1 -0
  141. package/compiled/signal-exit/package.json +1 -0
  142. package/dist/builder/build.d.ts +23 -0
  143. package/dist/builder/build.js +269 -0
  144. package/dist/builder/build.js.map +1 -0
  145. package/dist/builder/clear.d.ts +3 -0
  146. package/dist/builder/clear.js +67 -0
  147. package/dist/builder/clear.js.map +1 -0
  148. package/dist/builder/copy.d.ts +11 -0
  149. package/dist/builder/copy.js +196 -0
  150. package/dist/builder/copy.js.map +1 -0
  151. package/dist/builder/dts/index.d.ts +2 -0
  152. package/dist/builder/dts/index.js +32 -0
  153. package/dist/builder/dts/index.js.map +1 -0
  154. package/dist/builder/dts/rollup.d.ts +17 -0
  155. package/dist/builder/dts/rollup.js +167 -0
  156. package/dist/builder/dts/rollup.js.map +1 -0
  157. package/dist/builder/dts/tsc.d.ts +3 -0
  158. package/dist/builder/dts/tsc.js +153 -0
  159. package/dist/builder/dts/tsc.js.map +1 -0
  160. package/dist/builder/index.d.ts +8 -0
  161. package/dist/builder/index.js +116 -0
  162. package/dist/builder/index.js.map +1 -0
  163. package/dist/builder/platform.d.ts +4 -0
  164. package/dist/builder/platform.js +132 -0
  165. package/dist/builder/platform.js.map +1 -0
  166. package/dist/cli.d.ts +3 -0
  167. package/dist/cli.js +95 -0
  168. package/dist/cli.js.map +1 -0
  169. package/dist/command.d.ts +7 -0
  170. package/dist/command.js +164 -0
  171. package/dist/command.js.map +1 -0
  172. package/dist/config/defineConfig.d.ts +2 -0
  173. package/dist/config/defineConfig.js +29 -0
  174. package/dist/config/defineConfig.js.map +1 -0
  175. package/dist/config/normalize.d.ts +17 -0
  176. package/dist/config/normalize.js +168 -0
  177. package/dist/config/normalize.js.map +1 -0
  178. package/dist/config/schema.d.ts +641 -0
  179. package/dist/config/schema.js +215 -0
  180. package/dist/config/schema.js.map +1 -0
  181. package/dist/constants/build-presets.d.ts +81 -0
  182. package/dist/constants/build-presets.js +236 -0
  183. package/dist/constants/build-presets.js.map +1 -0
  184. package/dist/constants/build.d.ts +5 -0
  185. package/dist/constants/build.js +78 -0
  186. package/dist/constants/build.js.map +1 -0
  187. package/dist/constants/colors.d.ts +4 -0
  188. package/dist/constants/colors.js +35 -0
  189. package/dist/constants/colors.js.map +1 -0
  190. package/dist/constants/dts.d.ts +4 -0
  191. package/dist/constants/dts.js +52 -0
  192. package/dist/constants/dts.js.map +1 -0
  193. package/dist/constants/file.d.ts +3 -0
  194. package/dist/constants/file.js +35 -0
  195. package/dist/constants/file.js.map +1 -0
  196. package/dist/constants/legacy-build-presets.d.ts +13 -0
  197. package/dist/constants/legacy-build-presets.js +198 -0
  198. package/dist/constants/legacy-build-presets.js.map +1 -0
  199. package/dist/constants/log.d.ts +8 -0
  200. package/dist/constants/log.js +43 -0
  201. package/dist/constants/log.js.map +1 -0
  202. package/dist/dev.d.ts +10 -0
  203. package/dist/dev.js +129 -0
  204. package/dist/dev.js.map +1 -0
  205. package/dist/{types/features/build/error.d.ts → error.d.ts} +1 -1
  206. package/dist/error.js +148 -0
  207. package/dist/error.js.map +1 -0
  208. package/dist/hooks/build.d.ts +22 -0
  209. package/dist/hooks/build.js +39 -0
  210. package/dist/hooks/build.js.map +1 -0
  211. package/dist/hooks/dev.d.ts +12 -0
  212. package/dist/hooks/dev.js +37 -0
  213. package/dist/hooks/dev.js.map +1 -0
  214. package/dist/hooks/index.d.ts +29 -0
  215. package/dist/hooks/index.js +46 -0
  216. package/dist/hooks/index.js.map +1 -0
  217. package/dist/hooks/misc.d.ts +5 -0
  218. package/dist/hooks/misc.js +33 -0
  219. package/dist/hooks/misc.js.map +1 -0
  220. package/dist/index.d.ts +5 -0
  221. package/dist/index.js +37 -0
  222. package/dist/index.js.map +1 -0
  223. package/dist/{types/locale → locale}/en.d.ts +0 -0
  224. package/dist/locale/en.js +51 -0
  225. package/dist/locale/en.js.map +1 -0
  226. package/dist/{types/locale → locale}/index.d.ts +0 -0
  227. package/dist/locale/index.js +39 -0
  228. package/dist/locale/index.js.map +1 -0
  229. package/dist/{types/locale → locale}/zh.d.ts +0 -0
  230. package/dist/locale/zh.js +51 -0
  231. package/dist/locale/zh.js.map +1 -0
  232. package/dist/plugins.d.ts +2 -0
  233. package/dist/plugins.js +55 -0
  234. package/dist/plugins.js.map +1 -0
  235. package/dist/types/color.d.ts +1 -0
  236. package/dist/types/color.js +17 -0
  237. package/dist/types/color.js.map +1 -0
  238. package/dist/types/command.d.ts +11 -0
  239. package/dist/types/command.js +17 -0
  240. package/dist/types/command.js.map +1 -0
  241. package/dist/types/config/index.d.ts +92 -0
  242. package/dist/types/config/index.js +19 -0
  243. package/dist/types/config/index.js.map +1 -0
  244. package/dist/types/config/style.d.ts +12 -0
  245. package/dist/types/config/style.js +17 -0
  246. package/dist/types/config/style.js.map +1 -0
  247. package/dist/types/context.d.ts +5 -0
  248. package/dist/types/context.js +17 -0
  249. package/dist/types/context.js.map +1 -0
  250. package/dist/types/copy.d.ts +15 -0
  251. package/dist/types/copy.js +17 -0
  252. package/dist/types/copy.js.map +1 -0
  253. package/dist/types/{utils/tsconfig.d.ts → dts.d.ts} +11 -3
  254. package/dist/types/dts.js +17 -0
  255. package/dist/types/dts.js.map +1 -0
  256. package/dist/types/hooks.d.ts +25 -0
  257. package/dist/types/hooks.js +17 -0
  258. package/dist/types/hooks.js.map +1 -0
  259. package/dist/types/index.d.ts +17 -6
  260. package/dist/types/index.js +23 -0
  261. package/dist/types/index.js.map +1 -0
  262. package/dist/types/utils.d.ts +7 -0
  263. package/dist/types/utils.js +17 -0
  264. package/dist/types/utils.js.map +1 -0
  265. package/dist/utils/builder.d.ts +8 -0
  266. package/dist/utils/builder.js +104 -0
  267. package/dist/utils/builder.js.map +1 -0
  268. package/dist/utils/config.d.ts +6 -0
  269. package/dist/utils/config.js +167 -0
  270. package/dist/utils/config.js.map +1 -0
  271. package/dist/utils/context.d.ts +7 -0
  272. package/dist/utils/context.js +60 -0
  273. package/dist/utils/context.js.map +1 -0
  274. package/dist/utils/dts.d.ts +14 -0
  275. package/dist/utils/dts.js +186 -0
  276. package/dist/utils/dts.js.map +1 -0
  277. package/dist/utils/input.d.ts +16 -0
  278. package/dist/utils/input.js +113 -0
  279. package/dist/utils/input.js.map +1 -0
  280. package/dist/utils/language.d.ts +2 -0
  281. package/dist/utils/language.js +68 -0
  282. package/dist/utils/language.js.map +1 -0
  283. package/dist/utils/libuild-plugins.d.ts +6 -0
  284. package/dist/utils/libuild-plugins.js +83 -0
  285. package/dist/utils/libuild-plugins.js.map +1 -0
  286. package/dist/utils/log.d.ts +2 -0
  287. package/dist/utils/log.js +68 -0
  288. package/dist/utils/log.js.map +1 -0
  289. package/dist/utils/onExit.d.ts +1 -0
  290. package/dist/utils/onExit.js +63 -0
  291. package/dist/utils/onExit.js.map +1 -0
  292. package/dist/utils/path.d.ts +1 -0
  293. package/dist/utils/path.js +59 -0
  294. package/dist/utils/path.js.map +1 -0
  295. package/dist/utils/style.d.ts +31 -0
  296. package/dist/utils/style.js +129 -0
  297. package/dist/utils/style.js.map +1 -0
  298. package/dist/{types/utils/tspaths-transform/index.d.ts → utils/tspaths-transform.d.ts} +0 -0
  299. package/dist/utils/tspaths-transform.js +119 -0
  300. package/dist/utils/tspaths-transform.js.map +1 -0
  301. package/package.json +43 -72
  302. package/dist/js/modern/cli/build.js +0 -11
  303. package/dist/js/modern/cli/dev.js +0 -11
  304. package/dist/js/modern/cli/index.js +0 -3
  305. package/dist/js/modern/cli/new.js +0 -13
  306. package/dist/js/modern/commands/build.js +0 -69
  307. package/dist/js/modern/commands/dev.js +0 -43
  308. package/dist/js/modern/commands/index.js +0 -2
  309. package/dist/js/modern/features/build/build-platform.js +0 -69
  310. package/dist/js/modern/features/build/bundle/index.js +0 -9
  311. package/dist/js/modern/features/build/bundle/runRollup.js +0 -136
  312. package/dist/js/modern/features/build/bundle/runSpeedy.js +0 -176
  313. package/dist/js/modern/features/build/bundleless/copy-assets.js +0 -75
  314. package/dist/js/modern/features/build/bundleless/generator-dts/index.js +0 -106
  315. package/dist/js/modern/features/build/bundleless/generator-dts/utils.js +0 -94
  316. package/dist/js/modern/features/build/bundleless/index.js +0 -21
  317. package/dist/js/modern/features/build/bundleless/runBabel.js +0 -242
  318. package/dist/js/modern/features/build/bundleless/style.js +0 -241
  319. package/dist/js/modern/features/build/constants.js +0 -98
  320. package/dist/js/modern/features/build/error.js +0 -127
  321. package/dist/js/modern/features/build/index.js +0 -117
  322. package/dist/js/modern/features/build/legacy-constants.js +0 -103
  323. package/dist/js/modern/features/build/logger/index.js +0 -2
  324. package/dist/js/modern/features/build/logger/logText.js +0 -56
  325. package/dist/js/modern/features/build/logger/loggerManager.js +0 -93
  326. package/dist/js/modern/features/build/normalize.js +0 -277
  327. package/dist/js/modern/features/build/types.js +0 -0
  328. package/dist/js/modern/features/build/utils.js +0 -92
  329. package/dist/js/modern/features/dev/index.js +0 -47
  330. package/dist/js/modern/hooks/build.js +0 -20
  331. package/dist/js/modern/hooks/dev.js +0 -14
  332. package/dist/js/modern/hooks/index.js +0 -15
  333. package/dist/js/modern/index.js +0 -63
  334. package/dist/js/modern/locale/en.js +0 -25
  335. package/dist/js/modern/locale/index.js +0 -10
  336. package/dist/js/modern/locale/zh.js +0 -25
  337. package/dist/js/modern/schema/build-config.js +0 -117
  338. package/dist/js/modern/schema/index.js +0 -4
  339. package/dist/js/modern/schema/output.js +0 -45
  340. package/dist/js/modern/schema/source.js +0 -7
  341. package/dist/js/modern/schema/tools.js +0 -6
  342. package/dist/js/modern/schema/types.js +0 -0
  343. package/dist/js/modern/types.js +0 -0
  344. package/dist/js/modern/utils/babel.js +0 -84
  345. package/dist/js/modern/utils/color.js +0 -2
  346. package/dist/js/modern/utils/constants.js +0 -3
  347. package/dist/js/modern/utils/copy.js +0 -70
  348. package/dist/js/modern/utils/init-env.js +0 -13
  349. package/dist/js/modern/utils/json.js +0 -13
  350. package/dist/js/modern/utils/language.js +0 -6
  351. package/dist/js/modern/utils/logger.js +0 -96
  352. package/dist/js/modern/utils/readline.js +0 -17
  353. package/dist/js/modern/utils/tsconfig.js +0 -13
  354. package/dist/js/modern/utils/tspaths-transform/constants.js +0 -5
  355. package/dist/js/modern/utils/tspaths-transform/index.js +0 -113
  356. package/dist/js/modern/utils/tspaths-transform/utils.js +0 -18
  357. package/dist/js/modern/utils/valide.js +0 -26
  358. package/dist/js/node/cli/build.js +0 -18
  359. package/dist/js/node/cli/dev.js +0 -18
  360. package/dist/js/node/cli/index.js +0 -38
  361. package/dist/js/node/cli/new.js +0 -20
  362. package/dist/js/node/commands/build.js +0 -80
  363. package/dist/js/node/commands/dev.js +0 -52
  364. package/dist/js/node/commands/index.js +0 -19
  365. package/dist/js/node/features/build/build-platform.js +0 -76
  366. package/dist/js/node/features/build/bundle/index.js +0 -17
  367. package/dist/js/node/features/build/bundle/runRollup.js +0 -145
  368. package/dist/js/node/features/build/bundle/runSpeedy.js +0 -186
  369. package/dist/js/node/features/build/bundleless/copy-assets.js +0 -84
  370. package/dist/js/node/features/build/bundleless/generator-dts/index.js +0 -114
  371. package/dist/js/node/features/build/bundleless/generator-dts/utils.js +0 -105
  372. package/dist/js/node/features/build/bundleless/index.js +0 -29
  373. package/dist/js/node/features/build/bundleless/runBabel.js +0 -255
  374. package/dist/js/node/features/build/bundleless/style.js +0 -254
  375. package/dist/js/node/features/build/constants.js +0 -116
  376. package/dist/js/node/features/build/error.js +0 -139
  377. package/dist/js/node/features/build/index.js +0 -128
  378. package/dist/js/node/features/build/legacy-constants.js +0 -111
  379. package/dist/js/node/features/build/logger/index.js +0 -27
  380. package/dist/js/node/features/build/logger/logText.js +0 -66
  381. package/dist/js/node/features/build/logger/loggerManager.js +0 -95
  382. package/dist/js/node/features/build/normalize.js +0 -288
  383. package/dist/js/node/features/build/types.js +0 -0
  384. package/dist/js/node/features/build/utils.js +0 -107
  385. package/dist/js/node/features/dev/index.js +0 -56
  386. package/dist/js/node/hooks/build.js +0 -32
  387. package/dist/js/node/hooks/dev.js +0 -24
  388. package/dist/js/node/hooks/index.js +0 -36
  389. package/dist/js/node/index.js +0 -83
  390. package/dist/js/node/locale/en.js +0 -32
  391. package/dist/js/node/locale/index.js +0 -17
  392. package/dist/js/node/locale/zh.js +0 -32
  393. package/dist/js/node/schema/build-config.js +0 -126
  394. package/dist/js/node/schema/index.js +0 -11
  395. package/dist/js/node/schema/output.js +0 -52
  396. package/dist/js/node/schema/source.js +0 -14
  397. package/dist/js/node/schema/tools.js +0 -13
  398. package/dist/js/node/schema/types.js +0 -0
  399. package/dist/js/node/types.js +0 -0
  400. package/dist/js/node/utils/babel.js +0 -93
  401. package/dist/js/node/utils/color.js +0 -9
  402. package/dist/js/node/utils/constants.js +0 -11
  403. package/dist/js/node/utils/copy.js +0 -79
  404. package/dist/js/node/utils/init-env.js +0 -20
  405. package/dist/js/node/utils/json.js +0 -20
  406. package/dist/js/node/utils/language.js +0 -12
  407. package/dist/js/node/utils/logger.js +0 -107
  408. package/dist/js/node/utils/readline.js +0 -25
  409. package/dist/js/node/utils/tsconfig.js +0 -21
  410. package/dist/js/node/utils/tspaths-transform/constants.js +0 -12
  411. package/dist/js/node/utils/tspaths-transform/index.js +0 -123
  412. package/dist/js/node/utils/tspaths-transform/utils.js +0 -25
  413. package/dist/js/node/utils/valide.js +0 -34
  414. package/dist/types/cli/build.d.ts +0 -3
  415. package/dist/types/cli/dev.d.ts +0 -3
  416. package/dist/types/cli/index.d.ts +0 -3
  417. package/dist/types/cli/new.d.ts +0 -2
  418. package/dist/types/commands/build.d.ts +0 -17
  419. package/dist/types/commands/dev.d.ts +0 -5
  420. package/dist/types/commands/index.d.ts +0 -2
  421. package/dist/types/features/build/build-platform.d.ts +0 -7
  422. package/dist/types/features/build/bundle/index.d.ts +0 -3
  423. package/dist/types/features/build/bundle/runRollup.d.ts +0 -3
  424. package/dist/types/features/build/bundle/runSpeedy.d.ts +0 -10
  425. package/dist/types/features/build/bundleless/copy-assets.d.ts +0 -3
  426. package/dist/types/features/build/bundleless/generator-dts/index.d.ts +0 -3
  427. package/dist/types/features/build/bundleless/generator-dts/utils.d.ts +0 -21
  428. package/dist/types/features/build/bundleless/index.d.ts +0 -4
  429. package/dist/types/features/build/bundleless/runBabel.d.ts +0 -32
  430. package/dist/types/features/build/bundleless/style.d.ts +0 -25
  431. package/dist/types/features/build/constants.d.ts +0 -18
  432. package/dist/types/features/build/index.d.ts +0 -12
  433. package/dist/types/features/build/legacy-constants.d.ts +0 -8
  434. package/dist/types/features/build/logger/index.d.ts +0 -2
  435. package/dist/types/features/build/logger/logText.d.ts +0 -39
  436. package/dist/types/features/build/logger/loggerManager.d.ts +0 -40
  437. package/dist/types/features/build/normalize.d.ts +0 -19
  438. package/dist/types/features/build/types.d.ts +0 -15
  439. package/dist/types/features/build/utils.d.ts +0 -36
  440. package/dist/types/features/dev/index.d.ts +0 -9
  441. package/dist/types/hooks/build.d.ts +0 -46
  442. package/dist/types/hooks/dev.d.ts +0 -20
  443. package/dist/types/hooks/index.d.ts +0 -30
  444. package/dist/types/schema/build-config.d.ts +0 -205
  445. package/dist/types/schema/index.d.ts +0 -217
  446. package/dist/types/schema/output.d.ts +0 -215
  447. package/dist/types/schema/source.d.ts +0 -6
  448. package/dist/types/schema/tools.d.ts +0 -6
  449. package/dist/types/schema/types.d.ts +0 -45
  450. package/dist/types/types.d.ts +0 -51
  451. package/dist/types/utils/babel.d.ts +0 -8
  452. package/dist/types/utils/color.d.ts +0 -2
  453. package/dist/types/utils/constants.d.ts +0 -2
  454. package/dist/types/utils/copy.d.ts +0 -5
  455. package/dist/types/utils/init-env.d.ts +0 -21
  456. package/dist/types/utils/json.d.ts +0 -4
  457. package/dist/types/utils/language.d.ts +0 -1
  458. package/dist/types/utils/logger.d.ts +0 -58
  459. package/dist/types/utils/readline.d.ts +0 -9
  460. package/dist/types/utils/tspaths-transform/constants.d.ts +0 -1
  461. package/dist/types/utils/tspaths-transform/utils.d.ts +0 -4
  462. package/dist/types/utils/valide.d.ts +0 -12
  463. package/types.d.ts +0 -1
@@ -0,0 +1,104 @@
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 });
10
+ };
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 builder_exports = {};
45
+ __export(builder_exports, {
46
+ getAllDeps: () => getAllDeps,
47
+ getFinalExternals: () => getFinalExternals
48
+ });
49
+ module.exports = __toCommonJS(builder_exports);
50
+ var import_path = __toESM(require("path"));
51
+ const getFinalExternals = (config, options) => __async(void 0, null, function* () {
52
+ const { autoExternal, externals } = config;
53
+ const { appDirectory } = options;
54
+ if (typeof autoExternal === "boolean") {
55
+ if (!autoExternal) {
56
+ return externals || [];
57
+ }
58
+ const deps2 = yield getAllDeps(appDirectory, {
59
+ dependencies: true,
60
+ peerDependencies: true
61
+ });
62
+ return [
63
+ ...deps2.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
64
+ ...externals || []
65
+ ];
66
+ }
67
+ const deps = yield getAllDeps(appDirectory, autoExternal);
68
+ return [
69
+ ...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
70
+ ...externals || []
71
+ ];
72
+ });
73
+ const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDirectory, options = {}) {
74
+ const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
75
+ try {
76
+ const json = JSON.parse(
77
+ fs.readFileSync(import_path.default.resolve(appDirectory, "./package.json"), "utf8")
78
+ );
79
+ let deps = [];
80
+ if (options.dependencies) {
81
+ deps = [
82
+ ...deps,
83
+ ...Object.keys(json.dependencies || {})
84
+ ];
85
+ }
86
+ if (options.peerDependencies) {
87
+ deps = [
88
+ ...deps,
89
+ ...Object.keys(json.peerDependencies || {})
90
+ ];
91
+ }
92
+ return deps;
93
+ } catch (e) {
94
+ console.warn("[WARN] package.json is broken");
95
+ return [];
96
+ }
97
+ });
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ getAllDeps,
101
+ getFinalExternals
102
+ });
103
+
104
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGV,MAAM,oBAAoB,CAC/B,QACA,YACG;AACH,QAAM,EAAE,cAAc,UAAU,IAAI;AACpC,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,OAAO,iBAAiB,WAAW;AACrC,QAAI,CAAC,cAAc;AACjB,aAAO,aAAa,CAAC;AAAA,IACvB;AAEA,UAAMA,QAAO,MAAM,WAAW,cAAc;AAAA,MAC1C,cAAc;AAAA,MACd,kBAAkB;AAAA,IACpB,CAAC;AACD,WAAO;AAAA,MACL,GAAGA,MAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,MACpD,GAAI,aAAa,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,WAAW,cAAc,YAAY;AACxD,SAAO;AAAA,IACL,GAAG,KAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,IACpD,GAAI,aAAa,CAAC;AAAA,EACpB;AACF;AAEO,MAAM,aAAa,CACxB,OAKG,wBALH,IAKG,mBALH,cACA,UAGI,CAAC,GACF;AACH,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO;AAC5B,MAAI;AACF,UAAM,OAAO,KAAK;AAAA,MAChB,GAAG,aAAa,oBAAK,QAAQ,cAAc,gBAAgB,GAAG,MAAM;AAAA,IACtE;AAEA,QAAI,OAAiB,CAAC;AAEtB,QAAI,QAAQ,cAAc;AACxB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,gBAAkC,CAAC,CAAC;AAAA,MAC3D;AAAA,IACF;AAEA,QAAI,QAAQ,kBAAkB;AAC5B,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,oBAAsC,CAAC,CAAC;AAAA,MAC/D;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,GAAP;AACA,YAAQ,KAAK,+BAA+B;AAC5C,WAAO,CAAC;AAAA,EACV;AACF;;;;;;","names":["deps"],"sources":["../../src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport type { BaseBuildConfig } from '../types/config';\n\nexport const getFinalExternals = async (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n) => {\n const { autoExternal, externals } = config;\n const { appDirectory } = options;\n\n if (typeof autoExternal === 'boolean') {\n if (!autoExternal) {\n return externals || [];\n }\n\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n peerDependencies: true,\n });\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n }\n\n const deps = await getAllDeps(appDirectory, autoExternal);\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n};\n\nexport const getAllDeps = async <T>(\n appDirectory: string,\n options: {\n dependencies?: boolean;\n peerDependencies?: boolean;\n } = {},\n) => {\n const { fs } = await import('@modern-js/utils');\n try {\n const json = JSON.parse(\n fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'),\n );\n\n let deps: string[] = [];\n\n if (options.dependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.dependencies as T | undefined) || {}),\n ];\n }\n\n if (options.peerDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.peerDependencies as T | undefined) || {}),\n ];\n }\n\n return deps;\n } catch (e) {\n console.warn('[WARN] package.json is broken');\n return [];\n }\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import { ModuleContext } from '../types';
2
+ import type { BaseBuildConfig, PartialBuildConfig, PartialBaseBuildConfig, DTSOptions } from '../types/config';
3
+ export declare const validPartialBuildConfig: (config: PartialBuildConfig) => void;
4
+ export declare const validBuildTypeAndFormat: (config: PartialBaseBuildConfig) => void;
5
+ export declare const mergeDefaultBaseConfig: (pConfig: PartialBaseBuildConfig, context: ModuleContext) => Promise<BaseBuildConfig>;
6
+ export declare const getDtsConfig: (userDTS: PartialBaseBuildConfig['dts'], defaultDTS: Required<DTSOptions>) => Promise<false | Required<DTSOptions>>;
@@ -0,0 +1,167 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __async = (__this, __arguments, generator) => {
42
+ return new Promise((resolve, reject) => {
43
+ var fulfilled = (value) => {
44
+ try {
45
+ step(generator.next(value));
46
+ } catch (e) {
47
+ reject(e);
48
+ }
49
+ };
50
+ var rejected = (value) => {
51
+ try {
52
+ step(generator.throw(value));
53
+ } catch (e) {
54
+ reject(e);
55
+ }
56
+ };
57
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
58
+ step((generator = generator.apply(__this, __arguments)).next());
59
+ });
60
+ };
61
+ var config_exports = {};
62
+ __export(config_exports, {
63
+ getDtsConfig: () => getDtsConfig,
64
+ mergeDefaultBaseConfig: () => mergeDefaultBaseConfig,
65
+ validBuildTypeAndFormat: () => validBuildTypeAndFormat,
66
+ validPartialBuildConfig: () => validPartialBuildConfig
67
+ });
68
+ module.exports = __toCommonJS(config_exports);
69
+ const validPartialBuildConfig = (config) => {
70
+ if (Array.isArray(config)) {
71
+ for (const c of config) {
72
+ validBuildTypeAndFormat(c);
73
+ }
74
+ } else {
75
+ validBuildTypeAndFormat(config);
76
+ }
77
+ };
78
+ const validBuildTypeAndFormat = (config) => {
79
+ var _a;
80
+ if (config.buildType === "bundleless" && ["iife", "umd"].includes((_a = config.format) != null ? _a : "")) {
81
+ throw new Error(
82
+ `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`
83
+ );
84
+ }
85
+ };
86
+ const mergeDefaultBaseConfig = (pConfig, context) => __async(void 0, null, function* () {
87
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
88
+ const { defaultBuildConfig: defaultConfig } = yield Promise.resolve().then(() => __toESM(require("../constants/build")));
89
+ const { cloneDeep } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils/lodash")));
90
+ const { applyOptionsChain, ensureAbsolutePath, slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
91
+ const { getDefaultIndexEntry } = yield Promise.resolve().then(() => __toESM(require("./input")));
92
+ const { getStyleConfig } = yield Promise.resolve().then(() => __toESM(require("./style")));
93
+ const defaultAlias = {
94
+ "@": context.srcDirectory
95
+ };
96
+ const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);
97
+ const alias = Object.keys(mergedAlias).reduce(
98
+ (prev, name) => {
99
+ const formattedValue = (value2) => {
100
+ if (typeof value2 === "string" && value2.startsWith(".")) {
101
+ return slash(ensureAbsolutePath(context.appDirectory, value2));
102
+ }
103
+ return value2;
104
+ };
105
+ const value = formattedValue(mergedAlias[name]);
106
+ prev[name] = value;
107
+ return prev;
108
+ },
109
+ {}
110
+ );
111
+ const styleConfig = yield getStyleConfig(pConfig);
112
+ const buildType = (_a = pConfig.buildType) != null ? _a : defaultConfig.buildType;
113
+ const sourceDir = (_b = pConfig.sourceDir) != null ? _b : defaultConfig.sourceDir;
114
+ const input = buildType === "bundle" ? yield getDefaultIndexEntry(context) : [sourceDir];
115
+ const userDefine = (_c = pConfig.define) != null ? _c : {};
116
+ const define = __spreadValues(__spreadValues({}, defaultConfig.define), Object.keys(userDefine).reduce((memo, name) => {
117
+ memo[name] = JSON.stringify(userDefine[name]);
118
+ return memo;
119
+ }, {}));
120
+ return {
121
+ asset: __spreadValues(__spreadValues({}, defaultConfig.asset), pConfig.asset),
122
+ buildType,
123
+ format: (_d = pConfig.format) != null ? _d : defaultConfig.format,
124
+ target: (_e = pConfig.target) != null ? _e : defaultConfig.target,
125
+ sourceMap: (_f = pConfig.sourceMap) != null ? _f : defaultConfig.sourceMap,
126
+ copy: (_g = pConfig.copy) != null ? _g : cloneDeep(defaultConfig.copy),
127
+ outdir: (_h = pConfig.outdir) != null ? _h : defaultConfig.outdir,
128
+ dts: yield getDtsConfig(pConfig.dts, defaultConfig.dts),
129
+ jsx: (_i = pConfig.jsx) != null ? _i : defaultConfig.jsx,
130
+ input: (_j = pConfig.input) != null ? _j : cloneDeep(input),
131
+ platform: (_k = pConfig.platform) != null ? _k : defaultConfig.platform,
132
+ splitting: (_l = pConfig.splitting) != null ? _l : defaultConfig.splitting,
133
+ minify: (_m = pConfig.minify) != null ? _m : defaultConfig.minify,
134
+ autoExternal: (_n = pConfig.autoExternal) != null ? _n : defaultConfig.autoExternal,
135
+ umdGlobals: __spreadValues(__spreadValues({}, defaultConfig.umdGlobals), pConfig.umdGlobals),
136
+ umdModuleName: (_o = pConfig.umdModuleName) != null ? _o : defaultConfig.umdModuleName,
137
+ externals: (_p = pConfig.externals) != null ? _p : defaultConfig.externals,
138
+ sourceDir,
139
+ alias,
140
+ define,
141
+ style: __spreadProps(__spreadValues({}, styleConfig), {
142
+ inject: (_r = (_q = pConfig.style) == null ? void 0 : _q.inject) != null ? _r : defaultConfig.style.inject,
143
+ modules: (_t = (_s = pConfig.style) == null ? void 0 : _s.modules) != null ? _t : defaultConfig.style.modules,
144
+ autoModules: (_v = (_u = pConfig.style) == null ? void 0 : _u.autoModules) != null ? _v : defaultConfig.style.autoModules,
145
+ tailwindCss: defaultConfig.style.tailwindCss
146
+ })
147
+ };
148
+ });
149
+ const getDtsConfig = (userDTS, defaultDTS) => __async(void 0, null, function* () {
150
+ const { cloneDeep, isUndefined, isObject } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils/lodash")));
151
+ if (isUndefined(userDTS)) {
152
+ return cloneDeep(defaultDTS);
153
+ }
154
+ if (isObject(userDTS)) {
155
+ return __spreadValues(__spreadValues({}, defaultDTS), userDTS);
156
+ }
157
+ return userDTS;
158
+ });
159
+ // Annotate the CommonJS export names for ESM import in node:
160
+ 0 && (module.exports = {
161
+ getDtsConfig,
162
+ mergeDefaultBaseConfig,
163
+ validBuildTypeAndFormat,
164
+ validPartialBuildConfig
165
+ });
166
+
167
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":"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","names":["value"],"sources":["../../src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n} from '../types/config';\n\nexport const validPartialBuildConfig = (config: PartialBuildConfig) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n validBuildTypeAndFormat(c);\n }\n } else {\n validBuildTypeAndFormat(config);\n }\n};\n\nexport const validBuildTypeAndFormat = (config: PartialBaseBuildConfig) => {\n if (\n config.buildType === 'bundleless' &&\n ['iife', 'umd'].includes(config.format ?? '')\n ) {\n throw new Error(\n `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`,\n );\n }\n};\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { defaultBuildConfig: defaultConfig } = await import(\n '../constants/build'\n );\n const { cloneDeep } = await import('@modern-js/utils/lodash');\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('./input');\n const { getStyleConfig } = await import('./style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const input =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? cloneDeep(defaultConfig.copy),\n outdir: pConfig.outdir ?? defaultConfig.outdir,\n dts: await getDtsConfig(pConfig.dts, defaultConfig.dts as DTSOptions),\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input: pConfig.input ?? cloneDeep(input),\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal: pConfig.autoExternal ?? defaultConfig.autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n externals: pConfig.externals ?? defaultConfig.externals,\n sourceDir,\n alias,\n define,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindCss: defaultConfig.style.tailwindCss,\n },\n };\n};\n\nexport const getDtsConfig = async (\n userDTS: PartialBaseBuildConfig['dts'],\n defaultDTS: Required<DTSOptions>,\n) => {\n const { cloneDeep, isUndefined, isObject } = await import(\n '@modern-js/utils/lodash'\n );\n\n if (isUndefined(userDTS)) {\n return cloneDeep(defaultDTS);\n }\n\n if (isObject(userDTS)) {\n return {\n ...defaultDTS,\n ...userDTS,\n };\n }\n\n return userDTS;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import type { PluginAPI } from '@modern-js/core';
2
+ import type { ModuleTools } from '../types';
3
+ export declare const initModuleContext: (api: PluginAPI<ModuleTools>) => Promise<{
4
+ isTsProject: boolean;
5
+ appDirectory: string;
6
+ srcDirectory: string;
7
+ }>;
@@ -0,0 +1,60 @@
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 });
10
+ };
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 context_exports = {};
45
+ __export(context_exports, {
46
+ initModuleContext: () => initModuleContext
47
+ });
48
+ module.exports = __toCommonJS(context_exports);
49
+ const initModuleContext = (api) => __async(void 0, null, function* () {
50
+ const { isTypescript } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
51
+ const { appDirectory, srcDirectory } = api.useAppContext();
52
+ const isTsProject = isTypescript(appDirectory);
53
+ return { isTsProject, appDirectory, srcDirectory };
54
+ });
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ initModuleContext
58
+ });
59
+
60
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,oBAAoB,CAAO,QAAgC;AACtE,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO;AACtC,QAAM,EAAE,cAAc,aAAa,IAAI,IAAI,cAAc;AACzD,QAAM,cAAc,aAAa,YAAY;AAE7C,SAAO,EAAE,aAAa,cAAc,aAAa;AACnD;;;;;","names":[],"sources":["../../src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
@@ -0,0 +1,14 @@
1
+ import type { ITsconfig, BundlelessGeneratorDtsConfig, BuildCommandOptions, BaseBuildConfig } from '../types';
2
+ export declare const generatorTsConfig: (projectTsconfig: ITsconfig, config: BundlelessGeneratorDtsConfig) => Promise<{
3
+ tempTsconfigPath: string;
4
+ tempDistAbsRootPath: string;
5
+ tempDistAbsSrcPath: string;
6
+ }>;
7
+ export declare const getTscBinPath: (appDirectory: string) => Promise<string>;
8
+ export declare const resolveAlias: (config: BundlelessGeneratorDtsConfig, options: {
9
+ userTsconfig: ITsconfig;
10
+ tempTsconfigPath: string;
11
+ tempDistAbsRootPath: string;
12
+ tempDistAbsSrcPath: string;
13
+ }, watchFilenames?: string[]) => Promise<void>;
14
+ export declare const assignTsConfigPath: (config: BaseBuildConfig, options: BuildCommandOptions) => Promise<BaseBuildConfig>;
@@ -0,0 +1,186 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __async = (__this, __arguments, generator) => {
42
+ return new Promise((resolve, reject) => {
43
+ var fulfilled = (value) => {
44
+ try {
45
+ step(generator.next(value));
46
+ } catch (e) {
47
+ reject(e);
48
+ }
49
+ };
50
+ var rejected = (value) => {
51
+ try {
52
+ step(generator.throw(value));
53
+ } catch (e) {
54
+ reject(e);
55
+ }
56
+ };
57
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
58
+ step((generator = generator.apply(__this, __arguments)).next());
59
+ });
60
+ };
61
+ var dts_exports = {};
62
+ __export(dts_exports, {
63
+ assignTsConfigPath: () => assignTsConfigPath,
64
+ generatorTsConfig: () => generatorTsConfig,
65
+ getTscBinPath: () => getTscBinPath,
66
+ resolveAlias: () => resolveAlias
67
+ });
68
+ module.exports = __toCommonJS(dts_exports);
69
+ var import_path = __toESM(require("path"));
70
+ const generatorTsConfig = (projectTsconfig, config) => __async(void 0, null, function* () {
71
+ var _a, _b, _c;
72
+ const { fs, lodash, nanoid } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
73
+ const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
74
+ const {
75
+ appDirectory,
76
+ sourceDir: absSourceDir,
77
+ distAbsPath,
78
+ tsconfigPath
79
+ } = config;
80
+ const tempDistAbsRootPath = import_path.default.join(
81
+ appDirectory,
82
+ `${dtsTempDirectory}/${nanoid()}`
83
+ );
84
+ const tempDistAbsSrcPath = import_path.default.join(
85
+ tempDistAbsRootPath,
86
+ import_path.default.relative(appDirectory, absSourceDir)
87
+ );
88
+ const rootDir = import_path.default.relative(tempDistAbsRootPath, appDirectory);
89
+ const baseUrl = ((_a = projectTsconfig.compilerOptions) == null ? void 0 : _a.baseUrl) ? import_path.default.join(appDirectory, (_b = projectTsconfig.compilerOptions) == null ? void 0 : _b.baseUrl) : appDirectory;
90
+ const include = [import_path.default.relative(tempDistAbsRootPath, absSourceDir)];
91
+ const resetConfig = {
92
+ compilerOptions: __spreadProps(__spreadValues({}, projectTsconfig == null ? void 0 : projectTsconfig.compilerOptions), {
93
+ rootDir,
94
+ baseUrl,
95
+ declaration: true,
96
+ emitDeclarationOnly: true,
97
+ outDir: tempDistAbsRootPath
98
+ }),
99
+ include,
100
+ exclude: (_c = projectTsconfig.exclude) != null ? _c : []
101
+ };
102
+ if (projectTsconfig.extends) {
103
+ resetConfig.extends = projectTsconfig.extends.startsWith(".") ? import_path.default.join(
104
+ import_path.default.relative(`${distAbsPath}/tsconfig.json`, tsconfigPath),
105
+ projectTsconfig.extends
106
+ ) : projectTsconfig.extends;
107
+ }
108
+ const recommendOption = {
109
+ compilerOptions: {
110
+ isolatedModules: true
111
+ }
112
+ };
113
+ const tempTsconfigPath = import_path.default.join(tempDistAbsRootPath, `tsconfig.json`);
114
+ fs.ensureFileSync(tempTsconfigPath);
115
+ const deepMerge = lodash.merge;
116
+ fs.writeJSONSync(
117
+ tempTsconfigPath,
118
+ deepMerge(
119
+ recommendOption,
120
+ projectTsconfig,
121
+ resetConfig
122
+ )
123
+ );
124
+ return { tempTsconfigPath, tempDistAbsRootPath, tempDistAbsSrcPath };
125
+ });
126
+ const getTscBinPath = (appDirectory) => __async(void 0, null, function* () {
127
+ const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
128
+ const { default: findUp, exists: pathExists } = yield Promise.resolve().then(() => __toESM(require("../../compiled/find-up")));
129
+ const tscBinFile = yield findUp(
130
+ (directory) => __async(void 0, null, function* () {
131
+ const targetFilePath = import_path.default.join(directory, "./node_modules/.bin/tsc");
132
+ const hasTscBinFile = yield pathExists(targetFilePath);
133
+ if (hasTscBinFile) {
134
+ return targetFilePath;
135
+ }
136
+ return void 0;
137
+ }),
138
+ { cwd: appDirectory }
139
+ );
140
+ if (!tscBinFile || !fs.existsSync(tscBinFile)) {
141
+ throw new Error(
142
+ "Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory."
143
+ );
144
+ }
145
+ return tscBinFile;
146
+ });
147
+ const resolveAlias = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (config, options, watchFilenames = []) {
148
+ var _a, _b;
149
+ const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;
150
+ const { globby, fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
151
+ const { transformDtsAlias } = yield Promise.resolve().then(() => __toESM(require("./tspaths-transform")));
152
+ const { distAbsPath } = config;
153
+ const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;
154
+ const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, { absolute: true });
155
+ const result = transformDtsAlias({
156
+ filenames: dtsFilenames,
157
+ baseUrl: tempDistAbsRootPath,
158
+ paths: (_b = (_a = userTsconfig.compilerOptions) == null ? void 0 : _a.paths) != null ? _b : {}
159
+ });
160
+ for (const r of result) {
161
+ fs.writeFileSync(r.path, r.content);
162
+ }
163
+ yield fs.copy(tempDistAbsSrcPath, distAbsPath);
164
+ });
165
+ const assignTsConfigPath = (config, options) => __async(void 0, null, function* () {
166
+ var _a;
167
+ const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
168
+ if (typeof options.tsconfig === "string" && options.tsconfig !== defaultTsConfigPath) {
169
+ config.dts = __spreadProps(__spreadValues({
170
+ only: false,
171
+ distPath: "./"
172
+ }, (_a = config.dts) != null ? _a : {}), {
173
+ tsconfigPath: options.tsconfig
174
+ });
175
+ }
176
+ return config;
177
+ });
178
+ // Annotate the CommonJS export names for ESM import in node:
179
+ 0 && (module.exports = {
180
+ assignTsConfigPath,
181
+ generatorTsConfig,
182
+ getTscBinPath,
183
+ resolveAlias
184
+ });
185
+
186
+ //# sourceMappingURL=dts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":"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","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n projectTsconfig: ITsconfig,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, lodash, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const {\n appDirectory,\n sourceDir: absSourceDir,\n distAbsPath,\n tsconfigPath,\n } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsSrcPath = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const rootDir = path.relative(tempDistAbsRootPath, appDirectory);\n const baseUrl = projectTsconfig.compilerOptions?.baseUrl\n ? path.join(appDirectory, projectTsconfig.compilerOptions?.baseUrl)\n : appDirectory;\n // if include = ['src'], final include should be ['../src']\n const include = [path.relative(tempDistAbsRootPath, absSourceDir)];\n\n const resetConfig: ITsconfig = {\n compilerOptions: {\n ...projectTsconfig?.compilerOptions,\n rootDir,\n baseUrl,\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsRootPath,\n },\n include,\n exclude: projectTsconfig.exclude ?? [],\n };\n\n // extends: '../tsconfig.json'\n if (projectTsconfig.extends) {\n resetConfig.extends = projectTsconfig.extends.startsWith('.')\n ? path.join(\n path.relative(`${distAbsPath}/tsconfig.json`, tsconfigPath),\n projectTsconfig.extends,\n )\n : projectTsconfig.extends;\n }\n\n const recommendOption = {\n // Ensure that Babel can safely transpile files in the TypeScript project\n compilerOptions: {\n isolatedModules: true,\n },\n };\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const deepMerge = lodash.merge;\n fs.writeJSONSync(\n tempTsconfigPath,\n deepMerge(\n recommendOption,\n projectTsconfig,\n // 此处是必须要覆盖用户默认配置\n resetConfig,\n ),\n );\n\n return { tempTsconfigPath, tempDistAbsRootPath, tempDistAbsSrcPath };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspaths-transform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { ModuleContext } from '../types';
2
+ import type { Input, BaseBuildConfig, PartialBuildConfig } from '../types/config';
3
+ interface EntryOptions {
4
+ appDirectory: string;
5
+ }
6
+ export declare const getAbsInput: (entry: Input, options: EntryOptions) => Promise<string[] | Record<string, string>>;
7
+ export declare const addInputToPreset: (config: PartialBuildConfig, context: ModuleContext) => Promise<PartialBuildConfig>;
8
+ export declare const getDefaultIndexEntry: ({
9
+ isTsProject,
10
+ appDirectory
11
+ }: {
12
+ isTsProject: boolean;
13
+ appDirectory: string;
14
+ }) => Promise<string[]>;
15
+ export declare const normalizeInput: (baseConfig: BaseBuildConfig, options: EntryOptions) => Promise<string[] | Record<string, string>>;
16
+ export {};