@modern-js/app-tools 1.22.1 → 2.0.0-alpha.0

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 (325) hide show
  1. package/CHANGELOG.md +1383 -87
  2. package/bin/modern.js +13 -1
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +48 -15
  5. package/dist/js/modern/analyze/generateCode.js +286 -133
  6. package/dist/js/modern/analyze/getBundleEntry.js +39 -41
  7. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
  8. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
  9. package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
  10. package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
  11. package/dist/js/modern/analyze/getFileSystemEntry.js +74 -39
  12. package/dist/js/modern/analyze/getHtmlTemplate.js +90 -57
  13. package/dist/js/modern/analyze/getServerRoutes.js +123 -140
  14. package/dist/js/modern/analyze/index.js +220 -133
  15. package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -20
  16. package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -13
  17. package/dist/js/modern/analyze/nestedRoutes.js +166 -0
  18. package/dist/js/modern/analyze/templates.js +289 -29
  19. package/dist/js/modern/analyze/utils.js +128 -58
  20. package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
  21. package/dist/js/modern/builder/index.js +154 -0
  22. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  23. package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
  24. package/dist/js/modern/builder/share.js +46 -0
  25. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
  26. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
  27. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
  28. package/dist/js/modern/commands/build.js +75 -138
  29. package/dist/js/modern/commands/deploy.js +27 -4
  30. package/dist/js/modern/commands/dev.js +102 -66
  31. package/dist/js/modern/commands/index.js +1 -1
  32. package/dist/js/modern/commands/inspect.js +33 -64
  33. package/dist/js/modern/commands/serve.js +54 -0
  34. package/dist/js/modern/config/default.js +173 -0
  35. package/dist/js/modern/config/index.js +8 -0
  36. package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
  37. package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
  38. package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
  39. package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
  40. package/dist/js/modern/config/initial/index.js +16 -0
  41. package/dist/js/modern/config/initial/inits.js +153 -0
  42. package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
  43. package/dist/js/modern/defineConfig.js +27 -0
  44. package/dist/js/modern/exports/server.js +4 -1
  45. package/dist/js/modern/hooks.js +37 -21
  46. package/dist/js/modern/index.js +185 -94
  47. package/dist/js/modern/initialize/index.js +120 -0
  48. package/dist/js/modern/locale/en.js +20 -22
  49. package/dist/js/modern/locale/index.js +6 -6
  50. package/dist/js/modern/locale/zh.js +21 -23
  51. package/dist/js/modern/schema/Schema.js +40 -0
  52. package/dist/js/modern/schema/index.js +88 -0
  53. package/dist/js/modern/schema/legacy.js +148 -0
  54. package/dist/js/modern/types/config/deploy.js +0 -0
  55. package/dist/js/modern/types/config/dev.js +0 -0
  56. package/dist/js/modern/types/config/experiments.js +0 -0
  57. package/dist/js/modern/types/config/html.js +0 -0
  58. package/dist/js/modern/types/config/index.js +1 -0
  59. package/dist/js/modern/types/config/output.js +0 -0
  60. package/dist/js/modern/types/config/performance.js +0 -0
  61. package/dist/js/modern/types/config/security.js +0 -0
  62. package/dist/js/modern/types/config/source.js +0 -0
  63. package/dist/js/modern/types/config/tools.js +0 -0
  64. package/dist/js/modern/types/hooks.js +0 -0
  65. package/dist/js/modern/types/index.js +3 -0
  66. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  67. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  68. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  69. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  70. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  71. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  72. package/dist/js/modern/utils/commands.js +13 -0
  73. package/dist/js/modern/utils/config.js +102 -52
  74. package/dist/js/modern/utils/createFileWatcher.js +115 -0
  75. package/dist/js/modern/utils/createServer.js +67 -10
  76. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  77. package/dist/js/modern/utils/getSpecifiedEntries.js +46 -25
  78. package/dist/js/modern/utils/language.js +6 -3
  79. package/dist/js/modern/utils/printInstructions.js +29 -9
  80. package/dist/js/modern/utils/restart.js +44 -0
  81. package/dist/js/modern/utils/routes.js +29 -14
  82. package/dist/js/node/analyze/Builder.js +64 -0
  83. package/dist/js/node/analyze/constants.js +86 -33
  84. package/dist/js/node/analyze/generateCode.js +305 -163
  85. package/dist/js/node/analyze/getBundleEntry.js +66 -58
  86. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
  87. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
  88. package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
  89. package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
  90. package/dist/js/node/analyze/getFileSystemEntry.js +99 -58
  91. package/dist/js/node/analyze/getHtmlTemplate.js +121 -83
  92. package/dist/js/node/analyze/getServerRoutes.js +146 -160
  93. package/dist/js/node/analyze/index.js +243 -161
  94. package/dist/js/node/analyze/isDefaultExportFunction.js +59 -38
  95. package/dist/js/node/analyze/makeLegalIdentifier.js +31 -19
  96. package/dist/js/node/analyze/nestedRoutes.js +193 -0
  97. package/dist/js/node/analyze/templates.js +316 -43
  98. package/dist/js/node/analyze/utils.js +158 -78
  99. package/dist/js/node/builder/builderPlugins/compatModern.js +258 -0
  100. package/dist/js/node/builder/index.js +177 -0
  101. package/dist/js/node/builder/loaders/routerLoader.js +38 -0
  102. package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
  103. package/dist/js/node/builder/share.js +75 -0
  104. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
  105. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
  106. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
  107. package/dist/js/node/commands/build.js +97 -159
  108. package/dist/js/node/commands/deploy.js +49 -12
  109. package/dist/js/node/commands/dev.js +121 -93
  110. package/dist/js/node/commands/index.js +19 -44
  111. package/dist/js/node/commands/inspect.js +56 -93
  112. package/dist/js/node/commands/serve.js +83 -0
  113. package/dist/js/node/config/default.js +195 -0
  114. package/dist/js/node/config/index.js +34 -0
  115. package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
  116. package/dist/js/node/config/initial/createOutputConfig.js +91 -0
  117. package/dist/js/node/config/initial/createSourceConfig.js +62 -0
  118. package/dist/js/node/config/initial/createToolsConfig.js +65 -0
  119. package/dist/js/node/config/initial/index.js +41 -0
  120. package/dist/js/node/config/initial/inits.js +176 -0
  121. package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
  122. package/dist/js/node/defineConfig.js +49 -0
  123. package/dist/js/node/exports/server.js +25 -11
  124. package/dist/js/node/hooks.js +53 -36
  125. package/dist/js/node/index.js +216 -128
  126. package/dist/js/node/initialize/index.js +135 -0
  127. package/dist/js/node/locale/en.js +40 -26
  128. package/dist/js/node/locale/index.js +31 -18
  129. package/dist/js/node/locale/zh.js +41 -27
  130. package/dist/js/node/schema/Schema.js +63 -0
  131. package/dist/js/node/schema/index.js +118 -0
  132. package/dist/js/node/schema/legacy.js +169 -0
  133. package/dist/js/node/types/config/deploy.js +15 -0
  134. package/dist/js/node/types/config/dev.js +15 -0
  135. package/dist/js/node/types/config/experiments.js +15 -0
  136. package/dist/js/node/types/config/html.js +15 -0
  137. package/dist/js/node/types/config/index.js +17 -0
  138. package/dist/js/node/types/config/output.js +15 -0
  139. package/dist/js/node/types/config/performance.js +15 -0
  140. package/dist/js/node/types/config/security.js +15 -0
  141. package/dist/js/node/types/config/source.js +15 -0
  142. package/dist/js/node/types/config/tools.js +15 -0
  143. package/dist/js/node/types/hooks.js +15 -0
  144. package/dist/js/node/types/index.js +19 -0
  145. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  146. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  147. package/dist/js/node/types/legacyConfig/index.js +15 -0
  148. package/dist/js/node/types/legacyConfig/output.js +15 -0
  149. package/dist/js/node/types/legacyConfig/source.js +15 -0
  150. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  151. package/dist/js/node/utils/commands.js +37 -0
  152. package/dist/js/node/utils/config.js +125 -75
  153. package/dist/js/node/utils/createFileWatcher.js +139 -0
  154. package/dist/js/node/utils/createServer.js +96 -25
  155. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  156. package/dist/js/node/utils/getSpecifiedEntries.js +68 -34
  157. package/dist/js/node/utils/language.js +28 -10
  158. package/dist/js/node/utils/printInstructions.js +51 -19
  159. package/dist/js/node/utils/restart.js +67 -0
  160. package/dist/js/node/utils/routes.js +58 -24
  161. package/dist/js/node/utils/types.js +15 -0
  162. package/dist/js/treeshaking/analyze/Builder.js +199 -0
  163. package/dist/js/treeshaking/analyze/constants.js +37 -0
  164. package/dist/js/treeshaking/analyze/generateCode.js +615 -0
  165. package/dist/js/treeshaking/analyze/getBundleEntry.js +64 -0
  166. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
  167. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
  168. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
  169. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
  170. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
  171. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
  172. package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
  173. package/dist/js/treeshaking/analyze/index.js +589 -0
  174. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
  175. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
  176. package/dist/js/treeshaking/analyze/nestedRoutes.js +426 -0
  177. package/dist/js/treeshaking/analyze/templates.js +446 -0
  178. package/dist/js/treeshaking/analyze/utils.js +390 -0
  179. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +304 -0
  180. package/dist/js/treeshaking/builder/index.js +374 -0
  181. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  182. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
  183. package/dist/js/treeshaking/builder/share.js +40 -0
  184. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
  185. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
  186. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +343 -0
  187. package/dist/js/treeshaking/commands/build.js +291 -0
  188. package/dist/js/treeshaking/commands/deploy.js +154 -0
  189. package/dist/js/treeshaking/commands/dev.js +319 -0
  190. package/dist/js/treeshaking/commands/index.js +3 -0
  191. package/dist/js/treeshaking/commands/inspect.js +149 -0
  192. package/dist/js/treeshaking/commands/serve.js +199 -0
  193. package/dist/js/treeshaking/config/default.js +208 -0
  194. package/dist/js/treeshaking/config/index.js +3 -0
  195. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
  196. package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
  197. package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
  198. package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
  199. package/dist/js/treeshaking/config/initial/index.js +12 -0
  200. package/dist/js/treeshaking/config/initial/inits.js +213 -0
  201. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
  202. package/dist/js/treeshaking/defineConfig.js +61 -0
  203. package/dist/js/treeshaking/exports/server.js +2 -0
  204. package/dist/js/treeshaking/hooks.js +31 -0
  205. package/dist/js/treeshaking/index.js +694 -0
  206. package/dist/js/treeshaking/initialize/index.js +300 -0
  207. package/dist/js/treeshaking/locale/en.js +35 -0
  208. package/dist/js/treeshaking/locale/index.js +9 -0
  209. package/dist/js/treeshaking/locale/zh.js +35 -0
  210. package/dist/js/treeshaking/schema/Schema.js +273 -0
  211. package/dist/js/treeshaking/schema/index.js +181 -0
  212. package/dist/js/treeshaking/schema/legacy.js +337 -0
  213. package/dist/js/treeshaking/types/config/deploy.js +1 -0
  214. package/dist/js/treeshaking/types/config/dev.js +1 -0
  215. package/dist/js/treeshaking/types/config/experiments.js +1 -0
  216. package/dist/js/treeshaking/types/config/html.js +1 -0
  217. package/dist/js/treeshaking/types/config/index.js +1 -0
  218. package/dist/js/treeshaking/types/config/output.js +1 -0
  219. package/dist/js/treeshaking/types/config/performance.js +1 -0
  220. package/dist/js/treeshaking/types/config/security.js +1 -0
  221. package/dist/js/treeshaking/types/config/source.js +1 -0
  222. package/dist/js/treeshaking/types/config/tools.js +1 -0
  223. package/dist/js/treeshaking/types/hooks.js +1 -0
  224. package/dist/js/treeshaking/types/index.js +3 -0
  225. package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
  226. package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
  227. package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
  228. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  229. package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
  230. package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
  231. package/dist/js/treeshaking/utils/commands.js +10 -0
  232. package/dist/js/treeshaking/utils/config.js +302 -0
  233. package/dist/js/treeshaking/utils/createFileWatcher.js +283 -0
  234. package/dist/js/treeshaking/utils/createServer.js +258 -0
  235. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  236. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +185 -0
  237. package/dist/js/treeshaking/utils/language.js +6 -0
  238. package/dist/js/treeshaking/utils/printInstructions.js +152 -0
  239. package/dist/js/treeshaking/utils/restart.js +187 -0
  240. package/dist/js/treeshaking/utils/routes.js +153 -0
  241. package/dist/js/treeshaking/utils/types.js +1 -0
  242. package/dist/types/analyze/Builder.d.ts +8 -0
  243. package/dist/types/analyze/constants.d.ts +13 -1
  244. package/dist/types/analyze/generateCode.d.ts +3 -2
  245. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  246. package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
  247. package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
  248. package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
  249. package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
  250. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  251. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  252. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  253. package/dist/types/analyze/index.d.ts +3 -40
  254. package/dist/types/analyze/nestedRoutes.d.ts +5 -0
  255. package/dist/types/analyze/templates.d.ts +24 -5
  256. package/dist/types/analyze/utils.d.ts +12 -2
  257. package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
  258. package/dist/types/builder/index.d.ts +18 -0
  259. package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
  260. package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
  261. package/dist/types/builder/share.d.ts +26 -0
  262. package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
  263. package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
  264. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +4 -0
  265. package/dist/types/commands/build.d.ts +2 -1
  266. package/dist/types/commands/deploy.d.ts +2 -1
  267. package/dist/types/commands/dev.d.ts +2 -1
  268. package/dist/types/commands/index.d.ts +1 -1
  269. package/dist/types/commands/inspect.d.ts +10 -6
  270. package/dist/types/commands/serve.d.ts +3 -0
  271. package/dist/types/config/default.d.ts +3 -0
  272. package/dist/types/config/index.d.ts +2 -0
  273. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  274. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  275. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  276. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  277. package/dist/types/config/initial/index.d.ts +4 -0
  278. package/dist/types/config/initial/inits.d.ts +4 -0
  279. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  280. package/dist/types/defineConfig.d.ts +8 -0
  281. package/dist/types/hooks.d.ts +2 -37
  282. package/dist/types/index.d.ts +9 -3
  283. package/dist/types/initialize/index.d.ts +5 -0
  284. package/dist/types/locale/en.d.ts +1 -2
  285. package/dist/types/locale/index.d.ts +2 -4
  286. package/dist/types/locale/zh.d.ts +1 -2
  287. package/dist/types/schema/Schema.d.ts +14 -0
  288. package/dist/types/schema/index.d.ts +4 -0
  289. package/dist/types/schema/legacy.d.ts +3 -0
  290. package/dist/types/types/config/deploy.d.ts +9 -0
  291. package/dist/types/types/config/dev.d.ts +13 -0
  292. package/dist/types/types/config/experiments.d.ts +4 -0
  293. package/dist/types/types/config/html.d.ts +4 -0
  294. package/dist/types/types/config/index.d.ts +66 -0
  295. package/dist/types/types/config/output.d.ts +22 -0
  296. package/dist/types/types/config/performance.d.ts +4 -0
  297. package/dist/types/types/config/security.d.ts +4 -0
  298. package/dist/types/types/config/source.d.ts +24 -0
  299. package/dist/types/types/config/tools.d.ts +24 -0
  300. package/dist/types/types/hooks.d.ts +89 -0
  301. package/dist/types/types/index.d.ts +23 -0
  302. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  303. package/dist/types/types/legacyConfig/dev.d.ts +13 -0
  304. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  305. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  306. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  307. package/dist/types/types/legacyConfig/tools.d.ts +17 -0
  308. package/dist/types/utils/commands.d.ts +2 -0
  309. package/dist/types/utils/config.d.ts +2 -2
  310. package/dist/types/utils/createFileWatcher.d.ts +4 -0
  311. package/dist/types/utils/createServer.d.ts +9 -1
  312. package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
  313. package/dist/types/utils/printInstructions.d.ts +3 -2
  314. package/dist/types/utils/restart.d.ts +3 -0
  315. package/dist/types/utils/types.d.ts +2 -3
  316. package/lib/types.d.ts +1 -1
  317. package/package.json +37 -46
  318. package/dist/js/modern/analyze/getClientRoutes.js +0 -219
  319. package/dist/js/modern/commands/start.js +0 -31
  320. package/dist/js/modern/utils/createCompiler.js +0 -61
  321. package/dist/js/node/analyze/getClientRoutes.js +0 -241
  322. package/dist/js/node/commands/start.js +0 -47
  323. package/dist/js/node/utils/createCompiler.js +0 -81
  324. package/dist/types/commands/start.d.ts +0 -2
  325. package/dist/types/utils/createCompiler.d.ts +0 -13
