powerlines 0.23.2 → 0.23.4

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 (297) hide show
  1. package/dist/api--9pVSIbm.d.cts +168 -0
  2. package/dist/api-DxPACGY4.d.ts +168 -0
  3. package/dist/api.cjs +3 -3
  4. package/dist/api.d.cts +16 -7
  5. package/dist/api.d.ts +16 -7
  6. package/dist/api.js +2 -2
  7. package/dist/astro.cjs +8 -8
  8. package/dist/astro.d.cts +3 -5
  9. package/dist/astro.d.ts +3 -5
  10. package/dist/astro.js +5 -5
  11. package/dist/{chunk-ZFO3FUM4.cjs → chunk-2FLICTDF.cjs} +2 -2
  12. package/dist/{chunk-JAJ4CI2F.cjs → chunk-3OQXZ5MM.cjs} +2 -2
  13. package/dist/{chunk-KFRKOIP3.js → chunk-5B6P2VUG.js} +1 -1
  14. package/dist/{chunk-GNNF5SG6.cjs → chunk-6ACGI52O.cjs} +2 -2
  15. package/dist/{chunk-JZAQW55G.cjs → chunk-AF5VNWZD.cjs} +2 -2
  16. package/dist/{chunk-J7MZRPLN.cjs → chunk-AIC2EHPW.cjs} +5 -4
  17. package/dist/{chunk-3WDMXRK6.cjs → chunk-AYKZK666.cjs} +1 -1
  18. package/dist/chunk-CHNKTBUA.cjs +32 -0
  19. package/dist/{chunk-M4QJ2474.cjs → chunk-CTSSNO5L.cjs} +4 -4
  20. package/dist/{chunk-5A7FM72H.cjs → chunk-GP6XGAJ4.cjs} +2 -2
  21. package/dist/{chunk-DUYZ3TCT.js → chunk-HLQGKQZY.js} +1 -1
  22. package/dist/{chunk-LKN52AAX.js → chunk-HNJC47JM.js} +1 -1
  23. package/dist/{chunk-IGWSCIES.js → chunk-ISLX4Z3L.js} +3 -2
  24. package/dist/{chunk-J5LKLH5Z.js → chunk-KFSVTJMR.js} +1 -1
  25. package/dist/{chunk-RWVNX2CP.js → chunk-MI3U2GAT.js} +1 -1
  26. package/dist/{chunk-4ODWTALP.js → chunk-N3F54RFW.js} +2 -2
  27. package/dist/{chunk-Q7HBETZW.js → chunk-O2WB6QZ6.js} +1 -1
  28. package/dist/{chunk-DWV5QAGZ.cjs → chunk-OEKSQ22R.cjs} +2997 -2710
  29. package/dist/{chunk-WSLPUUGZ.js → chunk-PTZB4LWS.js} +1 -1
  30. package/dist/{chunk-CPRXGMH2.js → chunk-QSNFMINQ.js} +1 -1
  31. package/dist/{chunk-YQ76DZYD.cjs → chunk-QUZ4T5AX.cjs} +2 -2
  32. package/dist/chunk-UTAJPBVT.js +29 -0
  33. package/dist/{chunk-WG55ZHJL.cjs → chunk-UW3MXOWV.cjs} +2 -2
  34. package/dist/{chunk-F6BDL4HD.js → chunk-VDBKZJV6.js} +1 -1
  35. package/dist/{chunk-J3LN5HOC.cjs → chunk-VFLCP3SA.cjs} +2 -2
  36. package/dist/{chunk-FM4ABZQ2.js → chunk-VT7NVLLU.js} +1 -1
  37. package/dist/{chunk-WDBPA4RQ.cjs → chunk-VXAKPZ3A.cjs} +2 -2
  38. package/dist/{chunk-WXU3KLBP.cjs → chunk-XOI5CY62.cjs} +2 -2
  39. package/dist/{chunk-NH7U3PTV.js → chunk-ZQ7PDXYO.js} +1 -1
  40. package/dist/{chunk-TNYZH6EG.js → chunk-ZYCPZLIG.js} +2982 -2700
  41. package/dist/config.d.cts +3 -5
  42. package/dist/config.d.ts +3 -5
  43. package/dist/esbuild.cjs +7 -7
  44. package/dist/esbuild.d.cts +3 -5
  45. package/dist/esbuild.d.ts +3 -5
  46. package/dist/esbuild.js +4 -4
  47. package/dist/farm.cjs +4 -4
  48. package/dist/farm.d.cts +3 -5
  49. package/dist/farm.d.ts +3 -5
  50. package/dist/farm.js +3 -3
  51. package/dist/index.cjs +54 -33
  52. package/dist/index.d.cts +191 -39
  53. package/dist/index.d.ts +191 -39
  54. package/dist/index.js +18 -17
  55. package/dist/lib/api-B6hfFxVS.d.ts +167 -0
  56. package/dist/lib/api-CD2QlMig.d.cts +167 -0
  57. package/dist/lib/build/esbuild.d.cts +2 -4
  58. package/dist/lib/build/esbuild.d.ts +2 -4
  59. package/dist/lib/build/index.d.cts +4 -5
  60. package/dist/lib/build/index.d.ts +4 -5
  61. package/dist/lib/build/rolldown.d.cts +2 -4
  62. package/dist/lib/build/rolldown.d.ts +2 -4
  63. package/dist/lib/build/rollup.d.cts +2 -4
  64. package/dist/lib/build/rollup.d.ts +2 -4
  65. package/dist/lib/build/rspack.d.cts +2 -4
  66. package/dist/lib/build/rspack.d.ts +2 -4
  67. package/dist/lib/build/tsup.d.cts +2 -4
  68. package/dist/lib/build/tsup.d.ts +2 -4
  69. package/dist/lib/build/unbuild.d.cts +4 -23
  70. package/dist/lib/build/unbuild.d.ts +4 -23
  71. package/dist/lib/build/vite.d.cts +2 -4
  72. package/dist/lib/build/vite.d.ts +2 -4
  73. package/dist/lib/build/webpack.d.cts +2 -4
  74. package/dist/lib/build/webpack.d.ts +2 -4
  75. package/dist/lib/chunk-32Q2PG5D.js +9 -0
  76. package/dist/lib/chunk-35FGUJFD.cjs +2 -0
  77. package/dist/lib/{chunk-LIN4KAV3.js → chunk-52VDUP5J.js} +5 -7
  78. package/dist/lib/chunk-B3EE3VHZ.cjs +127 -0
  79. package/dist/lib/{chunk-UWHGJ4JS.js → chunk-BLNW3ZQA.js} +483 -1776
  80. package/dist/lib/chunk-DX2VAXZB.cjs +11 -0
  81. package/dist/lib/{chunk-VGSV2BEL.cjs → chunk-EFYMNU53.cjs} +6 -12
  82. package/dist/lib/chunk-FBQIPNRV.cjs +146 -0
  83. package/dist/lib/chunk-FFT4PWRM.js +1 -0
  84. package/dist/lib/{chunk-L4NEN725.js → chunk-G7S5PIAC.js} +1 -1
  85. package/dist/lib/chunk-KFJCWNVG.js +120 -0
  86. package/dist/lib/chunk-M2U6XIQ2.js +144 -0
  87. package/dist/lib/chunk-MVIKYHBX.cjs +2 -0
  88. package/dist/lib/chunk-NYNHNTHT.js +1 -0
  89. package/dist/lib/{chunk-A5SB72VO.cjs → chunk-PYQADZVV.cjs} +493 -1779
  90. package/dist/lib/chunk-QP6WX3Q3.js +1190 -0
  91. package/dist/lib/chunk-S7LLEDQM.cjs +1218 -0
  92. package/dist/lib/chunk-UHGGYHSK.cjs +175 -0
  93. package/dist/lib/chunk-YNKFRPUY.js +168 -0
  94. package/dist/lib/{chunk-ULJVBW4L.cjs → chunk-ZBDVQVUK.cjs} +1 -1
  95. package/dist/lib/{config-BoGlIhnH.d.cts → config-DTSdCZsw.d.cts} +650 -633
  96. package/dist/lib/{config-CTej7RMP.d.ts → config-DeUaQYc_.d.ts} +650 -633
  97. package/dist/lib/config-file.d.cts +4 -5
  98. package/dist/lib/config-file.d.ts +4 -5
  99. package/dist/lib/contexts/api-context.cjs +18 -0
  100. package/dist/lib/contexts/api-context.d.cts +69 -0
  101. package/dist/lib/contexts/api-context.d.ts +69 -0
  102. package/dist/lib/contexts/api-context.js +9 -0
  103. package/dist/lib/contexts/context.cjs +15 -0
  104. package/dist/lib/contexts/context.d.cts +255 -0
  105. package/dist/lib/contexts/context.d.ts +255 -0
  106. package/dist/lib/contexts/context.js +6 -0
  107. package/dist/lib/contexts/environment-context.cjs +17 -0
  108. package/dist/lib/contexts/environment-context.d.cts +65 -0
  109. package/dist/lib/contexts/environment-context.d.ts +65 -0
  110. package/dist/lib/contexts/environment-context.js +8 -0
  111. package/dist/lib/contexts/index.cjs +31 -0
  112. package/dist/lib/contexts/index.d.cts +35 -0
  113. package/dist/lib/contexts/index.d.ts +35 -0
  114. package/dist/lib/contexts/index.js +10 -0
  115. package/dist/lib/contexts/plugin-context.cjs +11 -0
  116. package/dist/lib/contexts/plugin-context.d.cts +42 -0
  117. package/dist/lib/contexts/plugin-context.d.ts +42 -0
  118. package/dist/lib/contexts/plugin-context.js +2 -0
  119. package/dist/lib/entry.d.cts +2 -4
  120. package/dist/lib/entry.d.ts +2 -4
  121. package/dist/lib/index.cjs +96 -74
  122. package/dist/lib/index.d.cts +26 -23
  123. package/dist/lib/index.d.ts +26 -23
  124. package/dist/lib/index.js +18 -12
  125. package/dist/lib/internal-CpVMJCaU.d.ts +39 -0
  126. package/dist/lib/internal-ypnrUNZy.d.cts +39 -0
  127. package/dist/lib/logger.d.cts +4 -5
  128. package/dist/lib/logger.d.ts +4 -5
  129. package/dist/lib/typescript/compiler-host.cjs +1 -1
  130. package/dist/lib/typescript/compiler-host.d.cts +5 -5
  131. package/dist/lib/typescript/compiler-host.d.ts +5 -5
  132. package/dist/lib/typescript/compiler-host.js +1 -1
  133. package/dist/lib/typescript/import-transformer.d.cts +2 -4
  134. package/dist/lib/typescript/import-transformer.d.ts +2 -4
  135. package/dist/lib/typescript/index.cjs +29 -24
  136. package/dist/lib/typescript/index.d.cts +6 -6
  137. package/dist/lib/typescript/index.d.ts +6 -6
  138. package/dist/lib/typescript/index.js +3 -2
  139. package/dist/lib/typescript/isolated-decl.d.cts +2 -1
  140. package/dist/lib/typescript/isolated-decl.d.ts +2 -1
  141. package/dist/lib/typescript/program.d.cts +5 -5
  142. package/dist/lib/typescript/program.d.ts +5 -5
  143. package/dist/lib/typescript/ts-morph.cjs +11 -0
  144. package/dist/lib/{create-program.d.ts → typescript/ts-morph.d.cts} +3 -5
  145. package/dist/lib/{create-program.d.cts → typescript/ts-morph.d.ts} +3 -5
  146. package/dist/lib/typescript/ts-morph.js +2 -0
  147. package/dist/lib/unplugin/factory.cjs +8 -4
  148. package/dist/lib/unplugin/factory.d.cts +27 -10
  149. package/dist/lib/unplugin/factory.d.ts +27 -10
  150. package/dist/lib/unplugin/factory.js +7 -3
  151. package/dist/lib/unplugin/helpers.cjs +11 -0
  152. package/dist/lib/unplugin/helpers.d.cts +128 -0
  153. package/dist/lib/unplugin/helpers.d.ts +128 -0
  154. package/dist/lib/unplugin/helpers.js +2 -0
  155. package/dist/lib/unplugin/index.cjs +12 -7
  156. package/dist/lib/unplugin/index.d.cts +6 -8
  157. package/dist/lib/unplugin/index.d.ts +6 -8
  158. package/dist/lib/unplugin/index.js +9 -4
  159. package/dist/lib/unplugin/plugin.cjs +4 -3
  160. package/dist/lib/unplugin/plugin.d.cts +4 -5
  161. package/dist/lib/unplugin/plugin.d.ts +4 -5
  162. package/dist/lib/unplugin/plugin.js +3 -2
  163. package/dist/lib/unplugin/resolve-id.cjs +2 -2
  164. package/dist/lib/unplugin/resolve-id.d.cts +5 -5
  165. package/dist/lib/unplugin/resolve-id.d.ts +5 -5
  166. package/dist/lib/unplugin/resolve-id.js +1 -1
  167. package/dist/lib/utilities/bundle.d.cts +2 -4
  168. package/dist/lib/utilities/bundle.d.ts +2 -4
  169. package/dist/lib/utilities/cache.d.cts +2 -4
  170. package/dist/lib/utilities/cache.d.ts +2 -4
  171. package/dist/lib/utilities/file-header.d.cts +4 -5
  172. package/dist/lib/utilities/file-header.d.ts +4 -5
  173. package/dist/lib/utilities/index.cjs +18 -18
  174. package/dist/lib/utilities/index.d.cts +5 -7
  175. package/dist/lib/utilities/index.d.ts +5 -7
  176. package/dist/lib/utilities/index.js +4 -4
  177. package/dist/lib/utilities/meta.d.cts +4 -5
  178. package/dist/lib/utilities/meta.d.ts +4 -5
  179. package/dist/lib/utilities/resolve-path.d.cts +2 -4
  180. package/dist/lib/utilities/resolve-path.d.ts +2 -4
  181. package/dist/lib/utilities/resolve.d.cts +2 -4
  182. package/dist/lib/utilities/resolve.d.ts +2 -4
  183. package/dist/lib/utilities/source-file.d.cts +2 -4
  184. package/dist/lib/utilities/source-file.d.ts +2 -4
  185. package/dist/lib/utilities/source-map.d.cts +2 -4
  186. package/dist/lib/utilities/source-map.d.ts +2 -4
  187. package/dist/lib/utilities/worker.d.cts +4 -5
  188. package/dist/lib/utilities/worker.d.ts +4 -5
  189. package/dist/lib/utilities/write-file.d.cts +2 -4
  190. package/dist/lib/utilities/write-file.d.ts +2 -4
  191. package/dist/next.cjs +8 -8
  192. package/dist/next.js +5 -5
  193. package/dist/nuxt.cjs +9 -9
  194. package/dist/nuxt.js +6 -6
  195. package/dist/plugin-utils/{context-D1I2JQgs.d.cts → context-DRFZE3XI.d.cts} +535 -518
  196. package/dist/plugin-utils/{context-D1I2JQgs.d.ts → context-DRFZE3XI.d.ts} +535 -518
  197. package/dist/plugin-utils/context-helpers.d.cts +2 -4
  198. package/dist/plugin-utils/context-helpers.d.ts +2 -4
  199. package/dist/plugin-utils/enforce.d.cts +2 -4
  200. package/dist/plugin-utils/enforce.d.ts +2 -4
  201. package/dist/plugin-utils/extend.d.cts +2 -4
  202. package/dist/plugin-utils/extend.d.ts +2 -4
  203. package/dist/plugin-utils/get-config-path.d.cts +2 -4
  204. package/dist/plugin-utils/get-config-path.d.ts +2 -4
  205. package/dist/plugin-utils/helpers.d.cts +2 -4
  206. package/dist/plugin-utils/helpers.d.ts +2 -4
  207. package/dist/plugin-utils/index.d.cts +3 -5
  208. package/dist/plugin-utils/index.d.ts +3 -5
  209. package/dist/plugin-utils/merge.d.cts +4 -5
  210. package/dist/plugin-utils/merge.d.ts +4 -5
  211. package/dist/plugin-utils/paths.d.cts +2 -4
  212. package/dist/plugin-utils/paths.d.ts +2 -4
  213. package/dist/{resolved-DYLxPDut.d.cts → resolved-C00CJgsk.d.cts} +128 -9
  214. package/dist/{resolved-D1ySEdUv.d.ts → resolved-DKFZ11S7.d.ts} +128 -9
  215. package/dist/rolldown.cjs +7 -7
  216. package/dist/rolldown.d.cts +3 -5
  217. package/dist/rolldown.d.ts +3 -5
  218. package/dist/rolldown.js +4 -4
  219. package/dist/rollup.cjs +7 -7
  220. package/dist/rollup.d.cts +3 -5
  221. package/dist/rollup.d.ts +3 -5
  222. package/dist/rollup.js +4 -4
  223. package/dist/rspack.cjs +7 -7
  224. package/dist/rspack.d.cts +3 -5
  225. package/dist/rspack.d.ts +3 -5
  226. package/dist/rspack.js +4 -4
  227. package/dist/tsup.cjs +8 -8
  228. package/dist/tsup.js +5 -5
  229. package/dist/types/api.cjs +4 -0
  230. package/dist/types/api.d.cts +36 -0
  231. package/dist/types/api.d.ts +36 -0
  232. package/dist/types/api.js +1 -0
  233. package/dist/types/babel.d.cts +3 -5
  234. package/dist/types/babel.d.ts +3 -5
  235. package/dist/types/build.d.cts +26 -1
  236. package/dist/types/build.d.ts +26 -1
  237. package/dist/types/commands.d.cts +3 -5
  238. package/dist/types/commands.d.ts +3 -5
  239. package/dist/types/config.d.cts +3 -5
  240. package/dist/types/config.d.ts +3 -5
  241. package/dist/types/context.d.cts +3 -5
  242. package/dist/types/context.d.ts +3 -5
  243. package/dist/types/{vfs.cjs → fs.cjs} +3 -3
  244. package/dist/types/{vfs.d.cts → fs.d.cts} +54 -35
  245. package/dist/types/{vfs.d.ts → fs.d.ts} +54 -35
  246. package/dist/types/fs.js +2 -0
  247. package/dist/types/hooks.d.cts +3 -5
  248. package/dist/types/hooks.d.ts +3 -5
  249. package/dist/types/index.cjs +9 -8
  250. package/dist/types/index.d.cts +8 -9
  251. package/dist/types/index.d.ts +8 -9
  252. package/dist/types/index.js +3 -2
  253. package/dist/types/internal.d.cts +46 -9
  254. package/dist/types/internal.d.ts +46 -9
  255. package/dist/types/plugin.d.cts +3 -5
  256. package/dist/types/plugin.d.ts +3 -5
  257. package/dist/types/resolved.d.cts +3 -5
  258. package/dist/types/resolved.d.ts +3 -5
  259. package/dist/types/tsconfig.d.cts +8 -1
  260. package/dist/types/tsconfig.d.ts +8 -1
  261. package/dist/types/typedoc.d.cts +3 -1
  262. package/dist/types/typedoc.d.ts +3 -1
  263. package/dist/types/unplugin.d.cts +22 -11
  264. package/dist/types/unplugin.d.ts +22 -11
  265. package/dist/unloader.cjs +7 -7
  266. package/dist/unloader.d.cts +12 -14
  267. package/dist/unloader.d.ts +12 -14
  268. package/dist/unloader.js +4 -4
  269. package/dist/unplugin.cjs +18 -18
  270. package/dist/unplugin.d.cts +6 -9
  271. package/dist/unplugin.d.ts +6 -9
  272. package/dist/unplugin.js +15 -15
  273. package/dist/vite.cjs +7 -7
  274. package/dist/vite.d.cts +3 -5
  275. package/dist/vite.d.ts +3 -5
  276. package/dist/vite.js +4 -4
  277. package/dist/webpack.cjs +7 -7
  278. package/dist/webpack.d.cts +3 -5
  279. package/dist/webpack.d.ts +3 -5
  280. package/dist/webpack.js +4 -4
  281. package/package.json +39 -11
  282. package/schemas/fs.capnp +73 -15
  283. package/dist/chunk-RODEAGIJ.cjs +0 -32
  284. package/dist/chunk-SKLSRHBU.js +0 -29
  285. package/dist/hooks-D2UGCryi.d.ts +0 -28
  286. package/dist/hooks-DJG3B-Hw.d.cts +0 -28
  287. package/dist/lib/create-program.cjs +0 -11
  288. package/dist/lib/create-program.js +0 -2
  289. package/dist/lib/hooks-CDLPWf7j.d.cts +0 -28
  290. package/dist/lib/hooks-Cn-IqwYp.d.ts +0 -28
  291. package/dist/types/vfs.js +0 -2
  292. /package/dist/{chunk-KIKTWMI3.cjs → chunk-2NCILNCH.cjs} +0 -0
  293. /package/dist/{chunk-XVLT2RQ2.js → chunk-BLNT5INX.js} +0 -0
  294. /package/dist/{lib/chunk-RJ4277VZ.cjs → chunk-GRU7B3QM.cjs} +0 -0
  295. /package/dist/{lib/chunk-ZBLDAREE.js → chunk-T2P533I5.js} +0 -0
  296. /package/dist/lib/{chunk-CGYAL3S2.cjs → chunk-4EIXDLFP.cjs} +0 -0
  297. /package/dist/lib/{chunk-CXRSMYEX.js → chunk-RD5AUWXN.js} +0 -0
