@bemedev/dev-utils 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/README.md +34 -0
  2. package/lib/_virtual/_rolldown/runtime.cjs +1 -1
  3. package/lib/build-tests/addTarball.cjs +5 -1
  4. package/lib/build-tests/addTarball.cjs.map +1 -1
  5. package/lib/build-tests/addTarball.d.ts +3 -0
  6. package/lib/build-tests/addTarball.js +5 -1
  7. package/lib/build-tests/addTarball.js.map +1 -1
  8. package/lib/build-tests/buildPackageJson.cjs +17 -9
  9. package/lib/build-tests/buildPackageJson.cjs.map +1 -1
  10. package/lib/build-tests/buildPackageJson.d.ts +5 -0
  11. package/lib/build-tests/buildPackageJson.js +17 -9
  12. package/lib/build-tests/buildPackageJson.js.map +1 -1
  13. package/lib/build-tests/cleanup.cjs +3 -0
  14. package/lib/build-tests/cleanup.cjs.map +1 -1
  15. package/lib/build-tests/cleanup.d.ts +3 -0
  16. package/lib/build-tests/cleanup.js +3 -0
  17. package/lib/build-tests/cleanup.js.map +1 -1
  18. package/lib/build-tests/cli/cli.cjs +6 -0
  19. package/lib/build-tests/cli/cli.cjs.map +1 -1
  20. package/lib/build-tests/cli/cli.d.ts +6 -0
  21. package/lib/build-tests/cli/cli.js +6 -0
  22. package/lib/build-tests/cli/cli.js.map +1 -1
  23. package/lib/build-tests/cli/index.cjs.map +1 -1
  24. package/lib/build-tests/cli/post.cjs +3 -0
  25. package/lib/build-tests/cli/post.cjs.map +1 -1
  26. package/lib/build-tests/cli/post.d.ts +3 -0
  27. package/lib/build-tests/cli/post.js +3 -0
  28. package/lib/build-tests/cli/post.js.map +1 -1
  29. package/lib/build-tests/cli/pre.cjs +3 -0
  30. package/lib/build-tests/cli/pre.cjs.map +1 -1
  31. package/lib/build-tests/cli/pre.d.ts +3 -0
  32. package/lib/build-tests/cli/pre.js +3 -0
  33. package/lib/build-tests/cli/pre.js.map +1 -1
  34. package/lib/build-tests/cli/test.cjs +3 -0
  35. package/lib/build-tests/cli/test.cjs.map +1 -1
  36. package/lib/build-tests/cli/test.d.ts +3 -0
  37. package/lib/build-tests/cli/test.js +3 -0
  38. package/lib/build-tests/cli/test.js.map +1 -1
  39. package/lib/build-tests/constants.cjs +42 -0
  40. package/lib/build-tests/constants.cjs.map +1 -1
  41. package/lib/build-tests/constants.d.ts +42 -0
  42. package/lib/build-tests/constants.js +42 -0
  43. package/lib/build-tests/constants.js.map +1 -1
  44. package/lib/build-tests/getRelativePath.cjs +7 -0
  45. package/lib/build-tests/getRelativePath.cjs.map +1 -1
  46. package/lib/build-tests/getRelativePath.d.ts +7 -0
  47. package/lib/build-tests/getRelativePath.js +7 -0
  48. package/lib/build-tests/getRelativePath.js.map +1 -1
  49. package/lib/build-tests/getTypescriptOutdir.cjs +5 -0
  50. package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
  51. package/lib/build-tests/getTypescriptOutdir.d.ts +5 -0
  52. package/lib/build-tests/getTypescriptOutdir.js +5 -0
  53. package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
  54. package/lib/build-tests/import.cjs +9 -0
  55. package/lib/build-tests/import.cjs.map +1 -1
  56. package/lib/build-tests/import.d.ts +9 -0
  57. package/lib/build-tests/import.js +9 -0
  58. package/lib/build-tests/import.js.map +1 -1
  59. package/lib/build-tests/imports/create.cjs +7 -0
  60. package/lib/build-tests/imports/create.cjs.map +1 -1
  61. package/lib/build-tests/imports/create.d.ts +13 -0
  62. package/lib/build-tests/imports/create.js +7 -0
  63. package/lib/build-tests/imports/create.js.map +1 -1
  64. package/lib/build-tests/imports/helper.cjs +9 -0
  65. package/lib/build-tests/imports/helper.cjs.map +1 -1
  66. package/lib/build-tests/imports/helper.d.ts +12 -0
  67. package/lib/build-tests/imports/helper.js +9 -0
  68. package/lib/build-tests/imports/helper.js.map +1 -1
  69. package/lib/build-tests/pack.cjs +7 -1
  70. package/lib/build-tests/pack.cjs.map +1 -1
  71. package/lib/build-tests/pack.d.ts +5 -0
  72. package/lib/build-tests/pack.js +7 -1
  73. package/lib/build-tests/pack.js.map +1 -1
  74. package/lib/plugins/index.cjs +3 -0
  75. package/lib/plugins/index.d.ts +1 -0
  76. package/lib/plugins/index.js +2 -0
  77. package/lib/plugins/suppressWarnings.cjs +37 -0
  78. package/lib/plugins/suppressWarnings.cjs.map +1 -0
  79. package/lib/plugins/suppressWarnings.d.ts +12 -0
  80. package/lib/plugins/suppressWarnings.js +36 -0
  81. package/lib/plugins/suppressWarnings.js.map +1 -0
  82. package/lib/rolldown-config/config.cjs +13 -5
  83. package/lib/rolldown-config/config.cjs.map +1 -1
  84. package/lib/rolldown-config/config.d.ts +7 -0
  85. package/lib/rolldown-config/config.js +13 -5
  86. package/lib/rolldown-config/config.js.map +1 -1
  87. package/lib/rolldown-config/constants.cjs +15 -0
  88. package/lib/rolldown-config/constants.cjs.map +1 -1
  89. package/lib/rolldown-config/constants.d.ts +15 -0
  90. package/lib/rolldown-config/constants.js +15 -0
  91. package/lib/rolldown-config/constants.js.map +1 -1
  92. package/lib/rolldown-config/helpers.cjs +16 -1
  93. package/lib/rolldown-config/helpers.cjs.map +1 -1
  94. package/lib/rolldown-config/helpers.d.ts +14 -0
  95. package/lib/rolldown-config/helpers.js +16 -1
  96. package/lib/rolldown-config/helpers.js.map +1 -1
  97. package/lib/rolldown-config/input.cjs +8 -0
  98. package/lib/rolldown-config/input.cjs.map +1 -1
  99. package/lib/rolldown-config/input.d.ts +8 -0
  100. package/lib/rolldown-config/input.js +8 -0
  101. package/lib/rolldown-config/input.js.map +1 -1
  102. package/lib/rolldown-config/output.cjs +8 -0
  103. package/lib/rolldown-config/output.cjs.map +1 -1
  104. package/lib/rolldown-config/output.d.ts +8 -0
  105. package/lib/rolldown-config/output.js +8 -0
  106. package/lib/rolldown-config/output.js.map +1 -1
  107. package/lib/rolldown-config/plugins/circulars.cjs +4 -4
  108. package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
  109. package/lib/rolldown-config/plugins/circulars.d.ts +7 -4
  110. package/lib/rolldown-config/plugins/circulars.js +4 -4
  111. package/lib/rolldown-config/plugins/circulars.js.map +1 -1
  112. package/lib/rolldown-config/plugins/clean.cjs +10 -1
  113. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  114. package/lib/rolldown-config/plugins/clean.d.ts +10 -0
  115. package/lib/rolldown-config/plugins/clean.js +10 -1
  116. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  117. package/lib/rolldown-config/plugins/externals.cjs +4 -3
  118. package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
  119. package/lib/rolldown-config/plugins/externals.d.ts +7 -3
  120. package/lib/rolldown-config/plugins/externals.js +4 -3
  121. package/lib/rolldown-config/plugins/externals.js.map +1 -1
  122. package/lib/rolldown-config/plugins/index.cjs +6 -0
  123. package/lib/rolldown-config/plugins/index.cjs.map +1 -1
  124. package/lib/rolldown-config/plugins/index.d.ts +6 -0
  125. package/lib/rolldown-config/plugins/index.js +6 -0
  126. package/lib/rolldown-config/plugins/index.js.map +1 -1
  127. package/lib/rolldown-config/plugins/typescript.cjs +7 -0
  128. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  129. package/lib/rolldown-config/plugins/typescript.config.cjs +15 -0
  130. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  131. package/lib/rolldown-config/plugins/typescript.config.d.ts +15 -0
  132. package/lib/rolldown-config/plugins/typescript.config.js +15 -0
  133. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  134. package/lib/rolldown-config/plugins/typescript.d.ts +10 -0
  135. package/lib/rolldown-config/plugins/typescript.fast.cjs +9 -1
  136. package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
  137. package/lib/rolldown-config/plugins/typescript.fast.d.ts +10 -0
  138. package/lib/rolldown-config/plugins/typescript.fast.js +9 -1
  139. package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
  140. package/lib/rolldown-config/plugins/typescript.js +7 -0
  141. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  142. package/lib/rolldown-config/types.d.ts +18 -0
  143. package/lib/utils/array.cjs +7 -0
  144. package/lib/utils/array.cjs.map +1 -1
  145. package/lib/utils/array.d.ts +8 -0
  146. package/lib/utils/array.js +7 -0
  147. package/lib/utils/array.js.map +1 -1
  148. package/lib/utils/bemedev/globals/types.d.ts +20 -0
  149. package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
  150. package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
  151. package/lib/utils/bemedev/globals/utils/expandFn.d.ts +11 -0
  152. package/lib/utils/bemedev/globals/utils/expandFn.js +11 -0
  153. package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
  154. package/lib/utils/identity.cjs +9 -0
  155. package/lib/utils/identity.cjs.map +1 -1
  156. package/lib/utils/identity.d.ts +9 -0
  157. package/lib/utils/identity.js +9 -0
  158. package/lib/utils/identity.js.map +1 -1
  159. package/lib/utils/sleep.cjs +7 -0
  160. package/lib/utils/sleep.cjs.map +1 -1
  161. package/lib/utils/sleep.d.ts +7 -0
  162. package/lib/utils/sleep.js +7 -0
  163. package/lib/utils/sleep.js.map +1 -1
  164. package/lib/utils/types.d.ts +9 -0
  165. package/lib/vitest-exclude/constants.cjs +3 -0
  166. package/lib/vitest-exclude/constants.cjs.map +1 -1
  167. package/lib/vitest-exclude/constants.d.ts +3 -0
  168. package/lib/vitest-exclude/constants.js +3 -0
  169. package/lib/vitest-exclude/constants.js.map +1 -1
  170. package/lib/vitest-exclude/types.d.ts +11 -0
  171. package/lib/vitest-exclude/vitest.cjs +25 -12
  172. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  173. package/lib/vitest-exclude/vitest.d.ts +9 -8
  174. package/lib/vitest-exclude/vitest.js +25 -12
  175. package/lib/vitest-exclude/vitest.js.map +1 -1
  176. package/lib/vitest-exclude/vitest.utils.cjs +30 -0
  177. package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
  178. package/lib/vitest-exclude/vitest.utils.d.ts +30 -0
  179. package/lib/vitest-exclude/vitest.utils.js +30 -0
  180. package/lib/vitest-exclude/vitest.utils.js.map +1 -1
  181. package/lib/vitest-extended/acceptation.cjs +11 -2
  182. package/lib/vitest-extended/acceptation.cjs.map +1 -1
  183. package/lib/vitest-extended/acceptation.d.ts +9 -1
  184. package/lib/vitest-extended/acceptation.js +11 -2
  185. package/lib/vitest-extended/acceptation.js.map +1 -1
  186. package/lib/vitest-extended/createTests.cjs +34 -27
  187. package/lib/vitest-extended/createTests.cjs.map +1 -1
  188. package/lib/vitest-extended/createTests.d.ts +20 -37
  189. package/lib/vitest-extended/createTests.js +34 -27
  190. package/lib/vitest-extended/createTests.js.map +1 -1
  191. package/lib/vitest-extended/createTests.types.d.ts +13 -2
  192. package/lib/vitest-extended/done.cjs +18 -15
  193. package/lib/vitest-extended/done.cjs.map +1 -1
  194. package/lib/vitest-extended/done.d.ts +6 -5
  195. package/lib/vitest-extended/done.js +18 -15
  196. package/lib/vitest-extended/done.js.map +1 -1
  197. package/lib/vitest-extended/each/error.cjs +12 -0
  198. package/lib/vitest-extended/each/error.cjs.map +1 -1
  199. package/lib/vitest-extended/each/error.d.ts +12 -0
  200. package/lib/vitest-extended/each/error.js +12 -0
  201. package/lib/vitest-extended/each/error.js.map +1 -1
  202. package/lib/vitest-extended/each/error.types.d.ts +17 -0
  203. package/lib/vitest-extended/each/pass.cjs +9 -20
  204. package/lib/vitest-extended/each/pass.cjs.map +1 -1
  205. package/lib/vitest-extended/each/pass.d.ts +9 -20
  206. package/lib/vitest-extended/each/pass.js +9 -20
  207. package/lib/vitest-extended/each/pass.js.map +1 -1
  208. package/lib/vitest-extended/each/pass.types.d.ts +24 -0
  209. package/lib/vitest-extended/fakeWaiter.cjs +7 -0
  210. package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
  211. package/lib/vitest-extended/fakeWaiter.d.ts +32 -0
  212. package/lib/vitest-extended/fakeWaiter.js +7 -0
  213. package/lib/vitest-extended/fakeWaiter.js.map +1 -1
  214. package/lib/vitest-extended/fixtures/coverage.cjs +11 -0
  215. package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
  216. package/lib/vitest-extended/fixtures/coverage.js +11 -0
  217. package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
  218. package/lib/vitest-extended/fixtures/partialCall.cjs +9 -4
  219. package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
  220. package/lib/vitest-extended/fixtures/partialCall.js +9 -4
  221. package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
  222. package/lib/vitest-extended/fixtures/toUpper.cjs +18 -0
  223. package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
  224. package/lib/vitest-extended/fixtures/toUpper.js +18 -0
  225. package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
  226. package/lib/vitest-extended/fixtures/vitest.cjs +3 -0
  227. package/lib/vitest-extended/fixtures/vitest.cjs.map +1 -1
  228. package/lib/vitest-extended/fixtures/vitest.js +3 -0
  229. package/lib/vitest-extended/fixtures/vitest.js.map +1 -1
  230. package/lib/vitest-extended/fixtures/zod.cjs +22 -0
  231. package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
  232. package/lib/vitest-extended/fixtures/zod.js +22 -0
  233. package/lib/vitest-extended/fixtures/zod.js.map +1 -1
  234. package/lib/vitest-extended/identity.cjs +18 -0
  235. package/lib/vitest-extended/identity.cjs.map +1 -1
  236. package/lib/vitest-extended/identity.d.ts +18 -0
  237. package/lib/vitest-extended/identity.js +18 -0
  238. package/lib/vitest-extended/identity.js.map +1 -1
  239. package/lib/vitest-extended/isDefined.cjs +9 -0
  240. package/lib/vitest-extended/isDefined.cjs.map +1 -1
  241. package/lib/vitest-extended/isDefined.d.ts +9 -0
  242. package/lib/vitest-extended/isDefined.js +9 -0
  243. package/lib/vitest-extended/isDefined.js.map +1 -1
  244. package/lib/vitest-extended/isFunction.cjs +7 -0
  245. package/lib/vitest-extended/isFunction.cjs.map +1 -1
  246. package/lib/vitest-extended/isFunction.d.ts +7 -0
  247. package/lib/vitest-extended/isFunction.js +7 -0
  248. package/lib/vitest-extended/isFunction.js.map +1 -1
  249. package/lib/vitest-extended/project.cjs +7 -0
  250. package/lib/vitest-extended/project.cjs.map +1 -1
  251. package/lib/vitest-extended/project.d.ts +7 -0
  252. package/lib/vitest-extended/project.js +7 -0
  253. package/lib/vitest-extended/project.js.map +1 -1
  254. package/lib/vitest-extended/toArray.cjs +6 -0
  255. package/lib/vitest-extended/toArray.cjs.map +1 -1
  256. package/lib/vitest-extended/toArray.d.ts +6 -0
  257. package/lib/vitest-extended/toArray.js +6 -0
  258. package/lib/vitest-extended/toArray.js.map +1 -1
  259. package/lib/vitest-extended/toStringFlat.cjs +8 -0
  260. package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
  261. package/lib/vitest-extended/toStringFlat.d.ts +8 -0
  262. package/lib/vitest-extended/toStringFlat.js +8 -0
  263. package/lib/vitest-extended/toStringFlat.js.map +1 -1
  264. package/lib/vitest-extended/types.d.ts +64 -0
  265. package/package.json +14 -9
