@bemedev/dev-utils 1.0.1 → 1.0.2

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 (83) hide show
  1. package/README.md +30 -5
  2. package/lib/build-tests/addTarball.d.ts +1 -1
  3. package/lib/build-tests/buildPackageJson.d.ts +3 -3
  4. package/lib/build-tests/cleanup.d.ts +1 -1
  5. package/lib/build-tests/cli/cli.d.ts +51 -1
  6. package/lib/build-tests/cli/index.d.ts +1 -0
  7. package/lib/build-tests/cli/post.d.ts +5 -1
  8. package/lib/build-tests/cli/pre.d.ts +5 -1
  9. package/lib/build-tests/cli/test.d.ts +15 -1
  10. package/lib/build-tests/constants.d.ts +1 -1
  11. package/lib/build-tests/getRelativePath.d.ts +1 -1
  12. package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
  13. package/lib/build-tests/import.d.ts +2 -2
  14. package/lib/build-tests/imports/create.d.ts +3 -3
  15. package/lib/build-tests/imports/helper.d.ts +7 -3
  16. package/lib/build-tests/imports/index.d.ts +1 -1
  17. package/lib/build-tests/index.d.ts +5 -5
  18. package/lib/build-tests/pack.d.ts +1 -1
  19. package/lib/rolldown-config/config.d.ts +1 -1
  20. package/lib/rolldown-config/constants.d.ts +5 -5
  21. package/lib/rolldown-config/helpers.d.ts +2 -2
  22. package/lib/rolldown-config/index.d.ts +3 -3
  23. package/lib/rolldown-config/input.d.ts +1 -1
  24. package/lib/rolldown-config/output.d.ts +15 -1
  25. package/lib/rolldown-config/plugins/circulars.d.ts +9 -9
  26. package/lib/rolldown-config/plugins/clean.cjs +3 -1
  27. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  28. package/lib/rolldown-config/plugins/clean.d.ts +13 -4
  29. package/lib/rolldown-config/plugins/clean.js +4 -2
  30. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  31. package/lib/rolldown-config/plugins/externals.d.ts +7 -7
  32. package/lib/rolldown-config/plugins/index.d.ts +23 -2
  33. package/lib/rolldown-config/plugins/typescript.cjs +29 -41
  34. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  35. package/lib/rolldown-config/plugins/typescript.config.cjs +46 -39
  36. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  37. package/lib/rolldown-config/plugins/typescript.config.d.ts +2 -4
  38. package/lib/rolldown-config/plugins/typescript.config.js +47 -41
  39. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  40. package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
  41. package/lib/rolldown-config/plugins/typescript.js +29 -43
  42. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  43. package/lib/rolldown-config/types.d.ts +13 -13
  44. package/lib/utils/array.d.ts +1 -1
  45. package/lib/utils/identity.d.ts +1 -1
  46. package/lib/utils/index.d.ts +4 -4
  47. package/lib/utils/sleep.d.ts +1 -1
  48. package/lib/utils/types.d.ts +1 -4
  49. package/lib/vitest-exclude/index.d.ts +1 -1
  50. package/lib/vitest-exclude/types.d.ts +11 -8
  51. package/lib/vitest-exclude/vitest.cjs +0 -2
  52. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  53. package/lib/vitest-exclude/vitest.d.ts +27 -15
  54. package/lib/vitest-exclude/vitest.js +0 -2
  55. package/lib/vitest-exclude/vitest.js.map +1 -1
  56. package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
  57. package/lib/vitest-extended/acceptation.d.ts +3 -2
  58. package/lib/vitest-extended/bemedev/globals/types.d.ts +1 -4
  59. package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -10
  60. package/lib/vitest-extended/createTests.d.ts +55 -34
  61. package/lib/vitest-extended/createTests.types.d.ts +6 -10
  62. package/lib/vitest-extended/done.d.ts +14 -8
  63. package/lib/vitest-extended/each/error.d.ts +1 -1
  64. package/lib/vitest-extended/each/error.types.d.ts +4 -10
  65. package/lib/vitest-extended/each/index.d.ts +2 -2
  66. package/lib/vitest-extended/each/pass.d.ts +26 -26
  67. package/lib/vitest-extended/each/pass.types.d.ts +6 -18
  68. package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
  69. package/lib/vitest-extended/identity.d.ts +2 -2
  70. package/lib/vitest-extended/index.cjs +2 -0
  71. package/lib/vitest-extended/index.d.ts +7 -6
  72. package/lib/vitest-extended/index.js +2 -1
  73. package/lib/vitest-extended/isDefined.d.ts +1 -1
  74. package/lib/vitest-extended/isFunction.d.ts +1 -1
  75. package/lib/vitest-extended/project.cjs +23 -0
  76. package/lib/vitest-extended/project.cjs.map +1 -0
  77. package/lib/vitest-extended/project.d.ts +2 -0
  78. package/lib/vitest-extended/project.js +22 -0
  79. package/lib/vitest-extended/project.js.map +1 -0
  80. package/lib/vitest-extended/toArray.d.ts +1 -1
  81. package/lib/vitest-extended/toStringFlat.d.ts +1 -1
  82. package/lib/vitest-extended/types.d.ts +38 -40
  83. package/package.json +3 -7
