@wyw-in-js/transform 0.1.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 (480) hide show
  1. package/LICENSE +21 -0
  2. package/esm/babel.js +2 -0
  3. package/esm/babel.js.map +1 -0
  4. package/esm/cache.js +80 -0
  5. package/esm/cache.js.map +1 -0
  6. package/esm/debug/fileReporter.js +144 -0
  7. package/esm/debug/fileReporter.js.map +1 -0
  8. package/esm/evaluators/index.js +14 -0
  9. package/esm/evaluators/index.js.map +1 -0
  10. package/esm/index.js +24 -0
  11. package/esm/index.js.map +1 -0
  12. package/esm/module.js +316 -0
  13. package/esm/module.js.map +1 -0
  14. package/esm/options/babel-merge.d.js +2 -0
  15. package/esm/options/babel-merge.d.js.map +1 -0
  16. package/esm/options/buildOptions.js +28 -0
  17. package/esm/options/buildOptions.js.map +1 -0
  18. package/esm/options/loadBabelOptions.js +24 -0
  19. package/esm/options/loadBabelOptions.js.map +1 -0
  20. package/esm/plugins/babel-transform.js +53 -0
  21. package/esm/plugins/babel-transform.js.map +1 -0
  22. package/esm/plugins/collector.js +66 -0
  23. package/esm/plugins/collector.js.map +1 -0
  24. package/esm/plugins/dynamic-import.js +28 -0
  25. package/esm/plugins/dynamic-import.js.map +1 -0
  26. package/esm/plugins/preeval.js +75 -0
  27. package/esm/plugins/preeval.js.map +1 -0
  28. package/esm/plugins/shaker.js +296 -0
  29. package/esm/plugins/shaker.js.map +1 -0
  30. package/esm/shaker.js +50 -0
  31. package/esm/shaker.js.map +1 -0
  32. package/esm/transform/BaseEntrypoint.js +164 -0
  33. package/esm/transform/BaseEntrypoint.js.map +1 -0
  34. package/esm/transform/Entrypoint.helpers.js +168 -0
  35. package/esm/transform/Entrypoint.helpers.js.map +1 -0
  36. package/esm/transform/Entrypoint.js +212 -0
  37. package/esm/transform/Entrypoint.js.map +1 -0
  38. package/esm/transform/Entrypoint.types.js +2 -0
  39. package/esm/transform/Entrypoint.types.js.map +1 -0
  40. package/esm/transform/EvaluatedEntrypoint.js +6 -0
  41. package/esm/transform/EvaluatedEntrypoint.js.map +1 -0
  42. package/esm/transform/actions/AbortError.js +8 -0
  43. package/esm/transform/actions/AbortError.js.map +1 -0
  44. package/esm/transform/actions/BaseAction.js +134 -0
  45. package/esm/transform/actions/BaseAction.js.map +1 -0
  46. package/esm/transform/actions/UnprocessedEntrypointError.js +8 -0
  47. package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -0
  48. package/esm/transform/actions/actionRunner.js +73 -0
  49. package/esm/transform/actions/actionRunner.js.map +1 -0
  50. package/esm/transform/actions/types.js +2 -0
  51. package/esm/transform/actions/types.js.map +1 -0
  52. package/esm/transform/generators/baseProcessingHandlers.js +22 -0
  53. package/esm/transform/generators/baseProcessingHandlers.js.map +1 -0
  54. package/esm/transform/generators/collect.js +58 -0
  55. package/esm/transform/generators/collect.js.map +1 -0
  56. package/esm/transform/generators/evalFile.js +50 -0
  57. package/esm/transform/generators/evalFile.js.map +1 -0
  58. package/esm/transform/generators/explodeReexports.js +63 -0
  59. package/esm/transform/generators/explodeReexports.js.map +1 -0
  60. package/esm/transform/generators/extract.js +120 -0
  61. package/esm/transform/generators/extract.js.map +1 -0
  62. package/esm/transform/generators/getExports.js +73 -0
  63. package/esm/transform/generators/getExports.js.map +1 -0
  64. package/esm/transform/generators/index.js +13 -0
  65. package/esm/transform/generators/index.js.map +1 -0
  66. package/esm/transform/generators/processEntrypoint.js +43 -0
  67. package/esm/transform/generators/processEntrypoint.js.map +1 -0
  68. package/esm/transform/generators/processImports.js +23 -0
  69. package/esm/transform/generators/processImports.js.map +1 -0
  70. package/esm/transform/generators/resolveImports.js +148 -0
  71. package/esm/transform/generators/resolveImports.js.map +1 -0
  72. package/esm/transform/generators/transform.js +117 -0
  73. package/esm/transform/generators/transform.js.map +1 -0
  74. package/esm/transform/generators/workflow.js +82 -0
  75. package/esm/transform/generators/workflow.js.map +1 -0
  76. package/esm/transform/helpers/loadLinariaOptions.js +66 -0
  77. package/esm/transform/helpers/loadLinariaOptions.js.map +1 -0
  78. package/esm/transform/helpers/withDefaultServices.js +21 -0
  79. package/esm/transform/helpers/withDefaultServices.js.map +1 -0
  80. package/esm/transform/rootLog.js +3 -0
  81. package/esm/transform/rootLog.js.map +1 -0
  82. package/esm/transform/types.js +2 -0
  83. package/esm/transform/types.js.map +1 -0
  84. package/esm/transform.js +121 -0
  85. package/esm/transform.js.map +1 -0
  86. package/esm/types.js +2 -0
  87. package/esm/types.js.map +1 -0
  88. package/esm/utils/EventEmitter.js +52 -0
  89. package/esm/utils/EventEmitter.js.map +1 -0
  90. package/esm/utils/ShakerMetadata.js +2 -0
  91. package/esm/utils/ShakerMetadata.js.map +1 -0
  92. package/esm/utils/TransformMetadata.js +11 -0
  93. package/esm/utils/TransformMetadata.js.map +1 -0
  94. package/esm/utils/addIdentifierToLinariaPreval.js +68 -0
  95. package/esm/utils/addIdentifierToLinariaPreval.js.map +1 -0
  96. package/esm/utils/collectExportsAndImports.js +974 -0
  97. package/esm/utils/collectExportsAndImports.js.map +1 -0
  98. package/esm/utils/collectTemplateDependencies.js +219 -0
  99. package/esm/utils/collectTemplateDependencies.js.map +1 -0
  100. package/esm/utils/createId.js +6 -0
  101. package/esm/utils/createId.js.map +1 -0
  102. package/esm/utils/dispose-polyfill.js +6 -0
  103. package/esm/utils/dispose-polyfill.js.map +1 -0
  104. package/esm/utils/findIdentifiers.js +62 -0
  105. package/esm/utils/findIdentifiers.js.map +1 -0
  106. package/esm/utils/findPackageJSON.js +22 -0
  107. package/esm/utils/findPackageJSON.js.map +1 -0
  108. package/esm/utils/getFileIdx.js +10 -0
  109. package/esm/utils/getFileIdx.js.map +1 -0
  110. package/esm/utils/getPluginKey.js +13 -0
  111. package/esm/utils/getPluginKey.js.map +1 -0
  112. package/esm/utils/getScope.js +6 -0
  113. package/esm/utils/getScope.js.map +1 -0
  114. package/esm/utils/getSource.js +15 -0
  115. package/esm/utils/getSource.js.map +1 -0
  116. package/esm/utils/getTagProcessor.js +304 -0
  117. package/esm/utils/getTagProcessor.js.map +1 -0
  118. package/esm/utils/getVisitorKeys.js +5 -0
  119. package/esm/utils/getVisitorKeys.js.map +1 -0
  120. package/esm/utils/hasLinariaPreval.js +7 -0
  121. package/esm/utils/hasLinariaPreval.js.map +1 -0
  122. package/esm/utils/isExports.js +22 -0
  123. package/esm/utils/isExports.js.map +1 -0
  124. package/esm/utils/isGlobal.js +6 -0
  125. package/esm/utils/isGlobal.js.map +1 -0
  126. package/esm/utils/isNode.js +2 -0
  127. package/esm/utils/isNode.js.map +1 -0
  128. package/esm/utils/isNodePath.js +4 -0
  129. package/esm/utils/isNodePath.js.map +1 -0
  130. package/esm/utils/isNotNull.js +4 -0
  131. package/esm/utils/isNotNull.js.map +1 -0
  132. package/esm/utils/isRemoved.js +46 -0
  133. package/esm/utils/isRemoved.js.map +1 -0
  134. package/esm/utils/isRequire.js +13 -0
  135. package/esm/utils/isRequire.js.map +1 -0
  136. package/esm/utils/isSerializable.js +13 -0
  137. package/esm/utils/isSerializable.js.map +1 -0
  138. package/esm/utils/isTypedNode.js +6 -0
  139. package/esm/utils/isTypedNode.js.map +1 -0
  140. package/esm/utils/isUnnecessaryReactCall.js +72 -0
  141. package/esm/utils/isUnnecessaryReactCall.js.map +1 -0
  142. package/esm/utils/peek.js +2 -0
  143. package/esm/utils/peek.js.map +1 -0
  144. package/esm/utils/processTemplateExpression.js +11 -0
  145. package/esm/utils/processTemplateExpression.js.map +1 -0
  146. package/esm/utils/removeDangerousCode.js +127 -0
  147. package/esm/utils/removeDangerousCode.js.map +1 -0
  148. package/esm/utils/scopeHelpers.js +514 -0
  149. package/esm/utils/scopeHelpers.js.map +1 -0
  150. package/esm/utils/traversalCache.js +28 -0
  151. package/esm/utils/traversalCache.js.map +1 -0
  152. package/esm/utils/unwrapSequence.js +14 -0
  153. package/esm/utils/unwrapSequence.js.map +1 -0
  154. package/esm/utils/valueToLiteral.js +59 -0
  155. package/esm/utils/valueToLiteral.js.map +1 -0
  156. package/esm/utils/visitors/JSXElementsRemover.js +51 -0
  157. package/esm/utils/visitors/JSXElementsRemover.js.map +1 -0
  158. package/esm/vm/createVmContext.js +72 -0
  159. package/esm/vm/createVmContext.js.map +1 -0
  160. package/esm/vm/process.js +29 -0
  161. package/esm/vm/process.js.map +1 -0
  162. package/lib/babel.js +2 -0
  163. package/lib/babel.js.map +1 -0
  164. package/lib/cache.js +87 -0
  165. package/lib/cache.js.map +1 -0
  166. package/lib/debug/fileReporter.js +153 -0
  167. package/lib/debug/fileReporter.js.map +1 -0
  168. package/lib/evaluators/index.js +20 -0
  169. package/lib/evaluators/index.js.map +1 -0
  170. package/lib/index.js +225 -0
  171. package/lib/index.js.map +1 -0
  172. package/lib/module.js +327 -0
  173. package/lib/module.js.map +1 -0
  174. package/lib/options/babel-merge.d.js +2 -0
  175. package/lib/options/babel-merge.d.js.map +1 -0
  176. package/lib/options/buildOptions.js +35 -0
  177. package/lib/options/buildOptions.js.map +1 -0
  178. package/lib/options/loadBabelOptions.js +31 -0
  179. package/lib/options/loadBabelOptions.js.map +1 -0
  180. package/lib/plugins/babel-transform.js +60 -0
  181. package/lib/plugins/babel-transform.js.map +1 -0
  182. package/lib/plugins/collector.js +76 -0
  183. package/lib/plugins/collector.js.map +1 -0
  184. package/lib/plugins/dynamic-import.js +34 -0
  185. package/lib/plugins/dynamic-import.js.map +1 -0
  186. package/lib/plugins/preeval.js +82 -0
  187. package/lib/plugins/preeval.js.map +1 -0
  188. package/lib/plugins/shaker.js +303 -0
  189. package/lib/plugins/shaker.js.map +1 -0
  190. package/lib/shaker.js +58 -0
  191. package/lib/shaker.js.map +1 -0
  192. package/lib/transform/BaseEntrypoint.js +175 -0
  193. package/lib/transform/BaseEntrypoint.js.map +1 -0
  194. package/lib/transform/Entrypoint.helpers.js +182 -0
  195. package/lib/transform/Entrypoint.helpers.js.map +1 -0
  196. package/lib/transform/Entrypoint.js +226 -0
  197. package/lib/transform/Entrypoint.js.map +1 -0
  198. package/lib/transform/Entrypoint.types.js +2 -0
  199. package/lib/transform/Entrypoint.types.js.map +1 -0
  200. package/lib/transform/EvaluatedEntrypoint.js +13 -0
  201. package/lib/transform/EvaluatedEntrypoint.js.map +1 -0
  202. package/lib/transform/actions/AbortError.js +16 -0
  203. package/lib/transform/actions/AbortError.js.map +1 -0
  204. package/lib/transform/actions/BaseAction.js +144 -0
  205. package/lib/transform/actions/BaseAction.js.map +1 -0
  206. package/lib/transform/actions/UnprocessedEntrypointError.js +16 -0
  207. package/lib/transform/actions/UnprocessedEntrypointError.js.map +1 -0
  208. package/lib/transform/actions/actionRunner.js +82 -0
  209. package/lib/transform/actions/actionRunner.js.map +1 -0
  210. package/lib/transform/actions/types.js +2 -0
  211. package/lib/transform/actions/types.js.map +1 -0
  212. package/lib/transform/generators/baseProcessingHandlers.js +27 -0
  213. package/lib/transform/generators/baseProcessingHandlers.js.map +1 -0
  214. package/lib/transform/generators/collect.js +66 -0
  215. package/lib/transform/generators/collect.js.map +1 -0
  216. package/lib/transform/generators/evalFile.js +57 -0
  217. package/lib/transform/generators/evalFile.js.map +1 -0
  218. package/lib/transform/generators/explodeReexports.js +70 -0
  219. package/lib/transform/generators/explodeReexports.js.map +1 -0
  220. package/lib/transform/generators/extract.js +128 -0
  221. package/lib/transform/generators/extract.js.map +1 -0
  222. package/lib/transform/generators/getExports.js +80 -0
  223. package/lib/transform/generators/getExports.js.map +1 -0
  224. package/lib/transform/generators/index.js +19 -0
  225. package/lib/transform/generators/index.js.map +1 -0
  226. package/lib/transform/generators/processEntrypoint.js +49 -0
  227. package/lib/transform/generators/processEntrypoint.js.map +1 -0
  228. package/lib/transform/generators/processImports.js +29 -0
  229. package/lib/transform/generators/processImports.js.map +1 -0
  230. package/lib/transform/generators/resolveImports.js +158 -0
  231. package/lib/transform/generators/resolveImports.js.map +1 -0
  232. package/lib/transform/generators/transform.js +130 -0
  233. package/lib/transform/generators/transform.js.map +1 -0
  234. package/lib/transform/generators/workflow.js +90 -0
  235. package/lib/transform/generators/workflow.js.map +1 -0
  236. package/lib/transform/helpers/loadLinariaOptions.js +73 -0
  237. package/lib/transform/helpers/loadLinariaOptions.js.map +1 -0
  238. package/lib/transform/helpers/withDefaultServices.js +30 -0
  239. package/lib/transform/helpers/withDefaultServices.js.map +1 -0
  240. package/lib/transform/rootLog.js +9 -0
  241. package/lib/transform/rootLog.js.map +1 -0
  242. package/lib/transform/types.js +8 -0
  243. package/lib/transform/types.js.map +1 -0
  244. package/lib/transform.js +128 -0
  245. package/lib/transform.js.map +1 -0
  246. package/lib/types.js +2 -0
  247. package/lib/types.js.map +1 -0
  248. package/lib/utils/EventEmitter.js +61 -0
  249. package/lib/utils/EventEmitter.js.map +1 -0
  250. package/lib/utils/ShakerMetadata.js +9 -0
  251. package/lib/utils/ShakerMetadata.js.map +1 -0
  252. package/lib/utils/TransformMetadata.js +19 -0
  253. package/lib/utils/TransformMetadata.js.map +1 -0
  254. package/lib/utils/addIdentifierToLinariaPreval.js +75 -0
  255. package/lib/utils/addIdentifierToLinariaPreval.js.map +1 -0
  256. package/lib/utils/collectExportsAndImports.js +990 -0
  257. package/lib/utils/collectExportsAndImports.js.map +1 -0
  258. package/lib/utils/collectTemplateDependencies.js +233 -0
  259. package/lib/utils/collectTemplateDependencies.js.map +1 -0
  260. package/lib/utils/createId.js +13 -0
  261. package/lib/utils/createId.js.map +1 -0
  262. package/lib/utils/dispose-polyfill.js +9 -0
  263. package/lib/utils/dispose-polyfill.js.map +1 -0
  264. package/lib/utils/findIdentifiers.js +73 -0
  265. package/lib/utils/findIdentifiers.js.map +1 -0
  266. package/lib/utils/findPackageJSON.js +29 -0
  267. package/lib/utils/findPackageJSON.js.map +1 -0
  268. package/lib/utils/getFileIdx.js +16 -0
  269. package/lib/utils/getFileIdx.js.map +1 -0
  270. package/lib/utils/getPluginKey.js +21 -0
  271. package/lib/utils/getPluginKey.js.map +1 -0
  272. package/lib/utils/getScope.js +12 -0
  273. package/lib/utils/getScope.js.map +1 -0
  274. package/lib/utils/getSource.js +24 -0
  275. package/lib/utils/getSource.js.map +1 -0
  276. package/lib/utils/getTagProcessor.js +318 -0
  277. package/lib/utils/getTagProcessor.js.map +1 -0
  278. package/lib/utils/getVisitorKeys.js +11 -0
  279. package/lib/utils/getVisitorKeys.js.map +1 -0
  280. package/lib/utils/hasLinariaPreval.js +13 -0
  281. package/lib/utils/hasLinariaPreval.js.map +1 -0
  282. package/lib/utils/isExports.js +27 -0
  283. package/lib/utils/isExports.js.map +1 -0
  284. package/lib/utils/isGlobal.js +13 -0
  285. package/lib/utils/isGlobal.js.map +1 -0
  286. package/lib/utils/isNode.js +9 -0
  287. package/lib/utils/isNode.js.map +1 -0
  288. package/lib/utils/isNodePath.js +10 -0
  289. package/lib/utils/isNodePath.js.map +1 -0
  290. package/lib/utils/isNotNull.js +10 -0
  291. package/lib/utils/isNotNull.js.map +1 -0
  292. package/lib/utils/isRemoved.js +52 -0
  293. package/lib/utils/isRemoved.js.map +1 -0
  294. package/lib/utils/isRequire.js +18 -0
  295. package/lib/utils/isRequire.js.map +1 -0
  296. package/lib/utils/isSerializable.js +19 -0
  297. package/lib/utils/isSerializable.js.map +1 -0
  298. package/lib/utils/isTypedNode.js +13 -0
  299. package/lib/utils/isTypedNode.js.map +1 -0
  300. package/lib/utils/isUnnecessaryReactCall.js +81 -0
  301. package/lib/utils/isUnnecessaryReactCall.js.map +1 -0
  302. package/lib/utils/peek.js +9 -0
  303. package/lib/utils/peek.js.map +1 -0
  304. package/lib/utils/processTemplateExpression.js +18 -0
  305. package/lib/utils/processTemplateExpression.js.map +1 -0
  306. package/lib/utils/removeDangerousCode.js +134 -0
  307. package/lib/utils/removeDangerousCode.js.map +1 -0
  308. package/lib/utils/scopeHelpers.js +544 -0
  309. package/lib/utils/scopeHelpers.js.map +1 -0
  310. package/lib/utils/traversalCache.js +38 -0
  311. package/lib/utils/traversalCache.js.map +1 -0
  312. package/lib/utils/unwrapSequence.js +20 -0
  313. package/lib/utils/unwrapSequence.js.map +1 -0
  314. package/lib/utils/valueToLiteral.js +65 -0
  315. package/lib/utils/valueToLiteral.js.map +1 -0
  316. package/lib/utils/visitors/JSXElementsRemover.js +57 -0
  317. package/lib/utils/visitors/JSXElementsRemover.js.map +1 -0
  318. package/lib/vm/createVmContext.js +80 -0
  319. package/lib/vm/createVmContext.js.map +1 -0
  320. package/lib/vm/process.js +38 -0
  321. package/lib/vm/process.js.map +1 -0
  322. package/package.json +63 -0
  323. package/types/babel.d.ts +2 -0
  324. package/types/babel.js +2 -0
  325. package/types/cache.d.ts +24 -0
  326. package/types/cache.js +85 -0
  327. package/types/debug/fileReporter.d.ts +27 -0
  328. package/types/debug/fileReporter.js +151 -0
  329. package/types/evaluators/index.d.ts +10 -0
  330. package/types/evaluators/index.js +15 -0
  331. package/types/index.d.ts +30 -0
  332. package/types/index.js +69 -0
  333. package/types/module.d.ts +62 -0
  334. package/types/module.js +318 -0
  335. package/types/options/buildOptions.d.ts +7 -0
  336. package/types/options/buildOptions.js +35 -0
  337. package/types/options/loadBabelOptions.d.ts +3 -0
  338. package/types/options/loadBabelOptions.js +27 -0
  339. package/types/plugins/babel-transform.d.ts +4 -0
  340. package/types/plugins/babel-transform.js +49 -0
  341. package/types/plugins/collector.d.ts +16 -0
  342. package/types/plugins/collector.js +67 -0
  343. package/types/plugins/dynamic-import.d.ts +6 -0
  344. package/types/plugins/dynamic-import.js +32 -0
  345. package/types/plugins/preeval.d.ts +16 -0
  346. package/types/plugins/preeval.js +69 -0
  347. package/types/plugins/shaker.d.ts +11 -0
  348. package/types/plugins/shaker.js +299 -0
  349. package/types/shaker.d.ts +3 -0
  350. package/types/shaker.js +64 -0
  351. package/types/transform/BaseEntrypoint.d.ts +23 -0
  352. package/types/transform/BaseEntrypoint.js +182 -0
  353. package/types/transform/Entrypoint.d.ts +50 -0
  354. package/types/transform/Entrypoint.helpers.d.ts +14 -0
  355. package/types/transform/Entrypoint.helpers.js +169 -0
  356. package/types/transform/Entrypoint.js +223 -0
  357. package/types/transform/Entrypoint.types.d.ts +23 -0
  358. package/types/transform/Entrypoint.types.js +2 -0
  359. package/types/transform/EvaluatedEntrypoint.d.ts +16 -0
  360. package/types/transform/EvaluatedEntrypoint.js +9 -0
  361. package/types/transform/actions/AbortError.d.ts +4 -0
  362. package/types/transform/actions/AbortError.js +12 -0
  363. package/types/transform/actions/BaseAction.d.ts +40 -0
  364. package/types/transform/actions/BaseAction.js +149 -0
  365. package/types/transform/actions/UnprocessedEntrypointError.d.ts +6 -0
  366. package/types/transform/actions/UnprocessedEntrypointError.js +13 -0
  367. package/types/transform/actions/actionRunner.d.ts +4 -0
  368. package/types/transform/actions/actionRunner.js +86 -0
  369. package/types/transform/actions/types.d.ts +15 -0
  370. package/types/transform/actions/types.js +2 -0
  371. package/types/transform/generators/baseProcessingHandlers.d.ts +17 -0
  372. package/types/transform/generators/baseProcessingHandlers.js +23 -0
  373. package/types/transform/generators/collect.d.ts +6 -0
  374. package/types/transform/generators/collect.js +57 -0
  375. package/types/transform/generators/evalFile.d.ts +6 -0
  376. package/types/transform/generators/evalFile.js +56 -0
  377. package/types/transform/generators/explodeReexports.d.ts +7 -0
  378. package/types/transform/generators/explodeReexports.js +67 -0
  379. package/types/transform/generators/extract.d.ts +8 -0
  380. package/types/transform/generators/extract.js +116 -0
  381. package/types/transform/generators/getExports.d.ts +8 -0
  382. package/types/transform/generators/getExports.js +65 -0
  383. package/types/transform/generators/index.d.ts +15 -0
  384. package/types/transform/generators/index.js +15 -0
  385. package/types/transform/generators/processEntrypoint.d.ts +9 -0
  386. package/types/transform/generators/processEntrypoint.js +88 -0
  387. package/types/transform/generators/processImports.d.ts +5 -0
  388. package/types/transform/generators/processImports.js +21 -0
  389. package/types/transform/generators/resolveImports.d.ts +9 -0
  390. package/types/transform/generators/resolveImports.js +124 -0
  391. package/types/transform/generators/transform.d.ts +17 -0
  392. package/types/transform/generators/transform.js +115 -0
  393. package/types/transform/generators/workflow.d.ts +7 -0
  394. package/types/transform/generators/workflow.js +77 -0
  395. package/types/transform/helpers/loadLinariaOptions.d.ts +6 -0
  396. package/types/transform/helpers/loadLinariaOptions.js +86 -0
  397. package/types/transform/helpers/withDefaultServices.d.ts +5 -0
  398. package/types/transform/helpers/withDefaultServices.js +40 -0
  399. package/types/transform/rootLog.d.ts +3 -0
  400. package/types/transform/rootLog.js +5 -0
  401. package/types/transform/types.d.ts +137 -0
  402. package/types/transform/types.js +4 -0
  403. package/types/transform.d.ts +20 -0
  404. package/types/transform.js +121 -0
  405. package/types/types.d.ts +72 -0
  406. package/types/types.js +5 -0
  407. package/types/utils/EventEmitter.d.ts +58 -0
  408. package/types/utils/EventEmitter.js +61 -0
  409. package/types/utils/ShakerMetadata.d.ts +7 -0
  410. package/types/utils/ShakerMetadata.js +5 -0
  411. package/types/utils/TransformMetadata.d.ts +13 -0
  412. package/types/utils/TransformMetadata.js +17 -0
  413. package/types/utils/addIdentifierToLinariaPreval.d.ts +4 -0
  414. package/types/utils/addIdentifierToLinariaPreval.js +75 -0
  415. package/types/utils/collectExportsAndImports.d.ts +31 -0
  416. package/types/utils/collectExportsAndImports.js +962 -0
  417. package/types/utils/collectTemplateDependencies.d.ts +17 -0
  418. package/types/utils/collectTemplateDependencies.js +212 -0
  419. package/types/utils/createId.d.ts +2 -0
  420. package/types/utils/createId.js +9 -0
  421. package/types/utils/dispose-polyfill.d.ts +0 -0
  422. package/types/utils/dispose-polyfill.js +5 -0
  423. package/types/utils/findIdentifiers.d.ts +6 -0
  424. package/types/utils/findIdentifiers.js +68 -0
  425. package/types/utils/findPackageJSON.d.ts +1 -0
  426. package/types/utils/findPackageJSON.js +29 -0
  427. package/types/utils/getFileIdx.d.ts +1 -0
  428. package/types/utils/getFileIdx.js +13 -0
  429. package/types/utils/getPluginKey.d.ts +2 -0
  430. package/types/utils/getPluginKey.js +16 -0
  431. package/types/utils/getScope.d.ts +2 -0
  432. package/types/utils/getScope.js +11 -0
  433. package/types/utils/getSource.d.ts +2 -0
  434. package/types/utils/getSource.js +22 -0
  435. package/types/utils/getTagProcessor.d.ts +6 -0
  436. package/types/utils/getTagProcessor.js +315 -0
  437. package/types/utils/getVisitorKeys.d.ts +5 -0
  438. package/types/utils/getVisitorKeys.js +8 -0
  439. package/types/utils/hasLinariaPreval.d.ts +4 -0
  440. package/types/utils/hasLinariaPreval.js +9 -0
  441. package/types/utils/isExports.d.ts +6 -0
  442. package/types/utils/isExports.js +20 -0
  443. package/types/utils/isGlobal.d.ts +2 -0
  444. package/types/utils/isGlobal.js +9 -0
  445. package/types/utils/isNode.d.ts +2 -0
  446. package/types/utils/isNode.js +7 -0
  447. package/types/utils/isNodePath.d.ts +3 -0
  448. package/types/utils/isNodePath.js +7 -0
  449. package/types/utils/isNotNull.d.ts +1 -0
  450. package/types/utils/isNotNull.js +7 -0
  451. package/types/utils/isRemoved.d.ts +5 -0
  452. package/types/utils/isRemoved.js +42 -0
  453. package/types/utils/isRequire.d.ts +6 -0
  454. package/types/utils/isRequire.js +15 -0
  455. package/types/utils/isSerializable.d.ts +2 -0
  456. package/types/utils/isSerializable.js +18 -0
  457. package/types/utils/isTypedNode.d.ts +5 -0
  458. package/types/utils/isTypedNode.js +9 -0
  459. package/types/utils/isUnnecessaryReactCall.d.ts +3 -0
  460. package/types/utils/isUnnecessaryReactCall.js +76 -0
  461. package/types/utils/peek.d.ts +1 -0
  462. package/types/utils/peek.js +5 -0
  463. package/types/utils/processTemplateExpression.d.ts +5 -0
  464. package/types/utils/processTemplateExpression.js +17 -0
  465. package/types/utils/removeDangerousCode.d.ts +3 -0
  466. package/types/utils/removeDangerousCode.js +144 -0
  467. package/types/utils/scopeHelpers.d.ts +12 -0
  468. package/types/utils/scopeHelpers.js +568 -0
  469. package/types/utils/traversalCache.d.ts +5 -0
  470. package/types/utils/traversalCache.js +36 -0
  471. package/types/utils/unwrapSequence.d.ts +8 -0
  472. package/types/utils/unwrapSequence.js +17 -0
  473. package/types/utils/valueToLiteral.d.ts +3 -0
  474. package/types/utils/valueToLiteral.js +64 -0
  475. package/types/utils/visitors/JSXElementsRemover.d.ts +3 -0
  476. package/types/utils/visitors/JSXElementsRemover.js +52 -0
  477. package/types/vm/createVmContext.d.ts +7 -0
  478. package/types/vm/createVmContext.js +92 -0
  479. package/types/vm/process.d.ts +25 -0
  480. package/types/vm/process.js +32 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.baseProcessingHandlers = void 0;