@@ -19,891 +19,912 @@ import { PackageJson } from '@stryke/types/package-json';
19
19
  import { Worker } from 'jest-worker';
20
20
  import { Jiti } from 'jiti';
21
21
  import MagicString, { SourceMap } from 'magic-string';
22
- import { ParserOptions, ParseResult } from 'oxc-parser';
23
22
  import { Range } from 'semver';
24
23
  import { TransformResult as TransformResult$1, ExternalIdResult, HookFilter, UnpluginOptions, UnpluginContext, UnpluginMessage, UnpluginBuildContext } from 'unplugin';
24
+ import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
25
25
  import { ArrayValues } from '@stryke/types/array';
26
26
  import { P as ParsedTypeScriptConfig, T as TSConfig } from './tsconfig-Bz-CiFqD.cjs';
27
- import { PrimitiveJsonValue } from '@stryke/json/types';
28
- import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
29
27
 
30
- type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
31
- type BuildVariant = UnpluginBuildVariant | "tsup" | "unbuild";
32
- type InferUnpluginVariant<TBuildVariant extends BuildVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
33
- interface BuildConfig {
28
+ declare const __VFS_PATCH__ = "__VFS_PATCH__";
29
+ declare const __VFS_REVERT__ = "__VFS_REVERT__";
30
+ type OutputModeType = "fs" | "virtual";
31
+ interface VirtualFileMetadata {
34
32
  /**
35
- * The platform to build the project for
36
- *
37
- * @defaultValue "neutral"
33
+ * The identifier for the file data.
38
34
  */
39
- platform?: "node" | "browser" | "neutral";
35
+ id: string;
40
36
  /**
41
- * Array of strings indicating the polyfills to include for the build.
42
- *
43
- * @remarks
44
- * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
45
- *
46
- * @example
47
- * ```ts
48
- * {
49
- * polyfill: ['{projectRoot}/custom-polyfill.ts']
50
- * }
51
- * ```
37
+ * The timestamp of the virtual file.
52
38
  */
53
- polyfill?: string[];
39
+ timestamp: number;
54
40
  /**
55
- * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
41
+ * The type of the file.
56
42
  *
57
- * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
58
- */
59
- mainFields?: string[];
60
- /**
61
- * Array of strings indicating what conditions should be used for module resolution.
43
+ * @remarks
44
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
45
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
46
+ * - `entry`: Indicates that the file is an entry point for execution.
47
+ * - `normal`: Indicates that the file is a standard file without any special role.
62
48
  */
63
- conditions?: string[];
49
+ type: string;
64
50
  /**
65
- * Array of strings indicating what file extensions should be used for module resolution.
66
- *
67
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
51
+ * The output mode of the file.
68
52
  */
69
- extensions?: string[];
53
+ mode: string;
70
54
  /**
71
- * Array of strings indicating what modules should be deduplicated to a single version in the build.
72
- *
73
- * @remarks
74
- * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
55
+ * Additional metadata associated with the file.
75
56
  */
76
- dedupe?: string[];
57
+ properties: Record<string, string>;
58
+ }
59
+ interface VirtualFileData {
77
60
  /**
78
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
61
+ * The identifier for the file data.
79
62
  */
80
- builtins?: (string | RegExp)[];
63
+ id?: string;
81
64
  /**
82
- * Define global variable replacements.
83
- *
84
- * @remarks
85
- * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
86
- *
87
- * @example
88
- * ```ts
89
- * {
90
- * define: {
91
- * __VERSION__: '"1.0.0"',
92
- * __DEV__: 'process.env.NODE_ENV !== "production"'
93
- * }
94
- * }
95
- * ```
96
- *
97
- * @see https://esbuild.github.io/api/#define
98
- * @see https://vitejs.dev/config/build-options.html#define
99
- * @see https://github.com/rollup/plugins/tree/master/packages/replace
65
+ * The contents of the virtual file.
100
66
  */
101
- define?: Record<string, any>;
67
+ code: string;
102
68
  /**
103
- * Global variables that will have import statements injected where necessary
69
+ * The type of the file.
104
70
  *
105
71
  * @remarks
106
- * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
107
- *
108
- * @example
109
- * ```ts
110
- * {
111
- * inject: {
112
- * process: 'process/browser',
113
- * Buffer: ['buffer', 'Buffer'],
114
- * }
115
- * }
116
- * ```
117
- *
118
- * @see https://github.com/rollup/plugins/tree/master/packages/inject
72
+ * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
73
+ * - `builtin`: Indicates that the file is a built-in module provided by the system.
74
+ * - `entry`: Indicates that the file is an entry point for execution.
75
+ * - `chunk`: Indicates that the file is a code chunk, typically used in code-splitting scenarios.
76
+ * - `prebuilt-chunk`: Indicates that the file is a prebuilt code chunk.
77
+ * - `asset`: Indicates that the file is a static asset, such as an image or stylesheet.
78
+ * - `normal`: Indicates that the file is a standard file without any special role.
119
79
  */
120
- inject?: Record<string, string | string[]>;
80
+ type?: string;
121
81
  /**
122
- * The alias mappings to use for module resolution during the build process.
123
- *
124
- * @remarks
125
- * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
126
- *
127
- * @example
128
- * ```ts
129
- * {
130
- * alias: {
131
- * "@utils": "./src/utils",
132
- * "@components": "./src/components"
133
- * }
134
- * }
135
- * ```
136
- *
137
- * @see https://github.com/rollup/plugins/tree/master/packages/alias
82
+ * The output mode of the file.
138
83
  */
139
- alias?: Record<string, string> | Array<{
140
- find: string | RegExp;
141
- replacement: string;
142
- }>;
84
+ mode?: string;
143
85
  /**
144
- * A list of modules that should not be bundled, even if they are external dependencies.
145
- *
146
- * @remarks
147
- * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
86
+ * Additional metadata associated with the file.
148
87
  */
149
- external?: (string | RegExp)[];
88
+ properties?: Record<string, string>;
89
+ }
90
+ interface VirtualFile extends Required<VirtualFileData>, VirtualFileMetadata {
150
91
  /**
151
- * A list of modules that should always be bundled, even if they are external dependencies.
92
+ * An additional name for the file.
152
93
  */
153
- noExternal?: (string | RegExp)[];
94
+ path: string;
154
95
  /**
155
- * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
96
+ * The timestamp of the virtual file.
156
97
  */
157
- skipNodeModulesBundle?: boolean;
98
+ timestamp: number;
99
+ }
100
+ interface ResolveFSOptions {
101
+ mode?: OutputModeType;
102
+ }
103
+ type MakeDirectoryOptions = (Mode | MakeDirectoryOptions$1) & ResolveFSOptions;
104
+ interface PowerlinesWriteFileOptions extends ResolveFSOptions {
158
105
  /**
159
- * An optional set of override options to apply to the selected build variant.
106
+ * Should the file skip formatting before being written?
160
107
  *
161
- * @remarks
162
- * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
108
+ * @defaultValue false
163
109
  */
164
- override?: Record<string, any>;
110
+ skipFormat?: boolean;
165
111
  }
166
- type BuildResolvedConfig = Omit<BuildConfig, "override">;
167
- type ESBuildBuildConfig = Omit<BuildOptions, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
168
- type ESBuildResolvedBuildConfig = Omit<BuildOptions, "inject"> & BuildResolvedConfig;
169
- type ViteBuildConfig = Omit<UserConfig$1, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig;
170
- type ViteResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
171
- type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
172
- type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
173
- type RspackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
174
- type RspackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
175
- type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
176
- type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
177
- output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
178
- } & BuildConfig;
179
- type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
180
- type RolldownBuildOutputConfig = Omit<RolldownOutput, "dir" | "format">;
181
- type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & {
182
- output: RolldownBuildOutputConfig | RolldownBuildOutputConfig[];
183
- } & BuildConfig;
184
- type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
185
- type TsupBuildConfig = Partial<Omit<BuildOptions$1, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
186
- type TsupResolvedBuildConfig = BuildOptions$1 & BuildResolvedConfig;
187
- type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
188
- type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
189
- type FarmBuildConfig = Partial<Omit<UserConfig$2, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
190
- type FarmResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
191
-
192
- declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
193
- type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
194
-
195
- interface ResolvedEntryTypeDefinition extends TypeDefinition {
112
+ type NodeWriteFileOptions = WriteFileOptions$1;
113
+ type WriteFileOptions = NodeWriteFileOptions | PowerlinesWriteFileOptions;
114
+ type WriteFileData = string | NodeJS.ArrayBufferView | VirtualFileData;
115
+ interface ResolvePathOptions extends ResolveFSOptions {
196
116
  /**
197
- * The user provided entry point in the source code
117
+ * Should the resolved path include the file extension?
118
+ *
119
+ * @defaultValue true
198
120
  */
199
- input: TypeDefinition;
121
+ withExtension?: boolean;
200
122
  /**
201
- * An optional name to use in the package export during the build process
123
+ * The paths to search for the file.
202
124
  */
203
- output?: string;
204
- }
205
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
125
+ paths?: string[];
206
126
  /**
207
- * The name of the environment
127
+ * The type of the path to resolve.
208
128
  */
209
- name: string;
129
+ pathType?: "file" | "directory";
130
+ }
131
+ interface VirtualFileSystemInterface {
210
132
  /**
211
- * Configuration options for the preview server
133
+ * Patches the File System to include the virtual file system (VFS) contents.
212
134
  */
213
- preview?: ResolvedPreviewOptions;
214
- };
215
- type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
216
- type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
217
- assets: ResolvedAssetGlob[];
218
- }>;
219
- /**
220
- * The resolved options for the Powerlines project configuration.
221
- */
222
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework">> & {
135
+ [__VFS_PATCH__]: () => void;
223
136
  /**
224
- * The configuration options that were provided inline to the Powerlines CLI.
137
+ * Reverts the virtual file system (VFS) to its previous state.
225
138
  */