package/README.md CHANGED
@@ -3,6 +3,11 @@
3
3
  A collection of utilities for Node.js development, including build tools,
4
4
  testing utilities, and configuration management.
5
5
 
6
+ ## HOTFIX fix for version 1.0.*
7
+
8
+ > It doesn't type declarations well, if you're not put directly the output
9
+ > type
10
+
6
11
  ## Modules
7
12
 
8
13
  | Module | Description |
@@ -365,6 +370,29 @@ vitestExtended.useTFA(myFunction, 'myFunction');
365
370
 
366
371
  ---
367
372
 
373
+ ### `defineProject(config)`
374
+
375
+ A wrapper around Vitest's `defineProject` / `defineConfig` that injects
376
+ default configurations.
377
+
378
+ > [!IMPORTANT] **HOT FIX**: Use this instead of standard `defineProject`
379
+ > from `vitest/config` to automatically resolve path aliases (via
380
+ > `tsconfigPaths: true`), set `globals: true`, configure
381
+ > `logHeapUsage: false`, and set the `NODE_ENV` environment variable to
382
+ > `'test'` by default.
383
+
384
+ ```typescript
385
+ import { defineProject } from '@bemedev/dev-utils/vitest-extended';
386
+
387
+ export default defineProject({
388
+ test: {
389
+ // your config here
390
+ },
391
+ });
392
+ ```
393
+
394
+ ---
395
+
368
396
  ### Utility helpers
369
397
 
370
398
  | Export | Signature | Description |
@@ -379,8 +407,7 @@ vitestExtended.useTFA(myFunction, 'myFunction');
379
407
  ## `rolldownConfig`
380
408
 
381
409
  Rolldown bundler configuration factory with built-in plugins for TypeScript
382
- declarations, circular dependency detection, and
383
- tree-shaking externals.
410
+ declarations, circular dependency detection, and tree-shaking externals.
384
411
 
385
412
  ### `defineConfig(additionals?)`
386
413
 
@@ -470,9 +497,7 @@ Pass plugin keys as strings in the `plugins` array to reorder or subset
470
497
  them:
471
498
 
472
499
  ```typescript
473
- defineConfig.default({
474
- plugins: ['externals', 'typescript'],
475
- });
500
+ defineConfig.default({ plugins: ['externals', 'typescript'] });
476
501
  ```
477
502
 
478
503
  ---
@@ -1 +1 @@
1
- export declare const addTarball: unknown;
1
+ export declare const addTarball: () => Promise<void>;
@@ -1,7 +1,7 @@
1
- import type { Fn } from "../utils/index.js";
1
+ import type { Fn } from '../utils/index.js';
2
2
  type BuldPackageJson_F = Fn<[], {
3
- packageJson: object;
4
- outDir: string;
3
+ packageJson: object;
4
+ outDir: string;
5
5
  }>;
6
6
  export declare const buildPackageJson: BuldPackageJson_F;
7
7
  export {};
@@ -1 +1 @@
1
- export declare const cleanup: unknown;
1
+ export declare const cleanup: () => void;
@@ -1,2 +1,52 @@
1
1
  export declare const BIN = "build-tests";
