@ts-ioc-container/bundler 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/AGENTS.md +45 -40
  2. package/README.md +181 -129
  3. package/cjm/app.js +2 -2
  4. package/cjm/cli/Application.js +4 -5
  5. package/cjm/cli/options.js +4 -2
  6. package/cjm/cli/usage.js +11 -8
  7. package/cjm/domain/CliIo.js +7 -1
  8. package/cjm/exceptions/DomainException.js +7 -7
  9. package/cjm/features/build/BuildConfig.js +108 -59
  10. package/cjm/features/build/BuildController.js +36 -46
  11. package/cjm/features/build/domain/ImportPaths.js +30 -8
  12. package/cjm/features/build/domain/emit.js +2 -2
  13. package/cjm/features/build/domain/scan.js +20 -4
  14. package/cjm/features/build/domain/tokenCollisions.js +1 -1
  15. package/cjm/features/build/domain/tsconfig.js +10 -35
  16. package/cjm/features/build/services/BundleBuilder.js +36 -29
  17. package/cjm/features/build/services/TicConfigService.js +10 -31
  18. package/cjm/index.js +9 -10
  19. package/cjm/schema/ticConfigSchema.js +5 -1
  20. package/package.json +2 -2
  21. package/tic.schema.json +117 -73
  22. package/tpl/index.cjs +15 -15
  23. package/typings/app.d.ts +7 -6
  24. package/typings/cli/Application.d.ts.map +1 -1
  25. package/typings/cli/options.d.ts +7 -1
  26. package/typings/cli/options.d.ts.map +1 -1
  27. package/typings/cli/usage.d.ts.map +1 -1
  28. package/typings/domain/CliIo.d.ts +2 -0
  29. package/typings/domain/CliIo.d.ts.map +1 -1
  30. package/typings/domain/GlobalConfig.d.ts +1 -1
  31. package/typings/domain/GlobalConfig.d.ts.map +1 -1
  32. package/typings/exceptions/DomainException.d.ts +4 -4
  33. package/typings/exceptions/DomainException.d.ts.map +1 -1
  34. package/typings/features/build/BuildConfig.d.ts +107 -94
  35. package/typings/features/build/BuildConfig.d.ts.map +1 -1
  36. package/typings/features/build/BuildController.d.ts +23 -17
  37. package/typings/features/build/BuildController.d.ts.map +1 -1
  38. package/typings/features/build/domain/ImportPaths.d.ts +15 -4
  39. package/typings/features/build/domain/ImportPaths.d.ts.map +1 -1
  40. package/typings/features/build/domain/emit.d.ts +4 -4
  41. package/typings/features/build/domain/emit.d.ts.map +1 -1
  42. package/typings/features/build/domain/scan.d.ts +2 -0
  43. package/typings/features/build/domain/scan.d.ts.map +1 -1
  44. package/typings/features/build/domain/tsconfig.d.ts +9 -16
  45. package/typings/features/build/domain/tsconfig.d.ts.map +1 -1
  46. package/typings/features/build/services/BundleBuilder.d.ts +25 -29
  47. package/typings/features/build/services/BundleBuilder.d.ts.map +1 -1
  48. package/typings/features/build/services/TicConfigService.d.ts +11 -15
  49. package/typings/features/build/services/TicConfigService.d.ts.map +1 -1
  50. package/typings/index.d.ts +6 -7
  51. package/typings/schema/ticConfigSchema.d.ts.map +1 -1
  52. package/cjm/features/build/domain/configFiles.js +0 -35
  53. package/typings/features/build/domain/configFiles.d.ts +0 -13
  54. package/typings/features/build/domain/configFiles.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../lib/cli/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,UAAU,EAAU,MAAM,kBAAkB,CAAC;AA6BpG;;;;;GAKG;AACH,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,WAAW;IAIpD,OAAO;IAKP,mFAAmF;IACnF,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;CAmB/B"}