7
+ var _explodeReexports = require("./explodeReexports");
8
+ var _getExports = require("./getExports");
9
+ var _processEntrypoint = require("./processEntrypoint");
10
+ var _processImports = require("./processImports");
11
+ var _transform = require("./transform");
12
+ // eslint-disable-next-line require-yield
13
+ function* emptyHandler() {
14
+ throw new Error(`Handler for ${this.type} is not implemented`);
15
+ }
16
+ const baseProcessingHandlers = exports.baseProcessingHandlers = {
17
+ collect: emptyHandler,
18
+ evalFile: emptyHandler,
19
+ extract: emptyHandler,
20
+ workflow: emptyHandler,
21
+ explodeReexports: _explodeReexports.explodeReexports,
22
+ getExports: _getExports.getExports,
23
+ processEntrypoint: _processEntrypoint.processEntrypoint,
24
+ processImports: _processImports.processImports,
25
+ transform: _transform.transform
26
+ };
27
+ //# sourceMappingURL=baseProcessingHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseProcessingHandlers.js","names":["_explodeReexports","require","_getExports","_processEntrypoint","_processImports","_transform","emptyHandler","Error","type","baseProcessingHandlers","exports","collect","evalFile","extract","workflow","explodeReexports","getExports","processEntrypoint","processImports","transform"],"sources":["../../../src/transform/generators/baseProcessingHandlers.ts"],"sourcesContent":["import type {\n SyncScenarioForAction,\n ICollectAction,\n IEvalAction,\n IExtractAction,\n IWorkflowAction,\n ActionQueueItem,\n} from '../types';\n\nimport { explodeReexports } from './explodeReexports';\nimport { getExports } from './getExports';\nimport { processEntrypoint } from './processEntrypoint';\nimport { processImports } from './processImports';\nimport { transform } from './transform';\n\n// eslint-disable-next-line require-yield\nfunction* emptyHandler<T extends ActionQueueItem>(\n this: T\n): SyncScenarioForAction<T> {\n throw new Error(`Handler for ${this.type} is not implemented`);\n}\n\nexport const baseProcessingHandlers = {\n collect: emptyHandler<ICollectAction>,\n evalFile: emptyHandler<IEvalAction>,\n extract: emptyHandler<IExtractAction>,\n workflow: emptyHandler<IWorkflowAction>,\n explodeReexports,\n getExports,\n processEntrypoint,\n processImports,\n transform,\n};\n"],"mappings":";;;;;;AASA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA;AACA,UAAUK,YAAYA,CAAA,EAEM;EAC1B,MAAM,IAAIC,KAAK,CAAE,eAAc,IAAI,CAACC,IAAK,qBAAoB,CAAC;AAChE;AAEO,MAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG;EACpCE,OAAO,EAAEL,YAA4B;EACrCM,QAAQ,EAAEN,YAAyB;EACnCO,OAAO,EAAEP,YAA4B;EACrCQ,QAAQ,EAAER,YAA6B;EACvCS,gBAAgB,EAAhBA,kCAAgB;EAChBC,UAAU,EAAVA,sBAAU;EACVC,iBAAiB,EAAjBA,oCAAiB;EACjBC,cAAc,EAAdA,8BAAc;EACdC,SAAS,EAATA;AACF,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collect = collect;
7
+ var _buildOptions = require("../../options/buildOptions");
8
+ var _collector = require("../../plugins/collector");
9
+ var _TransformMetadata = require("../../utils/TransformMetadata");
10
+ /**
11
+ * Parses the specified file, finds tags, applies run-time replacements,
12
+ * removes dead code.
13
+ */
14
+ // eslint-disable-next-line require-yield
15
+ function* collect() {
16
+ var _result$ast;
17
+ const {
18
+ babel,
19
+ options
20
+ } = this.services;
21
+ const {
22
+ valueCache
23
+ } = this.data;
24
+ const {
25
+ entrypoint
26
+ } = this;
27
+ const {
28
+ loadedAndParsed,
29
+ name
30
+ } = entrypoint;
31
+ if (loadedAndParsed.evaluator === 'ignored') {
32
+ throw new Error('entrypoint was ignored');
33
+ }
34
+ const transformPlugins = [[_collector.filename, {
35
+ ...options.pluginOptions,
36
+ values: valueCache
37
+ }]];
38
+ const transformConfig = (0, _buildOptions.buildOptions)({
39
+ envName: 'linaria',
40
+ plugins: transformPlugins,
41
+ sourceMaps: true,
42
+ sourceFileName: name,
43
+ inputSourceMap: options.inputSourceMap,
44
+ root: options.root,
45
+ ast: true,
46
+ babelrc: false,
47
+ configFile: false,
48
+ sourceType: 'unambiguous'
49
+ });
50
+ const result = babel.transformFromAstSync(loadedAndParsed.ast, loadedAndParsed.code, {
51
+ ...transformConfig,
52
+ cwd: options.root,
53
+ filename: name
54
+ });
55
+ if (!result || !((_result$ast = result.ast) !== null && _result$ast !== void 0 && _result$ast.program)) {
56
+ throw new Error('Babel transform failed');
57
+ }
58
+ const transformMetadata = (0, _TransformMetadata.getTransformMetadata)(result.metadata);
59
+ return {
60
+ ast: result.ast,
61
+ code: result.code,
62
+ map: result.map,
63
+ metadata: transformMetadata !== null && transformMetadata !== void 0 ? transformMetadata : null
64
+ };
65
+ }
66
+ //# sourceMappingURL=collect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect.js","names":["_buildOptions","require","_collector","_TransformMetadata","collect","_result$ast","babel","options","services","valueCache","data","entrypoint","loadedAndParsed","name","evaluator","Error","transformPlugins","collectorPlugin","pluginOptions","values","transformConfig","buildOptions","envName","plugins","sourceMaps","sourceFileName","inputSourceMap","root","ast","babelrc","configFile","sourceType","result","transformFromAstSync","code","cwd","filename","program","transformMetadata","getTransformMetadata","metadata","map"],"sources":["../../../src/transform/generators/collect.ts"],"sourcesContent":["import type { PluginItem } from '@babel/core';\n\nimport { buildOptions } from '../../options/buildOptions';\nimport { filename as collectorPlugin } from '../../plugins/collector';\nimport { getTransformMetadata } from '../../utils/TransformMetadata';\nimport type { ICollectAction, SyncScenarioForAction } from '../types';\n\n/**\n * Parses the specified file, finds tags, applies run-time replacements,\n * removes dead code.\n */\n// eslint-disable-next-line require-yield\nexport function* collect(\n this: ICollectAction\n): SyncScenarioForAction<ICollectAction> {\n const { babel, options } = this.services;\n const { valueCache } = this.data;\n const { entrypoint } = this;\n const { loadedAndParsed, name } = entrypoint;\n\n if (loadedAndParsed.evaluator === 'ignored') {\n throw new Error('entrypoint was ignored');\n }\n\n const transformPlugins: PluginItem[] = [\n [\n collectorPlugin,\n {\n ...options.pluginOptions,\n values: valueCache,\n },\n ],\n ];\n\n const transformConfig = buildOptions({\n envName: 'linaria',\n plugins: transformPlugins,\n sourceMaps: true,\n sourceFileName: name,\n inputSourceMap: options.inputSourceMap,\n root: options.root,\n ast: true,\n babelrc: false,\n configFile: false,\n sourceType: 'unambiguous',\n });\n\n const result = babel.transformFromAstSync(\n loadedAndParsed.ast,\n loadedAndParsed.code,\n {\n ...transformConfig,\n cwd: options.root,\n filename: name,\n }\n );\n\n if (!result || !result.ast?.program) {\n throw new Error('Babel transform failed');\n }\n\n const transformMetadata = getTransformMetadata(result.metadata);\n\n return {\n ast: result.ast,\n code: result.code,\n map: result.map,\n metadata: transformMetadata ?? null,\n };\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACO,UAAUG,OAAOA,CAAA,EAEiB;EAAA,IAAAC,WAAA;EACvC,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAG,IAAI,CAACC,QAAQ;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAI,CAACC,IAAI;EAChC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAI;EAC3B,MAAM;IAAEC,eAAe;IAAEC;EAAK,CAAC,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iB,GAAI;EACjC,CAAC;AACH"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.evalFile = evalFile;
7
+ var _evaluators = _interopRequireDefault(require("../../evaluators"));
8
+ var _hasLinariaPreval = _interopRequireDefault(require("../../utils/hasLinariaPreval"));
9
+ var _UnprocessedEntrypointError = require("../actions/UnprocessedEntrypointError");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const wrap = fn => {
12
+ try {
13
+ return fn();
14
+ } catch (e) {
15
+ return e;
16
+ }
17
+ };
18
+
19
+ /**
20
+ * Executes the code prepared in previous steps within the current `Entrypoint`.
21
+ * Returns all exports that were requested in `only`.
22
+ */
23
+ // eslint-disable-next-line require-yield
24
+ function* evalFile() {
25
+ const {
26
+ entrypoint
27
+ } = this;
28
+ const {
29
+ log
30
+ } = entrypoint;
31
+ log(`>> evaluate __linariaPreval`);
32
+ let evaluated;
33
+ while (evaluated === undefined) {
34
+ try {
35
+ evaluated = (0, _evaluators.default)(this.services, entrypoint);
36
+ } catch (e) {
37
+ if ((0, _UnprocessedEntrypointError.isUnprocessedEntrypointError)(e)) {
38
+ entrypoint.log('Evaluation has been aborted because one if the required files is not processed. Schedule reprocessing and repeat evaluation.');
39
+ yield ['processEntrypoint', e.entrypoint, undefined];
40
+ } else {
41
+ throw e;
42
+ }
43
+ }
44
+ }
45
+ const linariaPreval = (0, _hasLinariaPreval.default)(evaluated.value) ? evaluated.value.__linariaPreval : undefined;
46
+ if (!linariaPreval) {
47
+ return null;
48
+ }
49
+ const valueCache = new Map();
50
+ Object.entries(linariaPreval).forEach(([key, lazyValue]) => {
51
+ const value = wrap(lazyValue);
52
+ valueCache.set(key, value);
53
+ });
54
+ log(`<< evaluated __linariaPreval %O`, valueCache);
55
+ return [valueCache, evaluated.dependencies];
56
+ }
57
+ //# sourceMappingURL=evalFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evalFile.js","names":["_evaluators","_interopRequireDefault","require","_hasLinariaPreval","_UnprocessedEntrypointError","obj","__esModule","default","wrap","fn","e","evalFile","entrypoint","log","evaluated","undefined","evaluate","services","isUnprocessedEntrypointError","linariaPreval","hasLinariaPreval","value","__linariaPreval","valueCache","Map","Object","entries","forEach","key","lazyValue","set","dependencies"],"sources":["../../../src/transform/generators/evalFile.ts"],"sourcesContent":["import type { ValueCache } from '@wyw-in-js/processor-utils';\n\nimport type { IEvaluateResult } from '../../evaluators';\nimport evaluate from '../../evaluators';\nimport hasLinariaPreval from '../../utils/hasLinariaPreval';\nimport { isUnprocessedEntrypointError } from '../actions/UnprocessedEntrypointError';\nimport type { IEvalAction, SyncScenarioForAction } from '../types';\n\nconst wrap = <T>(fn: () => T): T | Error => {\n try {\n return fn();\n } catch (e) {\n return e as Error;\n }\n};\n\n/**\n * Executes the code prepared in previous steps within the current `Entrypoint`.\n * Returns all exports that were requested in `only`.\n */\n// eslint-disable-next-line require-yield\nexport function* evalFile(\n this: IEvalAction\n): SyncScenarioForAction<IEvalAction> {\n const { entrypoint } = this;\n const { log } = entrypoint;\n\n log(`>> evaluate __linariaPreval`);\n\n let evaluated: IEvaluateResult | undefined;\n\n while (evaluated === undefined) {\n try {\n evaluated = evaluate(this.services, entrypoint);\n } catch (e) {\n if (isUnprocessedEntrypointError(e)) {\n entrypoint.log(\n 'Evaluation has been aborted because one if the required files is not processed. Schedule reprocessing and repeat evaluation.'\n );\n yield ['processEntrypoint', e.entrypoint, undefined];\n } else {\n throw e;\n }\n }\n }\n\n const linariaPreval = hasLinariaPreval(evaluated.value)\n ? evaluated.value.__linariaPreval\n : undefined;\n\n if (!linariaPreval) {\n return null;\n }\n\n const valueCache: ValueCache = new Map();\n Object.entries(linariaPreval).forEach(([key, lazyValue]) => {\n const value = wrap(lazyValue);\n valueCache.set(key, value);\n });\n\n log(`<< evaluated __linariaPreval %O`, valueCache);\n\n return [valueCache, evaluated.dependencies];\n}\n"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,OAAO,CAACP,aAAa,CAAC,CAACQ,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,SAAS,CAAC,KAAK;IAC1D,MAAMR,KAAK,GAAGb,IAAI,CAACqB,SAAS,CAAC;IAC7BN,UAAU,CAACO,GAAG,CAACF,GAAG,EAAEP,KAAK,CAAC;EAC5B,CAAC,CAAC;EAEFR,GAAG,CAAE,iCAAgC,EAAEU,UAAU,CAAC;EAElD,OAAO,CAACA,UAAU,EAAET,SAAS,CAACiB,YAAY,CAAC;AAC7C"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.explodeReexports = explodeReexports;
7
+ var _generator = _interopRequireDefault(require("@babel/generator"));
8
+ var _getExports = require("./getExports");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const getWildcardReexport = (babel, ast) => {
11
+ const reexportsFrom = [];
12
+ ast.program.body.forEach(node => {
13
+ if (babel.types.isExportAllDeclaration(node) && node.source && babel.types.isStringLiteral(node.source)) {
14
+ reexportsFrom.push({
15
+ source: node.source.value,
16
+ node
17
+ });
18
+ }
19
+ });
20
+ return reexportsFrom;
21
+ };
22
+
23
+ /**
24
+ * Replaces wildcard reexports with named reexports.
25
+ * Recursively emits getExports for each reexported module,
26
+ * and replaces wildcard with resolved named.
27
+ */
28
+ function* explodeReexports() {
29
+ const {
30
+ babel
31
+ } = this.services;
32
+ const {
33
+ log,
34
+ loadedAndParsed
35
+ } = this.entrypoint;
36
+ if (loadedAndParsed.evaluator === 'ignored') {
37
+ return;
38
+ }
39
+ const reexportsFrom = getWildcardReexport(babel, loadedAndParsed.ast);
40
+ if (!reexportsFrom.length) {
41
+ return;
42
+ }
43
+ log('has wildcard reexport from %o', reexportsFrom);
44
+ const resolvedImports = yield* this.getNext('resolveImports', this.entrypoint, {
45
+ imports: new Map(reexportsFrom.map(i => [i.source, []]))
46
+ });
47
+ const importedEntrypoints = (0, _getExports.findExportsInImports)(this.entrypoint, resolvedImports);
48
+ const replacements = new Map();
49
+ for (const importedEntrypoint of importedEntrypoints) {
50
+ const exports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
51
+ const reexport = reexportsFrom.find(i => i.source === importedEntrypoint.import);
52
+ if (reexport) {
53
+ replacements.set(reexport.node, exports.length ? babel.types.exportNamedDeclaration(null, exports.map(i => babel.types.exportSpecifier(babel.types.identifier(i), babel.types.identifier(i))), babel.types.stringLiteral(importedEntrypoint.import)) : null);
54
+ }
55
+ }
56
+
57
+ // Replace wildcard reexport with named reexports
58
+ babel.traverse(loadedAndParsed.ast, {
59
+ ExportAllDeclaration(path) {
60
+ const replacement = replacements.get(path.node);
61
+ if (replacement) {
62
+ path.replaceWith(replacement);
63
+ } else {
64
+ path.remove();
65
+ }
66
+ }
67
+ });
68
+ loadedAndParsed.code = (0, _generator.default)(loadedAndParsed.ast).code;
69
+ }
70
+ //# sourceMappingURL=explodeReexports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explodeReexports.js","names":["_generator","_interopRequireDefault","require","_getExports","obj","__esModule","default","getWildcardReexport","babel","ast","reexportsFrom","program","body","forEach","node","types","isExportAllDeclaration","source","isStringLiteral","push","value","explodeReexports","services","log","loadedAndParsed","entrypoint","evaluator","length","resolvedImports","getNext","imports","Map","map","i","importedEntrypoints","findExportsInImports","replacements","importedEntrypoint","exports","undefined","reexport","find","import","set","exportNamedDeclaration","exportSpecifier","identifier","stringLiteral","traverse","ExportAllDeclaration","path","replacement","get","replaceWith","remove","code","generate"],"sources":["../../../src/transform/generators/explodeReexports.ts"],"sourcesContent":["import generate from '@babel/generator';\nimport type { ExportAllDeclaration, File, Node } from '@babel/types';\n\nimport type { Core } from '../../babel';\nimport type { IExplodeReexportsAction, SyncScenarioForAction } from '../types';\n\nimport { findExportsInImports } from './getExports';\n\nconst getWildcardReexport = (babel: Core, ast: File) => {\n const reexportsFrom: { node: ExportAllDeclaration; source: string }[] = [];\n ast.program.body.forEach((node) => {\n if (\n babel.types.isExportAllDeclaration(node) &&\n node.source &&\n babel.types.isStringLiteral(node.source)\n ) {\n reexportsFrom.push({\n source: node.source.value,\n node,\n });\n }\n });\n\n return reexportsFrom;\n};\n\n/**\n * Replaces wildcard reexports with named reexports.\n * Recursively emits getExports for each reexported module,\n * and replaces wildcard with resolved named.\n */\nexport function* explodeReexports(\n this: IExplodeReexportsAction\n): SyncScenarioForAction<IExplodeReexportsAction> {\n const { babel } = this.services;\n const { log, loadedAndParsed } = this.entrypoint;\n if (loadedAndParsed.evaluator === 'ignored') {\n return;\n }\n\n const reexportsFrom = getWildcardReexport(babel, loadedAndParsed.ast);\n if (!reexportsFrom.length) {\n return;\n }\n\n log('has wildcard reexport from %o', reexportsFrom);\n\n const resolvedImports = yield* this.getNext(\n 'resolveImports',\n this.entrypoint,\n {\n imports: new Map(reexportsFrom.map((i) => [i.source, []])),\n }\n );\n\n const importedEntrypoints = findExportsInImports(\n this.entrypoint,\n resolvedImports\n );\n\n const replacements = new Map<ExportAllDeclaration, Node | null>();\n for (const importedEntrypoint of importedEntrypoints) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n const reexport = reexportsFrom.find(\n (i) => i.source === importedEntrypoint.import\n );\n if (reexport) {\n replacements.set(\n reexport.node,\n exports.length\n ? babel.types.exportNamedDeclaration(\n null,\n exports.map((i) =>\n babel.types.exportSpecifier(\n babel.types.identifier(i),\n babel.types.identifier(i)\n )\n ),\n babel.types.stringLiteral(importedEntrypoint.import)\n )\n : null\n );\n }\n }\n\n // Replace wildcard reexport with named reexports\n babel.traverse(loadedAndParsed.ast, {\n ExportAllDeclaration(path) {\n const replacement = replacements.get(path.node);\n if (replacement) {\n path.replaceWith(replacement);\n } else {\n path.remove();\n }\n },\n });\n\n loadedAndParsed.code = generate(loadedAndParsed.ast).code;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,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;QACLD,IAAI,CAACI,MAAM,CAAC,CAAC;MACf;IACF;EACF,CAAC,CAAC;EAEF9B,eAAe,CAAC+B,IAAI,GAAG,IAAAC,kBAAQ,EAAChC,eAAe,CAACf,GAAG,CAAC,CAAC8C,IAAI;AAC3D"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extract = extract;
7
+ exports.transformUrl = transformUrl;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _sourceMap = require("source-map");
10
+ var _stylis = _interopRequireDefault(require("stylis"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const STYLIS_DECLARATION = 1;
13
+ const posixSep = _path.default.posix.sep;
14
+ function transformUrl(url, outputFilename, sourceFilename, platformPath = _path.default) {
15
+ // Replace asset path with new path relative to the output CSS
16
+ const relative = platformPath.relative(platformPath.dirname(outputFilename),
17
+ // Get the absolute path to the asset from the path relative to the JS file
18
+ platformPath.resolve(platformPath.dirname(sourceFilename), url));
19
+ if (platformPath.sep === posixSep) {
20
+ return relative;
21
+ }
22
+ return relative.split(platformPath.sep).join(posixSep);
23
+ }
24
+ function extractCssFromAst(rules, originalCode, options) {
25
+ const mappings = [];
26
+ let cssText = '';
27
+ let preprocessor;
28
+ if (typeof options.preprocessor === 'function') {
29
+ // eslint-disable-next-line prefer-destructuring
30
+ preprocessor = options.preprocessor;
31
+ } else {
32
+ switch (options.preprocessor) {
33
+ case 'none':
34
+ preprocessor = (selector, text) => `${selector} {${text}}\n`;
35
+ break;
36
+ case 'stylis':
37
+ default:
38
+ _stylis.default.use(null)((context, decl) => {
39
+ const {
40
+ outputFilename
41
+ } = options;
42
+ if (context === STYLIS_DECLARATION && outputFilename) {
43
+ // When writing to a file, we need to adjust the relative paths inside url(..) expressions
44
+ // It'll allow css-loader to resolve an imported asset properly
45
+ return decl.replace(/\b(url\((["']?))(\.[^)]+?)(\2\))/g, (match, p1, p2, p3, p4) => p1 + transformUrl(p3, outputFilename, options.filename) + p4);
46
+ }
47
+ return decl;
48
+ });
49
+ preprocessor = _stylis.default;
50
+ }
51
+ }
52
+ Object.keys(rules).forEach((selector, index) => {
53
+ mappings.push({
54
+ generated: {
55
+ line: index + 1,
56
+ column: 0
57
+ },
58
+ original: rules[selector].start,
59
+ name: selector,
60
+ source: ''
61
+ });
62
+ if (rules[selector].atom) {
63
+ // For atoms, we just directly insert cssText, to give the atomizer full control over the rules
64
+ cssText += `${rules[selector].cssText}\n`;
65
+ } else {
66
+ // Run each rule through stylis to support nesting
67
+ cssText += `${preprocessor(selector, rules[selector].cssText)}\n`;
68
+ }
69
+ });
70
+ return {
71
+ cssText,
72
+ rules,
73
+ get cssSourceMapText() {
74
+ if (mappings !== null && mappings !== void 0 && mappings.length) {
75
+ const generator = new _sourceMap.SourceMapGenerator({
76
+ file: options.filename.replace(/\.js$/, '.css')
77
+ });
78
+ mappings.forEach(mapping => generator.addMapping({
79
+ ...mapping,
80
+ source: options.filename
81
+ }));
82
+ generator.setSourceContent(options.filename, originalCode);
83
+ return generator.toString();
84
+ }
85
+ return '';
86
+ }
87
+ };
88
+ }
89
+
90
+ /**
91
+ * Extract artifacts (e.g. CSS) from processors
92
+ */
93
+ // eslint-disable-next-line require-yield
94
+ function* extract() {
95
+ const {
96
+ options
97
+ } = this.services;
98
+ const {
99
+ entrypoint
100
+ } = this;
101
+ const {
102
+ processors
103
+ } = this.data;
104
+ const {
105
+ loadedAndParsed
106
+ } = entrypoint;
107
+ if (loadedAndParsed.evaluator === 'ignored') {
108
+ throw new Error('entrypoint was ignored');
109
+ }
110
+ let allRules = {};
111
+ const allReplacements = [];
112
+ processors.forEach(processor => {
113
+ processor.artifacts.forEach(artifact => {
114
+ if (artifact[0] !== 'css') return;
115
+ const [rules, replacements] = artifact[1];
116
+ allRules = {
117
+ ...allRules,
118
+ ...rules
119
+ };
120
+ allReplacements.push(...replacements);
121
+ });
122
+ });
123
+ return {
124
+ ...extractCssFromAst(allRules, loadedAndParsed.code, options),
125
+ replacements: allReplacements
126
+ };
127
+ }
128
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.js","names":["_path","_interopRequireDefault","require","_sourceMap","_stylis","obj","__esModule","default","STYLIS_DECLARATION","posixSep","path","posix","sep","transformUrl","url","outputFilename","sourceFilename","platformPath","relative","dirname","resolve","split","join","extractCssFromAst","rules","originalCode","options","mappings","cssText","preprocessor","selector","text","stylis","use","context","decl","replace","match","p1","p2","p3","p4","filename","Object","keys","forEach","index","push","generated","line","column","original","start","name","source","atom","cssSourceMapText","length","generator","SourceMapGenerator","file","mapping","addMapping","setSourceContent","toString","extract","services","entrypoint","processors","data","loadedAndParsed","evaluator","Error","allRules","allReplacements","processor","artifacts","artifact","replacements","code"],"sources":["../../../src/transform/generators/extract.ts"],"sourcesContent":["import path from 'path';\n\nimport type { Mapping } from 'source-map';\nimport { SourceMapGenerator } from 'source-map';\nimport stylis from 'stylis';\n\nimport type { Replacements, Rules } from '@wyw-in-js/shared';\n\nimport type { Options, PreprocessorFn } from '../../types';\nimport type { IExtractAction, SyncScenarioForAction } from '../types';\n\nconst STYLIS_DECLARATION = 1;\nconst posixSep = path.posix.sep;\n\nexport function transformUrl(\n url: string,\n outputFilename: string,\n sourceFilename: string,\n platformPath: typeof path = path\n) {\n // Replace asset path with new path relative to the output CSS\n const relative = platformPath.relative(\n platformPath.dirname(outputFilename),\n // Get the absolute path to the asset from the path relative to the JS file\n platformPath.resolve(platformPath.dirname(sourceFilename), url)\n );\n\n if (platformPath.sep === posixSep) {\n return relative;\n }\n\n return relative.split(platformPath.sep).join(posixSep);\n}\n\nfunction extractCssFromAst(\n rules: Rules,\n originalCode: string,\n options: Pick<Options, 'preprocessor' | 'filename' | 'outputFilename'>\n): { cssSourceMapText: string; cssText: string; rules: Rules } {\n const mappings: Mapping[] = [];\n\n let cssText = '';\n\n let preprocessor: PreprocessorFn;\n if (typeof options.preprocessor === 'function') {\n // eslint-disable-next-line prefer-destructuring\n preprocessor = options.preprocessor;\n } else {\n switch (options.preprocessor) {\n case 'none':\n preprocessor = (selector, text) => `${selector} {${text}}\\n`;\n break;\n case 'stylis':\n default:\n stylis.use(null)((context, decl) => {\n const { outputFilename } = options;\n if (context === STYLIS_DECLARATION && outputFilename) {\n // When writing to a file, we need to adjust the relative paths inside url(..) expressions\n // It'll allow css-loader to resolve an imported asset properly\n return decl.replace(\n /\\b(url\\(([\"']?))(\\.[^)]+?)(\\2\\))/g,\n (match, p1, p2, p3, p4) =>\n p1 + transformUrl(p3, outputFilename, options.filename) + p4\n );\n }\n\n return decl;\n });\n\n preprocessor = stylis;\n }\n }\n\n Object.keys(rules).forEach((selector, index) => {\n mappings.push({\n generated: {\n line: index + 1,\n column: 0,\n },\n original: rules[selector].start!,\n name: selector,\n source: '',\n });\n\n if (rules[selector].atom) {\n // For atoms, we just directly insert cssText, to give the atomizer full control over the rules\n cssText += `${rules[selector].cssText}\\n`;\n } else {\n // Run each rule through stylis to support nesting\n cssText += `${preprocessor(selector, rules[selector].cssText)}\\n`;\n }\n });\n\n return {\n cssText,\n rules,\n\n get cssSourceMapText() {\n if (mappings?.length) {\n const generator = new SourceMapGenerator({\n file: options.filename.replace(/\\.js$/, '.css'),\n });\n\n mappings.forEach((mapping) =>\n generator.addMapping({ ...mapping, source: options.filename })\n );\n\n generator.setSourceContent(options.filename, originalCode);\n\n return generator.toString();\n }\n\n return '';\n },\n };\n}\n\n/**\n * Extract artifacts (e.g. CSS) from processors\n */\n// eslint-disable-next-line require-yield\nexport function* extract(\n this: IExtractAction\n): SyncScenarioForAction<IExtractAction> {\n const { options } = this.services;\n const { entrypoint } = this;\n const { processors } = this.data;\n const { loadedAndParsed } = entrypoint;\n if (loadedAndParsed.evaluator === 'ignored') {\n throw new Error('entrypoint was ignored');\n }\n\n let allRules: Rules = {};\n const allReplacements: Replacements = [];\n processors.forEach((processor) => {\n processor.artifacts.forEach((artifact) => {\n if (artifact[0] !== 'css') return;\n const [rules, replacements] = artifact[1] as [\n rules: Rules,\n sourceMapReplacements: Replacements,\n ];\n\n allRules = {\n ...allRules,\n ...rules,\n };\n\n allReplacements.push(...replacements);\n });\n });\n\n return {\n ...extractCssFromAst(allRules, loadedAndParsed.code, options),\n replacements: allReplacements,\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA4B,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAO5B,MAAMG,kBAAkB,GAAG,CAAC;AAC5B,MAAMC,QAAQ,GAAGC,aAAI,CAACC,KAAK,CAACC,GAAG;AAExB,SAASC,YAAYA,CAC1BC,GAAW,EACXC,cAAsB,EACtBC,cAAsB,EACtBC,YAAyB,GAAGP,aAAI,EAChC;EACA;EACA,MAAMQ,QAAQ,GAAGD,YAAY,CAACC,QAAQ,CACpCD,YAAY,CAACE,OAAO,CAACJ,cAAc,CAAC;EACpC;EACAE,YAAY,CAACG,OAAO,CAACH,YAAY,CAACE,OAAO,CAACH,cAAc,CAAC,EAAEF,GAAG,CAChE,CAAC;EAED,IAAIG,YAAY,CAACL,GAAG,KAAKH,QAAQ,EAAE;IACjC,OAAOS,QAAQ;EACjB;EAEA,OAAOA,QAAQ,CAACG,KAAK,CAACJ,YAAY,CAACL,GAAG,CAAC,CAACU,IAAI,CAACb,QAAQ,CAAC;AACxD;AAEA,SAASc,iBAAiBA,CACxBC,KAAY,EACZC,YAAoB,EACpBC,OAAsE,EACT;EAC7D,MAAMC,QAAmB,GAAG,EAAE;EAE9B,IAAIC,OAAO,GAAG,EAAE;EAEhB,IAAIC,YAA4B;EAChC,IAAI,OAAOH,OAAO,CAACG,YAAY,KAAK,UAAU,EAAE;I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C/B,OAAO,CAAEgC,QAAQ,IAAK;MACxC,IAAIA,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;MAC3B,MAAM,CAACrD,KAAK,EAAEsD,YAAY,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAGvC;MAEDJ,QAAQ,GAAG;QACT,GAAGA,QAAQ;QACX,GAAGjD;MACL,CAAC;MAEDkD,eAAe,CAAC3B,IAAI,CAAC,GAAG+B,YAAY,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACL,GAAGvD,iBAAiB,CAACkD,QAAQ,EAAEH,eAAe,CAACS,IAAI,EAAErD,OAAO,CAAC;IAC7DoD,YAAY,EAAEJ;EAChB,CAAC;AACH"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findExportsInImports = findExportsInImports;
7
+ exports.getExports = getExports;
8
+ var _collectExportsAndImports = require("../../utils/collectExportsAndImports");
9
+ function findExportsInImports(entrypoint, imports) {
10
+ const results = [];
11
+ for (const imp of imports) {
12
+ const {
13
+ resolved
14
+ } = imp;
15
+ if (!resolved) {
16
+ throw new Error(`Could not resolve import ${imp.source}`);
17
+ }
18
+ const newEntrypoint = entrypoint.createChild(resolved, []);
19
+ if (newEntrypoint === 'loop') {
20
+ // eslint-disable-next-line no-continue
21
+ continue;
22
+ }
23
+ results.push({
24
+ entrypoint: newEntrypoint,
25
+ import: imp.source
26
+ });
27
+ }
28
+ return results;
29
+ }
30
+ function* getExports() {
31
+ const {
32
+ entrypoint,
33
+ services: {
34
+ cache
35
+ }
36
+ } = this;
37
+ const {
38
+ loadedAndParsed
39
+ } = entrypoint;
40
+ if (loadedAndParsed.ast === undefined) {
41
+ return [];
42
+ }
43
+ entrypoint.log(`get exports from %s`, entrypoint.name);
44
+ if (cache.has('exports', entrypoint.name)) {
45
+ return cache.get('exports', entrypoint.name);
46
+ }
47
+ let withWildcardReexport = [];
48
+ const result = [];
49
+ this.services.babel.traverse(loadedAndParsed.ast, {
50
+ Program(path) {
51
+ const {
52
+ exports,
53
+ reexports
54
+ } = (0, _collectExportsAndImports.collectExportsAndImports)(path, 'disabled');
55
+ Object.keys(exports).forEach(token => {
56
+ result.push(token);
57
+ });
58
+ reexports.forEach(e => {
59
+ if (e.exported !== '*') {
60
+ result.push(e.exported);
61
+ }
62
+ });
63
+ withWildcardReexport = reexports.filter(e => e.exported === '*');
64
+ }
65
+ });
66
+ if (withWildcardReexport.length) {
67
+ const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {
68
+ imports: new Map(withWildcardReexport.map(i => [i.source, []]))
69
+ });
70
+ const importedEntrypoints = findExportsInImports(entrypoint, resolvedImports);
71
+ for (const importedEntrypoint of importedEntrypoints) {
72
+ const exports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
73
+ result.push(...exports);
74
+ }
75
+ }
76
+ entrypoint.log(`exports: %o`, result);
77
+ cache.add('exports', entrypoint.name, result);
78
+ return result;
79
+ }
80
+ //# sourceMappingURL=getExports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getExports.js","names":["_collectExportsAndImports","require","findExportsInImports","entrypoint","imports","results","imp","resolved","Error","source","newEntrypoint","createChild","push","import","getExports","services","cache","loadedAndParsed","ast","undefined","log","name","has","get","withWildcardReexport","result","babel","traverse","Program","path","exports","reexports","collectExportsAndImports","Object","keys","forEach","token","e","exported","filter","length","resolvedImports","getNext","Map","map","i","importedEntrypoints","importedEntrypoint","add"],"sources":["../../../src/transform/generators/getExports.ts"],"sourcesContent":["import type { IReexport } from '../../utils/collectExportsAndImports';\nimport { collectExportsAndImports } from '../../utils/collectExportsAndImports';\nimport type { Entrypoint } from '../Entrypoint';\nimport type { IEntrypointDependency } from '../Entrypoint.types';\nimport type { IGetExportsAction, SyncScenarioForAction } from '../types';\n\nexport function findExportsInImports(\n entrypoint: Entrypoint,\n imports: IEntrypointDependency[]\n): { entrypoint: Entrypoint; import: string }[] {\n const results: {\n entrypoint: Entrypoint;\n import: string;\n }[] = [];\n\n for (const imp of imports) {\n const { resolved } = imp;\n if (!resolved) {\n throw new Error(`Could not resolve import ${imp.source}`);\n }\n\n const newEntrypoint = entrypoint.createChild(resolved, []);\n\n if (newEntrypoint === 'loop') {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n results.push({\n entrypoint: newEntrypoint,\n import: imp.source,\n });\n }\n\n return results;\n}\n\nexport function* getExports(\n this: IGetExportsAction\n): SyncScenarioForAction<IGetExportsAction> {\n const {\n entrypoint,\n services: { cache },\n } = this;\n const { loadedAndParsed } = entrypoint;\n if (loadedAndParsed.ast === undefined) {\n return [];\n }\n\n entrypoint.log(`get exports from %s`, entrypoint.name);\n\n if (cache.has('exports', entrypoint.name)) {\n return cache.get('exports', entrypoint.name)!;\n }\n\n let withWildcardReexport: IReexport[] = [];\n const result: string[] = [];\n\n this.services.babel.traverse(loadedAndParsed.ast!, {\n Program(path) {\n const { exports, reexports } = collectExportsAndImports(path, 'disabled');\n Object.keys(exports).forEach((token) => {\n result.push(token);\n });\n\n reexports.forEach((e) => {\n if (e.exported !== '*') {\n result.push(e.exported);\n }\n });\n\n withWildcardReexport = reexports.filter((e) => e.exported === '*');\n },\n });\n\n if (withWildcardReexport.length) {\n const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {\n imports: new Map(withWildcardReexport.map((i) => [i.source, []])),\n });\n\n const importedEntrypoints = findExportsInImports(\n entrypoint,\n resolvedImports\n );\n\n for (const importedEntrypoint of importedEntrypoints) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n result.push(...exports);\n }\n }\n\n entrypoint.log(`exports: %o`, result);\n\n cache.add('exports', entrypoint.name, result);\n\n return result;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,yBAAA,GAAAC,OAAA;AAKO,SAASC,oBAAoBA,CAClCC,UAAsB,EACtBC,OAAgC,EACc;EAC9C,MAAMC,OAGH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(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.baseHandlers = void 0;
7
+ var _baseProcessingHandlers = require("./baseProcessingHandlers");
8
+ var _collect = require("./collect");
9
+ var _evalFile = require("./evalFile");
10
+ var _extract = require("./extract");
11
+ var _workflow = require("./workflow");
12
+ const baseHandlers = exports.baseHandlers = {
13
+ ..._baseProcessingHandlers.baseProcessingHandlers,
14
+ collect: _collect.collect,
15
+ evalFile: _evalFile.evalFile,
16
+ extract: _extract.extract,
17
+ workflow: _workflow.workflow
18
+ };
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_baseProcessingHandlers","require","_collect","_evalFile","_extract","_workflow","baseHandlers","exports","baseProcessingHandlers","collect","evalFile","extract","workflow"],"sources":["../../../src/transform/generators/index.ts"],"sourcesContent":["import { baseProcessingHandlers } from './baseProcessingHandlers';\nimport { collect } from './collect';\nimport { evalFile } from './evalFile';\nimport { extract } from './extract';\nimport { workflow } from './workflow';\n\nexport const baseHandlers = {\n ...baseProcessingHandlers,\n collect,\n evalFile,\n extract,\n workflow,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEO,MAAMK,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B,GAAGE,8CAAsB;EACzBC,OAAO,EAAPA,gBAAO;EACPC,QAAQ,EAARA,kBAAQ;EACRC,OAAO,EAAPA,gBAAO;EACPC,QAAQ,EAARA;AACF,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.processEntrypoint = processEntrypoint;
7
+ var _AbortError = require("../actions/AbortError");
8
+ function dispose_SuppressedError(r, e) { return "undefined" != typeof SuppressedError ? dispose_SuppressedError = SuppressedError : (dispose_SuppressedError = function (r, e) { this.suppressed = r, this.error = e, this.stack = new Error().stack; }, dispose_SuppressedError.prototype = Object.create(Error.prototype, { constructor: { value: dispose_SuppressedError, writable: !0, configurable: !0 } })), new dispose_SuppressedError(r, e); }
9
+ function _dispose(r, e, s) { function next() { for (; r.length > 0;) try { var o = r.pop(), p = o.d.call(o.v); if (o.a) return Promise.resolve(p).then(next, err); } catch (r) { return err(r); } if (s) throw e; } function err(r) { return e = s ? new dispose_SuppressedError(r, e) : r, s = !0, next(); } return next(); }
10
+ function _using(o, e, n) { if (null == e) return e; if ("object" != typeof e) throw new TypeError("using declarations can only be used with objects, null, or undefined."); if (n) var r = e[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]; if (null == r && (r = e[Symbol.dispose || Symbol.for("Symbol.dispose")]), "function" != typeof r) throw new TypeError("Property [Symbol.dispose] is not a function."); return o.push({ v: e, d: r, a: n }), e; }
11
+ /**
12
+ * The first stage of processing an entrypoint.
13
+ * This stage is responsible for:
14
+ * - scheduling the explodeReexports action
15
+ * - scheduling the transform action
16
+ * - rescheduling itself if the entrypoint is superseded
17
+ */
18
+ function* processEntrypoint() {
19
+ const {
20
+ only,
21
+ log
22
+ } = this.entrypoint;
23
+ log('start processing (only: %o)', only);
24
+ try {
25
+ try {
26
+ var _stack = [];
27
+ const abortSignal = _using(_stack, this.createAbortSignal());
28
+ yield ['explodeReexports', this.entrypoint, undefined, abortSignal];
29
+ const result = yield* this.getNext('transform', this.entrypoint, undefined, abortSignal);
30
+ this.entrypoint.assertNotSuperseded();
31
+ this.entrypoint.setTransformResult(result);
32
+ log('entrypoint processing finished');
33
+ } catch (_) {
34
+ var _error = _;
35
+ var _hasError = true;
36
+ } finally {
37
+ _dispose(_stack, _error, _hasError);
38
+ }
39
+ } catch (e) {
40
+ if ((0, _AbortError.isAborted)(e) && this.entrypoint.supersededWith) {
41
+ log('processing aborted, schedule the next attempt');
42
+ yield* this.getNext('processEntrypoint', this.entrypoint.supersededWith, undefined, null);
43
+ return;
44
+ }
45
+ log(`Unhandled error: %O`, e);
46
+ throw e;
47
+ }
48
+ }
49
+ //# sourceMappingURL=processEntrypoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processEntrypoint.js","names":["_AbortError","require","dispose_SuppressedError","r","e","SuppressedError","suppressed","error","stack","Error","prototype","Object","create","constructor","value","writable","configurable","_dispose","s","next","length","o","pop","p","d","call","v","a","Promise","resolve","then","err","_using","n","TypeError","Symbol","asyncDispose","for","dispose","push","processEntrypoint","only","log","entrypoint","_stack","abortSignal","createAbortSignal","undefined","result","getNext","assertNotSuperseded","setTransformResult","_","_error","_hasError","isAborted","supersededWith"],"sources":["../../../src/transform/generators/processEntrypoint.ts"],"sourcesContent":["import { isAborted } from '../actions/AbortError';\nimport type { IProcessEntrypointAction, SyncScenarioForAction } from '../types';\n\n/**\n * The first stage of processing an entrypoint.\n * This stage is responsible for:\n * - scheduling the explodeReexports action\n * - scheduling the transform action\n * - rescheduling itself if the entrypoint is superseded\n */\nexport function* processEntrypoint(\n this: IProcessEntrypointAction\n): SyncScenarioForAction<IProcessEntrypointAction> {\n const { only, log } = this.entrypoint;\n log('start processing (only: %o)', only);\n\n try {\n using abortSignal = this.createAbortSignal();\n\n yield ['explodeReexports', this.entrypoint, undefined, abortSignal];\n const result = yield* this.getNext(\n 'transform',\n this.entrypoint,\n undefined,\n abortSignal\n );\n\n this.entrypoint.assertNotSuperseded();\n\n this.entrypoint.setTransformResult(result);\n\n log('entrypoint processing finished');\n } catch (e) {\n if (isAborted(e) && this.entrypoint.supersededWith) {\n log('processing aborted, schedule the next attempt');\n yield* this.getNext(\n 'processEntrypoint',\n this.entrypoint.supersededWith,\n undefined,\n null\n );\n\n return;\n }\n\n log(`Unhandled error: %O`, e);\n throw e;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAkD,SAAAC,wBAAAC,CAAA,EAAAC,CAA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BAAoB,EAAEtC,CAAC,CAAC;IAC7B,MAAMA,CAAC;EACT;AACF"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.processImports = processImports;
7
+ /* eslint-disable no-continue */
8
+
9
+ /**
10
+ * Creates new entrypoints and emits processEntrypoint for each resolved import
11
+ */
12
+ function* processImports() {
13
+ for (const dependency of this.data.resolved) {
14
+ const {
15
+ resolved,
16
+ only
17
+ } = dependency;
18
+ if (!resolved) {
19
+ continue;
20
+ }
21
+ this.entrypoint.addDependency(dependency);
22
+ const nextEntrypoint = this.entrypoint.createChild(resolved, only);
23
+ if (nextEntrypoint === 'loop' || nextEntrypoint.ignored) {
24
+ continue;
25
+ }
26
+ yield* this.getNext('processEntrypoint', nextEntrypoint, undefined, null);
27
+ }
28
+ }
29
+ //# sourceMappingURL=processImports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processImports.js","names":["processImports","dependency","data","resolved","only","entrypoint","addDependency","nextEntrypoint","createChild","ignored","getNext","undefined"],"sources":["../../../src/transform/generators/processImports.ts"],"sourcesContent":["/* eslint-disable no-continue */\nimport type { IProcessImportsAction, SyncScenarioForAction } from '../types';\n\n/**\n * Creates new entrypoints and emits processEntrypoint for each resolved import\n */\nexport function* processImports(\n this: IProcessImportsAction\n): SyncScenarioForAction<IProcessImportsAction> {\n for (const dependency of this.data.resolved) {\n const { resolved, only } = dependency;\n if (!resolved) {\n continue;\n }\n\n this.entrypoint.addDependency(dependency);\n\n const nextEntrypoint = this.entrypoint.createChild(resolved, only);\n if (nextEntrypoint === 'loop' || nextEntrypoint.ignored) {\n continue;\n }\n\n yield* this.getNext('processEntrypoint', nextEntrypoint, undefined, null);\n }\n}\n"],"mappings":";;;;;;AAAA;;AAGA;AACA;AACA;AACO,UAAUA,cAAcA,CAAA,EAEiB;EAC9C,KAAK,MAAMC,UAAU,IAAI,IAAI,CAACC,IAAI,CAACC,QAAQ,EAAE;IAC3C,MAAM;MAAEA,QAAQ;MAAEC;IAAK,CAAC,GAAGH,UAAU;IACrC,IAAI,CAACE,QAAQ,EAAE;MACb;IACF;IAEA,IAAI,CAACE,UAAU,CAACC,aAAa,CAACL,UAAU,CAAC;IAEzC,MAAMM,cAAc,GAAG,IAAI,CAACF,UAAU,CAACG,WAAW,CAACL,QAAQ,EAAEC,IAAI,CAAC;IAClE,IAAIG,cAAc,KAAK,MAAM,IAAIA,cAAc,CAACE,OAAO,EAAE;MACvD;IACF;IAEA,OAAO,IAAI,CAACC,OAAO,CAAC,mBAAmB,EAAEH,cAAc,EAAEI,SAAS,EAAE,IAAI,CAAC;EAC3E;AACF"}