2
- export declare const cli: unknown;
2
+ export declare const cli: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
3
+ parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
4
+ command: "posttest";
5
+ args: {};
6
+ } | {
7
+ command: "pretest";
8
+ args: {};
9
+ } | {
10
+ command: "test";
11
+ args: {
12
+ pretest: boolean;
13
+ posttest: boolean;
14
+ pre: boolean;
15
+ post: boolean;
16
+ };
17
+ }>>;
18
+ } & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{
19
+ command: "posttest";
20
+ args: {};
21
+ } | {
22
+ command: "pretest";
23
+ args: {};
24
+ } | {
25
+ command: "test";
26
+ args: {
27
+ pretest: boolean;
28
+ posttest: boolean;
29
+ pre: boolean;
30
+ post: boolean;
31
+ };
32
+ }, {
33
+ command: "posttest";
34
+ value: void;
35
+ } | {
36
+ command: "pretest";
37
+ value: Promise<void>;
38
+ } | {
39
+ command: "test";
40
+ value: Promise<void>;
41
+ }> & {
42
+ run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
43
+ command: "posttest";
44
+ value: void;
45
+ } | {
46
+ command: "pretest";
47
+ value: Promise<void>;
48
+ } | {
49
+ command: "test";
50
+ value: Promise<void>;
51
+ }>>;
52
+ };
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
@@ -1 +1,5 @@
1
- export declare const posttest: unknown;
1
+ export declare const posttest: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
2
+ parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{}>>;
3
+ } & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & import("cmd-ts/dist/cjs/helpdoc").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{}, void> & {
4
+ run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<void>>;
5
+ } & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned & import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Aliased>;
@@ -1 +1,5 @@
1
- export declare const pretest: unknown;
1
+ export declare const pretest: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
2
+ parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{}>>;
3
+ } & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & import("cmd-ts/dist/cjs/helpdoc").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{}, Promise<void>> & {
4
+ run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<Promise<void>>>;
5
+ } & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned & import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Aliased>;
@@ -1 +1,15 @@
1
- export declare const test: unknown;
1
+ export declare const test: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
2
+ parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
3
+ pretest: boolean;
4
+ posttest: boolean;
5
+ pre: boolean;
6
+ post: boolean;
7
+ }>>;
8
+ } & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & import("cmd-ts/dist/cjs/helpdoc").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{
9
+ pretest: boolean;
10
+ posttest: boolean;
11
+ pre: boolean;
12
+ post: boolean;
13
+ }, Promise<void>> & {
14
+ run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<Promise<void>>>;
15
+ } & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned & import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Aliased>;
@@ -10,5 +10,5 @@ export declare const TS_PATH = "./tsconfig.json";
10
10
  export declare const PACKAGE_PATH = "./package.json";
11
11
  export declare const TARBALL_FOLDER = ".pack";
12
12
  export declare const TARBALL_EXTENSION = ".tgz";
13
- export declare const TEARDOWN_COMMAND: unknown;
13
+ export declare const TEARDOWN_COMMAND = "pnpm remove this-gen-1";
14
14
  export declare const DEFAULT_OUT_DIR = "./lib";
@@ -1,4 +1,4 @@
1
- import type { Fn } from "../utils/types";
1
+ import type { Fn } from '../utils/types';
2
2
  type GetRelativePath_F = Fn<[string], string>;
3
3
  export declare const getRelativePath0: GetRelativePath_F;
4
4
  export {};
@@ -1,4 +1,4 @@
1
- import type { Fn } from "../utils/types";
1
+ import type { Fn } from '../utils/types';
2
2
  type Fn1 = Fn<[], string>;
3
3
  export declare const getTypescriptOutdir: Fn1;
4
4
  export {};
@@ -1,6 +1,6 @@
1
1
  type Args<T = any> = {
2
- path?: string;
3
- fn: (out: any) => T;
2
+ path?: string;
3
+ fn: (out: any) => T;
4
4
  };
5
5
  type CustomImport_F = <T = any>(args: Args<T>) => Promise<T>;
6
6
  export declare const customImport: CustomImport_F;