1
+ {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../lib/cli/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,UAAU,EAAU,MAAM,kBAAkB,CAAC;AA+BpG;;;;;GAKG;AACH,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,WAAW;IAIpD,OAAO;IAKP,mFAAmF;IACnF,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;CAsB/B"}
@@ -9,9 +9,15 @@ export declare const commandArgs: ({ args }: InjectOptions) => string[];
9
9
  * from the first flag onwards belongs to the action — what precedes it is the
10
10
  * command and the action name.
11
11
  *
12
+ * With `positionals`, the default action of a command takes arguments too: everything
13
+ * after the command is parsed, and the words that are not flags or their values come
14
+ * back as `positionals` (`tic build app.bundle.json`).
15
+ *
12
16
  * @throws {UsageError} when a flag is unknown or a flag that takes a value has none.
13
17
  */
14
- export declare const parseOptions: (options: OptionsConfig) => (argv: string[]) => Record<string, unknown>;
18
+ export declare const parseOptions: (options: OptionsConfig, { positionals }?: {
19
+ positionals?: boolean;
20
+ }) => (argv: string[]) => Record<string, unknown>;
15
21
  /**
16
22
  * Mapper that validates a loosely-typed value — parsed options in practice —
17
23
  * against a schema and narrows it to the schema's output type.
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../lib/cli/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAGtC,KAAK,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;AAE7D,4FAA4F;AAC5F,eAAO,MAAM,WAAW,GAAI,UAAe,aAAa,KAAG,MAAM,EAAsB,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GACtB,SAAS,aAAa,MACtB,MAAM,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAOvC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAClB,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,MAC5B,OAAO,OAAO,KAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAI3B,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../lib/cli/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAGtC,KAAK,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;AAE7D,4FAA4F;AAC5F,eAAO,MAAM,WAAW,GAAI,UAAe,aAAa,KAAG,MAAM,EAAsB,CAAC;AAExF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACtB,SAAS,aAAa,EAAE,kBAAyB;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,MAC/E,MAAM,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CASvC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAClB,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,MAC5B,OAAO,OAAO,KAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAI3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../lib/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,QAeN,CAAC"}
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../lib/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,QAkBN,CAAC"}
@@ -4,6 +4,8 @@ export interface CliIo {
4
4
  cwd: string;
5
5
  stdout: (line: string) => void;
6
6
  stderr: (line: string) => void;
7
+ /** All of standard input, or `undefined` when nothing is piped in (a terminal, or no stdin at all). */
8
+ stdin?: () => string | undefined;
7
9
  }
8
10
  export declare const CliIoKey: SingleToken<CliIo>;
9
11
  export declare const processIo: () => CliIo;