@@ -1,178 +1,260 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 analyze_exports = {};
62
+ __export(analyze_exports, {
63
+ default: () => analyze_default
5
64
  });
6
- exports.modifyServerRoutes = exports.modifyFileSystemRoutes = exports.modifyEntryRuntimePlugins = exports.modifyEntryRenderFunction = exports.modifyEntryImports = exports.modifyEntryExport = exports.modifyAsyncEntry = exports.htmlPartials = exports.default = exports.beforeGenerateRoutes = exports.addRuntimeExports = exports.addDefineTypes = void 0;
7
-
8
- var path = _interopRequireWildcard(require("path"));
9
-
10
- var _plugin = require("@modern-js/plugin");
11
-
12
- var _utils = require("@modern-js/utils");
13
-
14
- var _lodash = require("@modern-js/utils/lodash");
15
-
16
- var _utils2 = require("./utils");
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
- 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; }
23
-
24
- 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; }
25
-
26
- 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; }
27
-
28
- const debug = (0, _utils.createDebugger)('plugin-analyze');
29
- const modifyEntryImports = (0, _plugin.createAsyncWaterfall)();
30
- exports.modifyEntryImports = modifyEntryImports;
31
- const modifyEntryExport = (0, _plugin.createAsyncWaterfall)();
32
- exports.modifyEntryExport = modifyEntryExport;
33
- const addRuntimeExports = (0, _plugin.createAsyncWaterfall)();
34
- exports.addRuntimeExports = addRuntimeExports;
35
- const modifyEntryRuntimePlugins = (0, _plugin.createAsyncWaterfall)();
36
- exports.modifyEntryRuntimePlugins = modifyEntryRuntimePlugins;
37
- const modifyEntryRenderFunction = (0, _plugin.createAsyncWaterfall)();
38
- exports.modifyEntryRenderFunction = modifyEntryRenderFunction;
39
- const modifyAsyncEntry = (0, _plugin.createAsyncWaterfall)();
40
- exports.modifyAsyncEntry = modifyAsyncEntry;
41
- const modifyFileSystemRoutes = (0, _plugin.createAsyncWaterfall)();
42
- exports.modifyFileSystemRoutes = modifyFileSystemRoutes;
43
- const modifyServerRoutes = (0, _plugin.createAsyncWaterfall)();
44
- exports.modifyServerRoutes = modifyServerRoutes;
45
- const htmlPartials = (0, _plugin.createAsyncWaterfall)();
46
- exports.htmlPartials = htmlPartials;
47
- const beforeGenerateRoutes = (0, _plugin.createAsyncWaterfall)();
48
- exports.beforeGenerateRoutes = beforeGenerateRoutes;
49
- const addDefineTypes = (0, _plugin.createAsyncWaterfall)();
50
- exports.addDefineTypes = addDefineTypes;
51
-
52
- var _default = () => ({
53
- name: '@modern-js/plugin-analyze',
54
- registerHook: {
55
- modifyAsyncEntry,
56
- modifyEntryImports,
57
- modifyEntryExport,
58
- modifyEntryRuntimePlugins,
59
- modifyEntryRenderFunction,
60
- modifyFileSystemRoutes,
61
- modifyServerRoutes,
62
- htmlPartials,
63
- addRuntimeExports,
64
- beforeGenerateRoutes,
65
- addDefineTypes
66
- },
67
- setup: api => {
65
+ module.exports = __toCommonJS(analyze_exports);
66
+ var path = __toESM(require("path"));
67
+ var import_utils = require("@modern-js/utils");
68
+ var import_lodash = require("@modern-js/utils/lodash");
69
+ var import_builder = require("../builder");
70
+ var import_printInstructions = require("../utils/printInstructions");
71
+ var import_routes = require("../utils/routes");
72
+ var import_config = require("../utils/config");
73
+ var import_commands = require("../utils/commands");
74
+ var import_config2 = require("../config");
75
+ var import_utils2 = require("./utils");
76
+ var import_Builder = require("./Builder");
77
+ const debug = (0, import_utils.createDebugger)("plugin-analyze");
78
+ var analyze_default = () => ({
79
+ name: "@modern-js/plugin-analyze",
80
+ setup: (api) => {
68
81
  let pagesDir = [];
82
+ let nestedRouteEntries = [];
69
83
  let originEntrypoints = [];
70
84
  return {
71
- async prepare() {
72
- var _resolvedConfig$sourc;
73
-
74
- const appContext = api.useAppContext();
75
- const resolvedConfig = api.useResolvedConfigContext();
76
- const hookRunners = api.useHookRunners();
77
-
78
- try {
79
- _utils.fs.emptydirSync(appContext.internalDirectory);
80
- } catch (_unused) {// FIXME:
81
- }
82
-
83
- const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig$sourc = resolvedConfig.source) === null || _resolvedConfig$sourc === void 0 ? void 0 : _resolvedConfig$sourc.entriesDir);
84
- await hookRunners.addRuntimeExports();
85
-
86
- if (apiOnly) {
87
- const {
88
- routes
89
- } = await hookRunners.modifyServerRoutes({
90
- routes: []
85
+ prepare() {
86
+ return __async(this, null, function* () {
87
+ var _a2;
88
+ let appContext = api.useAppContext();
89
+ const resolvedConfig = api.useResolvedConfigContext();
90
+ const hookRunners = api.useHookRunners();
91
+ try {
92
+ import_utils.fs.emptydirSync(appContext.internalDirectory);
93
+ } catch (e) {
94
+ }
95
+ const apiOnly = yield (0, import_utils.isApiOnly)(
96
+ appContext.appDirectory,
97
+ (_a2 = resolvedConfig.source) == null ? void 0 : _a2.entriesDir
98
+ );
99
+ yield hookRunners.addRuntimeExports();
100
+ if (apiOnly) {
101
+ const { routes: routes2 } = yield hookRunners.modifyServerRoutes({
102
+ routes: []
103
+ });
104
+ debug(`server routes: %o`, routes2);
105
+ appContext = __spreadProps(__spreadValues({}, appContext), {
106
+ apiOnly,
107
+ serverRoutes: routes2
108
+ });
109
+ api.setAppContext(appContext);
110
+ return;
111
+ }
112
+ const [
113
+ { getBundleEntry },
114
+ { getServerRoutes },
115
+ { generateCode },
116
+ { getHtmlTemplate }
117
+ ] = yield Promise.all([
118
+ Promise.resolve().then(() => __toESM(require("./getBundleEntry"))),
119
+ Promise.resolve().then(() => __toESM(require("./getServerRoutes"))),
120
+ Promise.resolve().then(() => __toESM(require("./generateCode"))),
121
+ Promise.resolve().then(() => __toESM(require("./getHtmlTemplate")))
122
+ ]);
123
+ const entrypoints = getBundleEntry(appContext, resolvedConfig);
124
+ console.log("final entries", entrypoints);
125
+ const defaultChecked = entrypoints.map((point) => point.entryName);
126
+ debug(`entrypoints: %o`, entrypoints);
127
+ const initialRoutes = getServerRoutes(entrypoints, {
128
+ appContext,
129
+ config: resolvedConfig
130
+ });
131
+ const { routes } = yield hookRunners.modifyServerRoutes({
132
+ routes: initialRoutes
91
133
  });
92
134
  debug(`server routes: %o`, routes);
93
- api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
94
- apiOnly,
135
+ appContext = __spreadProps(__spreadValues({}, appContext), {
136
+ entrypoints,
95
137
  serverRoutes: routes
96
- }));
97
- return;
98
- }
99
-
100
- const [{
101
- getBundleEntry
102
- }, {
103
- getServerRoutes
104
- }, {
105
- generateCode
106
- }, {
107
- getHtmlTemplate
108
- }] = await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./getBundleEntry"))), Promise.resolve().then(() => _interopRequireWildcard(require("./getServerRoutes"))), Promise.resolve().then(() => _interopRequireWildcard(require("./generateCode"))), Promise.resolve().then(() => _interopRequireWildcard(require("./getHtmlTemplate")))]);
109
- const entrypoints = getBundleEntry(appContext, resolvedConfig);
110
- const defaultChecked = entrypoints.map(point => point.entryName);
111
- debug(`entrypoints: %o`, entrypoints);
112
- const initialRoutes = getServerRoutes(entrypoints, {
113
- appContext,
114
- config: resolvedConfig
115
- });
116
- const {
117
- routes
118
- } = await hookRunners.modifyServerRoutes({
119
- routes: initialRoutes
120
- });
121
- debug(`server routes: %o`, routes);
122
- api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
123
- entrypoints,
124
- serverRoutes: routes
125
- }));
126
- pagesDir = entrypoints.map(point => point.entry);
127
- originEntrypoints = (0, _lodash.cloneDeep)(entrypoints);
128
- await generateCode(appContext, resolvedConfig, entrypoints, api);
129
- const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
130
- appContext,
131
- config: resolvedConfig
138
+ });
139
+ api.setAppContext(appContext);
140
+ nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
141
+ pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
142
+ originEntrypoints = (0, import_lodash.cloneDeep)(entrypoints);
143
+ yield generateCode(appContext, resolvedConfig, entrypoints, api);
144
+ const htmlTemplates = yield getHtmlTemplate(entrypoints, api, {
145
+ appContext,
146
+ config: resolvedConfig
147
+ });
148
+ debug(`html templates: %o`, htmlTemplates);
149
+ yield hookRunners.addDefineTypes();
150
+ debug(`add Define Types`);
151
+ appContext = __spreadProps(__spreadValues({}, appContext), {
152
+ entrypoints,
153
+ checkedEntries: defaultChecked,
154
+ apiOnly,
155
+ serverRoutes: routes,
156
+ htmlTemplates
157
+ });
158
+ api.setAppContext(appContext);
159
+ const command = (0, import_commands.getCommand)();
160
+ const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
161
+ if (buildCommands.includes(command)) {
162
+ let _b;
163
+ const normalizedConfig = api.useResolvedConfigContext();
164
+ const builder = yield (0, import_builder.createBuilderForModern)({
165
+ normalizedConfig,
166
+ appContext,
167
+ compatPluginConfig: {
168
+ onBeforeBuild(_0) {
169
+ return __async(this, arguments, function* ({ bundlerConfigs }) {
170
+ const hookRunners2 = api.useHookRunners();
171
+ yield (0, import_routes.generateRoutes)(appContext);
172
+ yield hookRunners2.beforeBuild({ bundlerConfigs });
173
+ });
174
+ },
175
+ onAfterBuild(_0) {
176
+ return __async(this, arguments, function* ({ stats }) {
177
+ const hookRunners2 = api.useHookRunners();
178
+ yield hookRunners2.afterBuild({ stats });
179
+ yield (0, import_config.emitResolvedConfig)(
180
+ appContext.appDirectory,
181
+ normalizedConfig
182
+ );
183
+ });
184
+ },
185
+ onDevCompileDone(_0) {
186
+ return __async(this, arguments, function* ({ isFirstCompile }) {
187
+ const hookRunners2 = api.useHookRunners();
188
+ if (process.stdout.isTTY || isFirstCompile) {
189
+ hookRunners2.afterDev();
190
+ if (isFirstCompile) {
191
+ (0, import_printInstructions.printInstructions)(
192
+ hookRunners2,
193
+ appContext,
194
+ normalizedConfig
195
+ );
196
+ }
197
+ }
198
+ });
199
+ },
200
+ onBeforeCreateCompiler(_0) {
201
+ return __async(this, arguments, function* ({ bundlerConfigs }) {
202
+ const hookRunners2 = api.useHookRunners();
203
+ yield hookRunners2.beforeCreateCompiler({
204
+ bundlerConfigs
205
+ });
206
+ });
207
+ },
208
+ onAfterCreateCompiler(_0) {
209
+ return __async(this, arguments, function* ({ compiler }) {
210
+ const hookRunners2 = api.useHookRunners();
211
+ yield hookRunners2.afterCreateCompiler({ compiler });
212
+ });
213
+ }
214
+ }
215
+ });
216
+ builder.addPlugins(resolvedConfig.builderPlugins);
217
+ appContext = __spreadProps(__spreadValues({}, appContext), {
218
+ builder
219
+ });
220
+ api.setAppContext(appContext);
221
+ }
132
222
  });
133
- debug(`html templates: %o`, htmlTemplates);
134
- await hookRunners.addDefineTypes();
135
- debug(`add Define Types`);
136
- api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
137
- entrypoints,
138
- checkedEntries: defaultChecked,
139
- apiOnly,
140
- serverRoutes: routes,
141
- htmlTemplates
142
- }));
143
223
  },