226
- inlineConfig: InlineConfig<TUserConfig>;
139
+ [__VFS_REVERT__]: () => void;
227
140
  /**
228
- * The original configuration options that were provided by the user to the Powerlines process.
141
+ * The underlying file metadata.
229
142
  */
230
- userConfig: TUserConfig;
143
+ metadata: Record<string, VirtualFileMetadata | undefined>;
231
144
  /**
232
- * A string identifier for the Powerlines command being executed.
145
+ * A map of module ids to their file paths.
233
146
  */
234
- command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
147
+ ids: Record<string, string>;
235
148
  /**
236
- * The root directory of the project's source code
149
+ * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
237
150
  *
238
- * @defaultValue "\{projectRoot\}/src"
151
+ * @param pathOrId - The path or id to check.
152
+ * @param options - Optional parameters for resolving the path.
153
+ * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
239
154
  */
240
- sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
155
+ isVirtual: (pathOrId: string, options?: ResolvePathOptions) => boolean;
241
156
  /**
242
- * The root directory of the project.
157
+ * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
158
+ *
159
+ * @param pathOrId - The path or id to check.
160
+ * @param options - Optional parameters for resolving the path.
161
+ * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
243
162
  */
244
- projectRoot: NonUndefined<TUserConfig["root"]>;
163
+ isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
245
164
  /**
246
- * The type of project being built.
165
+ * Checks if a file exists in the virtual file system (VFS).
166
+ *
167
+ * @param path - The path of the file to check.
168
+ * @returns `true` if the file exists, otherwise `false`.
247
169
  */
