@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
@@ -1,9 +0,0 @@
1
- import pMap from 'p-map';
2
- import { runSpeedy } from "./runSpeedy";
3
- import { startRollup } from "./runRollup";
4
- export const build = async (api, config) => {
5
- const tasks = config.dtsOnly ? [startRollup] : [runSpeedy, startRollup];
6
- await pMap(tasks, async task => {
7
- await task(api, config);
8
- });
9
- };
@@ -1,136 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- import path from 'path';
5
- import ts from 'typescript';
6
- import hashbangPlugin from 'rollup-plugin-hashbang';
7
- import jsonPlugin from '@rollup/plugin-json';
8
- import { InternalDTSError } from "../error";
9
- import { SectionTitleStatus, watchSectionTitle } from "../utils";
10
-
11
- // Copied from https://github.com/egoist/tsup/blob/dev/src/rollup.ts
12
-
13
- const loadCompilerOptions = tsconfig => {
14
- if (!tsconfig) {
15
- return {};
16
- }
17
- const configFile = ts.readConfigFile(tsconfig, ts.sys.readFile);
18
- const {
19
- options
20
- } = ts.parseJsonConfigFileContent(configFile.config, ts.sys, './');
21
- return options;
22
- };
23
- const dtsPlugin = require('rollup-plugin-dts');
24
- const getRollupConfig = async (api, options) => {
25
- const {
26
- appDirectory
27
- } = api.useAppContext();
28
- const {
29
- output: {
30
- path: distPath = 'dist'
31
- }
32
- } = api.useResolvedConfigContext();
33
- const {
34
- outputPath,
35
- bundleOptions,
36
- tsconfig
37
- } = options;
38
- const distDir = path.join(appDirectory, distPath, outputPath);
39
- const compilerOptions = loadCompilerOptions(tsconfig);
40
- const dtsOptions = {
41
- entry: bundleOptions.entry
42
- };
43
- const ignoreFiles = {
44
- name: 'ignore-files',
45
- load(id) {
46
- if (!/\.(js|jsx|ts|tsx|json)$/.test(id)) {
47
- return '';
48
- }
49
- return null;
50
- }
51
- };
52
- return {
53
- inputConfig: {
54
- input: dtsOptions.entry,
55
- external: bundleOptions.externals,
56
- onwarn(warning, handler) {
57
- if (warning.code === 'UNRESOLVED_IMPORT' || warning.code === 'CIRCULAR_DEPENDENCY' || warning.code === 'EMPTY_BUNDLE') {
58
- return;
59
- }
60
- handler(warning);
61
- },
62
- plugins: [hashbangPlugin(), jsonPlugin(), ignoreFiles, dtsPlugin.default({
63
- // use external to prevent them which come from node_modules from be bundled.
64
- respectExternal: true,
65
- compilerOptions: _objectSpread(_objectSpread({}, compilerOptions), {}, {
66
- baseUrl: path.resolve(compilerOptions.baseUrl || '.'),
67
- // Ensure ".d.ts" modules are generated
68
- declaration: true,
69
- // Skip ".js" generation
70
- noEmit: false,
71
- emitDeclarationOnly: true,
72
- // Skip code generation when error occurs
73
- noEmitOnError: true,
74
- // Avoid extra work
75
- checkJs: false,
76
- declarationMap: false,
77
- skipLibCheck: true,
78
- preserveSymlinks: false,
79
- // Ensure we can parse the latest code
80
- target: ts.ScriptTarget.ESNext
81
- })
82
- })].filter(Boolean)
83
- },
84
- outputConfig: {
85
- dir: distDir,
86
- format: 'esm',
87
- exports: 'named'
88
- }
89
- };
90
- };
91
- async function runRollup(options, context) {
92
- try {
93
- const {
94
- rollup
95
- } = await import('rollup');
96
- const bundle = await rollup(options.inputConfig);
97
- await bundle.write(options.outputConfig);
98
- } catch (e) {
99
- if (e instanceof Error) {
100
- throw new InternalDTSError(e, _objectSpread({
101
- buildType: 'bundle'
102
- }, context));
103
- }
104
- }
105
- }
106
- async function watchRollup(options) {
107
- const {
108
- watch
109
- } = await import('rollup');
110
- const titleText = '[Bundle:DTS]';
111
- watch(_objectSpread(_objectSpread({}, options.inputConfig), {}, {
112
- plugins: options.inputConfig.plugins,
113
- output: options.outputConfig
114
- })).on('event', event => {
115
- if (event.code === 'START') {
116
- console.info(watchSectionTitle(titleText, SectionTitleStatus.Log));
117
- } else if (event.code === 'BUNDLE_END') {
118
- console.info(watchSectionTitle(titleText, SectionTitleStatus.Success));
119
- } else if (event.code === 'ERROR') {
120
- // this is dts rollup plugin bug, error not complete message
121
- }
122
- });
123
- }
124
- export const startRollup = async (api, options) => {
125
- if (options.enableDts) {
126
- const config = await getRollupConfig(api, options);
127
- if (options.watch) {
128
- watchRollup(config);
129
- } else {
130
- await runRollup(config, {
131
- target: options.target,
132
- format: options.format
133
- });
134
- }
135
- }
136
- };
@@ -1,176 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- import path from 'path';
5
- import { SpeedyBundler } from '@speedy-js/speedy-core';
6
- import { es5InputPlugin } from '@speedy-js/speedy-plugin-es5';
7
- import { applyOptionsChain, ensureAbsolutePath } from '@modern-js/utils';
8
- import { InternalBuildError } from "../error";
9
- import { getPostcssOption, SectionTitleStatus, watchSectionTitle } from "../utils";
10
- export const getAlias = api => {
11
- const {
12
- appDirectory,
13
- srcDirectory
14
- } = api.useAppContext();
15
- const {
16
- source
17
- } = api.useResolvedConfigContext();
18
- // TODO: maybe check tsconfig `paths`
19
- const defaultAlias = {
20
- '@': srcDirectory
21
- };
22
- const alias = applyOptionsChain(defaultAlias, source === null || source === void 0 ? void 0 : source.alias);
23
- return Object.keys(alias).reduce((o, name) => {
24
- return _objectSpread(_objectSpread({}, o), {}, {
25
- [name]: ensureAbsolutePath(appDirectory, alias[name])
26
- });
27
- }, {});
28
- };
29
- export const getDefine = api => {
30
- const {
31
- source: {
32
- envVars,
33
- globalVars
34
- }
35
- } = api.useResolvedConfigContext();
36
- const envVarsDefine = [...(envVars || [])].reduce((memo, name) => {
37
- memo[`process.env.${name}`] = JSON.stringify(process.env[name]);
38
- return memo;
39
- }, {});
40
- const globalVarsDefine = Object.keys(globalVars || {}).reduce((memo, name) => {
41
- memo[name] = globalVars ? JSON.stringify(globalVars[name]) : '';
42
- return memo;
43
- }, {});
44
- return _objectSpread(_objectSpread({}, envVarsDefine), globalVarsDefine);
45
- };
46
- const getStyleOptionFromModern = async api => {
47
- const runner = api.useHookRunners();
48
- const {
49
- appDirectory
50
- } = api.useAppContext();
51
- const modernConfig = api.useResolvedConfigContext();
52
- const lessOption = await runner.moduleLessConfig({
53
- modernConfig
54
- }, {
55
- onLast: async _ => undefined
56
- });
57
- const sassOption = await runner.moduleSassConfig({
58
- modernConfig
59
- }, {
60
- onLast: async _ => undefined
61
- });
62
- const tailwindPlugin = await runner.moduleTailwindConfig({
63
- modernConfig
64
- }, {
65
- onLast: async _ => undefined
66
- });
67
- const postcssOption = getPostcssOption(appDirectory, modernConfig);
68
- if (tailwindPlugin) {
69
- var _postcssOption$plugin;
70
- (_postcssOption$plugin = postcssOption.plugins) === null || _postcssOption$plugin === void 0 ? void 0 : _postcssOption$plugin.push(tailwindPlugin);
71
- }
72
- return {
73
- less: lessOption === null || lessOption === void 0 ? void 0 : lessOption.lessOption,
74
- sass: sassOption,
75
- postcss: _objectSpread(_objectSpread({}, postcssOption.options), {}, {
76
- plugins: postcssOption.plugins
77
- })
78
- };
79
- };
80
- export const runSpeedy = async (api, config) => {
81
- const {
82
- appDirectory
83
- } = api.useAppContext();
84
- const {
85
- output: {
86
- path: distPath = 'dist'
87
- },
88
- tools: {
89
- speedy: userSpeedyConfig
90
- } = {
91
- speedy: undefined
92
- }
93
- } = api.useResolvedConfigContext();
94
- const {
95
- target,
96
- watch,
97
- bundleOptions,
98
- outputPath,
99
- format,
100
- sourceMap
101
- } = config;
102
- const {
103
- entry,
104
- platform,
105
- splitting,
106
- minify,
107
- externals,
108
- getModuleId
109
- } = bundleOptions;
110
- const distDir = path.join(appDirectory, distPath, outputPath);
111
- const titleText = `[Bundle:Speedy:${format}_${target}]`;
112
- const style = await getStyleOptionFromModern(api);
113
- const alias = getAlias(api);
114
- const define = getDefine(api);
115
- const watchPlugin = () => {
116
- return {
117
- name: 'watch-plugin',
118
- apply(compiler) {
119
- compiler.hooks.watchChange.tap('watch-plugin', async () => {
120
- console.info(watchSectionTitle(titleText, SectionTitleStatus.Log));
121
- });
122
- }
123
- };
124
- };
125
- const plugins = target === 'es5' ? [es5InputPlugin()] : [];
126
- plugins.push(watchPlugin());
127
- // TODO: add speedy plugin about react
128
- const internalSpeedyConfig = {
129
- command: 'build',
130
- mode: 'production',
131
- html: false,
132
- preset: 'webapp',
133
- // support css and json
134
- platform,
135
- watch,
136
- input: entry,
137
- target,
138
- clearScreen: false,
139
- output: {
140
- path: distDir,
141
- format,
142
- splitting,
143
- filename: '[name]'
144
- },
145
- style,
146
- resolve: {
147
- alias
148
- },
149
- define,
150
- sourceMap,
151
- minify,
152
- external: externals,
153
- plugins,
154
- getModuleId
155
- };
156
- const speedyConfig = applyOptionsChain(internalSpeedyConfig, userSpeedyConfig);
157
- const compiler = await SpeedyBundler.create(speedyConfig);
158
- try {
159
- if (watch) {
160
- console.info(watchSectionTitle(titleText, SectionTitleStatus.Log));
161
- }
162
- await compiler.build();
163
- } catch (e) {
164
- /**
165
- * in watch mode
166
- * use speedy watch log
167
- */
168
- if (e instanceof Error) {
169
- throw new InternalBuildError(e, {
170
- target,
171
- format,
172
- buildType: 'bundle'
173
- });
174
- }
175
- }
176
- };
@@ -1,75 +0,0 @@
1
- import * as path from 'path';
2
- import { fs, watch, glob, WatchChangeType, Import } from '@modern-js/utils';
3
- const copyUtils = Import.lazy('../../../utils/copy', require);
4
- const SRC_DIRS = 'src';
5
- const copyAssets = ({
6
- targetDir,
7
- outputDir
8
- }) => {
9
- const assetsFiles = glob.sync(`${targetDir}/**/*.*`, {
10
- ignore: ['**/*.{js,jsx,ts,tsx,d.ts,scss,less,css,sass}']
11
- });
12
- if (assetsFiles.length > 0) {
13
- fs.ensureDirSync(outputDir);
14
- }
15
- for (const resource of assetsFiles) {
16
- const file = path.relative(targetDir, resource);
17
- fs.ensureDirSync(path.dirname(path.resolve(outputDir, file)));
18
- fs.copyFileSync(resource, path.resolve(outputDir, file));
19
- }
20
- };
21
- const watchAssets = (api, {
22
- targetDir,
23
- outputDir
24
- }) => {
25
- watch(`${targetDir}/**/*.*`, async ({
26
- changeType,
27
- changedFilePath
28
- }) => {
29
- if (changeType === WatchChangeType.UNLINK) {
30
- const removeFile = path.normalize(`${outputDir}/${path.relative(targetDir, changedFilePath)}`);
31
- fs.removeSync(removeFile);
32
- return;
33
- }
34
- const file = path.relative(targetDir, changedFilePath);
35
- fs.copyFileSync(changedFilePath, path.resolve(outputDir, file));
36
- }, ['**/*.{js,jsx,ts,tsx,d.ts,scss,less,css,sass}']);
37
- };
38
- export const copyStaticAssets = async (api, config) => {
39
- var _bundlelessOptions$so;
40
- const appContext = api.useAppContext();
41
- const modernConfig = api.useResolvedConfigContext();
42
- const {
43
- appDirectory
44
- } = appContext;
45
- const {
46
- path: distPath = 'dist'
47
- } = modernConfig.output;
48
- const {
49
- outputPath,
50
- bundlelessOptions
51
- } = config;
52
- const {
53
- static: {
54
- path: staticPath = './'
55
- } = {
56
- path: './'
57
- }
58
- } = bundlelessOptions;
59
- const srcDir = path.join(appDirectory, (_bundlelessOptions$so = bundlelessOptions.sourceDir) !== null && _bundlelessOptions$so !== void 0 ? _bundlelessOptions$so : SRC_DIRS);
60
- const outputDirToSrc = path.join(appDirectory, distPath, outputPath, staticPath);
61
- copyAssets({
62
- targetDir: srcDir,
63
- outputDir: outputDirToSrc
64
- });
65
- await copyUtils.copyTask({
66
- modernConfig,
67
- appContext
68
- });
69
- if (config.watch) {
70
- watchAssets(api, {
71
- targetDir: srcDir,
72
- outputDir: outputDirToSrc
73
- });
74
- }
75
- };
@@ -1,106 +0,0 @@
1
- import path from 'path';
2
- import { Import, execa, fs, json5 } from '@modern-js/utils';
3
- import { InternalDTSError } from "../../error";
4
- import { SectionTitleStatus, watchSectionTitle } from "../../utils";
5
- import { getTscBinPath } from "./utils";
6
- const utils = Import.lazy('./utils', require);
7
- const getProjectTsconfig = tsconfigPath => {
8
- if (!tsconfigPath || !fs.existsSync(tsconfigPath)) {
9
- return {};
10
- }
11
- return json5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
12
- };
13
- const resolveLog = (childProgress, {
14
- watch: _watch = false
15
- } = {}) => {
16
- var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
17
- /**
18
- * tsc 所有的log信息都是从stdout data 事件中获取
19
- * 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
20
- * watch 模式下,则使用这里的信息
21
- */
22
- (_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
23
- if (_watch) {
24
- console.info(watchSectionTitle('[Bundleless:DTS]', SectionTitleStatus.Log));
25
- console.info(data.toString());
26
- }
27
- });
28
- // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
29
- (_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
30
- console.error(error.message);
31
- });
32
- (_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
33
- console.error(chunk.toString());
34
- });
35
- };
36
- const generatorDts = async (_, config) => {
37
- const {
38
- tsconfigPath,
39
- distDir,
40
- sourceDir = 'src',
41
- appDirectory,
42
- watch = false
43
- } = config;
44
- const userTsconfig = getProjectTsconfig(tsconfigPath);
45
- const willDeleteTsconfigPath = utils.generatorTsConfig(userTsconfig, {
46
- appDirectory,
47
- distDir,
48
- sourceDir
49
- });
50
- const tscBinFile = getTscBinPath(appDirectory);
51
- const watchParams = watch ? ['-w'] : [];
52
- const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, /* Required parameter, use it stdout have color */
53
- '--pretty',
54
- // https://github.com/microsoft/TypeScript/issues/21824
55
- '--preserveWatchOutput', ...watchParams], {
56
- stdio: 'pipe',
57
- cwd: appDirectory
58
- });
59
- resolveLog(childProgress, {
60
- watch
61
- });
62
- try {
63
- await childProgress;
64
- } catch (e) {
65
- if (e instanceof Error) {
66
- throw new InternalDTSError(e, {
67
- buildType: 'bundleless'
68
- });
69
- }
70
- }
71
- fs.removeSync(willDeleteTsconfigPath);
72
- };
73
- export const genDts = async (api, config) => {
74
- const {
75
- outputPath,
76
- tsconfig: tsconfigPath,
77
- watch,
78
- bundlelessOptions: {
79
- sourceDir
80
- },
81
- enableDts
82
- } = config;
83
- if (!enableDts) {
84
- return;
85
- }
86
- const {
87
- appDirectory
88
- } = api.useAppContext();
89
- const modernConfig = api.useResolvedConfigContext();
90
- const {
91
- output: {
92
- path: distPath = 'dist'
93
- }
94
- } = modernConfig;
95
- const distDir = path.join(appDirectory, distPath, outputPath);
96
- const option = {
97
- appDirectory,
98
- distDir,
99
- tsconfigPath,
100
- watch,
101
- sourceDir
102
- };
103
- await generatorDts(modernConfig, option);
104
- // TODO: watch 模式下无法转换
105
- utils.resolveAlias(modernConfig, option);
106
- };
@@ -1,94 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- import * as path from 'path';
5
- import { Import, glob, fs, nanoid } from '@modern-js/utils';
6
- import { merge as deepMerge } from '@modern-js/utils/lodash';
7
- const babel = Import.lazy('../../../../utils/babel', require);
8
- const tsPathsTransform = Import.lazy('../../../../utils/tspaths-transform', require);
9
- export const generatorTsConfig = (projectTsconfig, {
10
- appDirectory,
11
- distDir,
12
- sourceDir: _sourceDir = 'src'
13
- }) => {
14
- var _projectTsconfig$comp, _projectTsconfig$comp2, _ref, _projectTsconfig$excl;
15
- const tempPath = path.resolve(appDirectory, './node_modules');
16
- const resolvePath = path.relative(tempPath, appDirectory);
17
- // const rootDir = projectTsconfig.compilerOptions?.rootDir
18
- // ? path.join(resolvePath, projectTsconfig.compilerOptions?.rootDir)
19
- // : resolvePath;
20
- // 目前限制 rootDir 的路径为 sourceDir
21
- const rootDir = path.join(resolvePath, _sourceDir);
22
- const baseUrl = (_projectTsconfig$comp = projectTsconfig.compilerOptions) !== null && _projectTsconfig$comp !== void 0 && _projectTsconfig$comp.baseUrl ? path.join(appDirectory, (_projectTsconfig$comp2 = projectTsconfig.compilerOptions) === null || _projectTsconfig$comp2 === void 0 ? void 0 : _projectTsconfig$comp2.baseUrl) : appDirectory;
23
- // if include = ['src'], final include should be ['../src']
24
- // const include = projectTsconfig.include?.map(includePath =>
25
- const include = (_ref = [_sourceDir]) === null || _ref === void 0 ? void 0 : _ref.map(includePath => path.join(resolvePath, includePath));
26
- const exclude = (_projectTsconfig$excl = projectTsconfig.exclude) === null || _projectTsconfig$excl === void 0 ? void 0 : _projectTsconfig$excl.map(excludePath => path.join(resolvePath, excludePath));
27
- const resetConfig = {
28
- compilerOptions: {
29
- rootDir,
30
- baseUrl,
31
- // Ensure that .d.ts files are created by tsc, but not .js files
32
- declaration: true,
33
- emitDeclarationOnly: true,
34
- outDir: distDir
35
- },
36
- include,
37
- exclude
38
- };
39
- if (projectTsconfig.extends) {
40
- resetConfig.extends = projectTsconfig.extends.startsWith('.') ? path.join(resolvePath, projectTsconfig.extends) : projectTsconfig.extends;
41
- }
42
- const recommendOption = {
43
- // Ensure that Babel can safely transpile files in the TypeScript project
44
- compilerOptions: {
45
- isolatedModules: true
46
- }
47
- };
48
- const tempTsconfigPath = path.join(tempPath, `tsconfig.${Date.now()}.${nanoid()}.json`);
49
- fs.ensureFileSync(tempTsconfigPath);
50
- fs.writeJSONSync(tempTsconfigPath, deepMerge(recommendOption, projectTsconfig,
51
- // 此处是必须要覆盖用户默认配置
52
- resetConfig));
53
- return tempTsconfigPath;
54
- };
55
- export const resolveAlias = (modernConfig, config, watchFilenames = []) => {
56
- const {
57
- output
58
- } = modernConfig;
59
- const defaultPaths = {
60
- '@': ['./src']
61
- };
62
- const dtsDistPath = `${config.distDir}/**/*.d.ts`;
63
- const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : glob.sync(dtsDistPath, {
64
- absolute: true
65
- });
66
- const alias = babel.getFinalAlias(modernConfig, {
67
- appDirectory: config.appDirectory,
68
- tsconfigPath: config.tsconfigPath || path.join(config.appDirectory, './tsconfig.json'),
69
- sourceAbsDir: config.distDir
70
- });
71
- const mergedPaths = alias.isTsPath ? alias.paths || {} : _objectSpread(_objectSpread({}, defaultPaths), alias.paths || {});
72
- const result = tsPathsTransform.transformDtsAlias({
73
- filenames: dtsFilenames,
74
- baseUrl: path.join(config.appDirectory, output.path || 'dist'),
75
- paths: mergedPaths
76
- });
77
- for (const r of result) {
78
- fs.writeFileSync(r.path, r.content);
79
- }
80
- };
81
- export const getTscBinPath = appDirectory => {
82
- const {
83
- root
84
- } = path.parse(appDirectory);
85
- let currentDirectory = appDirectory;
86
- while (currentDirectory !== root) {
87
- const tscBinFile = path.join(currentDirectory, './node_modules/.bin/tsc');
88
- if (fs.existsSync(tscBinFile)) {
89
- return tscBinFile;
90
- }
91
- currentDirectory = path.dirname(currentDirectory);
92
- }
93
- throw new Error('Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.');
94
- };
@@ -1,21 +0,0 @@
1
- import { chalk } from '@modern-js/utils';
2
- import pMap from 'p-map';
3
- import { runBabelBuild } from "./runBabel";
4
- import { buildStyle } from "./style";
5
- import { genDts } from "./generator-dts";
6
- import { copyStaticAssets } from "./copy-assets";
7
- export const build = async (api, config, legacyOptions) => {
8
- // valid format is umd
9
- if (config.format === 'umd') {
10
- console.info(chalk.yellowBright('bundleless 构建暂时不支持 umd 格式'));
11
- return;
12
- }
13
- if (legacyOptions !== null && legacyOptions !== void 0 && legacyOptions.styleOnly) {
14
- await buildStyle(api, config);
15
- return;
16
- }
17
- const tasks = config.dtsOnly ? [genDts] : [runBabelBuild, genDts, buildStyle, copyStaticAssets];
18
- await pMap(tasks, async task => {
19
- await task(api, config);
20
- });
21
- };