144
-
145
224
  watchFiles() {
146
225
  return pagesDir;
147
226
  },
148
-
149
- async fileChange(e) {
227
+ resolvedConfig({ resolved }) {
150
228
  const appContext = api.useAppContext();
151
- const {
152
- appDirectory
153
- } = appContext;
154
- const {
155
- filename,
156
- eventType
157
- } = e;
158
-
159
- const isPageFile = name => pagesDir.some(pageDir => name.includes(pageDir));
160
-
161
- const absoluteFilePath = path.resolve(appDirectory, filename);
162
- const isRouteComponent = isPageFile(absoluteFilePath) && (0, _utils2.isRouteComponentFile)(absoluteFilePath);
163
-
164
- if (isRouteComponent && (eventType === 'add' || eventType === 'unlink')) {
165
- const resolvedConfig = api.useResolvedConfigContext();
166
- const {
167
- generateCode
168
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./generateCode")));
169
- const entrypoints = (0, _lodash.cloneDeep)(originEntrypoints);
170
- generateCode(appContext, resolvedConfig, entrypoints, api);
171
- }
229
+ const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext);
230
+ return {
231
+ resolved: config
232
+ };
233
+ },
234
+ beforeRestart() {
235
+ return __async(this, null, function* () {
236
+ import_Builder.serverLoaderBuilder.stop();
237
+ import_Builder.loaderBuilder.stop();
238
+ });
239
+ },
240
+ fileChange(e) {
241
+ return __async(this, null, function* () {
242
+ const appContext = api.useAppContext();
243
+ const { appDirectory } = appContext;
244
+ const { filename, eventType } = e;
245
+ const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
246
+ const absoluteFilePath = path.resolve(appDirectory, filename);
247
+ const isRouteComponent = isPageFile(absoluteFilePath) && (0, import_utils2.isPageComponentFile)(absoluteFilePath);
248
+ if (isRouteComponent && (eventType === "add" || eventType === "unlink") || (0, import_utils2.isNestedRouteComponent)(nestedRouteEntries, absoluteFilePath) && eventType === "change") {
249
+ const resolvedConfig = api.useResolvedConfigContext();
250
+ const { generateCode } = yield Promise.resolve().then(() => __toESM(require("./generateCode")));
251
+ const entrypoints = (0, import_lodash.cloneDeep)(originEntrypoints);
252
+ generateCode(appContext, resolvedConfig, entrypoints, api);
253
+ }
254
+ });
172
255
  }
173
-
174
256
  };