248
- projectType: NonUndefined<TUserConfig["type"]>;
170
+ isFile: (path: string) => boolean;
249
171
  /**
250
- * The output configuration options to use for the build process
172
+ * Checks if a directory exists in the virtual file system (VFS).
173
+ *
174
+ * @param path - The path of the directory to check.
175
+ * @returns `true` if the directory exists, otherwise `false`.
251
176
  */
252
- output: OutputResolvedConfig;
177
+ isDirectory: (path: string) => boolean;
253
178
  /**
254
- * Configuration provided to build processes
179
+ * Checks if a file exists in the virtual file system (VFS).
255
180
  *
256
- * @remarks
257
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
181
+ * @param pathOrId - The path or id of the file.
182
+ * @returns `true` if the file exists, otherwise `false`.
258
183
  */
259
- build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
184
+ existsSync: (pathOrId: string) => boolean;
260
185
  /**
261
- * The log level to use for the Powerlines processes.
186
+ * Gets the metadata of a file in the virtual file system (VFS).
262
187
  *
263
- * @defaultValue "info"
188
+ * @param pathOrId - The path or id of the file.
189
+ * @returns The metadata of the file if it exists, otherwise undefined.
264
190
  */
265
- logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
266
- };
267
- type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
268
- type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
269
- type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
270
- type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
271
- type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
272
- type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
273
- type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
274
- type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
275
- type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
276
- type InferResolvedConfig<TBuildVariant extends BuildVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
277
-
278
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
191
+ getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
279
192
  /**
280
- * The order in which the plugin should be applied.
193
+ * Gets the stats of a file in the virtual file system (VFS).
194
+ *
195
+ * @param pathOrId - The path or id of the file.
196
+ * @param options - Optional parameters for getting the stats.
197
+ * @returns The stats of the file if it exists, otherwise undefined.
281
198
  */
282
- order?: "pre" | "post" | null | undefined;
199
+ lstat: (pathOrId: string, options?: StatSyncOptions & {
200
+ bigint?: false | undefined;
201
+ throwIfNoEntry: false;
202
+ }) => Promise<Stats>;
283
203
  /**
284
- * A filter to determine when the hook should be called.
204
+ * Gets the stats of a file in the virtual file system (VFS).
205
+ *
206
+ * @param pathOrId - The path or id of the file.
207
+ * @param options - Optional parameters for getting the stats.
208
+ * @returns The stats of the file if it exists, otherwise undefined.
285
209
  */
286
- filter?: Pick<HookFilter, TFilter>;
210
+ lstatSync: (pathOrId: string, options?: StatSyncOptions & {
211
+ bigint?: false | undefined;
212
+ throwIfNoEntry: false;
213
+ }) => Stats | undefined;
287
214
  /**
288
- * The hook function to be called.
215
+ * Gets the stats of a file in the virtual file system (VFS).
216
+ *
217
+ * @param pathOrId - The path or id of the file.
218
+ * @returns The stats of the file if it exists, otherwise false.
289
219
  */
290
- handler: THookFunction;
291
- }
292
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
293
- /**
294
- * A result returned by the plugin from the `generateTypes` hook that describes the declaration types output file.
295
- */
296
- interface GenerateTypesResult {
297
- directives?: string[];
298
- code: string;
299
- }
300
- type DeepPartial<T> = {
301
- [K in keyof T]?: DeepPartial<T[K]>;
302
- };
303
- type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
304
- interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
220
+ stat: (pathOrId: string, options?: StatSyncOptions & {
221
+ bigint?: false | undefined;
222
+ throwIfNoEntry: false;
223
+ }) => Promise<Stats>;
305
224
  /**
306
- * A function that returns configuration options to be merged with the build context's options.
307
- *
308
- * @remarks
309
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
310
- *
311
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
312
- *
313
- * @see https://vitejs.dev/guide/api-plugin#config
225
+ * Gets the stats of a file in the virtual file system (VFS).
314
226
  *
315
- * @param this - The build context.
316
- * @param config - The partial configuration object to be modified.
317
- * @returns A promise that resolves to a partial configuration object.
227
+ * @param pathOrId - The path or id of the file.
228
+ * @returns The stats of the file if it exists, otherwise false.
318
229
  */
319
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
230
+ statSync: (pathOrId: string, options?: StatSyncOptions & {
231
+ bigint?: false | undefined;
232
+ throwIfNoEntry: false;
233
+ }) => Stats | undefined;
320
234
  /**
321
- * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
322
- *
323
- * @remarks
324
- * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
325
- *
326
- * @see https://vitejs.dev/guide/api-plugin#configenvironment
235
+ * Lists files in a given path.
327
236
  *
328
- * @param this - The build context.
329
- * @param name - The name of the environment being configured.
330
- * @param environment - The Vite-like environment object containing information about the current build environment.
331
- * @returns A promise that resolves when the hook is complete.
237
+ * @param path - The path to list files from.
238
+ * @param options - Options for listing files, such as encoding and recursion.
239
+ * @returns An array of file names in the specified path.
332
240
  */
333
- configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
241
+ readdirSync: (path: string, options?: {
242
+ encoding: BufferEncoding | null;
243
+ withFileTypes?: false | undefined;
244
+ recursive?: boolean | undefined;
245
+ } | BufferEncoding) => string[];
334
246
  /**
335
- * A hook that is called when the plugin is resolved.
336
- *
337
- * @see https://vitejs.dev/guide/api-plugin#configresolved
247
+ * Lists files in a given path.
338
248
  *
339
- * @param this - The build context.
340
- * @returns A promise that resolves when the hook is complete.
249
+ * @param path - The path to list files from.
250
+ * @param options - Options for listing files, such as encoding and recursion.
251
+ * @returns An array of file names in the specified path.
341
252
  */
342
- configResolved: (this: TContext) => MaybePromise<void>;
253
+ readdir: (path: string, options?: {
254
+ encoding: BufferEncoding | null;
255
+ withFileTypes?: false | undefined;
256
+ recursive?: boolean | undefined;
257
+ } | BufferEncoding) => Promise<string[]>;
343
258
  /**
344
- * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
259
+ * Removes a file or symbolic link in the virtual file system (VFS).
345
260
  *
346
- * @param this - The build context.
347
- * @param code - The source code to generate types for.
348
- * @returns A promise that resolves when the hook is complete.
261
+ * @param path - The path to the file to remove.
262
+ * @returns A promise that resolves when the file is removed.
349
263
  */
350
- generateTypes: (this: TContext, code: string) => MaybePromise<GenerateTypesResult | string | undefined | null>;
264
+ unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;
351
265
  /**
352
- * A hook that is called at the start of the build process.
266
+ * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
353
267
  *
354
- * @param this - The build context and unplugin build context.
355
- * @returns A promise that resolves when the hook is complete.
268
+ * @param path - The path to the file to remove.
269
+ * @returns A promise that resolves when the file is removed.
356
270
  */
357
- buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
271
+ unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;
358
272
  /**
359
- * A hook that is called at the end of the build process.
273
+ * Removes a directory in the virtual file system (VFS).
360
274
  *
361
- * @param this - The build context and unplugin build context.
362
- * @returns A promise that resolves when the hook is complete.
275
+ * @param path - The path to create the directory at.
276
+ * @param options - Options for creating the directory.
363
277
  */
364
- buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
278
+ rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;
365
279
  /**
366
- * A hook that is called to transform the source code.
280
+ * Removes a directory in the virtual file system (VFS).
367
281
  *
368
- * @param this - The build context, unplugin build context, and unplugin context.
369
- * @param code - The source code to transform.
370
- * @param id - The identifier of the source code.
371
- * @returns A promise that resolves when the hook is complete.
282
+ * @param path - The path to create the directory at.
283
+ * @param options - Options for creating the directory.
284
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
372
285
  */
373
- transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>;
286
+ rmdir: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
374
287
  /**
375
- * A hook that is called to load the source code.
288
+ * Removes a file or directory in the virtual file system (VFS).
376
289
  *
377
- * @param this - The build context, unplugin build context, and unplugin context.
378
- * @param id - The identifier of the source code.
379
- * @returns A promise that resolves when the hook is complete.
290
+ * @param path - The path to the file or directory to remove.
291
+ * @param options - Options for removing the file or directory.
292
+ * @returns A promise that resolves when the file or directory is removed.
380
293
  */
381
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>;
294
+ rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;
382
295
  /**
383
- * A hook that is called to resolve the identifier of the source code.
296
+ * Synchronously removes a file or directory in the virtual file system (VFS).
384
297
  *
385
- * @param this - The build context, unplugin build context, and unplugin context.
386
- * @param id - The identifier of the source code.
387
- * @param importer - The importer of the source code.
388
- * @param options - The options for resolving the identifier.
389
- * @returns A promise that resolves when the hook is complete.
298
+ * @param path - The path to the file or directory to remove.
299
+ * @param options - Options for removing the file or directory.
390
300
  */
391
- resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
392
- isEntry: boolean;
393
- }) => MaybePromise<string | ExternalIdResult | null | undefined>;
301
+ rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;
394
302
  /**
395
- * A hook that is called to write the bundle to disk.
303
+ * Creates a directory in the virtual file system (VFS).
396
304
  *
397
- * @param this - The build context.
398
- * @returns A promise that resolves when the hook is complete.
305
+ * @param path - The path to create the directory at.
306
+ * @param options - Options for creating the directory.
307
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
399
308
  */