@@ -1,7 +1,7 @@
1
1
  export type ImportArgs = {
2
- path?: string;
3
- FAILS?: string[];
4
- SUCCESS: string[];
2
+ path?: string;
3
+ FAILS?: string[];
4
+ SUCCESS: string[];
5
5
  };
6
6
  export type CreateImportTest_F = (args: ImportArgs) => readonly [string, () => void];
7
7
  export declare const createImportFnTests: CreateImportTest_F;
@@ -1,5 +1,9 @@
1
+ import type { Fn } from '../../vitest-extended/bemedev/globals/types';
1
2
  export type Helper_F = (args: {
2
- path?: string;
3
- fn: string;
3
+ path?: string;
4
+ fn: string;
5
+ }) => Promise<void>;
6
+ export declare const helperFn: <T extends Fn = Fn>({ path, fn, }: {
7
+ path?: string;
8
+ fn: string;
4
9
  }) => Promise<void>;
5
- export declare const helperFn: unknown;
@@ -1 +1 @@
1
- export * from "./create";
1
+ export * from './create';
@@ -1,5 +1,5 @@
1
- export * from "./addTarball";
2
- export * from "./cleanup";
3
- export { THIS1 } from "./constants";
4
- export * from "./import";
5
- export * from "./imports";
1
+ export * from './addTarball';
2
+ export * from './cleanup';
3
+ export { THIS1 } from './constants';
4
+ export * from './import';
5
+ export * from './imports';
@@ -1,4 +1,4 @@
1
- import type { Fn } from "../utils/types";
1
+ import type { Fn } from '../utils/types';
2
2
  type Pack_F = Fn<[], Promise<string>>;
3
3
  export declare const pack: Pack_F;
4
4
  export {};
@@ -1,2 +1,2 @@
1
- import type { Config_F } from "./types";
1
+ import type { Config_F } from './types';
2
2
  export declare const defineConfig: Config_F;
@@ -1,8 +1,8 @@
1
- export declare const DEFAULT_EXCLUDE: unknown;
2
- export declare const DEFAULT_CIRCULAR_DEPS: unknown;
3
- export declare const IGNORE: unknown;
1
+ export declare const DEFAULT_EXCLUDE: string[];
2
+ export declare const DEFAULT_CIRCULAR_DEPS: string[];
3
+ export declare const IGNORE: string[];
4
4
  export declare const DEFAULT_DIR = "lib";
5
5
  export declare const WARNING_CODES: {
6
- EMPTY_BUNDLE: string;
7
- CIRCULAR_DEPENDENCY: string;
6
+ EMPTY_BUNDLE: string;
7
+ CIRCULAR_DEPENDENCY: string;
8
8
  };
@@ -1,2 +1,2 @@
1
- export declare const withoutExtension: unknown;
2
- export declare const cleanupJS: unknown;
1
+ export declare const withoutExtension: (file: string) => string;
2
+ export declare const cleanupJS: (files: Set<string>, dir: string, sourcemap: boolean) => void;
@@ -1,3 +1,3 @@
1
- export * from "./config";
2
- export * from "./plugins";
3
- export * from "./types";
1
+ export * from './config';
2
+ export * from './plugins';
3
+ export * from './types';
@@ -1,2 +1,2 @@
1
- import type { BuildInput_F } from "./types";
1
+ import type { BuildInput_F } from './types';
2
2
  export declare const buildInput: BuildInput_F;
@@ -1 +1,15 @@
1
- export declare const buildOutput: unknown;
1
+ export declare const buildOutput: (dir: string | undefined, sourcemap: boolean) => [{
2
+ readonly format: "es";
3
+ readonly sourcemap: boolean;
4
+ readonly preserveModulesRoot: "src";
5
+ readonly dir: string;
6
+ readonly preserveModules: true;
7
+ readonly entryFileNames: "[name].js";
8
+ }, {
9
+ readonly format: "cjs";
10
+ readonly sourcemap: boolean;
11
+ readonly preserveModulesRoot: "src";
12
+ readonly dir: string;
13
+ readonly preserveModules: true;
14
+ readonly entryFileNames: "[name].cjs";
15
+ }];
@@ -1,13 +1,13 @@
1
- import type { RolldownPluginOption } from "rolldown";
2
- import { circularDependencies } from "rollup-plugin-circular-dependencies";
1
+ import type { RolldownPluginOption } from 'rolldown';
2
+ import { circularDependencies } from 'rollup-plugin-circular-dependencies';
3
3
  export type CircularDependenciesOptions = Parameters<typeof circularDependencies>[0] & {
4
- exclude?: string | string[];
4
+ exclude?: string | string[];
5
5
  };