@@ -8,6 +8,13 @@ let path = require("path");
8
8
  let glob = require("glob");
9
9
  let _typescript_typescript6 = require("@typescript/typescript6");
10
10
  //#region src/rolldown-config/plugins/clean.ts
11
+ /**
12
+ * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.
13
+ *
14
+ * @param options - Configuration options of type {@linkcode EndPluginOptions}.
15
+ *
16
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
17
+ */
11
18
  const clean = (options) => {
12
19
  const { ignoresJS, sourcemap = false, dir } = options;
13
20
  const _ignoresJS = require_utils_array.toArray(ignoresJS);
@@ -27,7 +34,9 @@ const clean = (options) => {
27
34
  closeBundle: {
28
35
  order: "post",
29
36
  handler: () => {
30
- const outDir = require_rolldown_config_plugins_typescript_config.readTsConfig((0, _typescript_typescript6.findConfigFile)(process.cwd(), fs.existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
37
+ const cwd = process.cwd();
38
+ const tsconfigPath = (0, _typescript_typescript6.findConfigFile)(cwd, fs.existsSync, "tsconfig.json");
39
+ const outDir = require_rolldown_config_plugins_typescript_config.readTsConfig(tsconfigPath).options.outDir ?? dir ?? "lib";
31
40
  if (_ignoresJS.length > 0) try {
32
41
  const files = /* @__PURE__ */ new Set();
33
42
  _ignoresJS.forEach((pat) => {
@@ -1 +1 @@
1
- {"version":3,"file":"clean.cjs","names":["toArray","withoutExtension","WARNING_CODES","readTsConfig","existsSync"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;;AAmBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAaA,oBAAAA,QAAQ,SAAS;CA4DpC,OAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,OAAA,GAAA,KAAA,SAAA,CAAc,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAIC,gCAAAA,gBAAgB,CAAC,CACrB,KAAI,UAAA,GAAA,KAAA,SAAA,CAAiB,OAAO,IAAI,CAAC;GAMpC,IAHE,SAASC,kCAAAA,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IASb,MAAM,SADUC,kDAAAA,cAAAA,GAAAA,wBAAAA,eAAAA,CAPJ,QAAQ,IAGhB,GACFC,GAAAA,YACA,eAEsC,CAAC,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,CAAA,GAAA,KAAA,SAAA,CADuB,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,gCAAA,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
1
+ {"version":3,"file":"clean.cjs","names":["toArray","globSync","withoutExtension","relative","WARNING_CODES","findConfigFile","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the post-bundle cleanup plugin.\n */\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\n/**\n * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.\n *\n * @param options - Configuration options of type {@linkcode EndPluginOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAaA,oBAAAA,QAAQ,SAAS;CA4DpC,OAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,OAAA,GAAKC,KAAAA,SAAAA,CAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAIC,gCAAAA,gBAAgB,CAAC,CACrB,KAAI,UAAA,GAAQC,KAAAA,SAAAA,CAAS,OAAO,IAAI,CAAC;GAMpC,IAHE,SAASC,kCAAAA,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IACb,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,gBAAA,GAAeC,wBAAAA,eAAAA,CACnB,KACAC,GAAAA,YACA,eACF;IAEA,MAAM,SADUC,kDAAAA,aAAa,YAAY,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,CAAA,GADcN,KAAAA,SAAAA,CAAS,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,gCAAA,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
@@ -1,8 +1,18 @@
1
+ /**
2
+ * Options for the post-bundle cleanup plugin.
3
+ */
1
4
  export type EndPluginOptions = {
2
5
  ignoresJS?: string | string[];
3
6
  sourcemap?: boolean;
4
7
  dir?: string;
5
8
  };
9
+ /**
10
+ * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.
11
+ *
12
+ * @param options - Configuration options of type {@linkcode EndPluginOptions}.
13
+ *
14
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
15
+ */
6
16
  export declare const clean: (options: EndPluginOptions) => {
7
17
  name: string;
8
18
  onLog: {
@@ -7,6 +7,13 @@ import { relative } from "path";
7
7
  import { globSync } from "glob";
8
8
  import { findConfigFile } from "@typescript/typescript6";
9
9
  //#region src/rolldown-config/plugins/clean.ts
10
+ /**
11
+ * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.
12
+ *
13
+ * @param options - Configuration options of type {@linkcode EndPluginOptions}.
14
+ *
15
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
16
+ */
10
17
  const clean = (options) => {
11
18
  const { ignoresJS, sourcemap = false, dir } = options;
12
19
  const _ignoresJS = toArray(ignoresJS);
@@ -26,7 +33,9 @@ const clean = (options) => {
26
33
  closeBundle: {
27
34
  order: "post",
28
35
  handler: () => {
29
- const outDir = readTsConfig(findConfigFile(process.cwd(), existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
36
+ const cwd = process.cwd();
37
+ const tsconfigPath = findConfigFile(cwd, existsSync, "tsconfig.json");
38
+ const outDir = readTsConfig(tsconfigPath).options.outDir ?? dir ?? "lib";
30
39
  if (_ignoresJS.length > 0) try {
31
40
  const files = /* @__PURE__ */ new Set();
32
41
  _ignoresJS.forEach((pat) => {
@@ -1 +1 @@
1
- {"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;AAmBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAa,QAAQ,SAAS;CA4DpC,OAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAI,gBAAgB,CAAC,CACrB,KAAI,SAAQ,SAAS,OAAO,IAAI,CAAC;GAMpC,IAHE,SAAS,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IASb,MAAM,SADU,aALK,eAFT,QAAQ,IAGhB,GACF,YACA,eAEsC,CAAC,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,SADuB,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
1
+ {"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the post-bundle cleanup plugin.\n */\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\n/**\n * Plugin to clean up intermediate JavaScript and sourcemap files for type-only entries.\n *\n * @param options - Configuration options of type {@linkcode EndPluginOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAa,QAAQ,SAAS;CA4DpC,OAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAI,gBAAgB,CAAC,CACrB,KAAI,SAAQ,SAAS,OAAO,IAAI,CAAC;GAMpC,IAHE,SAAS,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IACb,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,eACnB,KACA,YACA,eACF;IAEA,MAAM,SADU,aAAa,YAAY,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,SADuB,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
@@ -2,10 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let rollup_plugin_node_externals = require("rollup-plugin-node-externals");
3
3
  //#region src/rolldown-config/plugins/externals.ts
4
4
  /**
5
- * Creates a configured node externals plugin instance
5
+ * Creates a configured node externals plugin instance for Rolldown.
6
6
  *
7
- * @param options - Configuration options for node externals
8
- * @returns Rolldown plugin
7
+ * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.
8
+ *
9
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
9
10
  */
10
11
  function externals(options = {}) {
11
12
  return (0, rollup_plugin_node_externals.nodeExternals)(options);
@@ -1 +1 @@
1
- {"version":3,"file":"externals.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance\n *\n * @param options - Configuration options for node externals\n * @returns Rolldown plugin\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,UACd,UAAgC,CAAC,GACX;CACtB,QAAA,GAAA,6BAAA,cAAA,CAAqB,OAAO;AAC9B"}
1
+ {"version":3,"file":"externals.cjs","names":["nodeExternals"],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\n/**\n * Options for the node externals plugin.\n */\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance for Rolldown.\n *\n * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAgB,UACd,UAAgC,CAAC,GACX;CACtB,QAAA,GAAOA,6BAAAA,cAAAA,CAAc,OAAO;AAC9B"}
@@ -1,10 +1,14 @@
1
1
  import type { RolldownPluginOption } from 'rolldown';
2
2
  import { nodeExternals } from 'rollup-plugin-node-externals';
3
+ /**
4
+ * Options for the node externals plugin.
5
+ */
3
6
  export type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];
4
7
  /**
5
- * Creates a configured node externals plugin instance
8
+ * Creates a configured node externals plugin instance for Rolldown.
9
+ *
10
+ * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.
6
11
  *
7
- * @param options - Configuration options for node externals
8
- * @returns Rolldown plugin
12
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
9
13
  */
10
14
  export declare function externals(options?: NodeExternalsOptions): RolldownPluginOption;
@@ -1,10 +1,11 @@
1
1
  import { nodeExternals } from "rollup-plugin-node-externals";
2
2
  //#region src/rolldown-config/plugins/externals.ts
3
3
  /**
4
- * Creates a configured node externals plugin instance
4
+ * Creates a configured node externals plugin instance for Rolldown.
5
5
  *
6
- * @param options - Configuration options for node externals
7
- * @returns Rolldown plugin
6
+ * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.
7
+ *
8
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
8
9
  */
9
10
  function externals(options = {}) {
10
11
  return nodeExternals(options);
@@ -1 +1 @@
1
- {"version":3,"file":"externals.js","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance\n *\n * @param options - Configuration options for node externals\n * @returns Rolldown plugin\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,UACd,UAAgC,CAAC,GACX;CACtB,OAAO,cAAc,OAAO;AAC9B"}
1
+ {"version":3,"file":"externals.js","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\n/**\n * Options for the node externals plugin.\n */\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance for Rolldown.\n *\n * @param options - Configuration options of type {@linkcode NodeExternalsOptions}.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,UACd,UAAgC,CAAC,GACX;CACtB,OAAO,cAAc,OAAO;AAC9B"}
@@ -6,6 +6,9 @@ const require_rolldown_config_plugins_typescript = require("./typescript.cjs");
6
6
  const require_rolldown_config_plugins_typescript_fast = require("./typescript.fast.cjs");
7
7
  let rolldown_plugins = require("rolldown/plugins");
8
8
  //#region src/rolldown-config/plugins/index.ts
9
+ /**
10
+ * Registry mapping plugin keys to their factory functions.
11
+ */
9
12
  const PLUGIN_BUILDERS = {
10
13
  typescript: require_rolldown_config_plugins_typescript.typescript,
11
14
  circulars: require_rolldown_config_plugins_circulars.circulars,
@@ -14,6 +17,9 @@ const PLUGIN_BUILDERS = {
14
17
  fast: require_rolldown_config_plugins_typescript_fast.typescriptFast,
15
18
  esm: rolldown_plugins.esmExternalRequirePlugin
16
19
  };
20
+ /**
21
+ * Default ordering sequence for Rolldown build plugins.
22
+ */
17
23
  const DEFAULT_PLUGINS_ORDER = Object.keys(PLUGIN_BUILDERS);
18
24
  //#endregion
19
25
  exports.DEFAULT_PLUGINS_ORDER = DEFAULT_PLUGINS_ORDER;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["typescriptFast","esmExternalRequirePlugin"],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { circulars } from './circulars';\nimport { clean } from './clean';\nimport { externals } from './externals';\nimport { typescript } from './typescript';\nimport { typescriptFast } from './typescript.fast';\n\nexport const PLUGIN_BUILDERS = {\n typescript,\n circulars,\n externals,\n clean,\n fast: typescriptFast,\n esm: esmExternalRequirePlugin,\n};\n\nexport const DEFAULT_PLUGINS_ORDER = Object.keys(\n PLUGIN_BUILDERS,\n) as (keyof typeof PLUGIN_BUILDERS)[];\n"],"mappings":";;;;;;;;AAQA,MAAa,kBAAkB;CAC7B,YAAA,2CAAA;CACA,WAAA,0CAAA;CACA,WAAA,0CAAA;CACA,OAAA,sCAAA;CACA,MAAMA,gDAAAA;CACN,KAAKC,iBAAAA;AACP;AAEA,MAAa,wBAAwB,OAAO,KAC1C,eACF"}
1
+ {"version":3,"file":"index.cjs","names":["typescriptFast","esmExternalRequirePlugin"],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { circulars } from './circulars';\nimport { clean } from './clean';\nimport { externals } from './externals';\nimport { typescript } from './typescript';\nimport { typescriptFast } from './typescript.fast';\n\n/**\n * Registry mapping plugin keys to their factory functions.\n */\nexport const PLUGIN_BUILDERS = {\n typescript,\n circulars,\n externals,\n clean,\n fast: typescriptFast,\n esm: esmExternalRequirePlugin,\n};\n\n/**\n * Default ordering sequence for Rolldown build plugins.\n */\nexport const DEFAULT_PLUGINS_ORDER = Object.keys(\n PLUGIN_BUILDERS,\n) as (keyof typeof PLUGIN_BUILDERS)[];\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,YAAA,2CAAA;CACA,WAAA,0CAAA;CACA,WAAA,0CAAA;CACA,OAAA,sCAAA;CACA,MAAMA,gDAAAA;CACN,KAAKC,iBAAAA;AACP;;;;AAKA,MAAa,wBAAwB,OAAO,KAC1C,eACF"}
@@ -1,6 +1,9 @@
1
1
  import { esmExternalRequirePlugin } from 'rolldown/plugins';
2
2
  import { circulars } from './circulars';
3
3
  import { externals } from './externals';
4
+ /**
5
+ * Registry mapping plugin keys to their factory functions.
6
+ */
4
7
  export declare const PLUGIN_BUILDERS: {
5
8
  typescript: ({ exclude, include, declarationMap, dir, }?: {
6
9
  exclude?: string | string[];
@@ -28,4 +31,7 @@ export declare const PLUGIN_BUILDERS: {
28
31
  }) => import("rolldown").RolldownPluginOption;
29
32
  esm: typeof esmExternalRequirePlugin;
30
33
  };
34
+ /**
35
+ * Default ordering sequence for Rolldown build plugins.
36
+ */
31
37
  export declare const DEFAULT_PLUGINS_ORDER: (keyof typeof PLUGIN_BUILDERS)[];
@@ -5,6 +5,9 @@ import { typescript } from "./typescript.js";
5
5
  import { typescriptFast } from "./typescript.fast.js";
6
6
  import { esmExternalRequirePlugin } from "rolldown/plugins";
7
7
  //#region src/rolldown-config/plugins/index.ts
8
+ /**
9
+ * Registry mapping plugin keys to their factory functions.
10
+ */
8
11
  const PLUGIN_BUILDERS = {
9
12
  typescript,
10
13
  circulars,
@@ -13,6 +16,9 @@ const PLUGIN_BUILDERS = {
13
16
  fast: typescriptFast,
14
17
  esm: esmExternalRequirePlugin
15
18
  };
19
+ /**
20
+ * Default ordering sequence for Rolldown build plugins.
21
+ */
16
22
  const DEFAULT_PLUGINS_ORDER = Object.keys(PLUGIN_BUILDERS);
17
23
  //#endregion
18
24
  export { DEFAULT_PLUGINS_ORDER, PLUGIN_BUILDERS };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { circulars } from './circulars';\nimport { clean } from './clean';\nimport { externals } from './externals';\nimport { typescript } from './typescript';\nimport { typescriptFast } from './typescript.fast';\n\nexport const PLUGIN_BUILDERS = {\n typescript,\n circulars,\n externals,\n clean,\n fast: typescriptFast,\n esm: esmExternalRequirePlugin,\n};\n\nexport const DEFAULT_PLUGINS_ORDER = Object.keys(\n PLUGIN_BUILDERS,\n) as (keyof typeof PLUGIN_BUILDERS)[];\n"],"mappings":";;;;;;;AAQA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA,MAAM;CACN,KAAK;AACP;AAEA,MAAa,wBAAwB,OAAO,KAC1C,eACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import { esmExternalRequirePlugin } from 'rolldown/plugins';\n\nimport { circulars } from './circulars';\nimport { clean } from './clean';\nimport { externals } from './externals';\nimport { typescript } from './typescript';\nimport { typescriptFast } from './typescript.fast';\n\n/**\n * Registry mapping plugin keys to their factory functions.\n */\nexport const PLUGIN_BUILDERS = {\n typescript,\n circulars,\n externals,\n clean,\n fast: typescriptFast,\n esm: esmExternalRequirePlugin,\n};\n\n/**\n * Default ordering sequence for Rolldown build plugins.\n */\nexport const DEFAULT_PLUGINS_ORDER = Object.keys(\n PLUGIN_BUILDERS,\n) as (keyof typeof PLUGIN_BUILDERS)[];\n"],"mappings":";;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA,MAAM;CACN,KAAK;AACP;;;;AAKA,MAAa,wBAAwB,OAAO,KAC1C,eACF"}
@@ -8,6 +8,13 @@ let _typescript_typescript6 = require("@typescript/typescript6");
8
8
  _typescript_typescript6 = require_runtime.__toESM(_typescript_typescript6, 1);
9
9
  let tsc_alias = require("tsc-alias");
10
10
  //#region src/rolldown-config/plugins/typescript.ts
11
+ /**
12
+ * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).
13
+ *
14
+ * @param props - Configuration options.
15
+ *
16
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
17
+ */
11
18
  const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
12
19
  let done = false;
13
20
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.cjs","names":["toArray","ts","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(\n ts.formatDiagnosticsWithColorAndContext(errors, host),\n );\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHAA,oBAAAA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAeC,wBAAAA,QAAG,eACtB,KACAC,GAAAA,YACA,eACF;IAEA,MAAM,aAAaC,kDAAAA,aAAa,YAAY;IAC5C,MAAM,OAAOF,wBAAAA,QAAG,mBAAmB,WAAW,OAAO;IACrD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAASA,wBAAAA,QAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAGD,oBAAAA,QAAQ,OAAO,GAAG,MAAM;KACrC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;KACF;IACF,GACAC,wBAAAA,QAAG,KACH,GACF;IAEA,MAAM,UAAUA,wBAAAA,QAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;IACF,GACA,IACF;IAEA,MAAM,aAAa,QAAQ,KAAK;IAEhC,MAAM,SAASA,wBAAAA,QACZ,sBAAsB,OAAO,CAAC,CAC9B,OAAO,WAAW,WAAW,CAAC,CAC9B,QAAO,MAAK,EAAE,aAAaA,wBAAAA,QAAG,mBAAmB,KAAK;IAEzD,IAAI,OAAO,SAAS,GAClB,QAAQ,MACNA,wBAAAA,QAAG,qCAAqC,QAAQ,IAAI,CACtD;IAGF,OAAA,GAAA,UAAA,qBAAA,CAA2B;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
1
+ {"version":3,"file":"typescript.cjs","names":["toArray","ts","existsSync","readTsConfig","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\n\nimport ts from '@typescript/typescript6';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(\n ts.formatDiagnosticsWithColorAndContext(errors, host),\n );\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHAA,oBAAAA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAeC,wBAAAA,QAAG,eACtB,KACAC,GAAAA,YACA,eACF;IAEA,MAAM,aAAaC,kDAAAA,aAAa,YAAY;IAC5C,MAAM,OAAOF,wBAAAA,QAAG,mBAAmB,WAAW,OAAO;IACrD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAASA,wBAAAA,QAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAGD,oBAAAA,QAAQ,OAAO,GAAG,MAAM;KACrC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;KACF;IACF,GACAC,wBAAAA,QAAG,KACH,GACF;IAEA,MAAM,UAAUA,wBAAAA,QAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;IACF,GACA,IACF;IAEA,MAAM,aAAa,QAAQ,KAAK;IAEhC,MAAM,SAASA,wBAAAA,QACZ,sBAAsB,OAAO,CAAC,CAC9B,OAAO,WAAW,WAAW,CAAC,CAC9B,QAAO,MAAK,EAAE,aAAaA,wBAAAA,QAAG,mBAAmB,KAAK;IAEzD,IAAI,OAAO,SAAS,GAClB,QAAQ,MACNA,wBAAAA,QAAG,qCAAqC,QAAQ,IAAI,CACtD;IAGF,OAAA,GAAMG,UAAAA,qBAAAA,CAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
@@ -43,10 +43,25 @@ const _host = {
43
43
  fileExists: fs.existsSync,
44
44
  readFile: _readFile
45
45
  };
46
+ /**
47
+ * Loads and parses the closest `tsconfig.json` from the search path.
48
+ *
49
+ * @param searchPath - Directory path from which to locate the tsconfig.
50
+ * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.
51
+ *
52
+ * @returns Parsed TypeScript configuration object.
53
+ */
46
54
  function getConfig(searchPath, configName = "tsconfig.json") {
47
55
  const tsconfigPath = _typescript_typescript6.default.findConfigFile(searchPath, fs.existsSync, configName);
48
56
  return readTsConfig(tsconfigPath);
49
57
  }
58
+ /**
59
+ * Reads and parses the specified `tsconfig.json` file path.
60
+ *
61
+ * @param path - Absolute or relative path to the tsconfig file.
62
+ *
63
+ * @returns Parsed TypeScript configuration object.
64
+ */
50
65
  const readTsConfig = (path$1) => {
51
66
  const configFile = _typescript_typescript6.default.readConfigFile(path$1, _readFile);
52
67
  if (configFile.error) throw new Error(_typescript_typescript6.default.formatDiagnostic(configFile.error, {
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.config.cjs","names":["existsSync","ts","path"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,QAAA,GAAA,GAAA,aAAA,CAAoB,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,WAAA,GAAA,GAAA,YAAA,CAAsB,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAA,GAAA,KAAA,KAAA,CAAgB,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,QAAA,GAAA,GAAA,SAAA,CAAgB,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAYA,GAAAA;CACZ,UAAU;AACZ;AAEA,SAAgB,UACd,YACA,aAAqB,iBACrB;CACA,MAAM,eAAeC,wBAAAA,QAAG,eACtB,YACAD,GAAAA,YACA,UACF;CAGA,OADmB,aAAa,YAChB;AAClB;AAEA,MAAa,gBAAgB,WAAiB;CAC5C,MAAM,aAAaC,wBAAAA,QAAG,eAAeC,QAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACRD,wBAAAA,QAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqBA,wBAAAA,QAAG,2BACtB,WAAW,QACX,QAAA,GAAA,KAAA,QAAA,CACQC,MAAI,CAGI;AACpB"}
1
+ {"version":3,"file":"typescript.config.cjs","names":["readFileSync","readdirSync","join","statSync","existsSync","ts","path","dirname"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\n/**\n * Loads and parses the closest `tsconfig.json` from the search path.\n *\n * @param searchPath - Directory path from which to locate the tsconfig.\n * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\n/**\n * Reads and parses the specified `tsconfig.json` file path.\n *\n * @param path - Absolute or relative path to the tsconfig file.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,QAAA,GAAOA,GAAAA,aAAAA,CAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,WAAA,GAAUC,GAAAA,YAAAA,CAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAA,GAAWC,KAAAA,KAAAA,CAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,QAAA,GAAOC,GAAAA,SAAAA,CAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAYC,GAAAA;CACZ,UAAU;AACZ;;;;;;;;;AAUA,SAAgB,UACd,YACA,aAAqB,iBACrB;CACA,MAAM,eAAeC,wBAAAA,QAAG,eACtB,YACAD,GAAAA,YACA,UACF;CAGA,OADmB,aAAa,YAChB;AAClB;;;;;;;;AASA,MAAa,gBAAgB,WAAiB;CAC5C,MAAM,aAAaC,wBAAAA,QAAG,eAAeC,QAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACRD,wBAAAA,QAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqBA,wBAAAA,QAAG,2BACtB,WAAW,QACX,QAAA,GACAE,KAAAA,QAAAA,CAAQD,MAAI,CAGI;AACpB"}
@@ -1,3 +1,18 @@
1
1
  import ts from '@typescript/typescript6';
2
+ /**
3
+ * Loads and parses the closest `tsconfig.json` from the search path.
4
+ *
5
+ * @param searchPath - Directory path from which to locate the tsconfig.
6
+ * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.
7
+ *
8
+ * @returns Parsed TypeScript configuration object.
9
+ */
2
10
  export declare function getConfig(searchPath: string, configName?: string): ts.ParsedCommandLine;
11
+ /**
12
+ * Reads and parses the specified `tsconfig.json` file path.
13
+ *
14
+ * @param path - Absolute or relative path to the tsconfig file.
15
+ *
16
+ * @returns Parsed TypeScript configuration object.
17
+ */
3
18
  export declare const readTsConfig: (path: string) => ts.ParsedCommandLine;
@@ -40,10 +40,25 @@ const _host = {
40
40
  fileExists: existsSync,
41
41
  readFile: _readFile
42
42
  };
43
+ /**
44
+ * Loads and parses the closest `tsconfig.json` from the search path.
45
+ *
46
+ * @param searchPath - Directory path from which to locate the tsconfig.
47
+ * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.
48
+ *
49
+ * @returns Parsed TypeScript configuration object.
50
+ */
43
51
  function getConfig(searchPath, configName = "tsconfig.json") {
44
52
  const tsconfigPath = ts.findConfigFile(searchPath, existsSync, configName);
45
53
  return readTsConfig(tsconfigPath);
46
54
  }
55
+ /**
56
+ * Reads and parses the specified `tsconfig.json` file path.
57
+ *
58
+ * @param path - Absolute or relative path to the tsconfig file.
59
+ *
60
+ * @returns Parsed TypeScript configuration object.
61
+ */
47
62
  const readTsConfig = (path) => {
48
63
  const configFile = ts.readConfigFile(path, _readFile);
49
64
  if (configFile.error) throw new Error(ts.formatDiagnostic(configFile.error, {
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,OAAO,aAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,OAAO,SAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;AACZ;AAEA,SAAgB,UACd,YACA,aAAqB,iBACrB;CACA,MAAM,eAAe,GAAG,eACtB,YACA,YACA,UACF;CAGA,OADmB,aAAa,YAChB;AAClB;AAEA,MAAa,gBAAgB,SAAiB;CAC5C,MAAM,aAAa,GAAG,eAAe,MAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACR,GAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqB,GAAG,2BACtB,WAAW,QACX,OACA,QAAQ,IAAI,CAGI;AACpB"}
1
+ {"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nimport ts from '@typescript/typescript6';\n\nconst _readFile = (filePath: string): string | undefined => {\n try {\n return readFileSync(filePath, 'utf-8');\n } catch {\n return undefined;\n }\n};\n\nconst _readDirectory: ts.ParseConfigHost['readDirectory'] = (\n rootDir,\n extensions,\n _,\n __,\n depth,\n): string[] => {\n const results: string[] = [];\n\n const walk = (dir: string, currentDepth: number) => {\n if (depth !== undefined && currentDepth > depth) return;\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n let stat;\n try {\n stat = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stat.isDirectory()) {\n walk(fullPath, currentDepth + 1);\n } else if (\n !extensions ||\n extensions.some(ext => entry.endsWith(ext))\n ) {\n results.push(fullPath);\n }\n }\n };\n\n walk(rootDir, 0);\n return results;\n};\n\nconst _host: ts.ParseConfigHost = {\n useCaseSensitiveFileNames: true,\n readDirectory: _readDirectory,\n fileExists: existsSync,\n readFile: _readFile,\n};\n\n/**\n * Loads and parses the closest `tsconfig.json` from the search path.\n *\n * @param searchPath - Directory path from which to locate the tsconfig.\n * @param configName - Name of the configuration file, defaults to `'tsconfig.json'`.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport function getConfig(\n searchPath: string,\n configName: string = 'tsconfig.json',\n) {\n const tsconfigPath = ts.findConfigFile(\n searchPath,\n existsSync,\n configName,\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n return configFile;\n}\n\n/**\n * Reads and parses the specified `tsconfig.json` file path.\n *\n * @param path - Absolute or relative path to the tsconfig file.\n *\n * @returns Parsed TypeScript configuration object.\n */\nexport const readTsConfig = (path: string) => {\n const configFile = ts.readConfigFile(path, _readFile);\n\n if (configFile.error) {\n throw new Error(\n ts.formatDiagnostic(configFile.error, {\n getCanonicalFileName: f => f,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => '\\n',\n }),\n );\n }\n\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n _host,\n dirname(path),\n );\n\n return parsedConfig;\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,OAAO,aAAa,UAAU,OAAO;CACvC,QAAQ;EACN;CACF;AACF;AAEA,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,GAAG;EAC3B,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,KAAK;GAChC,IAAI;GACJ,IAAI;IACF,OAAO,SAAS,QAAQ;GAC1B,QAAQ;IACN;GACF;GAEA,IAAI,KAAK,YAAY,GACnB,KAAK,UAAU,eAAe,CAAC;QAC1B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAE1C,QAAQ,KAAK,QAAQ;EAEzB;CACF;CAEA,KAAK,SAAS,CAAC;CACf,OAAO;AACT;AAEA,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;AACZ;;;;;;;;;AAUA,SAAgB,UACd,YACA,aAAqB,iBACrB;CACA,MAAM,eAAe,GAAG,eACtB,YACA,YACA,UACF;CAGA,OADmB,aAAa,YAChB;AAClB;;;;;;;;AASA,MAAa,gBAAgB,SAAiB;CAC5C,MAAM,aAAa,GAAG,eAAe,MAAM,SAAS;CAEpD,IAAI,WAAW,OACb,MAAM,IAAI,MACR,GAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,IAAI;EACvC,kBAAkB;CACpB,CAAC,CACH;CASF,OANqB,GAAG,2BACtB,WAAW,QACX,OACA,QAAQ,IAAI,CAGI;AACpB"}
@@ -1,9 +1,19 @@
1
1
  import type { RolldownPluginOption } from 'rolldown';
2
+ /**
3
+ * Options for the TypeScript DTS generation plugin.
4
+ */
2
5
  type Props = {
3
6
  exclude?: string | string[];
4
7
  include?: Record<string, string>;
5
8
  declarationMap?: boolean;
6
9
  dir?: string;
7
10
  };
11
+ /**
12
+ * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).
13
+ *
14
+ * @param props - Configuration options.
15
+ *
16
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
17
+ */
8
18
  export declare const typescript: ({ exclude, include, declarationMap, dir, }?: Props) => RolldownPluginOption;
9
19
  export {};
@@ -11,6 +11,13 @@ _typescript_typescript6 = require_runtime.__toESM(_typescript_typescript6, 1);
11
11
  let tsc_alias = require("tsc-alias");
12
12
  let oxc_transform = require("oxc-transform");
13
13
  //#region src/rolldown-config/plugins/typescript.fast.ts
14
+ /**
15
+ * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).
16
+ *
17
+ * @param props - Configuration options.
18
+ *
19
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
20
+ */
14
21
  const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
15
22
  let done = false;
16
23
  return {
@@ -34,7 +41,8 @@ const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
34
41
  files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
35
42
  const errors = [];
36
43
  for (const file of files) try {
37
- const result = (0, oxc_transform.transformSync)(file, (0, fs.readFileSync)(file, "utf-8"), {
44
+ const content = (0, fs.readFileSync)(file, "utf-8");
45
+ const result = (0, oxc_transform.transformSync)(file, content, {
38
46
  sourcemap: !!declarationMap,
39
47
  typescript: { declaration: { sourcemap: !!declarationMap } }
40
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.fast.cjs","names":["toArray","ts","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"typescript.fast.cjs","names":["toArray","ts","existsSync","readTsConfig","join","globSync","readFileSync","transformSync","relative","dirname","basename","replaceTscAliasPaths"],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the fast TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":"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"}
@@ -1,9 +1,19 @@
1
1
  import type { RolldownPluginOption } from 'rolldown';
2
+ /**
3
+ * Options for the fast TypeScript DTS generation plugin.
4
+ */
2
5
  type Props = {
3
6
  exclude?: string | string[];
4
7
  include?: Record<string, string>;
5
8
  declarationMap?: boolean;
6
9
  dir?: string;
7
10
  };
11
+ /**
12
+ * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).
13
+ *
14
+ * @param props - Configuration options.
15
+ *
16
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
17
+ */
8
18
  export declare const typescriptFast: ({ exclude, include, declarationMap, dir, }?: Props) => RolldownPluginOption;
9
19
  export {};
@@ -8,6 +8,13 @@ import ts from "@typescript/typescript6";
8
8
  import { replaceTscAliasPaths } from "tsc-alias";
9
9
  import { transformSync } from "oxc-transform";
10
10
  //#region src/rolldown-config/plugins/typescript.fast.ts
11
+ /**
12
+ * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).
13
+ *
14
+ * @param props - Configuration options.
15
+ *
16
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
17
+ */
11
18
  const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
12
19
  let done = false;
13
20
  return {
@@ -31,7 +38,8 @@ const typescriptFast = ({ exclude, include, declarationMap, dir } = {}) => {
31
38
  files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
32
39
  const errors = [];
33
40
  for (const file of files) try {
34
- const result = transformSync(file, readFileSync(file, "utf-8"), {
41
+ const content = readFileSync(file, "utf-8");
42
+ const result = transformSync(file, content, {
35
43
  sourcemap: !!declarationMap,
36
44
  typescript: { declaration: { sourcemap: !!declarationMap } }
37
45
  });
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.fast.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;AA0BA,MAAa,kBAAkB,EAC7B,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,eACF;IAEA,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAC5C,MAAM,UAAU,WAAW,QAAQ,WAAW,KAAK,KAAK,KAAK;IAE7D,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,QAAQ,SAAS,KAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQ,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KAEF,MAAM,SAAS,cAAc,MADb,aAAa,MAAM,OACM,GAAG;MAC1C,WAAW,CAAC,CAAC;MACb,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;KAC7D,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,eAAe,SAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,UAAU,KAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,UAAU,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,0BAA0B,SAAS,OAAO,EAAE;MACvD,cACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,cAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
1
+ {"version":3,"file":"typescript.fast.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.fast.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport ts from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { readTsConfig } from './typescript.config';\n\n/**\n * Options for the fast TypeScript DTS generation plugin.\n */\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\n/**\n * Fast Rolldown plugin using `oxc-transform` for generating TypeScript declaration files (`.d.ts`).\n *\n * @param props - Configuration options.\n *\n * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.\n */\nexport const typescriptFast = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-fast-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir = configFile.options.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n sourcemap: !!declarationMap,\n typescript: { declaration: { sourcemap: !!declarationMap } },\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAa,kBAAkB,EAC7B,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,eACF;IAEA,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAC5C,MAAM,UAAU,WAAW,QAAQ,WAAW,KAAK,KAAK,KAAK;IAE7D,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,QAAQ,SAAS,KAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQ,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KACF,MAAM,UAAU,aAAa,MAAM,OAAO;KAC1C,MAAM,SAAS,cAAc,MAAM,SAAS;MAC1C,WAAW,CAAC,CAAC;MACb,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;KAC7D,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,eAAe,SAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,UAAU,KAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,UAAU,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,0BAA0B,SAAS,OAAO,EAAE;MACvD,cACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,cAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
@@ -5,6 +5,13 @@ import { existsSync } from "fs";
5
5
  import ts from "@typescript/typescript6";
6
6
  import { replaceTscAliasPaths } from "tsc-alias";
7
7
  //#region src/rolldown-config/plugins/typescript.ts
8
+ /**
9
+ * Rolldown plugin using `@typescript/typescript6` for generating TypeScript declaration files (`.d.ts`).
10
+ *
11
+ * @param props - Configuration options.
12
+ *
13
+ * @returns Rolldown plugin option of type {@linkcode RolldownPluginOption}.
14
+ */
8
15
  const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
9
16
  let done = false;
10
17
  return {