400
- writeBundle: (this: TContext) => MaybePromise<void>;
401
- }
402
- type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant] = Required<UnpluginOptions>[TBuildVariant]> = {
403
- [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey];
404
- };
405
- type ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant> = {
406
- [TKey in keyof BuildPlugin<TContext, TBuildVariant> & string as `${TBuildVariant}:${TKey}`]: BuildPlugin<TContext, TBuildVariant>[TKey];
407
- };
408
- type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
409
- type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
410
- type PluginHooks<TContext extends PluginContext = PluginContext> = {
411
- [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]>;
412
- } & {
309
+ mkdirSync: (path: PathLike, options?: MakeDirectoryOptions) => string | undefined;
413
310
  /**
414
- * A function that returns configuration options to be merged with the build context's options.
311
+ * Creates a directory in the virtual file system (VFS).
415
312
  *
416
- * @remarks
417
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
313
+ * @param path - The path to create the directory at.
314
+ * @param options - Options for creating the directory.
315
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
316
+ */
317
+ mkdir: (path: PathLike, options?: MakeDirectoryOptions) => Promise<string | undefined>;
318
+ /**
319
+ * Reads a file from the virtual file system (VFS).
418
320
  *
419
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
321
+ * @param pathOrId - The path or id of the file.
322
+ * @returns The contents of the file if it exists, otherwise undefined.
323
+ */
324
+ readFile: (pathOrId: string) => Promise<string | undefined>;
325
+ /**
326
+ * Reads a file from the virtual file system (VFS).
420
327
  *
421
- * @see https://vitejs.dev/guide/api-plugin#config
328
+ * @param pathOrId - The path or id of the file.
329
+ */
330
+ readFileSync: (pathOrId: string) => string | undefined;
331
+ /**
332
+ * Writes a file to the virtual file system (VFS).
422
333
  *
423
- * @param this - The build context.
424
- * @param config - The partial configuration object to be modified.
425
- * @returns A promise that resolves to a partial configuration object.
334
+ * @param path - The path to the file.
335
+ * @param data - The contents of the file.
336
+ * @param options - Optional parameters for writing the file.
337
+ * @returns A promise that resolves when the file is written.
426
338
  */
427
- config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
339
+ writeFile: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => Promise<void>;
428
340
  /**
429
- * A hook that is called to transform the source code.
341
+ * Writes a file to the virtual file system (VFS).
430
342
  *
431
- * @param this - The build context, unplugin build context, and unplugin context.
432
- * @param code - The source code to transform.
433
- * @param id - The identifier of the source code.
434
- * @returns A promise that resolves when the hook is complete.
343
+ * @param path - The path to the file.
344
+ * @param data - The contents of the file.
345
+ * @param options - Optional parameters for writing the file.
435
346
  */
436
- transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>, "code" | "id">;
347
+ writeFileSync: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => void;
437
348
  /**
438
- * A hook that is called to load the source code.
349
+ * Moves a file from one path to another in the virtual file system (VFS).
439
350
  *
440
- * @param this - The build context, unplugin build context, and unplugin context.
441
- * @param id - The identifier of the source code.
442
- * @returns A promise that resolves when the hook is complete.
351
+ * @param srcPath - The source path to move
352
+ * @param destPath - The destination path to move to
443
353
  */
444
- load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>, "id">;
354
+ move: (srcPath: string, destPath: string) => Promise<void>;
445
355
  /**
446
- * A hook that is called to resolve the identifier of the source code.
356
+ * Synchronously moves a file from one path to another in the virtual file system (VFS).
447
357
  *
448
- * @param this - The build context, unplugin build context, and unplugin context.
449
- * @param id - The identifier of the source code.
450
- * @param importer - The importer of the source code.
451
- * @param options - The options for resolving the identifier.
452
- * @returns A promise that resolves when the hook is complete.
358
+ * @param srcPath - The source path to move
359
+ * @param destPath - The destination path to move to
453
360
  */
454
- resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
455
- isEntry: boolean;
456
- }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
457
- };
458
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = {
459
- [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant>;
460
- };
461
- interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
361
+ moveSync: (srcPath: string, destPath: string) => void;
462
362
  /**
463
- * The name of the plugin, for use in deduplication, error messages and logs.
363
+ * Copies a file from one path to another in the virtual file system (VFS).
364
+ *
365
+ * @param srcPath - The source path to copy
366
+ * @param destPath - The destination path to copy to
464
367
  */
465
- name: string;
368
+ copy: (srcPath: string, destPath: string) => Promise<void>;
466
369
  /**
467
- * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
370
+ * Synchronously copies a file from one path to another in the virtual file system (VFS).
468
371
  *
469
- * @remarks
470
- * The Plugin invocation order is as follows:
471
- * - `enforce: 'pre'` plugins
472
- * - `order: 'pre'` plugin hooks
473
- * - any other plugins (normal)
474
- * - `order: 'post'` plugin hooks
475
- * - `enforce: 'post'` plugins
372
+ * @param srcPath - The source path to copy
373
+ * @param destPath - The destination path to copy to
374
+ */
375
+ copySync: (srcPath: string, destPath: string) => void;
376
+ /**
377
+ * Glob files in the virtual file system (VFS) based on the provided pattern(s).
476
378
  *
477
- * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
478
- * @see https://rollupjs.org/plugin-development/#build-hooks
479
- * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
480
- * @see https://esbuild.github.io/plugins/#concepts
379
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
380
+ * @returns An array of file paths matching the provided pattern(s)
481
381
  */
482
- enforce?: "pre" | "post";
382
+ glob: (pattern: string | string[]) => Promise<string[]>;
483
383
  /**
484
- * A function to determine if two plugins are the same and can be de-duplicated.
384
+ * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
485
385
  *
486
- * @remarks
487
- * If this is not provided, plugins are de-duplicated by comparing their names.
386
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
387
+ * @returns An array of file paths matching the provided pattern(s)
388
+ */
389
+ globSync: (pattern: string | string[]) => string[];
390
+ /**
391
+ * Resolves a path or id to a file path in the virtual file system.
488
392
  *
489
- * @param other - The other plugin to compare against.
490
- * @returns `true` if the two plugins are the same, `false` otherwise.
393
+ * @param pathOrId - The path or id of the file to resolve.
394
+ * @param options - Optional parameters for resolving the path.
395
+ * @returns The resolved path of the file if it exists, otherwise false.
491
396
  */
492
- dedupe?: false | ((other: Plugin<any>) => boolean);
397
+ resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
493
398
  /**
494
- * A list of pre-requisite plugins that must be loaded before this plugin can be used.
399
+ * Formats a path to match the virtual file system (VFS) structure.
400
+ *
401
+ * @param path - The path to format.
402
+ * @returns The formatted path.
495
403
  */
496
- dependsOn?: PluginConfig<any>[];
404
+ formatPath: (path: string) => string;
497
405
  /**
498
- * Define environments where this plugin should be active. By default, the plugin is active in all environments.
406
+ * Resolves a path or id to a file path in the virtual file system.
499
407
  *
500
- * @param environment - The environment to check.
501
- * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
408
+ * @param pathOrId - The path or id of the file to resolve.
409
+ * @returns The resolved path of the file if it exists, otherwise false.
502
410
  */
503
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | Plugin<any>>;
504
- }
505
-
506
- type BaseHooks<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext>;
507
- type BaseHookKeys<TContext extends PluginContext = PluginContext> = keyof BaseHooks<TContext>;
508
- type ExternalHooks<TContext extends PluginContext = PluginContext> = ExternalPluginHookFunctions<TContext>;
509
- type ExternalHookKeys<TContext extends PluginContext = PluginContext> = keyof ExternalHooks<TContext>;
510
- type Hooks<TContext extends PluginContext = PluginContext> = PluginHookFunctions<TContext>;
511
- type HookKeys<TContext extends PluginContext = PluginContext> = keyof Hooks<TContext>;
512
- interface BaseHooksListItem<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> extends PluginHookObject<BaseHooks<TContext>[TKey]> {
513
- plugin: Plugin<TContext>;
514
- }
515
- interface BaseHooksList<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> {
516
- preOrdered?: BaseHooksListItem<TContext, TKey>[];
517
- preEnforced?: BaseHooksListItem<TContext, TKey>[];
518
- normal?: BaseHooksListItem<TContext, TKey>[];
519
- postEnforced?: BaseHooksListItem<TContext, TKey>[];
520
- postOrdered?: BaseHooksListItem<TContext, TKey>[];
521
- }
522
- interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
523
- plugin: Plugin<TContext>;
524
- handler: ExternalHooks<TContext>[TKey];
411
+ realpathSync: (pathOrId: string) => string;
412
+ /**
413
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
414
+ */
415
+ dispose: () => Promise<void>;
525
416
  }
526
- type HooksList<TContext extends PluginContext = PluginContext> = {
527
- [TKey in BaseHookKeys<TContext>]?: BaseHooksList<TContext, TKey>;
528
- } & {
529
- [TKey in ExternalHookKeys<TContext>]?: ExternalHooksListItem<TContext, TKey>[];
530
- };
531
- type InferHookHandler<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Hooks<TContext>[TKey];
532
- type InferHookReturnType<TContext extends PluginContext, TKey extends HookKeys<TContext>> = ReturnType<InferHookHandler<TContext, TKey>> extends Promise<infer U> ? U extends Promise<infer V> ? V : U : ReturnType<InferHookHandler<TContext, TKey>>;
533
- type InferHookParameters<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Parameters<InferHookHandler<TContext, TKey>>;
534
417
 