175
257
  }
176
258
  });
177
-
178
- exports.default = _default;
259
+ // Annotate the CommonJS export names for ESM import in node:
260
+ 0 && (module.exports = {});
@@ -1,44 +1,63 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 isDefaultExportFunction_exports = {};
25
+ __export(isDefaultExportFunction_exports, {
26
+ isDefaultExportFunction: () => isDefaultExportFunction
5
27
  });
6
- exports.isDefaultExportFunction = void 0;
7
-
8
- var _fs = _interopRequireDefault(require("fs"));
9
-
10
- var _parser = require("@babel/parser");
11
-
12
- var _traverse = _interopRequireDefault(require("@babel/traverse"));
13
-
14
- var t = _interopRequireWildcard(require("@babel/types"));
15
-
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- const isFunction = node => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
23
-
24
- const isDefaultExportFunction = file => {
25
- if (!file || !_fs.default.existsSync(file)) {
28
+ module.exports = __toCommonJS(isDefaultExportFunction_exports);
29
+ var import_fs = __toESM(require("fs"));
30
+ var import_parser = require("@babel/parser");
31
+ var import_traverse = __toESM(require("@babel/traverse"));
32
+ var t = __toESM(require("@babel/types"));
33
+ const isFunction = (node) => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
34
+ const isDefaultExportFunction = (file) => {
35
+ if (!file || !import_fs.default.existsSync(file)) {
26
36
  return false;
27
37
  }
28
-
29
- const ast = (0, _parser.parse)(_fs.default.readFileSync(file, 'utf8'), {
30
- sourceType: 'unambiguous',
31
- plugins: ['jsx', 'typescript', 'classProperties', 'dynamicImport', 'exportDefaultFrom', 'exportNamespaceFrom', 'decorators-legacy', 'functionBind', 'classPrivateMethods', ['pipelineOperator', {
32
- proposal: 'minimal'
33
- }], 'optionalChaining', 'optionalCatchBinding', 'objectRestSpread', 'numericSeparator']
38
+ const ast = (0, import_parser.parse)(import_fs.default.readFileSync(file, "utf8"), {
39
+ sourceType: "unambiguous",
40
+ plugins: [
41
+ "jsx",
42
+ "typescript",
43
+ "classProperties",
44
+ "dynamicImport",
45
+ "exportDefaultFrom",
46
+ "exportNamespaceFrom",
47
+ "decorators-legacy",
48
+ "functionBind",
49
+ "classPrivateMethods",
50
+ ["pipelineOperator", { proposal: "minimal" }],
51
+ "optionalChaining",
52
+ "optionalCatchBinding",
53
+ "objectRestSpread",
54
+ "numericSeparator"
55
+ ]
34
56
  });
35
57
  let isExportFunction = false;
36
- (0, _traverse.default)(ast, {
37
- ExportDefaultDeclaration: path => {
38
- const {
39
- declaration
40
- } = path.node;
41
-
58
+ (0, import_traverse.default)(ast, {
59
+ ExportDefaultDeclaration: (path) => {
60
+ const { declaration } = path.node;
42
61
  if (isFunction(declaration)) {
43
62
  isExportFunction = true;
44
63
  }
@@ -46,5 +65,7 @@ const isDefaultExportFunction = file => {
46
65
  });
47
66
  return isExportFunction;
48
67
  };
49
-
50
- exports.isDefaultExportFunction = isDefaultExportFunction;
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ isDefaultExportFunction
71
+ });
@@ -1,24 +1,36 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var makeLegalIdentifier_exports = {};
19
+ __export(makeLegalIdentifier_exports, {
20
+ makeLegalIdentifier: () => makeLegalIdentifier
5
21
  });
6
- exports.makeLegalIdentifier = makeLegalIdentifier;
7
-
8
- /**
9
- * modified from https://github.com/rollup/plugins/blob/master/packages/pluginutils
10
- * license at https://github.com/rollup/plugins/blob/master/LICENSE
11
- */
12
- const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
13
- const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
14
- const forbidList = new Set(`${reservedWords} ${builtins}`.split(' '));
15
-
22
+ module.exports = __toCommonJS(makeLegalIdentifier_exports);
23
+ const reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
24
+ const builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
25
+ const forbidList = new Set(`${reservedWords} ${builtins}`.split(" "));
16
26
  function makeLegalIdentifier(str) {
17
- const identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, '_');
18
-
27
+ const identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
19
28
  if (/\d/.test(identifier[0]) || forbidList.has(identifier)) {
20
29
  return `_${identifier}`;
21
30
  }
22
-
23
- return identifier || '_';
24
- }
31
+ return identifier || "_";
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ makeLegalIdentifier
36
+ });