@@ -1 +1 @@
1
- {"version":3,"file":"CliIo.d.ts","sourceRoot":"","sources":["../../lib/domain/CliIo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,6FAA6F;AAC7F,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,QAAQ,oBAAkC,CAAC;AAExD,eAAO,MAAM,SAAS,QAAO,KAA6E,CAAC"}
1
+ {"version":3,"file":"CliIo.d.ts","sourceRoot":"","sources":["../../lib/domain/CliIo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,6FAA6F;AAC7F,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,QAAQ,oBAAkC,CAAC;AAExD,eAAO,MAAM,SAAS,QAAO,KAK3B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type InjectFn, SingleToken } from 'ts-ioc-container';
2
2
  /** Settings every service shares for one run: the process-level context the CLI was started in. */
3
3
  export type GlobalConfig = {
4
- /** Directory relative paths (`--config`, `build({ config })`) resolve against. */
4
+ /** Directory a relative `<config>` path (and `build({ config })`) resolves against. */
5
5
  cwd: string;
6
6
  };
7
7
  export declare const GlobalConfigKey: SingleToken<GlobalConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalConfig.d.ts","sourceRoot":"","sources":["../../lib/domain/GlobalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9D,mGAAmG;AACnG,MAAM,MAAM,YAAY,GAAG;IACzB,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,eAAe,2BAAgD,CAAC;AAE7E,qFAAqF;AACrF,eAAO,MAAM,YAAY,GACtB,CAAC,SAAS,MAAM,YAAY,EAAE,KAAK,CAAC,KAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAE3B,CAAC"}
1
+ {"version":3,"file":"GlobalConfig.d.ts","sourceRoot":"","sources":["../../lib/domain/GlobalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9D,mGAAmG;AACnG,MAAM,MAAM,YAAY,GAAG;IACzB,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,eAAe,2BAAgD,CAAC;AAE7E,qFAAqF;AACrF,eAAO,MAAM,YAAY,GACtB,CAAC,SAAS,MAAM,YAAY,EAAE,KAAK,CAAC,KAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAE3B,CAAC"}
@@ -10,6 +10,10 @@ export declare abstract class TicError extends Error {
10
10
  export declare class TicConfigError extends TicError {
11
11
  constructor(message: string);
12
12
  }
13
+ /** A namespace is neither an existing folder nor a `tsconfig.json` `paths` alias of one. */
14
+ export declare class NamespaceNotFoundError extends TicError {
15
+ constructor(message: string);
16
+ }
13
17
  /** The command line names no command. */
14
18
  export declare class MissingCommandError extends TicError {
15
19
  constructor(usage: string);
@@ -26,8 +30,4 @@ export declare class UnknownActionError extends TicError {
26
30
  export declare class UsageError extends TicError {
27
31
  constructor(message: string);
28
32
  }
29
- /** `tic build --check` found generated bundles that differ from what a build would write. */
30
- export declare class StaleBundlesError extends TicError {
31
- constructor(count: number);
32
- }
33
33
  //# sourceMappingURL=DomainException.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainException.d.ts","sourceRoot":"","sources":["../../lib/exceptions/DomainException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,QAAS,SAAQ,KAAK;IAExC,QAAQ,CAAC,IAAI,EAAE,MAAM;IADvB,SAAS,aACE,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,8FAA8F;AAC9F,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,yCAAyC;AACzC,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,KAAK,EAAE,MAAM;CAG1B;AAED,wEAAwE;AACxE,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM;CAG5B;AAED,kFAAkF;AAClF,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAG5C;AAED,uFAAuF;AACvF,qBAAa,UAAW,SAAQ,QAAQ;gBAC1B,OAAO,EAAE,MAAM;CAG5B;AAED,6FAA6F;AAC7F,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,EAAE,MAAM;CAG1B"}
1
+ {"version":3,"file":"DomainException.d.ts","sourceRoot":"","sources":["../../lib/exceptions/DomainException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,QAAS,SAAQ,KAAK;IAExC,QAAQ,CAAC,IAAI,EAAE,MAAM;IADvB,SAAS,aACE,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,8FAA8F;AAC9F,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,4FAA4F;AAC5F,qBAAa,sBAAuB,SAAQ,QAAQ;gBACtC,OAAO,EAAE,MAAM;CAG5B;AAED,yCAAyC;AACzC,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,KAAK,EAAE,MAAM;CAG1B;AAED,wEAAwE;AACxE,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM;CAG5B;AAED,kFAAkF;AAClF,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAG5C;AAED,uFAAuF;AACvF,qBAAa,UAAW,SAAQ,QAAQ;gBAC1B,OAAO,EAAE,MAAM;CAG5B"}
@@ -1,10 +1,32 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Which files a bundle reads and parses: the first, cheap stage of selection,
4
+ * decided by path alone. `paths` are the folders the files come from; within them
5
+ * a file is parsed when it matches one of `include` and none of `exclude`. Globs
6
+ * are relative to the config file and `/`-separated. With a file naming convention
7
+ * (`*.service.ts`), `include` keeps the bundler from reading anything else.
8
+ */
9
+ export interface GlobSelector {
10
+ /** Folders to scan: relative to the config file (`./src/services`), or tsconfig `paths` aliases (`@app/services`). */
11
+ paths: (string | PathConfig)[];
12
+ /** Globs a file must match one of, e.g. `**\/*.service.ts`. Default: every source file. */
13
+ include?: string[];
14
+ /** Globs of files never read. Replaces {@link DEFAULT_EXCLUDE} when given. */
15
+ exclude?: string[];
16
+ }
17
+ /** A {@link GlobSelector} with its defaults filled in and its globs compiled. */
18
+ export interface ResolvedGlobSelector {
19
+ paths: Required<PathConfig>[];
20
+ include?: RegExp[];
21
+ exclude: RegExp[];
22
+ }
2
23
  /** Which exports of a file count: both kinds, only named exports, or only the default export. */
3
24
  export type ExportKind = 'any' | 'named' | 'default';
4
25
  /**
5
- * Which classes of a parsed file are registered. A class is selected when it is
6
- * exported, not abstract, and meets every criterion set here; an empty rule
7
- * selects every exported class.
26
+ * Which classes of a parsed file are registered: the second stage of selection,
27
+ * run on the files {@link GlobSelector} let through. A class is selected when
28
+ * it is exported, not abstract, and meets every criterion set here; an empty
29
+ * rule selects every exported class.
8
30
  */
9
31
  export interface ClassSelector {
10
32
  /** Default `any`. */
@@ -14,146 +36,137 @@ export interface ClassSelector {
14
36
  * composed one). Default {@link DEFAULT_DECORATORS}; `[]` requires none.
15
37
  */
16
38
  decorators?: string[];
17
- /** A glob the class name must match, e.g. `*Service`. An anonymous default export is named after its file. */
18
- name?: string;
19
39
  /**
20
- * Class names to drop after selection, e.g. one test double sitting next to the
21
- * real registration in the same file.
40
+ * Globs the class name must match one of, e.g. `*Service` or `["*Service", "*Repository"]`.
41
+ * An anonymous default export is named after its file.
22
42
  */
23
- excludeClasses?: string[];
24
- /** A glob the class name must NOT match, e.g. `*Mock`. An anonymous default export is named after its file. */
25
- excludeName?: string;
43
+ glob?: string | string[];
44
+ /**
45
+ * Globs the class name must match none of, applied after every other criterion. A plain
46
+ * name is a glob too, so `["MockUserRepository", "*Fake"]` drops one class by name and a
47
+ * family by pattern.
48
+ */
49
+ exclude?: string | string[];
26
50
  }
27
51
  /** A {@link ClassSelector} with its defaults filled in and its globs compiled. */
28
52
  export interface ResolvedClassSelector {
29
53
  export: ExportKind;
30
54
  decorators?: string[];
31
- name?: RegExp;
32
- excludeClasses?: string[];
33
- excludeName?: RegExp;
55
+ glob?: RegExp[];
56
+ exclude?: RegExp[];
34
57
  }
35
- /**
36
- * `compilerOptions` of a bundle config: the tsconfig's own options plus the bundler's.
37
- * `importExtension` and `classes` are read by `tic build`; every other option (`paths`,
38
- * `baseUrl`, `rootDir`, `moduleResolution`, ...) is handed to TypeScript on top of the
39
- * extended tsconfig, exactly as a child tsconfig's would be.
40
- */
41
- export interface BundleCompilerOptions {
42
- /** Extension of generated imports. Inferred from the tsconfig's `moduleResolution` when omitted. */
43
- importExtension?: string;
44
- /** Which classes of a scanned file are registered. Default: every exported class decorated with `@register`. */
45
- classes?: ClassSelector;
46
- [option: string]: unknown;
58
+ export interface PathConfig {
59
+ /** A folder relative to the config file (`./src/services`) or a tsconfig `paths` alias (`@app/services`). */
60
+ path: string;
61
+ /** Scan sub-folders too. Default `true`. */
62
+ recursive?: boolean;
47
63
  }
48
64
  /**
49
- * The shape of `*.bundle.json`: one bundle, written as a tsconfig. `extends`, `include`,
50
- * `exclude` and `compilerOptions` mean what they mean in a tsconfig, so the files the bundle
51
- * scans are the files this config would compile; `output`, `name` and the bundler's
52
- * own compiler options describe the generated module. A project that needs several bundles
53
- * keeps one config file per bundle.
65
+ * A bundle config file: one bundle, described explicitly — the folders it scans and the
66
+ * classes it registers. `tic build <config>` prints the bundle to stdout; where it is
67
+ * saved is the caller's choice (`tic build app.bundle.json > src/di/app.bundle.ts`).
54
68
  */
55
69
  export interface BundleConfig {
56
70
  $schema?: string;
57
- /**
58
- * The generated file, relative to the config file. Default `<root>/<name>.bundle.ts`:
59
- * `<root>` is the compiled `rootDir`, else the common folder of the files compiled.
60
- */
61
- output?: string;
62
71
  /**
63
72
  * The bundle's name: letters, digits, `-` and `_`, starting with a letter. Default: the
64
- * config file's stem (`production.bundle.json` -> `production`), else {@link DEFAULT_BUNDLE_NAME}.
65
- * It names the default output (`production.bundle.ts`) and the generated class,
66
- * an `IContainerModule` (`ProductionBundle`, see {@link toClassName}).
73
+ * config file's stem (`production.bundle.json` -> `production`); required for a config
74
+ * file named otherwise. It names the generated class, an `IContainerModule`
75
+ * (`ProductionBundle`, see {@link toClassName}).
67
76
  */
68
77
  name?: string;
69
78
  /**
70
- * The tsconfig this config extends, as a tsconfig's own `extends`. Relative to the config
71
- * file. Default `./tsconfig.json`, which may be absent; a tsconfig named here must exist.
79
+ * The tsconfig whose `paths` aliases `glob.paths` may name and generated imports are
80
+ * written in, and whose `moduleResolution` sets the import extension. It contributes
81
+ * nothing else: the files scanned are `glob.paths` alone. Relative to the config file.
82
+ * Default `./tsconfig.json`, which may be absent; a tsconfig named here must exist.
72
83
  */
73
- extends?: string;
74
- /** tsconfig `include`: replaces the extended tsconfig's. */
75
- include?: string[];
76
- /** tsconfig `exclude`: replaces the extended tsconfig's. {@link DEFAULT_EXCLUDE} applies regardless. */
77
- exclude?: string[];
78
- compilerOptions?: BundleCompilerOptions;
84
+ tsconfig?: string;
85
+ /** Extension of generated imports. Inferred from the tsconfig's `moduleResolution` when omitted. */
86
+ importExtension?: string;
87
+ /** Which files are parsed: the folders in `glob.paths`, minus {@link DEFAULT_EXCLUDE} unless `exclude` says otherwise. */
88
+ glob: GlobSelector;
89
+ /** Which classes of a parsed file are registered. Default: every exported class. */
90
+ className?: ClassSelector;
79
91
  }
80
- export declare const DEFAULT_EXTENDS = "./tsconfig.json";
81
- /** The bundle name when the config file gives none, e.g. building from `tsconfig.json` alone. */
82
- export declare const DEFAULT_BUNDLE_NAME = "base";
83
- /** What `classes.decorators` requires when omitted: the library's own `@register`. */
92
+ export declare const DEFAULT_TSCONFIG = "./tsconfig.json";
93
+ /** What `className.decorators` requires when omitted: the library's own `@register`. */
84
94
  export declare const DEFAULT_DECORATORS: string[];
85
- /** Files never scanned, whatever the tsconfig compiles: tests, and anything under `node_modules`. */
86
95
  export declare const DEFAULT_EXCLUDE: string[];
87
- /** The tsconfig part of a bundle config, handed to TypeScript as a tsconfig of its own. */
88
- export interface TsconfigOverrides {
89
- include?: string[];
90
- exclude?: string[];
91
- /** `compilerOptions` without the bundler's own options. */
92
- compilerOptions: Record<string, unknown>;
93
- }
94
96
  /** A {@link BundleConfig} whose defaults are filled in and whose paths are absolute. */
95
97
  export interface ResolvedConfig {
96
98
  /** The config file itself. */
97
99
  file: string;
100
+ /** Its folder: what the config's relative paths resolve against. */
98
101
  dir: string;
99
- /** `undefined`: derived from what is compiled at build time (see {@link BundleConfig.output}). */
100
- output?: string;
101
102
  /** The bundle name: `production` for `production.bundle.json`. */
102
103
  name: string;
103
104
  /** The generated class: `ProductionBundle`. */
104
- className: string;
105
- /** The extended tsconfig; `required` when the config names it, so it must exist. */
105
+ bundleClassName: string;
106
+ /** The tsconfig of `paths` aliases; `required` when the config names it, so it must exist. */
106
107
  tsconfig: {
107
108
  file: string;
108
109
  required: boolean;
109
110
  };
110
- /** What the config sets on top of {@link tsconfig}. */
111
- overrides: TsconfigOverrides;
112
111
  importExtension?: string;
113
- classes: ResolvedClassSelector;
112
+ glob: ResolvedGlobSelector;
113
+ className: ResolvedClassSelector;
114
+ /** Non-fatal problems found while resolving, e.g. a `glob.exclude` that drops a default test glob. */
115
+ warnings: string[];
114
116
  }
115
117
  /**
116
- * One `*.bundle.json` / `*.bundle.yaml`: a tsconfig with the bundler's fields. The published
117
- * `tic.schema.json` is generated from it (`ticConfigJsonSchema`), so the schema editors
118
- * validate against cannot drift from what `tic build` accepts.
118
+ * One `*.bundle.json` / `*.bundle.yaml`. The published `tic.schema.json` is generated
119
+ * from it (`ticConfigJsonSchema`), so the schema editors validate against cannot drift
120
+ * from what `tic build` accepts.
119
121
  */
120
122
  export declare const BUNDLE_CONFIG_SCHEMA: z.ZodObject<{
121
123
  $schema: z.ZodOptional<z.ZodString>;
122
- extends: z.ZodOptional<z.ZodString>;
123
- output: z.ZodOptional<z.ZodString>;
124
124
  name: z.ZodOptional<z.ZodString>;
125
- include: z.ZodOptional<z.ZodCustom<string[], string[]>>;
126
- exclude: z.ZodOptional<z.ZodCustom<string[], string[]>>;
127
- compilerOptions: z.ZodOptional<z.ZodObject<{
128
- importExtension: z.ZodOptional<z.ZodString>;
129
- classes: z.ZodOptional<z.ZodObject<{
130
- export: z.ZodDefault<z.ZodEnum<{
131
- default: "default";
132
- any: "any";
133
- named: "named";
134
- }>>;
135
- decorators: z.ZodDefault<z.ZodCustom<string[], string[]>>;
136
- name: z.ZodOptional<z.ZodString>;
137
- excludeClasses: z.ZodOptional<z.ZodCustom<string[], string[]>>;
138
- excludeName: z.ZodOptional<z.ZodString>;
139
- }, z.core.$strict>>;
140
- paths: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
141
- rootDir: z.ZodOptional<z.ZodString>;
142
- }, z.core.$loose>>;
125
+ tsconfig: z.ZodOptional<z.ZodString>;
126
+ importExtension: z.ZodOptional<z.ZodString>;
127
+ glob: z.ZodObject<{
128
+ paths: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
129
+ path: z.ZodString;
130
+ recursive: z.ZodDefault<z.ZodBoolean>;
131
+ }, z.core.$strip>]>>;
132
+ include: z.ZodOptional<z.ZodCustom<string[], string[]>>;
133
+ exclude: z.ZodDefault<z.ZodCustom<string[], string[]>>;
134
+ }, z.core.$strict>;
135
+ className: z.ZodOptional<z.ZodObject<{
136
+ export: z.ZodDefault<z.ZodEnum<{
137
+ default: "default";
138
+ any: "any";
139
+ named: "named";
140
+ }>>;
141
+ decorators: z.ZodDefault<z.ZodCustom<string[], string[]>>;
142
+ glob: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
143
+ exclude: z.ZodOptional<z.ZodCustom<string | string[], string | string[]>>;
144
+ }, z.core.$strict>>;
143
145
  }, z.core.$strict>;
144
146
  /**
145
- * A config file is named `<name>.bundle.json`, `<name>.bundle.yaml` or `<name>.bundle.yml`,
146
- * e.g. `app.bundle.json`, `production.bundle.yaml`. Every format has the same shape.
147
+ * A config file is named `<name>.bundle.json`, `<name>.bundle.yaml` or `<name>.bundle.yml`
148
+ * by convention, e.g. `app.bundle.json`; any `.json` / `.yaml` / `.yml` file works.
147
149
  */
148
150
  export declare const CONFIG_FILE_SUFFIXES: string[];
149
- /** The config suffix `file` ends with, if any. */
150
- export declare const configSuffix: (file: string) => string | undefined;
151
+ /** What stands for standard input where a config file is expected: `tic build -`. */
152
+ export declare const STDIN = "-";
153
+ /** The format of a config file, by extension; `undefined` for any other file. */
154
+ export declare const configFormat: (file: string) => ConfigFormat | undefined;
155
+ /** The format of config text: JSON or YAML. */
156
+ export type ConfigFormat = 'json' | 'yaml';
157
+ /**
158
+ * Parses config text in its format. An empty YAML document is `{}`.
159
+ *
160
+ * @throws {TicConfigError} when the text is not valid in its format.
161
+ */
162
+ export declare function parseConfig(text: string, format: ConfigFormat): unknown;
151
163
  /** The generated class for a bundle name: `production` -> `ProductionBundle`, `my-app_v2` -> `MyAppV2Bundle`. */
152
164
  export declare function toClassName(name: string): string;
153
165
  /**
154
- * Validates parsed `*.bundle.json` content and resolves its paths against `file`'s directory.
166
+ * Validates parsed config content and resolves its paths against `file`'s directory.
167
+ * Without a `name` the bundle is named after the file: `production.bundle.json` -> `production`.
155
168
  *
156
- * @throws {TicConfigError} when the content does not match the config shape; the message names the field.
169
+ * @throws {TicConfigError} when the content does not match the config shape, or names no bundle; the message names the field.
157
170
  */
158
171
  export declare function resolveConfig(content: unknown, file: string): ResolvedConfig;
159
172
  //# sourceMappingURL=BuildConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuildConfig.d.ts","sourceRoot":"","sources":["../../../lib/features/build/BuildConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,iGAAiG;AACjG,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,8GAA8G;IAC9G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,+GAA+G;IAC/G,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,kFAAkF;AAClF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE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4
  import { type IOutputService } from '../../services/OutputService.js';
4
5
  import { type IBundleBuilder } from './services/BundleBuilder.js';
5
- import { type ITicConfigService } from './services/TicConfigService.js';
6
- export declare const BUILD_OPTIONS: z.ZodObject<{
7
- config: z.ZodDefault<z.ZodArray<z.ZodString>>;
8
- check: z.ZodDefault<z.ZodBoolean>;
9
- }, z.core.$strip>;
6
+ export declare const BUILD_OPTIONS: z.ZodPipe<z.ZodObject<{
7
+ positionals: z.ZodArray<z.ZodString>;
8
+ }, z.core.$strip>, z.ZodTransform<{
9
+ config: string;
10
+ }, {
11
+ positionals: string[];
12
+ }>>;
10
13
  export type BuildCliOptions = z.output<typeof BUILD_OPTIONS>;
11
- /** `tic build [--config <path>]... [--check]`. */
14
+ /** `tic build [<config> | -]`: the bundle goes to stdout; without a config file, the config comes from stdin. */
12
15
  export declare class BuildController {
13
- private readonly cwd;
14
- private readonly configs;
16
+ private readonly io;
15
17
  private readonly builder;
16
18
  private readonly output;
17
19
  private readonly logger;
18
- constructor(cwd: string, configs: ITicConfigService, builder: IBundleBuilder, output: IOutputService, logger: ILogger);
20
+ constructor(io: CliIo, builder: IBundleBuilder, output: IOutputService, logger: ILogger);
19
21
  /**
20
- * Builds every config named with `--config`, else every `*.bundle.{json,yaml,yml}` of the
21
- * package, else one bundle from its `tsconfig.json`. With `--check` nothing is written and
22
- * an out-of-date bundle fails the run. One line per bundle goes to stdout, warnings to
23
- * stderr; an error names the config it came from.
22
+ * Builds the bundle the config file `<config>` describes — or, without one (or with `-`),
23
+ * the config piped into stdin — and prints it to stdout. Saving it is the shell's job:
24
+ * `tic build app.bundle.json > src/di/app.bundle.ts`, `cat app.bundle.yml | tic build > out.ts`.
25
+ * Warnings go to stderr, so they never end up in the bundle; an error names the config.
24
26
  *
25
- * @throws {UsageError} when an option is unknown or `--config` has no value.
26
- * @throws {TicConfigError} when a config or its tsconfig is missing or invalid, or none can be found.
27
- * @throws {StaleBundlesError} when `--check` finds a bundle that differs from what a build would write.
27
+ * @throws {UsageError} when an option is unknown, there is more than one `<config>`, or the config should come from stdin and nothing is piped in.
28
+ * @throws {TicConfigError} when the config file is missing or unreadable, the config or its tsconfig is invalid, the bundle has no name, or no tsconfig paths alias covers a selected class's file.
29
+ * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
28
30
  */
29
- build(options: BuildCliOptions): void;
31
+ build({ config }: BuildCliOptions): void;
32
+ /**
33
+ * @throws {UsageError} when nothing is piped into stdin.
34
+ */
35
+ private stdin;
30
36
  }
31
37
  //# sourceMappingURL=BuildController.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuildController.d.ts","sourceRoot":"","sources":["../../../lib/features/build/BuildController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,KAAK,cAAc,EAAwC,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,KAAK,iBAAiB,EAAuC,MAAM,6BAA6B,CAAC;AAE1G,eAAO,MAAM,aAAa;;;iBAGxB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAW7D,kDAAkD;AAClD,qBACa,eAAe;IAEK,OAAO,CAAC,QAAQ,CAAC,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,OAAO;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAJD,GAAG,EAAE,MAAM,EACN,OAAO,EAAE,iBAAiB,EAC7B,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,cAAc,EAC7B,MAAM,EAAE,OAAO;IAG1D;;;;;;;;;OASG;IAEH,KAAK,CAAgE,OAAO,EAAE,eAAe,GAAG,IAAI;CAiBrG"}
1
+ {"version":3,"file":"BuildController.d.ts","sourceRoot":"","sources":["../../../lib/features/build/BuildController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,8BAA8B,CAAC;AAEtF,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,0BAA0B,CAAC;AAElF,eAAO,MAAM,aAAa;;;;;;GAOxB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAI7D,iHAAiH;AACjH,qBACa,eAAe;IAEF,OAAO,CAAC,QAAQ,CAAC,EAAE;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAHR,EAAE,EAAE,KAAK,EACA,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,cAAc,EAC7B,MAAM,EAAE,OAAO;IAG1D;;;;;;;;;OASG;IAEH,KAAK,CAAgE,EAAE,MAAM,EAAE,EAAE,eAAe,GAAG,IAAI;IAavG;;OAEG;IACH,OAAO,CAAC,KAAK;CAOd"}
@@ -5,8 +5,8 @@ interface Alias {
5
5
  targets: string[];
6
6
  }
7
7
  /**
8
- * Import paths as a project's `tsconfig.json` sees them: writes imports in the
9
- * form of its `paths` aliases where one matches.
8
+ * Import paths as a project's `tsconfig.json` sees them: resolves namespaces
9
+ * written as `paths` aliases to folders, and writes imports back in alias form.
10
10
  */
11
11
  export declare class ImportPaths {
12
12
  private readonly aliases;
@@ -17,9 +17,20 @@ export declare class ImportPaths {
17
17
  */
18
18
  static fromOptions(options: ts.CompilerOptions, tsconfigFile: string, importExtension?: string): ImportPaths;
19
19
  constructor(aliases: Alias[], extension: string);
20
- /** The specifier `fromFile` imports `toFile` by: its most specific alias, else a relative path. */
21
- specifier(fromFile: string, toFile: string): string;
20
+ /**
21
+ * The folder a namespace names: a path relative to `baseDir`, or a `paths` alias.
22
+ *
23
+ * @throws {NamespaceNotFoundError} when the namespace is neither an existing folder nor an alias of one.
24
+ */
25
+ resolveNamespace(namespace: string, baseDir: string): string;
26
+ /**
27
+ * The specifier `file` is imported by: its most specific `paths` alias. `undefined` when no
28
+ * alias covers it — a bundle is written to stdout, so it has no location a relative import
29
+ * could start from.
30
+ */
31
+ specifier(file: string): string | undefined;
22
32
  private bestAlias;
33
+ private aliasTargets;
23
34
  /** A longer matched target prefix is a more specific alias; an exact file alias beats every wildcard. */
24
35
  private matchAlias;
25
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImportPaths.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/ImportPaths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAUD;;;GAGG;AACH,qBAAa,WAAW;IAmBpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAnB5B;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW;gBAczF,OAAO,EAAE,KAAK,EAAE,EACxB,SAAS,EAAE,MAAM;IAG5B,mGAAmG;IACnG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAUnD,OAAO,CAAC,SAAS;IAWjB,yGAAyG;IACzG,OAAO,CAAC,UAAU;CAanB"}
1
+ {"version":3,"file":"ImportPaths.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/ImportPaths.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAaD;;;GAGG;AACH,qBAAa,WAAW;IAmBpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAnB5B;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW;gBAczF,OAAO,EAAE,KAAK,EAAE,EACxB,SAAS,EAAE,MAAM;IAG5B;;;;OAIG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAa5D;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK3C,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,YAAY;IAWpB,yGAAyG;IACzG,OAAO,CAAC,UAAU;CAanB"}
@@ -2,8 +2,8 @@ import type { DiscoveredClass } from './scan.js';
2
2
  export interface EmitInput {
3
3
  /** Name of the generated class. */
4
4
  name: string;
5
- /** Shown in the header: where the output came from. */
6
- configPath: string;
5
+ /** Shown in the header: the folders scanned. */
6
+ paths: string[];
7
7
  classes: (DiscoveredClass & {
8
8
  specifier: string;
9
9
  })[];
@@ -12,7 +12,7 @@ export interface EmitInput {
12
12
  export declare const GENERATED_HEADER = "// Generated by `tic build`";
13
13
  /** What `protocols/Bundle.ts.hbs` renders. */
14
14
  export interface BundleView {
15
- configPath: string;
15
+ paths: string[];
16
16
  name: string;
17
17
  imports: {
18
18
  specifier: string;
@@ -27,7 +27,7 @@ export declare const BUNDLE_PROTOCOL = "Bundle.ts.hbs";
27
27
  * Prepares the data the bundle protocol renders: unique local names, and one import
28
28
  * per file in file order.
29
29
  */
30
- export declare function bundleView({ name, configPath, classes }: EmitInput): BundleView;
30
+ export declare function bundleView({ name, paths, classes }: EmitInput): BundleView;
31
31
  /**
32
32
  * Renders the generated bundle — static imports, `registrations`, and the bundle applying them —
33
33
  * from its protocol, `protocols/Bundle.ts.hbs`.
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/emit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,eAAe,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CACtD;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,gCAAgC,CAAC;AAE9D,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACxE,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,8CAA8C;AAC9C,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAI/C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,SAAS,GAAG,UAAU,CAqB/E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAEnD"}
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/emit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,eAAe,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CACtD;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,gCAAgC,CAAC;AAE9D,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACxE,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,8CAA8C;AAC9C,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAI/C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,SAAS,GAAG,UAAU,CAqB1E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAEnD"}
@@ -29,6 +29,8 @@ export interface DiscoveredClass {
29
29
  }
30
30
  /** A TypeScript source file the bundler may parse: not a declaration file. */
31
31
  export declare const isSourceFile: (file: string) => boolean;
32
+ /** Source files of `dir`, sorted by path so the generated output is stable across machines. */
33
+ export declare function listSourceFiles(dir: string, recursive: boolean, isExcluded: (file: string) => boolean): string[];
32
34
  /**
33
35
  * The exported, non-abstract classes of one file that `selector` selects, in
34
36
  * declaration order. Syntax only: decorators are recognised by name, not by type.
@@ -1 +1 @@
1
- {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/scan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;CACpD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAiE,CAAC;AA2B9G;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,SAA6B,GAChC,eAAe,EAAE,CAmFnB"}
1
+ {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/scan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;CACpD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAiE,CAAC;AAE9G,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,EAAE,CAchH;AA2BD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,SAA6B,GAChC,eAAe,EAAE,CAkFnB"}
@@ -1,21 +1,14 @@
1
- import type { ResolvedConfig } from '../BuildConfig.js';
2
1
  import { ImportPaths } from './ImportPaths.js';
3
- /** What a bundle compiles: the bundle config read as a tsconfig, on top of the tsconfig it extends. */
4
- export interface CompiledTsconfig {
5
- importPaths: ImportPaths;
6
- /** Absolute paths of the files compiled. */
7
- fileNames: string[];
8
- /**
9
- * Where the sources live, as tsc sees it: `rootDir`, else the longest common folder of
10
- * the non-declaration files compiled, else the config's folder.
11
- */
12
- rootDir: string;
13
- }
14
2
  /**
15
- * Compiles a bundle config as a tsconfig, following `extends`: the files it compiles
16
- * (`include` / `exclude`, as overridden), its `paths` aliases and import extension.
3
+ * Reads a bundle's tsconfig, following its own `extends`: its `paths` aliases and the
4
+ * import extension its `moduleResolution` needs; `importExtension` overrides the latter.
5
+ * Nothing else is taken from it — which files it compiles plays no part in a bundle.
6
+ * An absent tsconfig that was not named explicitly yields no aliases.
17
7
  *
18
- * @throws {TicConfigError} when a required tsconfig is missing, or the config or a tsconfig it extends is invalid.
8
+ * @throws {TicConfigError} when a required tsconfig is missing or cannot be parsed.
19
9
  */
20
- export declare function loadTsconfig(config: ResolvedConfig): CompiledTsconfig;
10
+ export declare function loadImportPaths(tsconfig: {
11
+ file: string;
12
+ required: boolean;
13
+ }, importExtension?: string): ImportPaths;
21
14
  //# sourceMappingURL=tsconfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5C,uGAAuG;AACvG,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,WAAW,CAAC;IACzB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AA+BD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAerE"}
1
+ {"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../../lib/features/build/domain/tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAapH"}