535
- declare const __VFS_PATCH__ = "__VFS_PATCH__";
536
- declare const __VFS_REVERT__ = "__VFS_REVERT__";
537
- type OutputModeType = "fs" | "virtual";
538
- interface VirtualFile {
418
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
419
+ type BuildVariant = UnpluginBuildVariant | "tsup" | "unbuild";
420
+ type InferUnpluginVariant<TBuildVariant extends BuildVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
421
+ interface BuildConfig {
539
422
  /**
540
- * The unique identifier for the virtual file.
423
+ * The platform to build the project for
541
424
  *
542
- * @remarks
543
- * If no specific id is provided, it defaults to the file's {@link path}.
544
- */
545
- id: string;
546
- /**
547
- * Additional metadata associated with the virtual file.
425
+ * @defaultValue "neutral"
548
426
  */
549
- details: Record<string, PrimitiveJsonValue>;
427
+ platform?: "node" | "browser" | "neutral";
550
428
  /**
551
- * The variant of the file.
429
+ * Array of strings indicating the polyfills to include for the build.
552
430
  *
553
431
  * @remarks
554
- * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
555
- * - `builtin`: Indicates that the file is a built-in module provided by the system.
556
- * - `entry`: Indicates that the file is an entry point for execution.
557
- * - `normal`: Indicates that the file is a standard file without any special role.
432
+ * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
433
+ *
434
+ * @example
435
+ * ```ts
436
+ * {
437
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
438
+ * }
439
+ * ```
558
440
  */
559
- variant: string;
441
+ polyfill?: string[];
560
442
  /**
561
- * The output mode of the file.
443
+ * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
562
444
  *
563
- * @remarks
564
- * This indicates whether the file is intended to be written to the actual file system (`fs`) or kept in the virtual file system (`virtual`).
445
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
565
446
  */
566
- mode: OutputModeType;
447
+ mainFields?: string[];
567
448
  /**
568
- * A virtual (or actual) path to the file in the file system.
449
+ * Array of strings indicating what conditions should be used for module resolution.
569
450
  */
570
- path: string;
451
+ conditions?: string[];
571
452
  /**
572
- * The contents of the file.
453
+ * Array of strings indicating what file extensions should be used for module resolution.
454
+ *
455
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
573
456
  */
574
- code: string | NodeJS.ArrayBufferView;
575
- }
576
- interface VirtualFileMetadata {
457
+ extensions?: string[];
577
458
  /**
578
- * The identifier for the file data.
459
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
460
+ *
461
+ * @remarks
462
+ * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
579
463
  */
580
- id: string;
464
+ dedupe?: string[];
581
465
  /**
582
- * The variant of the file.
466
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
583
467
  */
584
- variant: string;
468
+ builtins?: (string | RegExp)[];
585
469
  /**
586
- * The output mode of the file.
470
+ * Define global variable replacements.
471
+ *
472
+ * @remarks
473
+ * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
474
+ *
475
+ * @example
476
+ * ```ts
477
+ * {
478
+ * define: {
479
+ * __VERSION__: '"1.0.0"',
480
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
481
+ * }
482
+ * }
483
+ * ```
484
+ *
485
+ * @see https://esbuild.github.io/api/#define
486
+ * @see https://vitejs.dev/config/build-options.html#define
487
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
587
488
  */
588
- mode: string;
489
+ define?: Record<string, any>;
589
490
  /**
590
- * Additional metadata associated with the file.
491
+ * Global variables that will have import statements injected where necessary
492
+ *
493
+ * @remarks
494
+ * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
495
+ *
496
+ * @example
497
+ * ```ts
498
+ * {
499
+ * inject: {
500
+ * process: 'process/browser',
501
+ * Buffer: ['buffer', 'Buffer'],
502
+ * }
503
+ * }
504
+ * ```
505
+ *
506
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
591
507
  */
592
- properties: Record<string, string>;
593
- }
594
- interface ResolveFSOptions {
595
- mode?: OutputModeType;
596
- }
597
- type MakeDirectoryOptions = (Mode | MakeDirectoryOptions$1) & ResolveFSOptions;
598
- interface PowerlinesWriteFileOptions extends ResolveFSOptions {
599
- skipFormat?: boolean;
600
- }
601
- type NodeWriteFileOptions = WriteFileOptions$1;
602
- type WriteFileOptions = NodeWriteFileOptions | PowerlinesWriteFileOptions;
603
- type PowerLinesWriteFileData = Partial<Omit<VirtualFile, "path" | "mode" | "code">> & Pick<VirtualFile, "code">;
604
- type WriteFileData = string | NodeJS.ArrayBufferView | PowerLinesWriteFileData;
605
- interface ResolvePathOptions extends ResolveFSOptions {
508
+ inject?: Record<string, string | string[]>;
606
509
  /**
607
- * Should the resolved path include the file extension?
510
+ * The alias mappings to use for module resolution during the build process.
608
511
  *
609
- * @defaultValue true
512
+ * @remarks
513
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
514
+ *
515
+ * @example
516
+ * ```ts
517
+ * {
518
+ * alias: {
519
+ * "@utils": "./src/utils",
520
+ * "@components": "./src/components"
521
+ * }
522
+ * }
523
+ * ```
524
+ *
525
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
610
526
  */
611
- withExtension?: boolean;
527
+ alias?: Record<string, string> | Array<{
528
+ find: string | RegExp;
529
+ replacement: string;
530
+ }>;
612
531
  /**
613
- * The paths to search for the file.
532
+ * A list of modules that should not be bundled, even if they are external dependencies.
533
+ *
534
+ * @remarks
535
+ * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
614
536
  */
615
- paths?: string[];
537
+ external?: (string | RegExp)[];
616
538
  /**
617
- * The type of the path to resolve.
539
+ * A list of modules that should always be bundled, even if they are external dependencies.
618
540
  */
619
- type?: "file" | "directory";
620
- }
621
- interface VirtualFileSystemInterface {
541
+ noExternal?: (string | RegExp)[];
622
542
  /**
623
- * Patches the File System to include the virtual file system (VFS) contents.
543
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
624
544
  */
625
- [__VFS_PATCH__]: () => void;
545
+ skipNodeModulesBundle?: boolean;
626
546
  /**
627
- * Reverts the virtual file system (VFS) to its previous state.
547
+ * An optional set of override options to apply to the selected build variant.
548
+ *
549
+ * @remarks
550
+ * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
628
551
  */
629
- [__VFS_REVERT__]: () => void;
552
+ override?: Record<string, any>;
553
+ }
554
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
555
+ type ESBuildBuildConfig = Omit<BuildOptions, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
556
+ type ESBuildResolvedBuildConfig = Omit<BuildOptions, "inject"> & BuildResolvedConfig;
557
+ type ViteBuildConfig = Omit<UserConfig$1, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig;
558
+ type ViteResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
559
+ type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
560
+ type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
561
+ type RspackBuildConfig = Omit<Configuration$1, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
562
+ type RspackResolvedBuildConfig = Configuration$1 & BuildResolvedConfig;
563
+ type RollupBuildOutputConfig = Omit<OutputOptions, "dir" | "format">;
564
+ type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "output" | "logLevel"> & {
565
+ output: RollupBuildOutputConfig | RollupBuildOutputConfig[];
566
+ } & BuildConfig;
567
+ type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
568
+ type RolldownBuildOutputConfig = Omit<RolldownOutput, "dir" | "format">;
569
+ type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & {
570
+ output: RolldownBuildOutputConfig | RolldownBuildOutputConfig[];
571
+ } & BuildConfig;
572
+ type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
573
+ type TsupBuildConfig = Partial<Omit<BuildOptions$1, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
574
+ type TsupResolvedBuildConfig = BuildOptions$1 & BuildResolvedConfig;
575
+ type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
576
+ type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
577
+ type FarmBuildConfig = Partial<Omit<UserConfig$2, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
578
+ type FarmResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
579
+
580
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
581
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
582
+
583
+ interface ResolvedEntryTypeDefinition extends TypeDefinition {
630
584
  /**
631
- * The underlying file metadata.
585
+ * The user provided entry point in the source code
632
586
  */
633
- metadata: Record<string, VirtualFileMetadata | undefined>;
587
+ input: TypeDefinition;
634
588
  /**
635
- * A map of module ids to their file paths.
589
+ * An optional name to use in the package export during the build process
636
590
  */
637
- ids: Record<string, string>;
591
+ output?: string;
592
+ }
593
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
638
594
  /**
639
- * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
640
- *
641
- * @param pathOrId - The path or id to check.
642
- * @param options - Optional parameters for resolving the path.
643
- * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
595
+ * The name of the environment
644
596
  */
645
- isVirtual: (pathOrId: string, options?: ResolvePathOptions) => boolean;
597
+ name: string;
646
598
  /**
647
- * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
648
- *
649
- * @param pathOrId - The path or id to check.
650
- * @param options - Optional parameters for resolving the path.
651
- * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
599
+ * Configuration options for the preview server
652
600
  */
653
- isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
601
+ preview?: ResolvedPreviewOptions;
602
+ };
603
+ type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
604
+ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
605
+ assets: ResolvedAssetGlob[];
606
+ }>;
607
+ /**
608
+ * The resolved options for the Powerlines project configuration.
609
+ */
610
+ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework">> & {
654
611
  /**
655
- * Checks if a file exists in the virtual file system (VFS).
656
- *
657
- * @param path - The path of the file to check.
658
- * @returns `true` if the file exists, otherwise `false`.
612
+ * The configuration options that were provided inline to the Powerlines CLI.
659
613
  */
660
- isFile: (path: string) => boolean;
614
+ inlineConfig: InlineConfig<TUserConfig>;
661
615
  /**
662
- * Checks if a directory exists in the virtual file system (VFS).
663
- *
664
- * @param path - The path of the directory to check.
665
- * @returns `true` if the directory exists, otherwise `false`.
616
+ * The original configuration options that were provided by the user to the Powerlines process.
666
617
  */
667
- isDirectory: (path: string) => boolean;
618
+ userConfig: TUserConfig;
668
619
  /**
669
- * Checks if a file exists in the virtual file system (VFS).
670
- *
671
- * @param pathOrId - The path or id of the file.
672
- * @returns `true` if the file exists, otherwise `false`.
620
+ * A string identifier for the Powerlines command being executed.
673
621
  */
674
- existsSync: (pathOrId: string) => boolean;
622
+ command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
675
623
  /**
676
- * Gets the metadata of a file in the virtual file system (VFS).
624
+ * The root directory of the project's source code
677
625
  *
678
- * @param pathOrId - The path or id of the file.
679
- * @returns The metadata of the file if it exists, otherwise undefined.
626
+ * @defaultValue "\{projectRoot\}/src"
680
627
  */
681
- getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
628
+ sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
682
629
  /**
683
- * Gets the stats of a file in the virtual file system (VFS).
684
- *
685
- * @param pathOrId - The path or id of the file.
686
- * @param options - Optional parameters for getting the stats.
687
- * @returns The stats of the file if it exists, otherwise undefined.
630
+ * The root directory of the project.
688
631
  */
689
- lstat: (pathOrId: string, options?: StatSyncOptions & {
690
- bigint?: false | undefined;
691
- throwIfNoEntry: false;
692
- }) => Promise<Stats>;
632
+ projectRoot: NonUndefined<TUserConfig["root"]>;
693
633
  /**
694
- * Gets the stats of a file in the virtual file system (VFS).
695
- *
696
- * @param pathOrId - The path or id of the file.
697
- * @param options - Optional parameters for getting the stats.
698
- * @returns The stats of the file if it exists, otherwise undefined.
634
+ * The type of project being built.
699
635
  */
700
- lstatSync: (pathOrId: string, options?: StatSyncOptions & {
701
- bigint?: false | undefined;
702
- throwIfNoEntry: false;
703
- }) => Stats | undefined;
636
+ projectType: NonUndefined<TUserConfig["type"]>;
704
637
  /**
705
- * Gets the stats of a file in the virtual file system (VFS).
706
- *
707
- * @param pathOrId - The path or id of the file.
708
- * @returns The stats of the file if it exists, otherwise false.
638
+ * The output configuration options to use for the build process
709
639
  */
