@bemedev/dev-utils 0.7.0 → 0.8.1

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 (113) hide show
  1. package/lib/build-tests/addTarball.cjs.map +1 -1
  2. package/lib/build-tests/addTarball.js.map +1 -1
  3. package/lib/build-tests/buildPackageJson.cjs.map +1 -1
  4. package/lib/build-tests/buildPackageJson.js.map +1 -1
  5. package/lib/build-tests/cleanup.cjs.map +1 -1
  6. package/lib/build-tests/cleanup.js.map +1 -1
  7. package/lib/build-tests/cli/index.js +0 -0
  8. package/lib/build-tests/cli/test.cjs.map +1 -1
  9. package/lib/build-tests/cli/test.js.map +1 -1
  10. package/lib/build-tests/getRelativePath.cjs.map +1 -1
  11. package/lib/build-tests/getRelativePath.js.map +1 -1
  12. package/lib/build-tests/getTypescriptOutdir.cjs +10 -2
  13. package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
  14. package/lib/build-tests/getTypescriptOutdir.js +9 -2
  15. package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
  16. package/lib/build-tests/import.cjs.map +1 -1
  17. package/lib/build-tests/import.js.map +1 -1
  18. package/lib/build-tests/imports/create.cjs.map +1 -1
  19. package/lib/build-tests/imports/create.js.map +1 -1
  20. package/lib/build-tests/imports/helper.cjs.map +1 -1
  21. package/lib/build-tests/imports/helper.js.map +1 -1
  22. package/lib/build-tests/pack.cjs.map +1 -1
  23. package/lib/build-tests/pack.js.map +1 -1
  24. package/lib/rolldown-config/config.cjs +3 -3
  25. package/lib/rolldown-config/config.cjs.map +1 -1
  26. package/lib/rolldown-config/config.js +3 -3
  27. package/lib/rolldown-config/config.js.map +1 -1
  28. package/lib/rolldown-config/helpers.cjs.map +1 -1
  29. package/lib/rolldown-config/helpers.js.map +1 -1
  30. package/lib/rolldown-config/index.d.ts +1 -0
  31. package/lib/rolldown-config/input.cjs.map +1 -1
  32. package/lib/rolldown-config/input.js.map +1 -1
  33. package/lib/rolldown-config/output.cjs +2 -1
  34. package/lib/rolldown-config/output.cjs.map +1 -1
  35. package/lib/rolldown-config/output.d.ts +1 -1
  36. package/lib/rolldown-config/output.js +2 -1
  37. package/lib/rolldown-config/output.js.map +1 -1
  38. package/lib/rolldown-config/plugins/alias.cjs.map +1 -1
  39. package/lib/rolldown-config/plugins/alias.js.map +1 -1
  40. package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
  41. package/lib/rolldown-config/plugins/circulars.js.map +1 -1
  42. package/lib/rolldown-config/plugins/clean.cjs +10 -4
  43. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  44. package/lib/rolldown-config/plugins/clean.d.ts +1 -1
  45. package/lib/rolldown-config/plugins/clean.js +8 -3
  46. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  47. package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
  48. package/lib/rolldown-config/plugins/externals.js.map +1 -1
  49. package/lib/rolldown-config/plugins/index.d.ts +2 -2
  50. package/lib/rolldown-config/plugins/tsPaths.cjs.map +1 -1
  51. package/lib/rolldown-config/plugins/tsPaths.js.map +1 -1
  52. package/lib/rolldown-config/plugins/typescript.cjs +4 -2
  53. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  54. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  55. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  56. package/lib/rolldown-config/plugins/typescript.d.ts +1 -1
  57. package/lib/rolldown-config/plugins/typescript.js +4 -2
  58. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  59. package/lib/rolldown-config/utils.cjs.map +1 -1
  60. package/lib/rolldown-config/utils.js.map +1 -1
  61. package/lib/utils/sleep.cjs.map +1 -1
  62. package/lib/utils/sleep.js.map +1 -1
  63. package/lib/vitest-exclude/vitest.cjs +39 -14
  64. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  65. package/lib/vitest-exclude/vitest.d.ts +4 -3
  66. package/lib/vitest-exclude/vitest.js +39 -14
  67. package/lib/vitest-exclude/vitest.js.map +1 -1
  68. package/lib/vitest-exclude/vitest.utils.cjs +8 -8
  69. package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
  70. package/lib/vitest-exclude/vitest.utils.d.ts +4 -4
  71. package/lib/vitest-exclude/vitest.utils.js +8 -8
  72. package/lib/vitest-exclude/vitest.utils.js.map +1 -1
  73. package/lib/vitest-extended/acceptation.cjs.map +1 -1
  74. package/lib/vitest-extended/acceptation.js.map +1 -1
  75. package/lib/vitest-extended/createTests.cjs.map +1 -1
  76. package/lib/vitest-extended/createTests.js.map +1 -1
  77. package/lib/vitest-extended/done.cjs.map +1 -1
  78. package/lib/vitest-extended/done.js.map +1 -1
  79. package/lib/vitest-extended/each/error.cjs.map +1 -1
  80. package/lib/vitest-extended/each/error.js.map +1 -1
  81. package/lib/vitest-extended/each/pass.cjs.map +1 -1
  82. package/lib/vitest-extended/each/pass.js.map +1 -1
  83. package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
  84. package/lib/vitest-extended/fakeWaiter.js.map +1 -1
  85. package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
  86. package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
  87. package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
  88. package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
  89. package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
  90. package/lib/vitest-extended/fixtures/zod.js.map +1 -1
  91. package/lib/vitest-extended/identity.cjs.map +1 -1
  92. package/lib/vitest-extended/identity.js.map +1 -1
  93. package/lib/vitest-extended/index.d.ts +1 -0
  94. package/lib/vitest-extended/isDefined.cjs.map +1 -1
  95. package/lib/vitest-extended/isDefined.d.ts +1 -0
  96. package/lib/vitest-extended/isDefined.js.map +1 -1
  97. package/lib/vitest-extended/isFunction.cjs.map +1 -1
  98. package/lib/vitest-extended/isFunction.js.map +1 -1
  99. package/lib/vitest-extended/toArray.cjs.map +1 -1
  100. package/lib/vitest-extended/toArray.js.map +1 -1
  101. package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
  102. package/lib/vitest-extended/toStringFlat.js.map +1 -1
  103. package/lib/vitest-extended/types.d.ts +1 -1
  104. package/package.json +23 -67
  105. package/README.md +0 -696
  106. package/lib/vitest-alias/index.cjs +0 -4
  107. package/lib/vitest-alias/index.d.ts +0 -1
  108. package/lib/vitest-alias/index.js +0 -2
  109. package/lib/vitest-alias/vitest.cjs +0 -77
  110. package/lib/vitest-alias/vitest.cjs.map +0 -1
  111. package/lib/vitest-alias/vitest.d.ts +0 -38
  112. package/lib/vitest-alias/vitest.js +0 -74
  113. package/lib/vitest-alias/vitest.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"clean.cjs","names":["toArray","withoutExtension","WARNING_CODES"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { globSync } from 'glob';\nimport { relative } from 'node:path';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { toArray } from '../utils';\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 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, dir, 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":";;;;;;;;AAaA,MAAa,SAAS,UAA4B,EAAE,KAAK;CACvD,MAAM,EAAE,WAAW,YAAY,OAAO,MAAM,OAAO;CAEnD,MAAM,aAAaA,8BAAAA,QAAQ,UAAU;CAmDrC,OAAO;EAhDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,OAAA,GAAA,KAAA,UAAc,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC,CACtC,MAAM,CACN,IAAIC,gCAAAA,iBAAiB,CACrB,KAAI,UAAA,GAAA,KAAA,UAAiB,OAAO,KAAK,CAAC;GAMrC,IAHE,SAASC,kCAAAA,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,KAAK,CAAC,EAExC;IACT,MAAM,QAAQ,IAAI,OAAO,GAAG;IAC5B,QAAQ,IAAI,MAAM;IAClB,QAAQ,IAAI,mDAAmD;IAC/D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,OAAO,CAAC;IACtD,QAAQ,IAAI,MAAM;IAClB,OAAO;;KAKZ;EAED,aAAa;GACX,OAAO;GACP,eAAe;IACb,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,KAAa;KAC/B,WAAW,SAAQ,QAAO;MAExB,CAAA,GAAA,KAAA,UADuB,KAAK,EAAE,OAAO,MAAM,CACtC,CAAC,SAAQ,SAAQ,MAAM,IAAI,KAAK,CAAC;OACtC;KACF,gCAAA,UAAU,OAAO,KAAK,UAAU;KAChC,QAAQ,IAAI,iBAAiB;aAEtB,KAAK;KACZ,QAAQ,MAAM,iCAAiC,IAAI;;;GAI1D;EAGO"}
1
+ {"version":3,"file":"clean.cjs","names":["toArray","withoutExtension","WARNING_CODES","readTsConfig","ts","existsSync"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { globSync } from 'glob';\nimport { relative } from 'node:path';\nimport type { RolldownPluginOption } from 'rolldown';\nimport ts from 'typescript';\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { toArray } from '../utils';\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 = ts.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":";;;;;;;;;;;;AAgBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAaA,8BAAAA,QAAQ,UAAU;AA4DrC,QAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,OAAA,GAAA,KAAA,UAAc,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC,CACtC,MAAM,CACN,IAAIC,gCAAAA,iBAAiB,CACrB,KAAI,UAAA,GAAA,KAAA,UAAiB,OAAO,KAAK,CAAC;AAMrC,OAHE,SAASC,kCAAAA,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,KAAK,CAAC,EAExC;IACT,MAAM,QAAQ,IAAI,OAAO,GAAG;AAC5B,YAAQ,IAAI,MAAM;AAClB,YAAQ,IAAI,mDAAmD;AAC/D,WAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,OAAO,CAAC;AACtD,YAAQ,IAAI,MAAM;AAClB,WAAO;;KAKZ;EAED,aAAa;GACX,OAAO;GACP,eAAe;IACb,MAAM,MAAM,QAAQ,KAAK;IAQzB,MAAM,SADUC,kDAAAA,aALKC,WAAAA,QAAG,eACtB,KACAC,GAAAA,YACA,gBAEuC,CAAC,CAAC,QAAQ,UACzB,OAAA;AAC1B,QAAI,WAAW,SAAS,EACtB,KAAI;KACF,MAAM,wBAAQ,IAAI,KAAa;AAC/B,gBAAW,SAAQ,QAAO;AAExB,OAAA,GAAA,KAAA,UADuB,KAAK,EAAE,OAAO,MAAM,CACtC,CAAC,SAAQ,SAAQ,MAAM,IAAI,KAAK,CAAC;OACtC;AACF,qCAAA,UAAU,OAAO,QAAQ,UAAU;AACnC,aAAQ,IAAI,iBAAiB;aAEtB,KAAK;AACZ,aAAQ,MAAM,iCAAiC,IAAI;;;GAI1D;EAGO"}
@@ -3,7 +3,7 @@ export type EndPluginOptions = {
3
3
  sourcemap?: boolean;
4
4
  dir?: string;
5
5
  };
6
- export declare const clean: (options?: EndPluginOptions) => {
6
+ export declare const clean: (options: EndPluginOptions) => {
7
7
  name: string;
8
8
  onLog: {
9
9
  handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
@@ -1,11 +1,14 @@
1
1
  import { toArray } from "../utils.js";
2
2
  import { WARNING_CODES } from "../constants.js";
3
3
  import { cleanupJS, withoutExtension } from "../helpers.js";
4
+ import { readTsConfig } from "./typescript.config.js";
5
+ import { existsSync } from "fs";
4
6
  import { globSync } from "glob";
5
7
  import { relative } from "path";
8
+ import ts from "typescript";
6
9
  //#region src/rolldown-config/plugins/clean.ts
7
- const clean = (options = {}) => {
8
- const { ignoresJS, sourcemap = false, dir = "" } = options;
10
+ const clean = (options) => {
11
+ const { ignoresJS, sourcemap = false, dir } = options;
9
12
  const _ignoresJS = toArray(ignoresJS);
10
13
  return {
11
14
  name: "end-bemedev",
@@ -23,12 +26,14 @@ const clean = (options = {}) => {
23
26
  closeBundle: {
24
27
  order: "post",
25
28
  handler: () => {
29
+ const cwd = process.cwd();
30
+ const outDir = readTsConfig(ts.findConfigFile(cwd, existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
26
31
  if (_ignoresJS.length > 0) try {
27
32
  const files = /* @__PURE__ */ new Set();
28
33
  _ignoresJS.forEach((pat) => {
29
34
  globSync(pat, { nodir: true }).forEach((file) => files.add(file));
30
35
  });
31
- cleanupJS(files, dir, sourcemap);
36
+ cleanupJS(files, outDir, sourcemap);
32
37
  console.log("Build finished");
33
38
  } catch (err) {
34
39
  console.error("[end-bemedev] cleanup failed:", err);
@@ -1 +1 @@
1
- {"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { globSync } from 'glob';\nimport { relative } from 'node:path';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { toArray } from '../utils';\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 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, dir, 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":";;;;;;AAaA,MAAa,SAAS,UAA4B,EAAE,KAAK;CACvD,MAAM,EAAE,WAAW,YAAY,OAAO,MAAM,OAAO;CAEnD,MAAM,aAAa,QAAQ,UAAU;CAmDrC,OAAO;EAhDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC,CACtC,MAAM,CACN,IAAI,iBAAiB,CACrB,KAAI,SAAQ,SAAS,OAAO,KAAK,CAAC;GAMrC,IAHE,SAAS,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,KAAK,CAAC,EAExC;IACT,MAAM,QAAQ,IAAI,OAAO,GAAG;IAC5B,QAAQ,IAAI,MAAM;IAClB,QAAQ,IAAI,mDAAmD;IAC/D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,OAAO,CAAC;IACtD,QAAQ,IAAI,MAAM;IAClB,OAAO;;KAKZ;EAED,aAAa;GACX,OAAO;GACP,eAAe;IACb,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,KAAa;KAC/B,WAAW,SAAQ,QAAO;MAExB,SADuB,KAAK,EAAE,OAAO,MAAM,CACtC,CAAC,SAAQ,SAAQ,MAAM,IAAI,KAAK,CAAC;OACtC;KACF,UAAU,OAAO,KAAK,UAAU;KAChC,QAAQ,IAAI,iBAAiB;aAEtB,KAAK;KACZ,QAAQ,MAAM,iCAAiC,IAAI;;;GAI1D;EAGO"}
1
+ {"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { globSync } from 'glob';\nimport { relative } from 'node:path';\nimport type { RolldownPluginOption } from 'rolldown';\nimport ts from 'typescript';\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { toArray } from '../utils';\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 = ts.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":";;;;;;;;;AAgBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAa,QAAQ,UAAU;AA4DrC,QAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,MAAM,CAAC,CAAC,CACtC,MAAM,CACN,IAAI,iBAAiB,CACrB,KAAI,SAAQ,SAAS,OAAO,KAAK,CAAC;AAMrC,OAHE,SAAS,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,KAAK,CAAC,EAExC;IACT,MAAM,QAAQ,IAAI,OAAO,GAAG;AAC5B,YAAQ,IAAI,MAAM;AAClB,YAAQ,IAAI,mDAAmD;AAC/D,WAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,OAAO,CAAC;AACtD,YAAQ,IAAI,MAAM;AAClB,WAAO;;KAKZ;EAED,aAAa;GACX,OAAO;GACP,eAAe;IACb,MAAM,MAAM,QAAQ,KAAK;IAQzB,MAAM,SADU,aALK,GAAG,eACtB,KACA,YACA,gBAEuC,CAAC,CAAC,QAAQ,UACzB,OAAA;AAC1B,QAAI,WAAW,SAAS,EACtB,KAAI;KACF,MAAM,wBAAQ,IAAI,KAAa;AAC/B,gBAAW,SAAQ,QAAO;AACV,eAAS,KAAK,EAAE,OAAO,MAAM,CACtC,CAAC,SAAQ,SAAQ,MAAM,IAAI,KAAK,CAAC;OACtC;AACF,eAAU,OAAO,QAAQ,UAAU;AACnC,aAAQ,IAAI,iBAAiB;aAEtB,KAAK;AACZ,aAAQ,MAAM,iCAAiC,IAAI;;;GAI1D;EAGO"}
@@ -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 * @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":";;;;;;;;;AAUA,SAAgB,UACd,UAAgC,EAAE,EACZ;CACtB,QAAA,GAAA,6BAAA,eAAqB,QAAQ"}
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 * @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":";;;;;;;;;AAUA,SAAgB,UACd,UAAgC,EAAE,EACZ;AACtB,SAAA,GAAA,6BAAA,eAAqB,QAAQ"}
@@ -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 * @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":";;;;;;;AAUA,SAAgB,UACd,UAAgC,EAAE,EACZ;CACtB,OAAO,cAAc,QAAQ"}
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 * @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":";;;;;;;AAUA,SAAgB,UACd,UAAgC,EAAE,EACZ;AACtB,QAAO,cAAc,QAAQ"}
@@ -4,7 +4,7 @@ import { externals } from './externals';
4
4
  import { tsPaths } from './tsPaths';
5
5
  export declare const PLUGIN_BUILDERS: {
6
6
  alias: typeof alias;
7
- typescript: ({ exclude, include, declarationMap, dir: outDir, }?: {
7
+ typescript: ({ exclude, include, declarationMap, dir, }?: {
8
8
  exclude?: string | string[];
9
9
  include?: Record<string, string>;
10
10
  declarationMap?: boolean;
@@ -13,7 +13,7 @@ export declare const PLUGIN_BUILDERS: {
13
13
  tsPaths: typeof tsPaths;
14
14
  circulars: typeof circulars;
15
15
  externals: typeof externals;
16
- clean: (options?: import("./clean").EndPluginOptions) => {
16
+ clean: (options: import("./clean").EndPluginOptions) => {
17
17
  name: string;
18
18
  onLog: {
19
19
  handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"tsPaths.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/tsPaths.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport tsConfigPaths from 'rollup-plugin-tsconfig-paths';\n\nexport type TsConfigPathsOptions = Parameters<typeof tsConfigPaths>[0];\n/**\n * Creates a configured tsconfig-paths plugin instance\n * @param options - Configuration options for tsconfig-paths\n * @returns Rolldown plugin\n */\nexport function tsPaths(\n options: TsConfigPathsOptions = {},\n): RolldownPluginOption {\n return tsConfigPaths(options);\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,QACd,UAAgC,EAAE,EACZ;CACtB,QAAA,GAAA,6BAAA,SAAqB,QAAQ"}
1
+ {"version":3,"file":"tsPaths.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/tsPaths.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport tsConfigPaths from 'rollup-plugin-tsconfig-paths';\n\nexport type TsConfigPathsOptions = Parameters<typeof tsConfigPaths>[0];\n/**\n * Creates a configured tsconfig-paths plugin instance\n * @param options - Configuration options for tsconfig-paths\n * @returns Rolldown plugin\n */\nexport function tsPaths(\n options: TsConfigPathsOptions = {},\n): RolldownPluginOption {\n return tsConfigPaths(options);\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,QACd,UAAgC,EAAE,EACZ;AACtB,SAAA,GAAA,6BAAA,SAAqB,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"tsPaths.js","names":[],"sources":["../../../src/rolldown-config/plugins/tsPaths.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport tsConfigPaths from 'rollup-plugin-tsconfig-paths';\n\nexport type TsConfigPathsOptions = Parameters<typeof tsConfigPaths>[0];\n/**\n * Creates a configured tsconfig-paths plugin instance\n * @param options - Configuration options for tsconfig-paths\n * @returns Rolldown plugin\n */\nexport function tsPaths(\n options: TsConfigPathsOptions = {},\n): RolldownPluginOption {\n return tsConfigPaths(options);\n}\n"],"mappings":";;;;;;;AASA,SAAgB,QACd,UAAgC,EAAE,EACZ;CACtB,OAAO,cAAc,QAAQ"}
1
+ {"version":3,"file":"tsPaths.js","names":[],"sources":["../../../src/rolldown-config/plugins/tsPaths.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport tsConfigPaths from 'rollup-plugin-tsconfig-paths';\n\nexport type TsConfigPathsOptions = Parameters<typeof tsConfigPaths>[0];\n/**\n * Creates a configured tsconfig-paths plugin instance\n * @param options - Configuration options for tsconfig-paths\n * @returns Rolldown plugin\n */\nexport function tsPaths(\n options: TsConfigPathsOptions = {},\n): RolldownPluginOption {\n return tsConfigPaths(options);\n}\n"],"mappings":";;;;;;;AASA,SAAgB,QACd,UAAgC,EAAE,EACZ;AACtB,QAAO,cAAc,QAAQ"}
@@ -1,13 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
3
  const require_rolldown_config_utils = require("../utils.cjs");
4
+ require("../constants.cjs");
4
5
  const require_rolldown_config_plugins_typescript_config = require("./typescript.config.cjs");
5
6
  let fs = require("fs");
6
- let tsc_alias = require("tsc-alias");
7
7
  let typescript = require("typescript");
8
8
  typescript = require_runtime.__toESM(typescript, 1);
9
+ let tsc_alias = require("tsc-alias");
9
10
  //#region src/rolldown-config/plugins/typescript.ts
10
- const typescript$1 = ({ exclude, include, declarationMap, dir: outDir } = {}) => {
11
+ const typescript$1 = ({ exclude, include, declarationMap, dir } = {}) => {
11
12
  let done = false;
12
13
  return {
13
14
  name: "bemedev-dts",
@@ -23,6 +24,7 @@ const typescript$1 = ({ exclude, include, declarationMap, dir: outDir } = {}) =>
23
24
  const tsconfigPath = typescript.default.findConfigFile(cwd, fs.existsSync, "tsconfig.json");
24
25
  const configFile = require_rolldown_config_plugins_typescript_config.readTsConfig(tsconfigPath);
25
26
  const host = typescript.default.createCompilerHost(configFile.options);
27
+ const outDir = configFile.options.outDir ?? dir ?? "lib";
26
28
  const parsed = typescript.default.parseJsonConfigFileContent({
27
29
  ...configFile,
28
30
  include,
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.cjs","names":["typescript","toArray","ts","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { toArray } from '../utils';\nimport { existsSync } from 'node:fs';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\nimport ts from 'typescript';\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: outDir,\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\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({\n configFile: tsconfigPath,\n outDir,\n });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;AAcA,MAAaA,gBAAc,EACzB,SACA,SACA,gBACA,KAAK,WACI,EAAE,KAA2B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHAC,8BAAAA,QAAQ,KAAK,SAAS,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,OAEjB,EAAE,qBAAqB;GACnD,OAAO;;EAET,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,KAAK;IAEzB,MAAM,eAAeC,WAAAA,QAAG,eACtB,KACAC,GAAAA,YACA,gBACD;IAED,MAAM,aAAaC,kDAAAA,aAAa,aAAa;IAC7C,MAAM,OAAOF,WAAAA,QAAG,mBAAmB,WAAW,QAAQ;IAEtD,MAAM,SAASA,WAAAA,QAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAGD,8BAAAA,QAAQ,QAAQ,EAAE,OAAO;KACtC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;MACD;KACF,EACDC,WAAAA,QAAG,KACH,IACD;IAED,MAAM,UAAUA,WAAAA,QAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;KACD,EACD,KACD;IAED,MAAM,aAAa,QAAQ,MAAM;IAEjC,MAAM,SAASA,WAAAA,QACZ,sBAAsB,QAAQ,CAC9B,OAAO,WAAW,YAAY,CAC9B,QAAO,MAAK,EAAE,aAAaA,WAAAA,QAAG,mBAAmB,MAAM;IAE1D,IAAI,OAAO,SAAS,GAClB,QAAQ,MACNA,WAAAA,QAAG,qCAAqC,QAAQ,KAAK,CACtD;IAGH,OAAA,GAAA,UAAA,sBAA2B;KACzB,YAAY;KACZ;KACD,CAAC;IAEF,OAAO;IACP,QAAQ,IAAI,0BAA0B;;GAEzC;EACF"}
1
+ {"version":3,"file":"typescript.cjs","names":["typescript","toArray","ts","existsSync","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { toArray } from '../utils';\nimport { existsSync } from 'node:fs';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\nimport ts from 'typescript';\nimport { readTsConfig } from './typescript.config';\nimport { DEFAULT_DIR } from '../constants';\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({\n configFile: tsconfigPath,\n outDir,\n });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAaA,gBAAc,EACzB,SACA,SACA,gBACA,QACS,EAAE,KAA2B;CACtC,IAAI,OAAO;AAEX,QAAO;EACL,MAAM;EACN,QAAQ,MAAM;AAIZ,QAAK,WAAW,CAAC,GAHAC,8BAAAA,QAAQ,KAAK,SAAS,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,OAEjB,EAAE,qBAAqB;AACnD,UAAO;;EAET,aAAa;GACX,OAAO;GACP,MAAM,UAAU;AACd,QAAI,KAAM;IACV,MAAM,MAAM,QAAQ,KAAK;IAEzB,MAAM,eAAeC,WAAAA,QAAG,eACtB,KACAC,GAAAA,YACA,gBACD;IAED,MAAM,aAAaC,kDAAAA,aAAa,aAAa;IAC7C,MAAM,OAAOF,WAAAA,QAAG,mBAAmB,WAAW,QAAQ;IACtD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAASA,WAAAA,QAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAGD,8BAAAA,QAAQ,QAAQ,EAAE,OAAO;KACtC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;MACD;KACF,EACDC,WAAAA,QAAG,KACH,IACD;IAED,MAAM,UAAUA,WAAAA,QAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;KACD,EACD,KACD;IAED,MAAM,aAAa,QAAQ,MAAM;IAEjC,MAAM,SAASA,WAAAA,QACZ,sBAAsB,QAAQ,CAC9B,OAAO,WAAW,YAAY,CAC9B,QAAO,MAAK,EAAE,aAAaA,WAAAA,QAAG,mBAAmB,MAAM;AAE1D,QAAI,OAAO,SAAS,EAClB,SAAQ,MACNA,WAAAA,QAAG,qCAAqC,QAAQ,KAAK,CACtD;AAGH,WAAA,GAAA,UAAA,sBAA2B;KACzB,YAAY;KACZ;KACD,CAAC;AAEF,WAAO;AACP,YAAQ,IAAI,0BAA0B;;GAEzC;EACF"}
@@ -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';\nimport ts from 'typescript';\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 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":";;;;;;;AAIA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,QAAA,GAAA,GAAA,cAAoB,UAAU,QAAQ;SAChC;EACN;;;AAIJ,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,EAAE;CAE5B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,WAAA,GAAA,GAAA,aAAsB,IAAI;UACpB;GACN;;EAGF,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAA,GAAA,KAAA,MAAgB,KAAK,MAAM;GACjC,IAAI;GACJ,IAAI;IACF,QAAA,GAAA,GAAA,UAAgB,SAAS;WACnB;IACN;;GAGF,IAAI,KAAK,aAAa,EACpB,KAAK,UAAU,eAAe,EAAE;QAC3B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,IAAI,CAAC,EAE3C,QAAQ,KAAK,SAAS;;;CAK5B,KAAK,SAAS,EAAE;CAChB,OAAO;;AAGT,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAYA,GAAAA;CACZ,UAAU;CACX;AAED,MAAa,gBAAgB,WAAiB;CAC5C,MAAM,aAAaC,WAAAA,QAAG,eAAeC,QAAM,UAAU;CAErD,IAAI,WAAW,OACb,MAAM,IAAI,MACRD,WAAAA,QAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,KAAK;EACxC,kBAAkB;EACnB,CAAC,CACH;CASH,OANqBA,WAAAA,QAAG,2BACtB,WAAW,QACX,QAAA,GAAA,KAAA,SACQC,OAAK,CAGI"}
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';\nimport ts from 'typescript';\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 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":";;;;;;;AAIA,MAAM,aAAa,aAAyC;AAC1D,KAAI;AACF,UAAA,GAAA,GAAA,cAAoB,UAAU,QAAQ;SAChC;AACN;;;AAIJ,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,EAAE;CAE5B,MAAM,QAAQ,KAAa,iBAAyB;AAClD,MAAI,UAAU,KAAA,KAAa,eAAe,MAAO;EAEjD,IAAI;AACJ,MAAI;AACF,cAAA,GAAA,GAAA,aAAsB,IAAI;UACpB;AACN;;AAGF,OAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAA,GAAA,KAAA,MAAgB,KAAK,MAAM;GACjC,IAAI;AACJ,OAAI;AACF,YAAA,GAAA,GAAA,UAAgB,SAAS;WACnB;AACN;;AAGF,OAAI,KAAK,aAAa,CACpB,MAAK,UAAU,eAAe,EAAE;YAEhC,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,IAAI,CAAC,CAE3C,SAAQ,KAAK,SAAS;;;AAK5B,MAAK,SAAS,EAAE;AAChB,QAAO;;AAGT,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAYA,GAAAA;CACZ,UAAU;CACX;AAED,MAAa,gBAAgB,WAAiB;CAC5C,MAAM,aAAaC,WAAAA,QAAG,eAAeC,QAAM,UAAU;AAErD,KAAI,WAAW,MACb,OAAM,IAAI,MACRD,WAAAA,QAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,KAAK;EACxC,kBAAkB;EACnB,CAAC,CACH;AASH,QANqBA,WAAAA,QAAG,2BACtB,WAAW,QACX,QAAA,GAAA,KAAA,SACQC,OAAK,CAGI"}
@@ -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';\nimport ts from 'typescript';\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 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":";;;;AAIA,MAAM,aAAa,aAAyC;CAC1D,IAAI;EACF,OAAO,aAAa,UAAU,QAAQ;SAChC;EACN;;;AAIJ,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,EAAE;CAE5B,MAAM,QAAQ,KAAa,iBAAyB;EAClD,IAAI,UAAU,KAAA,KAAa,eAAe,OAAO;EAEjD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,IAAI;UACpB;GACN;;EAGF,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,MAAM;GACjC,IAAI;GACJ,IAAI;IACF,OAAO,SAAS,SAAS;WACnB;IACN;;GAGF,IAAI,KAAK,aAAa,EACpB,KAAK,UAAU,eAAe,EAAE;QAC3B,IACL,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,IAAI,CAAC,EAE3C,QAAQ,KAAK,SAAS;;;CAK5B,KAAK,SAAS,EAAE;CAChB,OAAO;;AAGT,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;CACX;AAED,MAAa,gBAAgB,SAAiB;CAC5C,MAAM,aAAa,GAAG,eAAe,MAAM,UAAU;CAErD,IAAI,WAAW,OACb,MAAM,IAAI,MACR,GAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,KAAK;EACxC,kBAAkB;EACnB,CAAC,CACH;CASH,OANqB,GAAG,2BACtB,WAAW,QACX,OACA,QAAQ,KAAK,CAGI"}
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';\nimport ts from 'typescript';\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 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":";;;;AAIA,MAAM,aAAa,aAAyC;AAC1D,KAAI;AACF,SAAO,aAAa,UAAU,QAAQ;SAChC;AACN;;;AAIJ,MAAM,kBACJ,SACA,YACA,GACA,IACA,UACa;CACb,MAAM,UAAoB,EAAE;CAE5B,MAAM,QAAQ,KAAa,iBAAyB;AAClD,MAAI,UAAU,KAAA,KAAa,eAAe,MAAO;EAEjD,IAAI;AACJ,MAAI;AACF,aAAU,YAAY,IAAI;UACpB;AACN;;AAGF,OAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,KAAK,KAAK,MAAM;GACjC,IAAI;AACJ,OAAI;AACF,WAAO,SAAS,SAAS;WACnB;AACN;;AAGF,OAAI,KAAK,aAAa,CACpB,MAAK,UAAU,eAAe,EAAE;YAEhC,CAAC,cACD,WAAW,MAAK,QAAO,MAAM,SAAS,IAAI,CAAC,CAE3C,SAAQ,KAAK,SAAS;;;AAK5B,MAAK,SAAS,EAAE;AAChB,QAAO;;AAGT,MAAM,QAA4B;CAChC,2BAA2B;CAC3B,eAAe;CACf,YAAY;CACZ,UAAU;CACX;AAED,MAAa,gBAAgB,SAAiB;CAC5C,MAAM,aAAa,GAAG,eAAe,MAAM,UAAU;AAErD,KAAI,WAAW,MACb,OAAM,IAAI,MACR,GAAG,iBAAiB,WAAW,OAAO;EACpC,uBAAsB,MAAK;EAC3B,2BAA2B,QAAQ,KAAK;EACxC,kBAAkB;EACnB,CAAC,CACH;AASH,QANqB,GAAG,2BACtB,WAAW,QACX,OACA,QAAQ,KAAK,CAGI"}
@@ -5,5 +5,5 @@ type Props = {
5
5
  declarationMap?: boolean;
6
6
  dir?: string;
7
7
  };
8
- export declare const typescript: ({ exclude, include, declarationMap, dir: outDir, }?: Props) => RolldownPluginOption;
8
+ export declare const typescript: ({ exclude, include, declarationMap, dir, }?: Props) => RolldownPluginOption;
9
9
  export {};
@@ -1,10 +1,11 @@
1
1
  import { toArray } from "../utils.js";
2
+ import "../constants.js";
2
3
  import { readTsConfig } from "./typescript.config.js";
3
4
  import { existsSync } from "fs";
4
- import { replaceTscAliasPaths } from "tsc-alias";
5
5
  import ts from "typescript";
6
+ import { replaceTscAliasPaths } from "tsc-alias";
6
7
  //#region src/rolldown-config/plugins/typescript.ts
7
- const typescript = ({ exclude, include, declarationMap, dir: outDir } = {}) => {
8
+ const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
8
9
  let done = false;
9
10
  return {
10
11
  name: "bemedev-dts",
@@ -20,6 +21,7 @@ const typescript = ({ exclude, include, declarationMap, dir: outDir } = {}) => {
20
21
  const tsconfigPath = ts.findConfigFile(cwd, existsSync, "tsconfig.json");
21
22
  const configFile = readTsConfig(tsconfigPath);
22
23
  const host = ts.createCompilerHost(configFile.options);
24
+ const outDir = configFile.options.outDir ?? dir ?? "lib";
23
25
  const parsed = ts.parseJsonConfigFileContent({
24
26
  ...configFile,
25
27
  include,
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { toArray } from '../utils';\nimport { existsSync } from 'node:fs';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\nimport ts from 'typescript';\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: outDir,\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\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({\n configFile: tsconfigPath,\n outDir,\n });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;AAcA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,KAAK,WACI,EAAE,KAA2B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,SAAS,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,OAEjB,EAAE,qBAAqB;GACnD,OAAO;;EAET,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,KAAK;IAEzB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,gBACD;IAED,MAAM,aAAa,aAAa,aAAa;IAC7C,MAAM,OAAO,GAAG,mBAAmB,WAAW,QAAQ;IAEtD,MAAM,SAAS,GAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAG,QAAQ,QAAQ,EAAE,OAAO;KACtC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;MACD;KACF,EACD,GAAG,KACH,IACD;IAED,MAAM,UAAU,GAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;KACD,EACD,KACD;IAED,MAAM,aAAa,QAAQ,MAAM;IAEjC,MAAM,SAAS,GACZ,sBAAsB,QAAQ,CAC9B,OAAO,WAAW,YAAY,CAC9B,QAAO,MAAK,EAAE,aAAa,GAAG,mBAAmB,MAAM;IAE1D,IAAI,OAAO,SAAS,GAClB,QAAQ,MACN,GAAG,qCAAqC,QAAQ,KAAK,CACtD;IAGH,MAAM,qBAAqB;KACzB,YAAY;KACZ;KACD,CAAC;IAEF,OAAO;IACP,QAAQ,IAAI,0BAA0B;;GAEzC;EACF"}
1
+ {"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { toArray } from '../utils';\nimport { existsSync } from 'node:fs';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\nimport ts from 'typescript';\nimport { readTsConfig } from './typescript.config';\nimport { DEFAULT_DIR } from '../constants';\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({\n configFile: tsconfigPath,\n outDir,\n });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;AAeA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,EAAE,KAA2B;CACtC,IAAI,OAAO;AAEX,QAAO;EACL,MAAM;EACN,QAAQ,MAAM;AAIZ,QAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,SAAS,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,OAEjB,EAAE,qBAAqB;AACnD,UAAO;;EAET,aAAa;GACX,OAAO;GACP,MAAM,UAAU;AACd,QAAI,KAAM;IACV,MAAM,MAAM,QAAQ,KAAK;IAEzB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,gBACD;IAED,MAAM,aAAa,aAAa,aAAa;IAC7C,MAAM,OAAO,GAAG,mBAAmB,WAAW,QAAQ;IACtD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAAS,GAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAG,QAAQ,QAAQ,EAAE,OAAO;KACtC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;MACD;KACF,EACD,GAAG,KACH,IACD;IAED,MAAM,UAAU,GAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;KACD,EACD,KACD;IAED,MAAM,aAAa,QAAQ,MAAM;IAEjC,MAAM,SAAS,GACZ,sBAAsB,QAAQ,CAC9B,OAAO,WAAW,YAAY,CAC9B,QAAO,MAAK,EAAE,aAAa,GAAG,mBAAmB,MAAM;AAE1D,QAAI,OAAO,SAAS,EAClB,SAAQ,MACN,GAAG,qCAAqC,QAAQ,KAAK,CACtD;AAGH,UAAM,qBAAqB;KACzB,YAAY;KACZ;KACD,CAAC;AAEF,WAAO;AACP,YAAQ,IAAI,0BAA0B;;GAEzC;EACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";;AAEA,MAAa,WAAqB,UAAS;CAGzC,IAFe,UAAU,KAAA,KAAa,UAAU,MAEpC,OAAO,EAAE;CACrB,IAAI,MAAM,QAAQ,MAAM,EAAE,OAAO;CAEjC,OAAO,CAAC,MAAM"}
1
+ {"version":3,"file":"utils.cjs","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";;AAEA,MAAa,WAAqB,UAAS;AAGzC,KAFe,UAAU,KAAA,KAAa,UAAU,KAEpC,QAAO,EAAE;AACrB,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO;AAEjC,QAAO,CAAC,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";AAEA,MAAa,WAAqB,UAAS;CAGzC,IAFe,UAAU,KAAA,KAAa,UAAU,MAEpC,OAAO,EAAE;CACrB,IAAI,MAAM,QAAQ,MAAM,EAAE,OAAO;CAEjC,OAAO,CAAC,MAAM"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";AAEA,MAAa,WAAqB,UAAS;AAGzC,KAFe,UAAU,KAAA,KAAa,UAAU,KAEpC,QAAO,EAAE;AACrB,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO;AAEjC,QAAO,CAAC,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;AAAA,MAAa,SAAS,OAAe;CACnC,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC"}
1
+ {"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;AAAA,MAAa,SAAS,OAAe;AACnC,QAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";AAAA,MAAa,SAAS,OAAe;CACnC,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC"}
1
+ {"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";AAAA,MAAa,SAAS,OAAe;AACnC,QAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC"}
@@ -8,17 +8,17 @@ const require_vitest_exclude_constants = require("./constants.cjs");
8
8
  * @param args Globs to ignore for test and coverage files
9
9
  * @returns an object with includeTest and includeCoverage string arrays
10
10
  */
11
- async function create(args = {}) {
11
+ async function create(args = {}, root) {
12
12
  const firsts = {
13
- patternTest: require_vitest_exclude_vitest_utils.testPattern(),
14
- patternCov: require_vitest_exclude_vitest_utils.defaultCovPattern()
13
+ patternTest: require_vitest_exclude_vitest_utils.testPattern(root),
14
+ patternCov: require_vitest_exclude_vitest_utils.defaultCovPattern(root)
15
15
  };
16
- return create.withPattern(firsts, args);
16
+ return create.withPattern(firsts, args, root);
17
17
  }
18
- create.withPattern = async ({ patternTest = require_vitest_exclude_vitest_utils.testPattern(), patternCov = require_vitest_exclude_vitest_utils.defaultCovPattern() } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}) => {
18
+ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}, root) => {
19
19
  return {
20
- files: await require_vitest_exclude_vitest_utils.buildInclude(patternTest, ignoreTestFiles),
21
- coverage: await require_vitest_exclude_vitest_utils.buildInclude(patternCov, ignoreCoverageFiles)
20
+ files: await require_vitest_exclude_vitest_utils.buildInclude(patternTest ?? require_vitest_exclude_vitest_utils.testPattern(root), ignoreTestFiles, root),
21
+ coverage: await require_vitest_exclude_vitest_utils.buildInclude(patternCov ?? require_vitest_exclude_vitest_utils.defaultCovPattern(root), ignoreCoverageFiles, root)
22
22
  };
23
23
  };
24
24
  /**
@@ -33,12 +33,36 @@ create.withPattern = async ({ patternTest = require_vitest_exclude_vitest_utils.
33
33
  * The default search patter is './src/**\/*.ts'
34
34
  */
35
35
  function exclude(args = {}) {
36
- const patternCov = require_vitest_exclude_vitest_utils.defaultCovPattern();
37
- const patternTest = require_vitest_exclude_vitest_utils.testPattern();
38
- return exclude.withPattern({
39
- patternCov,
40
- patternTest
41
- }, args);
36
+ return {
37
+ name: require_vitest_exclude_constants.name,
38
+ enforce: "pre",
39
+ config: async (options) => {
40
+ const root = options?.root ?? process.cwd();
41
+ const testConfig = options?.test;
42
+ const coverage = options?.test?.coverage;
43
+ const patternCov = require_vitest_exclude_vitest_utils.defaultCovPattern(root);
44
+ const patternTest = require_vitest_exclude_vitest_utils.testPattern(root);
45
+ const { ignoreCoverageFiles, ignoreTestFiles } = args;
46
+ const all = await create.withPattern({
47
+ patternTest,
48
+ patternCov
49
+ }, {
50
+ ignoreCoverageFiles,
51
+ ignoreTestFiles
52
+ }, root);
53
+ return {
54
+ ...options,
55
+ test: {
56
+ ...testConfig,
57
+ include: all.files,
58
+ coverage: {
59
+ ...coverage,
60
+ include: all.coverage
61
+ }
62
+ }
63
+ };
64
+ }
65
+ };
42
66
  }
43
67
  /**
44
68
  * Plugin to add files with glob patterns to vitest
@@ -52,6 +76,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
52
76
  name: require_vitest_exclude_constants.name,
53
77
  enforce: "pre",
54
78
  config: async (options) => {
79
+ const root = options?.root ?? process.cwd();
55
80
  const testConfig = options?.test;
56
81
  const coverage = options?.test?.coverage;
57
82
  const all = await create.withPattern({
@@ -60,7 +85,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
60
85
  }, {
61
86
  ignoreCoverageFiles,
62
87
  ignoreTestFiles
63
- });
88
+ }, root);
64
89
  return {
65
90
  ...options,
66
91
  test: {
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns an object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}) {\n const firsts = {\n patternTest: testPattern(),\n patternCov: defaultCovPattern(),\n };\n\n return create.withPattern(firsts, args);\n}\n\ncreate.withPattern = async (\n {\n patternTest = testPattern(),\n patternCov = defaultCovPattern(),\n }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n) => {\n const files = await buildInclude(patternTest, ignoreTestFiles);\n const coverage = await buildInclude(patternCov, ignoreCoverageFiles);\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n const patternCov = defaultCovPattern();\n const patternTest = testPattern();\n return exclude.withPattern({ patternCov, patternTest }, args);\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;AAcA,eAAsB,OAAO,OAAgB,EAAE,EAAE;CAC/C,MAAM,SAAS;EACb,aAAaA,oCAAAA,aAAa;EAC1B,YAAYC,oCAAAA,mBAAmB;EAChC;CAED,OAAO,OAAO,YAAY,QAAQ,KAAK;;AAGzC,OAAO,cAAc,OACnB,EACE,cAAcD,oCAAAA,aAAa,EAC3B,aAAaC,oCAAAA,mBAAmB,KACZ,EAAE,EACxB,EAAE,iBAAiB,wBAAiC,EAAE,KACnD;CAGH,OAAO;EAAE,OAAA,MAFWC,oCAAAA,aAAa,aAAa,gBAAgB;EAE9C,UAAA,MADOA,oCAAAA,aAAa,YAAY,oBAAoB;EAC1C;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;CAC1C,MAAM,aAAaD,oCAAAA,mBAAmB;CACtC,MAAM,cAAcD,oCAAAA,aAAa;CACjC,OAAO,QAAQ,YAAY;EAAE;EAAY;EAAa,EAAE,KAAK;;;;;;;;;AAU/D,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,CACzC;GAED,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
1
+ {"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\nimport type { Plugin } from 'vitest/config';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns an object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;AAeA,eAAsB,OAAO,OAAgB,EAAE,EAAE,MAAe;CAC9D,MAAM,SAAS;EACb,aAAaA,oCAAAA,YAAY,KAAK;EAC9B,YAAYC,oCAAAA,kBAAkB,KAAK;EACpC;AAED,QAAO,OAAO,YAAY,QAAQ,MAAM,KAAK;;AAG/C,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,EAAE,EAClD,EAAE,iBAAiB,wBAAiC,EAAE,EACtD,SACG;AAWH,QAAO;EAAE,OAAA,MAVWC,oCAAAA,aAClB,eAAeF,oCAAAA,YAAY,KAAK,EAChC,iBACA,KACD;EAMe,UAAA,MALOE,oCAAAA,aACrB,cAAcD,oCAAAA,kBAAkB,KAAK,EACrC,qBACA,KACD;EACyB;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;AAC1C,QAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAaA,oCAAAA,kBAAkB,KAAK;GAC1C,MAAM,cAAcD,oCAAAA,YAAY,KAAK;GAErC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ;;;;;;;;;AAUH,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;AACH,QAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
@@ -1,16 +1,17 @@
1
1
  import type { Args, WithPattern } from './types';
2
+ import type { Plugin } from 'vitest/config';
2
3
  /**
3
4
  * Create includeTest and includeCoverage arrays from glob patterns
4
5
  *
5
6
  * @param args Globs to ignore for test and coverage files
6
7
  * @returns an object with includeTest and includeCoverage string arrays
7
8
  */
8
- export declare function create(args?: Args[1]): Promise<{
9
+ export declare function create(args?: Args[1], root?: string): Promise<{
9
10
  files: string[];
10
11
  coverage: string[];
11
12
  }>;
12
13
  export declare namespace create {
13
- var withPattern: ({ patternTest, patternCov, }?: Partial<Args[0]>, { ignoreTestFiles, ignoreCoverageFiles }?: Args[1]) => Promise<{
14
+ var withPattern: ({ patternTest, patternCov }?: Partial<Args[0]>, { ignoreTestFiles, ignoreCoverageFiles }?: Args[1], root?: string) => Promise<{
14
15
  files: string[];
15
16
  coverage: string[];
16
17
  }>;
@@ -26,7 +27,7 @@ export declare namespace create {
26
27
  * You don't have to use test.exclude.
27
28
  * The default search patter is './src/**\/*.ts'
28
29
  */
29
- export declare function exclude(args?: Args[1]): import("vite").Plugin<any>;
30
+ export declare function exclude(args?: Args[1]): Plugin;
30
31
  export declare namespace exclude {
31
32
  var withPattern: WithPattern;
32
33
  }
@@ -7,17 +7,17 @@ import { name } from "./constants.js";
7
7
  * @param args Globs to ignore for test and coverage files
8
8
  * @returns an object with includeTest and includeCoverage string arrays
9
9
  */
10
- async function create(args = {}) {
10
+ async function create(args = {}, root) {
11
11
  const firsts = {
12
- patternTest: testPattern(),
13
- patternCov: defaultCovPattern()
12
+ patternTest: testPattern(root),
13
+ patternCov: defaultCovPattern(root)
14
14
  };
15
- return create.withPattern(firsts, args);
15
+ return create.withPattern(firsts, args, root);
16
16
  }
17
- create.withPattern = async ({ patternTest = testPattern(), patternCov = defaultCovPattern() } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}) => {
17
+ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}, root) => {
18
18
  return {
19
- files: await buildInclude(patternTest, ignoreTestFiles),
20
- coverage: await buildInclude(patternCov, ignoreCoverageFiles)
19
+ files: await buildInclude(patternTest ?? testPattern(root), ignoreTestFiles, root),
20
+ coverage: await buildInclude(patternCov ?? defaultCovPattern(root), ignoreCoverageFiles, root)
21
21
  };
22
22
  };
23
23
  /**
@@ -32,12 +32,36 @@ create.withPattern = async ({ patternTest = testPattern(), patternCov = defaultC
32
32
  * The default search patter is './src/**\/*.ts'
33
33
  */
34
34
  function exclude(args = {}) {
35
- const patternCov = defaultCovPattern();
36
- const patternTest = testPattern();
37
- return exclude.withPattern({
38
- patternCov,
39
- patternTest
40
- }, args);
35
+ return {
36
+ name,
37
+ enforce: "pre",
38
+ config: async (options) => {
39
+ const root = options?.root ?? process.cwd();
40
+ const testConfig = options?.test;
41
+ const coverage = options?.test?.coverage;
42
+ const patternCov = defaultCovPattern(root);
43
+ const patternTest = testPattern(root);
44
+ const { ignoreCoverageFiles, ignoreTestFiles } = args;
45
+ const all = await create.withPattern({
46
+ patternTest,
47
+ patternCov
48
+ }, {
49
+ ignoreCoverageFiles,
50
+ ignoreTestFiles
51
+ }, root);
52
+ return {
53
+ ...options,
54
+ test: {
55
+ ...testConfig,
56
+ include: all.files,
57
+ coverage: {
58
+ ...coverage,
59
+ include: all.coverage
60
+ }
61
+ }
62
+ };
63
+ }
64
+ };
41
65
  }
42
66
  /**
43
67
  * Plugin to add files with glob patterns to vitest
@@ -51,6 +75,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
51
75
  name,
52
76
  enforce: "pre",
53
77
  config: async (options) => {
78
+ const root = options?.root ?? process.cwd();
54
79
  const testConfig = options?.test;
55
80
  const coverage = options?.test?.coverage;
56
81
  const all = await create.withPattern({
@@ -59,7 +84,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
59
84
  }, {
60
85
  ignoreCoverageFiles,
61
86
  ignoreTestFiles
62
- });
87
+ }, root);
63
88
  return {
64
89
  ...options,
65
90
  test: {
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns an object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}) {\n const firsts = {\n patternTest: testPattern(),\n patternCov: defaultCovPattern(),\n };\n\n return create.withPattern(firsts, args);\n}\n\ncreate.withPattern = async (\n {\n patternTest = testPattern(),\n patternCov = defaultCovPattern(),\n }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n) => {\n const files = await buildInclude(patternTest, ignoreTestFiles);\n const coverage = await buildInclude(patternCov, ignoreCoverageFiles);\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n const patternCov = defaultCovPattern();\n const patternTest = testPattern();\n return exclude.withPattern({ patternCov, patternTest }, args);\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;AAcA,eAAsB,OAAO,OAAgB,EAAE,EAAE;CAC/C,MAAM,SAAS;EACb,aAAa,aAAa;EAC1B,YAAY,mBAAmB;EAChC;CAED,OAAO,OAAO,YAAY,QAAQ,KAAK;;AAGzC,OAAO,cAAc,OACnB,EACE,cAAc,aAAa,EAC3B,aAAa,mBAAmB,KACZ,EAAE,EACxB,EAAE,iBAAiB,wBAAiC,EAAE,KACnD;CAGH,OAAO;EAAE,OAAA,MAFW,aAAa,aAAa,gBAAgB;EAE9C,UAAA,MADO,aAAa,YAAY,oBAAoB;EAC1C;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;CAC1C,MAAM,aAAa,mBAAmB;CACtC,MAAM,cAAc,aAAa;CACjC,OAAO,QAAQ,YAAY;EAAE;EAAY;EAAa,EAAE,KAAK;;;;;;;;;AAU/D,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,CACzC;GAED,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
1
+ {"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\nimport type { Plugin } from 'vitest/config';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns an object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;AAeA,eAAsB,OAAO,OAAgB,EAAE,EAAE,MAAe;CAC9D,MAAM,SAAS;EACb,aAAa,YAAY,KAAK;EAC9B,YAAY,kBAAkB,KAAK;EACpC;AAED,QAAO,OAAO,YAAY,QAAQ,MAAM,KAAK;;AAG/C,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,EAAE,EAClD,EAAE,iBAAiB,wBAAiC,EAAE,EACtD,SACG;AAWH,QAAO;EAAE,OAAA,MAVW,aAClB,eAAe,YAAY,KAAK,EAChC,iBACA,KACD;EAMe,UAAA,MALO,aACrB,cAAc,kBAAkB,KAAK,EACrC,qBACA,KACD;EACyB;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;AAC1C,QAAO;EACL;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAa,kBAAkB,KAAK;GAC1C,MAAM,cAAc,YAAY,KAAK;GAErC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ;;;;;;;;;AAUH,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;AACH,QAAO;EACL;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
@@ -4,23 +4,23 @@ let fs = require("fs");
4
4
  let glob = require("glob");
5
5
  let path = require("path");
6
6
  //#region src/vitest-exclude/vitest.utils.ts
7
- const hasSrc = () => {
8
- return (0, fs.existsSync)((0, path.join)(process.cwd(), "src"));
7
+ const hasSrc = (root = process.cwd()) => {
8
+ return (0, fs.existsSync)((0, path.join)(root, "src"));
9
9
  };
10
- const defaultCovPattern = () => {
10
+ const defaultCovPattern = (root) => {
11
11
  /* v8 ignore next */
12
- return `${hasSrc() ? "src/" : ""}**/*.t{s,sx}`;
12
+ return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
13
13
  };
14
14
  const mapper = (str) => str.replace(/\\/g, "/");
15
- const buildInclude = async (pattern, ignore) => {
15
+ const buildInclude = async (pattern, ignore, root = process.cwd()) => {
16
16
  return (await (0, glob.glob)(pattern, {
17
17
  ignore,
18
- cwd: process.cwd()
18
+ cwd: root
19
19
  })).map(mapper).sort();
20
20
  };
21
- const testPattern = () => {
21
+ const testPattern = (root) => {
22
22
  /* v8 ignore next */
23
- return `${hasSrc() ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
23
+ return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
24
24
  };
25
25
  //#endregion
26
26
  exports.buildInclude = buildInclude;
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { glob } from 'glob';\nimport { join } from 'node:path';\n\nexport const hasSrc = () => {\n return existsSync(join(process.cwd(), 'src'));\n};\n\nexport const defaultCovPattern = () => {\n const _src = hasSrc();\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n) => {\n const include = await glob(pattern, {\n ignore,\n cwd: process.cwd(),\n });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = () => {\n const _src = hasSrc();\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;AAIA,MAAa,eAAe;CAC1B,QAAA,GAAA,GAAA,aAAA,GAAA,KAAA,MAAuB,QAAQ,KAAK,EAAE,MAAM,CAAC;;AAG/C,MAAa,0BAA0B;;CAGrC,OAAO,GAFM,QAEC,GAAG,SAAS,GAAG;;AAG/B,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,IAAI;AACvD,MAAa,eAAe,OAC1B,SACA,WACG;CAMH,QAAO,OAAA,GAAA,KAAA,MALoB,SAAS;EAClC;EACA,KAAK,QAAQ,KAAK;EACnB,CAAC,EAEa,IAAI,OAAO,CAAC,MAAM;;AAGnC,MAAa,oBAAoB;;CAG/B,OAAO,GAFM,QAEC,GAAG,SAAS,GAAG"}
1
+ {"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { glob } from 'glob';\nimport { join } from 'node:path';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, {\n ignore,\n cwd: root,\n });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;AAIA,MAAa,UAAU,OAAO,QAAQ,KAAK,KAAK;AAC9C,SAAA,GAAA,GAAA,aAAA,GAAA,KAAA,MAAuB,MAAM,MAAM,CAAC;;AAGtC,MAAa,qBAAqB,SAAkB;;AAGlD,QAAO,GAFM,OAAO,KAEN,GAAG,SAAS,GAAG;;AAG/B,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,IAAI;AACvD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,KAAK,KACjB;AAMH,SAAO,OAAA,GAAA,KAAA,MALoB,SAAS;EAClC;EACA,KAAK;EACN,CAAC,EAEa,IAAI,OAAO,CAAC,MAAM;;AAGnC,MAAa,eAAe,SAAkB;;AAG5C,QAAO,GAFM,OAAO,KAEN,GAAG,SAAS,GAAG"}
@@ -1,4 +1,4 @@
1
- export declare const hasSrc: () => boolean;
2
- export declare const defaultCovPattern: () => string;
3
- export declare const buildInclude: (pattern: string | string[], ignore?: string[]) => Promise<string[]>;
4
- export declare const testPattern: () => string;
1
+ export declare const hasSrc: (root?: string) => boolean;
2
+ export declare const defaultCovPattern: (root?: string) => string;
3
+ export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
4
+ export declare const testPattern: (root?: string) => string;