6
6
  /**
7
- * Creates a configured circular dependencies plugin instance
8
- *
9
- * @param options - Configuration options for circular dependencies
10
- * detection
11
- * @returns Rolldown plugin
12
- */
7
+ * Creates a configured circular dependencies plugin instance
8
+ *
9
+ * @param options - Configuration options for circular dependencies
10
+ * detection
11
+ * @returns Rolldown plugin
12
+ */
13
13
  export declare function circulars(options?: CircularDependenciesOptions): RolldownPluginOption;
@@ -3,8 +3,10 @@ const require_utils_array = require("../../utils/array.cjs");
3
3
  const require_rolldown_config_constants = require("../constants.cjs");
4
4
  const require_rolldown_config_helpers = require("../helpers.cjs");
5
5
  const require_rolldown_config_plugins_typescript_config = require("./typescript.config.cjs");
6
+ let fs = require("fs");
6
7
  let path = require("path");
7
8
  let glob = require("glob");
9
+ let _typescript_typescript6 = require("@typescript/typescript6");
8
10
  //#region src/rolldown-config/plugins/clean.ts
9
11
  const clean = (options) => {
10
12
  const { ignoresJS, sourcemap = false, dir } = options;
@@ -25,7 +27,7 @@ const clean = (options) => {
25
27
  closeBundle: {
26
28
  order: "post",
27
29
  handler: () => {
28
- const outDir = require_rolldown_config_plugins_typescript_config.readTsConfig(require_rolldown_config_plugins_typescript_config.findConfigFile(process.cwd(), "tsconfig.json")).compilerOptions.outDir ?? dir ?? "lib";
30
+ const outDir = require_rolldown_config_plugins_typescript_config.readTsConfig((0, _typescript_typescript6.findConfigFile)(process.cwd(), fs.existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
29
31
  if (_ignoresJS.length > 0) try {
30
32
  const files = /* @__PURE__ */ new Set();
31
33
  _ignoresJS.forEach((pat) => {
@@ -1 +1 @@
1
- {"version":3,"file":"clean.cjs","names":["toArray","withoutExtension","WARNING_CODES","readTsConfig","findConfigFile"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { relative } from 'node:path';\n\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 { findConfigFile, 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(cwd, 'tsconfig.json')!;\n const _outDir = readTsConfig(tsconfigPath).compilerOptions.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":";;;;;;;;AAiBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAaA,oBAAAA,QAAQ,SAAS;CAwDpC,OAAO;EArDL,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;IAKb,MAAM,SADUC,kDAAAA,aADKC,kDAAAA,eAFT,QAAQ,IAEkB,GAAG,eACD,CAAC,CAAC,CAAC,gBAAgB,UACjC,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","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,6 +1,15 @@
1
1
  export type EndPluginOptions = {
2
- ignoresJS?: string | string[];
3
- sourcemap?: boolean;
4
- dir?: string;
2
+ ignoresJS?: string | string[];
3
+ sourcemap?: boolean;
4
+ dir?: string;
5
+ };
6
+ export declare const clean: (options: EndPluginOptions) => {
7
+ name: string;
8
+ onLog: {
9
+ handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
10
+ };
11
+ closeBundle: {
12
+ order: "post";
13
+ handler: () => void;
14
+ };
5
15
  };
6
- export declare const clean: unknown;
@@ -1,9 +1,11 @@
1
1
  import { toArray } from "../../utils/array.js";
2
2
  import { WARNING_CODES } from "../constants.js";
3
3
  import { cleanupJS, withoutExtension } from "../helpers.js";
4
- import { findConfigFile, readTsConfig } from "./typescript.config.js";
4
+ import { readTsConfig } from "./typescript.config.js";
5
+ import { existsSync } from "fs";
5
6
  import { relative } from "path";
6
7
  import { globSync } from "glob";
8
+ import { findConfigFile } from "@typescript/typescript6";
7
9
  //#region src/rolldown-config/plugins/clean.ts
8
10
  const clean = (options) => {
9
11
  const { ignoresJS, sourcemap = false, dir } = options;
@@ -24,7 +26,7 @@ const clean = (options) => {
24
26
  closeBundle: {
25
27
  order: "post",
26
28
  handler: () => {
27
- const outDir = readTsConfig(findConfigFile(process.cwd(), "tsconfig.json")).compilerOptions.outDir ?? dir ?? "lib";
29
+ const outDir = readTsConfig(findConfigFile(process.cwd(), existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
28
30
  if (_ignoresJS.length > 0) try {
29
31
  const files = /* @__PURE__ */ new Set();
30
32
  _ignoresJS.forEach((pat) => {
@@ -1 +1 @@
1
- {"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { relative } from 'node:path';\n\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 { findConfigFile, 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(cwd, 'tsconfig.json')!;\n const _outDir = readTsConfig(tsconfigPath).compilerOptions.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":";;;;;;;AAiBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAa,QAAQ,SAAS;CAwDpC,OAAO;EArDL,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;IAKb,MAAM,SADU,aADK,eAFT,QAAQ,IAEkB,GAAG,eACD,CAAC,CAAC,CAAC,gBAAgB,UACjC,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\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,10 +1,10 @@
1
- import type { RolldownPluginOption } from "rolldown";
2
- import { nodeExternals } from "rollup-plugin-node-externals";
1
+ import type { RolldownPluginOption } from 'rolldown';
2
+ import { nodeExternals } from 'rollup-plugin-node-externals';
3
3
  export type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];
4
4
  /**
5
- * Creates a configured node externals plugin instance
6
- *
7
- * @param options - Configuration options for node externals
8
- * @returns Rolldown plugin
9
- */
5
+ * Creates a configured node externals plugin instance
6
+ *
7
+ * @param options - Configuration options for node externals
8
+ * @returns Rolldown plugin
9
+ */
10
10
  export declare function externals(options?: NodeExternalsOptions): RolldownPluginOption;
@@ -1,2 +1,23 @@
1
- export declare const PLUGIN_BUILDERS: {};
2
- export declare const DEFAULT_PLUGINS_ORDER: unknown;
1
+ import { circulars } from './circulars';
2
+ import { externals } from './externals';
3
+ export declare const PLUGIN_BUILDERS: {
4
+ typescript: ({ exclude, include, declarationMap, dir, }?: {
5
+ exclude?: string | string[];
6
+ include?: Record<string, string>;
7
+ declarationMap?: boolean;
8
+ dir?: string;
9
+ }) => import("rolldown").RolldownPluginOption;
10
+ circulars: typeof circulars;
11
+ externals: typeof externals;
12
+ clean: (options: import("./clean").EndPluginOptions) => {
13
+ name: string;
14
+ onLog: {
15
+ handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
16
+ };
17
+ closeBundle: {
18
+ order: "post";
19
+ handler: () => void;
20
+ };
21
+ };
22
+ };
23
+ export declare const DEFAULT_PLUGINS_ORDER: string[];
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
3
  const require_utils_array = require("../../utils/array.cjs");
3
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 path = require("path");
7
- let glob = require("glob");
8
- let oxc_transform = require("oxc-transform");
7
+ let _typescript_typescript6 = require("@typescript/typescript6");
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
11
  const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
@@ -21,46 +21,34 @@ const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
21
21
  async handler() {
22
22
  if (done) return;
23
23
  const cwd = process.cwd();
24
- const tsconfigPath = require_rolldown_config_plugins_typescript_config.findConfigFile(cwd, "tsconfig.json");
24
+ const tsconfigPath = _typescript_typescript6.default.findConfigFile(cwd, fs.existsSync, "tsconfig.json");
25
25
  const configFile = require_rolldown_config_plugins_typescript_config.readTsConfig(tsconfigPath);
26
- const outDir = configFile.compilerOptions.outDir ?? dir ?? "lib";
27
- const rootDir = configFile.compilerOptions.rootDir ?? (0, path.join)(cwd, "src");
28
- let files;
29
- if (include && Object.keys(include).length > 0) files = Object.values(include);
30
- else files = (0, glob.globSync)((0, path.join)(rootDir, "**/*.{ts,tsx,cts,mts}"), { ignore: require_utils_array.toArray(exclude) });
31
- files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
32
- const errors = [];
33
- for (const file of files) try {
34
- const result = (0, oxc_transform.transformSync)(file, (0, fs.readFileSync)(file, "utf-8"), {
35
- typescript: { declaration: { sourcemap: !!declarationMap } },
36
- sourcemap: !!declarationMap
37
- });
38
- if (result.errors && result.errors.length > 0) errors.push(...result.errors);
39
- const relativePath = (0, path.relative)(rootDir, file);
40
- let dtsName = relativePath;
41
- if (relativePath.endsWith(".tsx")) dtsName = relativePath.slice(0, -4) + ".d.ts";
42
- else if (relativePath.endsWith(".ts")) dtsName = relativePath.slice(0, -3) + ".d.ts";
43
- else if (relativePath.endsWith(".cts")) dtsName = relativePath.slice(0, -4) + ".d.cts";
44
- else if (relativePath.endsWith(".mts")) dtsName = relativePath.slice(0, -4) + ".d.mts";
45
- const outPath = (0, path.join)(outDir, dtsName);
46
- const outMapPath = outPath + ".map";
47
- (0, fs.mkdirSync)((0, path.dirname)(outPath), { recursive: true });
48
- let dtsCode = result.declaration ?? "";
49
- if (declarationMap && result.declarationMap) {
50
- dtsCode += `\n//# sourceMappingURL=${(0, path.basename)(dtsName)}.map\n`;
51
- (0, fs.writeFileSync)(outMapPath, JSON.stringify(result.declarationMap), "utf-8");
26
+ const host = _typescript_typescript6.default.createCompilerHost(configFile.options);
27
+ const outDir = configFile.options.outDir ?? dir ?? "lib";
28
+ const parsed = _typescript_typescript6.default.parseJsonConfigFileContent({
29
+ ...configFile,
30
+ include,
31
+ exclude: [...require_utils_array.toArray(exclude), "*.ts"],
32
+ compilerOptions: {
33
+ ...configFile.options,
34
+ outDir,
35
+ noEmit: false,
36
+ emitDeclarationOnly: true,
37
+ declaration: true,
38
+ declarationMap
52
39
  }
53
- (0, fs.writeFileSync)(outPath, dtsCode, "utf-8");
54
- } catch (err) {
55
- console.error(`[bemedev-dts] Failed to process ${file}:`, err);
56
- }
57
- if (errors.length > 0) {
58
- console.error(`[bemedev-dts] Generation completed with errors:`);
59
- for (const err of errors) {
60
- console.error(`Error in ${err.filename || "unknown file"}: ${err.message}`);
61
- if (err.codeframe) console.error(err.codeframe);
62
- }
63
- }
40
+ }, _typescript_typescript6.default.sys, cwd);
41
+ const program = _typescript_typescript6.default.createProgram(parsed.fileNames, {
42
+ ...configFile.options,
43
+ outDir,
44
+ noEmit: false,
45
+ emitDeclarationOnly: true,
46
+ declaration: true,
47
+ declarationMap
48
+ }, host);
49
+ const emitResult = program.emit();
50
+ const errors = _typescript_typescript6.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).filter((d) => d.category === _typescript_typescript6.default.DiagnosticCategory.Error);
51
+ if (errors.length > 0) console.error(_typescript_typescript6.default.formatDiagnosticsWithColorAndContext(errors, host));
64
52
  await (0, tsc_alias.replaceTscAliasPaths)({
65
53
  configFile: tsconfigPath,
66
54
  outDir
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.cjs","names":["toArray","findConfigFile","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\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 { findConfigFile, 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 = findConfigFile(cwd, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir =\n configFile.compilerOptions.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir =\n configFile.compilerOptions.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 typescript: { declaration: { sourcemap: !!declarationMap } },\n 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.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"}