710
- stat: (pathOrId: string, options?: StatSyncOptions & {
711
- bigint?: false | undefined;
712
- throwIfNoEntry: false;
713
- }) => Promise<Stats>;
640
+ output: OutputResolvedConfig;
714
641
  /**
715
- * Gets the stats of a file in the virtual file system (VFS).
642
+ * Configuration provided to build processes
716
643
  *
717
- * @param pathOrId - The path or id of the file.
718
- * @returns The stats of the file if it exists, otherwise false.
644
+ * @remarks
645
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
719
646
  */
720
- statSync: (pathOrId: string, options?: StatSyncOptions & {
721
- bigint?: false | undefined;
722
- throwIfNoEntry: false;
723
- }) => Stats | undefined;
647
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
724
648
  /**
725
- * Lists files in a given path.
649
+ * The log level to use for the Powerlines processes.
726
650
  *
727
- * @param path - The path to list files from.
728
- * @param options - Options for listing files, such as encoding and recursion.
729
- * @returns An array of file names in the specified path.
651
+ * @defaultValue "info"
730
652
  */
731
- readdirSync: (path: string, options?: {
732
- encoding: BufferEncoding | null;
733
- withFileTypes?: false | undefined;
734
- recursive?: boolean | undefined;
735
- } | BufferEncoding) => string[];
653
+ logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
654
+ };
655
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
656
+ type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
657
+ type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
658
+ type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
659
+ type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
660
+ type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
661
+ type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
662
+ type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
663
+ type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
664
+ type InferResolvedConfig<TBuildVariant extends BuildVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
665
+
666
+ interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
736
667
  /**
737
- * Lists files in a given path.
738
- *
739
- * @param path - The path to list files from.
740
- * @param options - Options for listing files, such as encoding and recursion.
741
- * @returns An array of file names in the specified path.
668
+ * The order in which the plugin should be applied.
742
669
  */
743
- readdir: (path: string, options?: {
744
- encoding: BufferEncoding | null;
745
- withFileTypes?: false | undefined;
746
- recursive?: boolean | undefined;
747
- } | BufferEncoding) => Promise<string[]>;
670
+ order?: "pre" | "post" | null | undefined;
748
671
  /**
749
- * Removes a file or symbolic link in the virtual file system (VFS).
750
- *
751
- * @param path - The path to the file to remove.
752
- * @returns A promise that resolves when the file is removed.
672
+ * A filter to determine when the hook should be called.
753
673
  */
754
- unlinkSync: (path: PathLike, options?: ResolveFSOptions) => void;
674
+ filter?: Pick<HookFilter, TFilter>;
755
675
  /**
756
- * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
757
- *
758
- * @param path - The path to the file to remove.
759
- * @returns A promise that resolves when the file is removed.
676
+ * The hook function to be called.
760
677
  */
761
- unlink: (path: string, options?: ResolveFSOptions) => Promise<void>;
678
+ handler: THookFunction;
679
+ }
680
+ type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
681
+ /**
682
+ * A result returned by the plugin from the `generateTypes` hook that describes the declaration types output file.
683
+ */
684
+ interface GenerateTypesResult {
685
+ directives?: string[];
686
+ code: string;
687
+ }
688
+ type DeepPartial<T> = {
689
+ [K in keyof T]?: DeepPartial<T[K]>;
690
+ };
691
+ type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
692
+ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
762
693
  /**
763
- * Removes a directory in the virtual file system (VFS).
694
+ * A function that returns configuration options to be merged with the build context's options.
695
+ *
696
+ * @remarks
697
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
698
+ *
699
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
764
700
  *
765
- * @param path - The path to create the directory at.
766
- * @param options - Options for creating the directory.
701
+ * @see https://vitejs.dev/guide/api-plugin#config
702
+ *
703
+ * @param this - The build context.
704
+ * @param config - The partial configuration object to be modified.
705
+ * @returns A promise that resolves to a partial configuration object.
767
706
  */
768
- rmdirSync: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => any;
707
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
769
708
  /**
770
- * Removes a directory in the virtual file system (VFS).
709
+ * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
771
710
  *
772
- * @param path - The path to create the directory at.
773
- * @param options - Options for creating the directory.
774
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
711
+ * @remarks
712
+ * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
713
+ *
714
+ * @see https://vitejs.dev/guide/api-plugin#configenvironment
715
+ *
716
+ * @param this - The build context.
717
+ * @param name - The name of the environment being configured.
718
+ * @param environment - The Vite-like environment object containing information about the current build environment.
719
+ * @returns A promise that resolves when the hook is complete.
775
720
  */
776
- rmdir: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
721
+ configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
777
722
  /**
778
- * Removes a file or directory in the virtual file system (VFS).
723
+ * A hook that is called when the plugin is resolved.
779
724
  *
780
- * @param path - The path to the file or directory to remove.
781
- * @param options - Options for removing the file or directory.
782
- * @returns A promise that resolves when the file or directory is removed.
725
+ * @see https://vitejs.dev/guide/api-plugin#configresolved
726
+ *
727
+ * @param this - The build context.
728
+ * @returns A promise that resolves when the hook is complete.
783
729
  */
784
- rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;
730
+ configResolved: (this: TContext) => MaybePromise<void>;
785
731
  /**
786
- * Synchronously removes a file or directory in the virtual file system (VFS).
732
+ * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
787
733
  *
788
- * @param path - The path to the file or directory to remove.
789
- * @param options - Options for removing the file or directory.
734
+ * @param this - The build context.
735
+ * @param code - The source code to generate types for.
736
+ * @returns A promise that resolves when the hook is complete.
790
737
  */
791
- rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;
738
+ generateTypes: (this: TContext, code: string) => MaybePromise<GenerateTypesResult | string | undefined | null>;
792
739
  /**
793
- * Creates a directory in the virtual file system (VFS).
740
+ * A hook that is called at the start of the build process.
794
741
  *
795
- * @param path - The path to create the directory at.
796
- * @param options - Options for creating the directory.
797
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
742
+ * @param this - The build context and unplugin build context.
743
+ * @returns A promise that resolves when the hook is complete.
798
744
  */
799
- mkdirSync: (path: PathLike, options?: MakeDirectoryOptions) => string | undefined;
745
+ buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
800
746
  /**
801
- * Creates a directory in the virtual file system (VFS).
747
+ * A hook that is called at the end of the build process.
802
748
  *
803
- * @param path - The path to create the directory at.
804
- * @param options - Options for creating the directory.
805
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
749
+ * @param this - The build context and unplugin build context.
750
+ * @returns A promise that resolves when the hook is complete.
806
751
  */
807
- mkdir: (path: PathLike, options?: MakeDirectoryOptions) => Promise<string | undefined>;
752
+ buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
808
753
  /**
809
- * Reads a file from the virtual file system (VFS).
754
+ * A hook that is called to transform the source code.
810
755
  *
811
- * @param pathOrId - The path or id of the file.
812
- * @returns The contents of the file if it exists, otherwise undefined.
756
+ * @param this - The build context, unplugin build context, and unplugin context.
757
+ * @param code - The source code to transform.
758
+ * @param id - The identifier of the source code.
759
+ * @returns A promise that resolves when the hook is complete.
813
760
  */
814
- readFile: (pathOrId: string) => Promise<string | undefined>;
761
+ transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>;
815
762
  /**
816
- * Reads a file from the virtual file system (VFS).
763
+ * A hook that is called to load the source code.
817
764
  *
818
- * @param pathOrId - The path or id of the file.
765
+ * @param this - The build context, unplugin build context, and unplugin context.
766
+ * @param id - The identifier of the source code.
767
+ * @returns A promise that resolves when the hook is complete.
819
768
  */
820
- readFileSync: (pathOrId: string) => string | undefined;
769
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>;
821
770
  /**
822
- * Writes a file to the virtual file system (VFS).
771
+ * A hook that is called to resolve the identifier of the source code.
823
772
  *
824
- * @param path - The path to the file.
825
- * @param data - The contents of the file.
826
- * @param options - Optional parameters for writing the file.
827
- * @returns A promise that resolves when the file is written.
773
+ * @param this - The build context, unplugin build context, and unplugin context.
774
+ * @param id - The identifier of the source code.
775
+ * @param importer - The importer of the source code.
776
+ * @param options - The options for resolving the identifier.
777
+ * @returns A promise that resolves when the hook is complete.
828
778
  */
829
- writeFile: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => Promise<void>;
779
+ resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
780
+ isEntry: boolean;
781
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>;
830
782
  /**
831
- * Writes a file to the virtual file system (VFS).
783
+ * A hook that is called to write the bundle to disk.
832
784
  *
833
- * @param path - The path to the file.
834
- * @param data - The contents of the file.
835
- * @param options - Optional parameters for writing the file.
785
+ * @param this - The build context.
786
+ * @returns A promise that resolves when the hook is complete.
836
787
  */
837
- writeFileSync: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => void;
788
+ writeBundle: (this: TContext) => MaybePromise<void>;
789
+ }
790
+ type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant] = Required<UnpluginOptions>[TBuildVariant]> = {
791
+ [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey];
792
+ };
793
+ type ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuildVariant = UnpluginBuildVariant> = {
794
+ [TKey in keyof BuildPlugin<TContext, TBuildVariant> & string as `${TBuildVariant}:${TKey}`]: BuildPlugin<TContext, TBuildVariant>[TKey];
795
+ };
796
+ type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
797
+ type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
798
+ type PluginHooks<TContext extends PluginContext = PluginContext> = {
799
+ [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]>;
800
+ } & {
838
801
  /**
839
- * Moves a file from one path to another in the virtual file system (VFS).
802
+ * A function that returns configuration options to be merged with the build context's options.
840
803
  *
841
- * @param srcPath - The source path to move
842
- * @param destPath - The destination path to move to
804
+ * @remarks
805
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
806
+ *
807
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
808
+ *
809
+ * @see https://vitejs.dev/guide/api-plugin#config
810
+ *
811
+ * @param this - The build context.
812
+ * @param config - The partial configuration object to be modified.
813
+ * @returns A promise that resolves to a partial configuration object.
843
814
  */
844
- move: (srcPath: string, destPath: string) => Promise<void>;
815
+ config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
845
816
  /**
846
- * Synchronously moves a file from one path to another in the virtual file system (VFS).
817
+ * A hook that is called to transform the source code.
847
818
  *
848
- * @param srcPath - The source path to move
849
- * @param destPath - The destination path to move to
819
+ * @param this - The build context, unplugin build context, and unplugin context.
820
+ * @param code - The source code to transform.
821
+ * @param id - The identifier of the source code.
822
+ * @returns A promise that resolves when the hook is complete.
850
823
  */
851
- moveSync: (srcPath: string, destPath: string) => void;
824
+ transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>, "code" | "id">;
852
825
  /**
853
- * Copies a file from one path to another in the virtual file system (VFS).
826
+ * A hook that is called to load the source code.
854
827
  *
855
- * @param srcPath - The source path to copy
856
- * @param destPath - The destination path to copy to
828
+ * @param this - The build context, unplugin build context, and unplugin context.
829
+ * @param id - The identifier of the source code.
830
+ * @returns A promise that resolves when the hook is complete.
857
831
  */
858
- copy: (srcPath: string, destPath: string) => Promise<void>;
832
+ load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>, "id">;
859
833
  /**
860
- * Synchronously copies a file from one path to another in the virtual file system (VFS).
834
+ * A hook that is called to resolve the identifier of the source code.
861
835
  *
862
- * @param srcPath - The source path to copy
863
- * @param destPath - The destination path to copy to
836
+ * @param this - The build context, unplugin build context, and unplugin context.
837
+ * @param id - The identifier of the source code.
838
+ * @param importer - The importer of the source code.
839
+ * @param options - The options for resolving the identifier.
840
+ * @returns A promise that resolves when the hook is complete.
864
841
  */
865
- copySync: (srcPath: string, destPath: string) => void;
842
+ resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
843
+ isEntry: boolean;
844
+ }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
866
845
  /**
867
- * Glob files in the virtual file system (VFS) based on the provided pattern(s).
846
+ * An API object that can be used for inter-plugin communication.
868
847
  *
869
- * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
870
- * @returns An array of file paths matching the provided pattern(s)
848
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
871
849
  */
872
- glob: (pattern: string | string[]) => Promise<string[]>;
850
+ api?: Record<string, any>;
851
+ };
852
+ type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = {
853
+ [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant>;
854
+ };
855
+ interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
873
856
  /**
874
- * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
875
- *
876
- * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
877
- * @returns An array of file paths matching the provided pattern(s)
857
+ * The name of the plugin, for use in deduplication, error messages and logs.
878
858
  */
879
- globSync: (pattern: string | string[]) => string[];
859
+ name: string;
880
860
  /**
881
- * Resolves a path or id to a file path in the virtual file system.
861
+ * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
882
862
  *
883
- * @param pathOrId - The path or id of the file to resolve.
884
- * @param options - Optional parameters for resolving the path.
885
- * @returns The resolved path of the file if it exists, otherwise false.
863
+ * @remarks
864
+ * The Plugin invocation order is as follows:
865
+ * - `enforce: 'pre'` plugins
866
+ * - `order: 'pre'` plugin hooks
867
+ * - any other plugins (normal)
868
+ * - `order: 'post'` plugin hooks
869
+ * - `enforce: 'post'` plugins
870
+ *
871
+ * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
872
+ * @see https://rollupjs.org/plugin-development/#build-hooks
873
+ * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
874
+ * @see https://esbuild.github.io/plugins/#concepts
886
875
  */
887
- resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
876
+ enforce?: "pre" | "post";
888
877
  /**
889
- * Formats a path to match the virtual file system (VFS) structure.
878
+ * A function to determine if two plugins are the same and can be de-duplicated.
890
879
  *
891
- * @param path - The path to format.
892
- * @returns The formatted path.
880
+ * @remarks
881
+ * If this is not provided, plugins are de-duplicated by comparing their names.
882
+ *
883
+ * @param other - The other plugin to compare against.
884
+ * @returns `true` if the two plugins are the same, `false` otherwise.
893
885
  */
894
- formatPath: (path: string) => string;
886
+ dedupe?: false | ((other: Plugin<any>) => boolean);
895
887
  /**
896
- * Resolves a path or id to a file path in the virtual file system.
897
- *
898
- * @param pathOrId - The path or id of the file to resolve.
899
- * @returns The resolved path of the file if it exists, otherwise false.
888
+ * A list of pre-requisite plugins that must be loaded before this plugin can be used.
900
889
  */
901
- realpathSync: (pathOrId: string) => string;
890
+ dependsOn?: PluginConfig<any>[];
902
891
  /**
903
- * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
892
+ * Define environments where this plugin should be active. By default, the plugin is active in all environments.
893
+ *
894
+ * @param environment - The environment to check.
895
+ * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
904
896
  */
905
- dispose: () => Promise<void>;
897
+ applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | Plugin<any>>;
898
+ }
899
+
900
+ type BaseHooks<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext>;
901
+ type BaseHookKeys<TContext extends PluginContext = PluginContext> = keyof BaseHooks<TContext>;
902
+ type ExternalHooks<TContext extends PluginContext = PluginContext> = ExternalPluginHookFunctions<TContext>;
903
+ type ExternalHookKeys<TContext extends PluginContext = PluginContext> = keyof ExternalHooks<TContext>;
904
+ type Hooks<TContext extends PluginContext = PluginContext> = PluginHookFunctions<TContext>;
905
+ type HookKeys<TContext extends PluginContext = PluginContext> = keyof Hooks<TContext>;
906
+ interface BaseHooksListItem<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> extends PluginHookObject<BaseHooks<TContext>[TKey]> {
907
+ plugin: Plugin<TContext>;
908
+ }
909
+ interface BaseHooksList<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> {
910
+ preOrdered?: BaseHooksListItem<TContext, TKey>[];
911
+ preEnforced?: BaseHooksListItem<TContext, TKey>[];
912
+ normal?: BaseHooksListItem<TContext, TKey>[];
913
+ postEnforced?: BaseHooksListItem<TContext, TKey>[];
914
+ postOrdered?: BaseHooksListItem<TContext, TKey>[];
915
+ }
916
+ interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
917
+ plugin: Plugin<TContext>;
918
+ handler: ExternalHooks<TContext>[TKey];
906
919
  }
920
+ type HooksList<TContext extends PluginContext = PluginContext> = {
921
+ [TKey in BaseHookKeys<TContext>]?: BaseHooksList<TContext, TKey>;
922
+ } & {
923
+ [TKey in ExternalHookKeys<TContext>]?: ExternalHooksListItem<TContext, TKey>[];
924
+ };
925
+ type InferHookHandler<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Hooks<TContext>[TKey];
926
+ type InferHookReturnType<TContext extends PluginContext, TKey extends HookKeys<TContext>> = ReturnType<InferHookHandler<TContext, TKey>> extends Promise<infer U> ? U extends Promise<infer V> ? V : U : ReturnType<InferHookHandler<TContext, TKey>>;
927
+ type InferHookParameters<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Parameters<InferHookHandler<TContext, TKey>>;
907
928
 
908
929
  type WorkerProcess<TExposedMethods extends ReadonlyArray<string>> = {
909
930
  [K in TExposedMethods[number]]: (data: any) => Promise<any>;
@@ -1114,7 +1135,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
1114
1135
  * @param path - An optional path to write the builtin file to
1115
1136
  * @param options - Options for writing the file
1116
1137
  */
1117
- writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1138
+ emitBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1118
1139
  /**
1119
1140
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1120
1141
  *
@@ -1122,11 +1143,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
1122
1143
  * @param path - An optional path to write the entry file to
1123
1144
  * @param options - Options for writing the file
1124
1145
  */
1125
- writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1126
- /**
1127
- * Parses the source code and returns a {@link ParseResult} object.
1128
- */
1129
- parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
1146
+ emitEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1130
1147
  /**
1131
1148
  * A function to update the context fields using a new user configuration options
1132
1149
  */
@@ -1634,4 +1651,4 @@ type DeployInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineCon
1634
1651
  command: "deploy";
1635
1652
  };
1636
1653
 
1637
- export { type APIContext as A, type BuildVariant as B, type Context as C, type PrepareInlineConfig as D, type ESBuildResolvedBuildConfig as E, type CleanInlineConfig as F, type BuildInlineConfig as G, type HookKeys as H, type InferHookParameters as I, type LintInlineConfig as J, type DocsInlineConfig as K, type LogFn as L, type MakeDirectoryOptions as M, type NewInlineConfig as N, type DeployInlineConfig as O, type PowerlinesCommand as P, type ResolvePathOptions as R, type SelectHooksOptions as S, type TsupBuildConfig as T, type UnbuildBuildConfig as U, type VirtualFileSystemInterface as V, type WriteFileData as W, __VFS_PATCH__ as _, type VirtualFileMetadata as a, type ResolveFSOptions as b, type WriteFileOptions as c, __VFS_REVERT__ as d, type WorkspaceConfig as e, type ParsedUserConfig as f, type ResolvedEntryTypeDefinition as g, type RolldownResolvedBuildConfig as h, type RollupResolvedBuildConfig as i, type TsupResolvedBuildConfig as j, type ViteResolvedBuildConfig as k, type PluginContext as l, type SourceFile as m, type MetaInfo as n, type TransformResult as o, type WorkerProcess as p, type ResolvedConfig as q, type EnvironmentContext as r, type InferHookReturnType as s, type UnbuildResolvedBuildConfig as t, type InferUnpluginVariant as u, type BuildPlugin as v, type InferResolvedConfig as w, type UnpluginBuildVariant as x, type InferUserConfig as y, type InitialUserConfig as z };
1654
+ export { type InferResolvedConfig as $, type APIContext as A, type InferHookReturnType as B, type Context as C, type SourceFile as D, type ESBuildResolvedBuildConfig as E, type TransformResult as F, type WorkerProcess as G, type HooksList as H, type InitialUserConfig as I, type PrepareInlineConfig as J, type CleanInlineConfig as K, type LogFn as L, type MakeDirectoryOptions as M, type NewInlineConfig as N, type BuildInlineConfig as O, type PowerlinesCommand as P, type LintInlineConfig as Q, type ResolvePathOptions as R, type SelectHooksOptions as S, type TsupBuildConfig as T, type UnbuildBuildConfig as U, type VirtualFileSystemInterface as V, type WriteFileData as W, type DocsInlineConfig as X, type DeployInlineConfig as Y, type UnpluginBuildVariant as Z, __VFS_PATCH__ as _, type VirtualFileMetadata as a, type InferUnpluginVariant as a0, type BuildPlugin as a1, type InferUserConfig as a2, type ResolveFSOptions as b, type WriteFileOptions as c, __VFS_REVERT__ as d, type WorkspaceConfig as e, type ParsedUserConfig as f, type ResolvedEntryTypeDefinition as g, type RolldownResolvedBuildConfig as h, type RollupResolvedBuildConfig as i, type TsupResolvedBuildConfig as j, type UnbuildResolvedBuildConfig as k, type ViteResolvedBuildConfig as l, type ResolvedConfig as m, type EnvironmentContext as n, type Plugin as o, type PluginContext as p, type EnvironmentResolvedConfig as q, type EnvironmentContextPlugin as r, type HookKeys as s, type InferHookHandler as t, type MetaInfo as u, type Resolver as v, type VirtualFile as w, type PowerlinesWriteFileOptions as x, type InitContextOptions as y, type InferHookParameters as z };