@ts-ioc-container/bundler 2.1.0 → 3.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 (34) hide show
  1. package/AGENTS.md +24 -22
  2. package/README.md +64 -84
  3. package/cjm/exceptions/DomainException.js +1 -7
  4. package/cjm/features/build/BuildConfig.js +35 -72
  5. package/cjm/features/build/domain/ImportPaths.js +0 -27
  6. package/cjm/features/build/domain/emit.js +2 -2
  7. package/cjm/features/build/domain/scan.js +0 -18
  8. package/cjm/features/build/domain/tokenCollisions.js +1 -1
  9. package/cjm/features/build/domain/tsconfig.js +16 -10
  10. package/cjm/features/build/services/BundleBuilder.js +8 -31
  11. package/cjm/index.js +2 -4
  12. package/cjm/schema/ticConfigSchema.js +0 -4
  13. package/package.json +2 -2
  14. package/tic.schema.json +73 -102
  15. package/tpl/index.cjs +19 -41
  16. package/typings/app.d.ts +1 -2
  17. package/typings/exceptions/DomainException.d.ts +0 -4
  18. package/typings/exceptions/DomainException.d.ts.map +1 -1
  19. package/typings/features/build/BuildConfig.d.ts +61 -81
  20. package/typings/features/build/BuildConfig.d.ts.map +1 -1
  21. package/typings/features/build/BuildController.d.ts +0 -1
  22. package/typings/features/build/BuildController.d.ts.map +1 -1
  23. package/typings/features/build/domain/ImportPaths.d.ts +2 -9
  24. package/typings/features/build/domain/ImportPaths.d.ts.map +1 -1
  25. package/typings/features/build/domain/emit.d.ts +1 -7
  26. package/typings/features/build/domain/emit.d.ts.map +1 -1
  27. package/typings/features/build/domain/scan.d.ts +0 -2
  28. package/typings/features/build/domain/scan.d.ts.map +1 -1
  29. package/typings/features/build/domain/tsconfig.d.ts +11 -15
  30. package/typings/features/build/domain/tsconfig.d.ts.map +1 -1
  31. package/typings/features/build/services/BundleBuilder.d.ts +5 -8
  32. package/typings/features/build/services/BundleBuilder.d.ts.map +1 -1
  33. package/typings/index.d.ts +4 -4
  34. package/typings/schema/ticConfigSchema.d.ts.map +1 -1
@@ -57,22 +57,28 @@ function commonDir(files) {
57
57
  }
58
58
  return first.slice(0, length).join(node_path_1.default.sep) || node_path_1.default.sep;
59
59
  }
60
- function loadTsconfig(tsconfig, importExtension) {
61
- if (!(0, node_fs_1.existsSync)(tsconfig.file)) {
62
- if (tsconfig.required)
63
- throw new DomainException_1.TicConfigError(`tsconfig not found: ${tsconfig.file}`);
64
- return { importPaths: new ImportPaths_1.ImportPaths([], importExtension ?? '') };
60
+ function asTsconfig(config) {
61
+ if (!(0, node_fs_1.existsSync)(config.tsconfig.file)) {
62
+ if (config.tsconfig.required)
63
+ throw new DomainException_1.TicConfigError(`tsconfig not found: ${config.tsconfig.file}`);
64
+ return { config: config.overrides };
65
65
  }
66
- const { config, error } = ts.readConfigFile(tsconfig.file, ts.sys.readFile);
67
- const parsed = ts.parseJsonConfigFileContent(config, ts.sys, node_path_1.default.dirname(tsconfig.file), undefined, tsconfig.file);
66
+ if (config.file === config.tsconfig.file)
67
+ return ts.readConfigFile(config.file, ts.sys.readFile);
68
+ return { config: { extends: config.tsconfig.file, ...config.overrides } };
69
+ }
70
+ function loadTsconfig(config) {
71
+ const { config: json, error } = asTsconfig(config);
72
+ const configFileName = config.file === config.tsconfig.file ? config.file : undefined;
73
+ const parsed = ts.parseJsonConfigFileContent(json ?? {}, ts.sys, config.dir, undefined, configFileName);
68
74
  const [fatal] = [error, ...parsed.errors].filter((d) => !!d && d.code !== NO_INPUTS);
69
75
  if (fatal) {
70
- throw new DomainException_1.TicConfigError(`${tsconfig.file}: ${ts.flattenDiagnosticMessageText(fatal.messageText, '\n')}`);
76
+ throw new DomainException_1.TicConfigError(`${config.file}: ${ts.flattenDiagnosticMessageText(fatal.messageText, '\n')}`);
71
77
  }
72
78
  const fileNames = parsed.fileNames.map((file) => node_path_1.default.resolve(file));
73
79
  return {
74
- importPaths: ImportPaths_1.ImportPaths.fromOptions(parsed.options, tsconfig.file, importExtension),
80
+ importPaths: ImportPaths_1.ImportPaths.fromOptions(parsed.options, config.file, config.importExtension),
75
81
  fileNames,
76
- rootDir: parsed.options.rootDir ?? commonDir(fileNames.filter(scan_1.isSourceFile)) ?? node_path_1.default.dirname(tsconfig.file),
82
+ rootDir: parsed.options.rootDir ?? commonDir(fileNames.filter(scan_1.isSourceFile)) ?? config.dir,
77
83
  };
78
84
  }
@@ -19,7 +19,6 @@ exports.BundleBuilder = exports.IBundleBuilderKey = void 0;
19
19
  const node_path_1 = __importDefault(require("node:path"));
20
20
  const ts_ioc_container_1 = require("ts-ioc-container");
21
21
  const GlobalConfig_1 = require("../../../domain/GlobalConfig");
22
- const DomainException_1 = require("../../../exceptions/DomainException");
23
22
  const HandlebarsRenderService_1 = require("../../../services/HandlebarsRenderService");
24
23
  const NodeFileSystemService_1 = require("../../../services/NodeFileSystemService");
25
24
  const BuildConfig_1 = require("../BuildConfig");
@@ -30,6 +29,7 @@ const scan_1 = require("../domain/scan");
30
29
  const tokenCollisions_1 = require("../domain/tokenCollisions");
31
30
  const tsconfig_1 = require("../domain/tsconfig");
32
31
  const TicConfigService_1 = require("./TicConfigService");
32
+ const DEFAULT_EXCLUDE_GLOBS = BuildConfig_1.DEFAULT_EXCLUDE.map(glob_1.globToRegExp);
33
33
  exports.IBundleBuilderKey = new ts_ioc_container_1.SingleToken('IBundleBuilder');
34
34
  let BundleBuilder = class BundleBuilder {
35
35
  cwd;
@@ -54,41 +54,20 @@ let BundleBuilder = class BundleBuilder {
54
54
  return {
55
55
  config: resolved.file,
56
56
  output: { file: output, bundle: resolved.className, status, registrations, content },
57
- warnings: [...resolved.warnings, ...warnings],
57
+ warnings,
58
58
  };
59
59
  }
60
60
  generate(config) {
61
- const { importPaths: paths, fileNames, rootDir } = (0, tsconfig_1.loadTsconfig)(config.tsconfig, config.importExtension);
62
- const output = config.output ?? (rootDir && node_path_1.default.join(rootDir, `${config.name}.bundle.ts`));
63
- if (output === undefined)
64
- throw new DomainException_1.TicConfigError('output: required when there is no tsconfig to extend');
65
- const relative = (file) => (0, glob_1.toPosix)(node_path_1.default.relative(config.dir, file));
66
- const { include, exclude } = config.files;
61
+ const { importPaths: paths, fileNames, rootDir } = (0, tsconfig_1.loadTsconfig)(config);
62
+ const output = config.output ?? node_path_1.default.join(rootDir, `${config.name}.bundle.ts`);
67
63
  const isExcluded = (file) => {
68
64
  if (file === output)
69
65
  return true;
70
- const filename = relative(file);
71
- if (include && !include.some((glob) => glob.test(filename)))
72
- return true;
73
- return exclude.some((glob) => glob.test(filename));
66
+ const filename = (0, glob_1.toPosix)(node_path_1.default.relative(config.dir, file));
67
+ return DEFAULT_EXCLUDE_GLOBS.some((glob) => glob.test(filename));
74
68
  };
75
- const files = new Set();
76
- if (config.files.paths) {
77
- for (const entry of config.files.paths) {
78
- const dir = paths.resolveNamespace(entry.path, config.dir);
79
- for (const file of (0, scan_1.listSourceFiles)(dir, entry.recursive, isExcluded))
80
- files.add(file);
81
- }
82
- }
83
- else if (fileNames) {
84
- for (const file of fileNames)
85
- if ((0, scan_1.isSourceFile)(file) && !isExcluded(file))
86
- files.add(file);
87
- }
88
- else {
89
- throw new DomainException_1.TicConfigError(`files.paths: required when there is no tsconfig to extend (${config.tsconfig.file} not found)`);
90
- }
91
- const classes = [...files]
69
+ const files = fileNames.filter((file) => (0, scan_1.isSourceFile)(file) && !isExcluded(file));
70
+ const classes = files
92
71
  .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
93
72
  .flatMap((file) => {
94
73
  const text = this.fs.readFile(file);
@@ -98,8 +77,6 @@ let BundleBuilder = class BundleBuilder {
98
77
  const content = this.renderer.render(emit_1.BUNDLE_PROTOCOL, (0, emit_1.bundleView)({
99
78
  name: config.className,
100
79
  configPath: (0, glob_1.toPosix)(node_path_1.default.relative(node_path_1.default.dirname(output), config.file)),
101
- paths: config.files.paths?.map((entry) => entry.path),
102
- tsconfigPath: (0, glob_1.toPosix)(node_path_1.default.relative(node_path_1.default.dirname(output), config.tsconfig.file)),
103
80
  classes,
104
81
  }));
105
82
  return { output, content, registrations: classes.length, warnings: (0, tokenCollisions_1.tokenCollisions)(classes) };
package/cjm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StdOutputService = exports.IOutputServiceKey = exports.CommonModule = exports.HelpModule = exports.globToRegExp = exports.tokenCollisions = exports.GENERATED_HEADER = exports.BUNDLE_PROTOCOL = exports.bundleView = exports.emitBundle = exports.listSourceFiles = exports.isSourceFile = exports.findClasses = exports.loadTsconfig = exports.ImportPaths = exports.ticConfigJsonSchema = exports.findPackageRoot = exports.findConfigFiles = exports.toClassName = exports.DEFAULT_DECORATORS = exports.DEFAULT_BUNDLE_NAME = exports.DEFAULT_EXCLUDE = exports.DEFAULT_EXTENDS = exports.CONFIG_FILE_SUFFIXES = exports.BUNDLE_CONFIG_SCHEMA = exports.resolveConfig = exports.TSCONFIG_FILE = exports.ITicConfigServiceKey = exports.TicConfigService = exports.IBundleBuilderKey = exports.BundleBuilder = exports.BUILD_OPTIONS = exports.BuildController = exports.BuildModule = exports.USAGE = exports.IErrorHandlerKey = exports.validate = exports.parseOptions = exports.commandArgs = exports.DEFAULT_ACTION = exports.onDefault = exports.action = exports.Application = exports.globalConfig = exports.GlobalConfigKey = exports.CliIoKey = exports.createContainer = exports.loadConfig = exports.run = exports.build = void 0;
4
- exports.ExceptionHandler = exports.StaleBundlesError = exports.UsageError = exports.UnknownActionError = exports.UnknownCommandError = exports.MissingCommandError = exports.NamespaceNotFoundError = exports.TicConfigError = exports.TicError = exports.renderProtocol = exports.HandlebarsRenderService = exports.IRenderServiceKey = exports.NodeFileSystemService = exports.IFileSystemServiceKey = exports.ConsoleLogger = exports.ILoggerKey = void 0;
3
+ exports.ILoggerKey = exports.StdOutputService = exports.IOutputServiceKey = exports.CommonModule = exports.HelpModule = exports.globToRegExp = exports.tokenCollisions = exports.GENERATED_HEADER = exports.BUNDLE_PROTOCOL = exports.bundleView = exports.emitBundle = exports.isSourceFile = exports.findClasses = exports.loadTsconfig = exports.ImportPaths = exports.ticConfigJsonSchema = exports.findPackageRoot = exports.findConfigFiles = exports.toClassName = exports.DEFAULT_DECORATORS = exports.DEFAULT_BUNDLE_NAME = exports.DEFAULT_EXCLUDE = exports.DEFAULT_EXTENDS = exports.CONFIG_FILE_SUFFIXES = exports.BUNDLE_CONFIG_SCHEMA = exports.resolveConfig = exports.TSCONFIG_FILE = exports.ITicConfigServiceKey = exports.TicConfigService = exports.IBundleBuilderKey = exports.BundleBuilder = exports.BUILD_OPTIONS = exports.BuildController = exports.BuildModule = exports.USAGE = exports.IErrorHandlerKey = exports.validate = exports.parseOptions = exports.commandArgs = exports.DEFAULT_ACTION = exports.onDefault = exports.action = exports.Application = exports.globalConfig = exports.GlobalConfigKey = exports.CliIoKey = exports.createContainer = exports.loadConfig = exports.run = exports.build = void 0;
4
+ exports.ExceptionHandler = exports.StaleBundlesError = exports.UsageError = exports.UnknownActionError = exports.UnknownCommandError = exports.MissingCommandError = exports.TicConfigError = exports.TicError = exports.renderProtocol = exports.HandlebarsRenderService = exports.IRenderServiceKey = exports.NodeFileSystemService = exports.IFileSystemServiceKey = exports.ConsoleLogger = void 0;
5
5
  var app_1 = require("./app");
6
6
  Object.defineProperty(exports, "build", { enumerable: true, get: function () { return app_1.build; } });
7
7
  Object.defineProperty(exports, "run", { enumerable: true, get: function () { return app_1.run; } });
@@ -55,7 +55,6 @@ Object.defineProperty(exports, "loadTsconfig", { enumerable: true, get: function
55
55
  var scan_1 = require("./features/build/domain/scan");
56
56
  Object.defineProperty(exports, "findClasses", { enumerable: true, get: function () { return scan_1.findClasses; } });
57
57
  Object.defineProperty(exports, "isSourceFile", { enumerable: true, get: function () { return scan_1.isSourceFile; } });
58
- Object.defineProperty(exports, "listSourceFiles", { enumerable: true, get: function () { return scan_1.listSourceFiles; } });
59
58
  var emit_1 = require("./features/build/domain/emit");
60
59
  Object.defineProperty(exports, "emitBundle", { enumerable: true, get: function () { return emit_1.emitBundle; } });
61
60
  Object.defineProperty(exports, "bundleView", { enumerable: true, get: function () { return emit_1.bundleView; } });
@@ -85,7 +84,6 @@ Object.defineProperty(exports, "renderProtocol", { enumerable: true, get: functi
85
84
  var DomainException_1 = require("./exceptions/DomainException");
86
85
  Object.defineProperty(exports, "TicError", { enumerable: true, get: function () { return DomainException_1.TicError; } });
87
86
  Object.defineProperty(exports, "TicConfigError", { enumerable: true, get: function () { return DomainException_1.TicConfigError; } });
88
- Object.defineProperty(exports, "NamespaceNotFoundError", { enumerable: true, get: function () { return DomainException_1.NamespaceNotFoundError; } });
89
87
  Object.defineProperty(exports, "MissingCommandError", { enumerable: true, get: function () { return DomainException_1.MissingCommandError; } });
90
88
  Object.defineProperty(exports, "UnknownCommandError", { enumerable: true, get: function () { return DomainException_1.UnknownCommandError; } });
91
89
  Object.defineProperty(exports, "UnknownActionError", { enumerable: true, get: function () { return DomainException_1.UnknownActionError; } });
@@ -8,10 +8,6 @@ function ticConfigJsonSchema() {
8
8
  io: 'input',
9
9
  target: 'draft-7',
10
10
  unrepresentable: 'any',
11
- override: ({ jsonSchema }) => {
12
- if (jsonSchema.type === 'object')
13
- jsonSchema.additionalProperties = false;
14
- },
15
11
  });
16
12
  const { $schema, ...rest } = schema;
17
13
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-ioc-container/bundler",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "Bundles your dependencies into a single container module for ts-ioc-container: the `tic` CLI scans folders (by path or tsconfig alias) and generates one typed bundle that registers every class — `container.useModule(new AppBundle())`.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -52,7 +52,7 @@
52
52
  "reflect-metadata": "^0.2.2",
53
53
  "yaml": "^2.8.3",
54
54
  "zod": "^4.6.5",
55
- "ts-ioc-container": "74.0.0"
55
+ "ts-ioc-container": "75.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "typescript": ">=5"
package/tic.schema.json CHANGED
@@ -8,8 +8,14 @@
8
8
  "$schema": {
9
9
  "type": "string"
10
10
  },
11
+ "extends": {
12
+ "default": "./tsconfig.json",
13
+ "description": "The tsconfig this bundle extends, as a tsconfig's own `extends`: its file set, `paths` aliases and module resolution apply unless this file overrides them. Relative to this file. The default may be absent; a tsconfig named here must exist.",
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
11
17
  "output": {
12
- "description": "The bundle file (convention: *.bundle.ts). Default `<root>/<name>.bundle.ts`: <root> is the tsconfig's rootDir, else the common folder of the files it compiles. Required when there is no tsconfig to extend.",
18
+ "description": "The bundle file (convention: *.bundle.ts). Default `<root>/<name>.bundle.ts`: <root> is the compiled rootDir, else the common folder of the files compiled.",
13
19
  "type": "string",
14
20
  "minLength": 1
15
21
  },
@@ -18,125 +24,90 @@
18
24
  "type": "string",
19
25
  "pattern": "^[A-Za-z][\\w-]*$"
20
26
  },
21
- "tags": {
22
- "default": [],
23
- "description": "Tags associated with the bundle.",
27
+ "include": {
28
+ "description": "tsconfig `include`: replaces the extended tsconfig's. Relative to this file.",
24
29
  "type": "array",
25
30
  "items": {
26
31
  "type": "string",
27
32
  "minLength": 1
28
33
  }
29
34
  },
30
- "extends": {
31
- "default": "./tsconfig.json",
32
- "description": "The tsconfig this bundle builds on, like a tsconfig's own `extends`: what it compiles (`files` / `include` / `exclude`) is the bundle's file set unless `files.paths` overrides it, and its `paths` aliases and module resolution shape the generated imports. Relative to this file. The default may be absent; a tsconfig named here must exist.",
33
- "type": "string",
34
- "minLength": 1
35
- },
36
- "importExtension": {
37
- "description": "Extension of generated imports, e.g. \".js\". Inferred from the tsconfig: \".js\" under node16/nodenext resolution, none otherwise.",
38
- "type": "string"
35
+ "exclude": {
36
+ "description": "tsconfig `exclude`: replaces the extended tsconfig's. Relative to this file.",
37
+ "type": "array",
38
+ "items": {
39
+ "type": "string",
40
+ "minLength": 1
41
+ }
39
42
  },
40
- "files": {
43
+ "compilerOptions": {
41
44
  "type": "object",
42
45
  "properties": {
43
- "paths": {
44
- "description": "Folders to scan instead of the extended tsconfig's file set: paths relative to this file (./src/services) or tsconfig paths aliases (@app/services). Required when there is no tsconfig to extend.",
45
- "minItems": 1,
46
- "type": "array",
47
- "items": {
48
- "anyOf": [
49
- {
46
+ "importExtension": {
47
+ "description": "Extension of generated imports, e.g. \".js\". Inferred from the tsconfig: \".js\" under node16/nodenext resolution, none otherwise.",
48
+ "type": "string"
49
+ },
50
+ "classes": {
51
+ "type": "object",
52
+ "properties": {
53
+ "export": {
54
+ "default": "any",
55
+ "description": "Which exports count.",
56
+ "type": "string",
57
+ "enum": ["any", "named", "default"]
58
+ },
59
+ "decorators": {
60
+ "default": ["register"],
61
+ "description": "The class must carry one of these decorators, recognised by name (e.g. \"register\", or a composed decorator). Default [\"register\"]; [] requires none.",
62
+ "type": "array",
63
+ "items": {
50
64
  "type": "string",
51
65
  "minLength": 1
52
- },
53
- {
54
- "type": "object",
55
- "properties": {
56
- "path": {
57
- "type": "string",
58
- "minLength": 1
59
- },
60
- "recursive": {
61
- "default": true,
62
- "type": "boolean"
63
- }
64
- },
65
- "required": ["path"],
66
- "additionalProperties": false
67
66
  }
68
- ]
69
- }
70
- },
71
- "include": {
72
- "description": "Globs a file must match one of, e.g. [\"**/*.service.ts\", \"**/*.repository.ts\"]. Default: every source file.",
73
- "type": "array",
74
- "items": {
75
- "type": "string",
76
- "minLength": 1
67
+ },
68
+ "name": {
69
+ "description": "Glob the class name must match, e.g. \"*Service\". An anonymous default export is named after its file.",
70
+ "type": "string",
71
+ "minLength": 1
72
+ },
73
+ "excludeClasses": {
74
+ "description": "Class names to drop after selection, e.g. one test double sitting next to the real registration in the same file.",
75
+ "type": "array",
76
+ "items": {
77
+ "type": "string",
78
+ "minLength": 1
79
+ },
80
+ "minItems": 1
81
+ },
82
+ "excludeName": {
83
+ "description": "Glob the class name must NOT match, e.g. \"*Mock\". An anonymous default export is named after its file.",
84
+ "type": "string",
85
+ "minLength": 1
86
+ }
77
87
  },
78
- "minItems": 1
79
- },
80
- "exclude": {
81
- "default": [
82
- "**/*.spec.ts",
83
- "**/*.test.ts",
84
- "**/*.spec.tsx",
85
- "**/*.test.tsx",
86
- "**/__tests__/**",
87
- "**/node_modules/**"
88
- ],
89
- "description": "Globs of files never read. Replaces the default when given. A non-empty list that omits a default glob makes `tic build` warn.",
90
- "type": "array",
91
- "items": {
92
- "type": "string",
93
- "minLength": 1
94
- }
95
- }
96
- },
97
- "additionalProperties": false,
98
- "description": "Which files this bundle reads and parses — decided by path alone, before parsing. The candidates are what the extended tsconfig compiles, or the folders in `paths` when given. A candidate is parsed when it matches one of `include` and none of `exclude`. Globs are relative to this file. With a file naming convention, `include` keeps every other file unread."
99
- },
100
- "classes": {
101
- "type": "object",
102
- "properties": {
103
- "export": {
104
- "default": "any",
105
- "description": "Which exports count.",
106
- "type": "string",
107
- "enum": ["any", "named", "default"]
88
+ "additionalProperties": false,
89
+ "description": "Which classes of a scanned file are registered. A class is selected when it is exported, not abstract, and meets every criterion set here; by default that is every exported class decorated with @register."
108
90
  },
109
- "decorators": {
110
- "default": ["register"],
111
- "description": "The class must carry one of these decorators, recognised by name (e.g. \"register\", or a composed decorator). Default [\"register\"]; [] requires none.",
112
- "type": "array",
113
- "items": {
114
- "type": "string",
115
- "minLength": 1
116
- }
117
- },
118
- "name": {
119
- "description": "Glob the class name must match, e.g. \"*Service\". An anonymous default export is named after its file.",
120
- "type": "string",
121
- "minLength": 1
122
- },
123
- "excludeClasses": {
124
- "description": "Class names to drop after selection, e.g. one test double sitting next to the real registration in the same file.",
125
- "type": "array",
126
- "items": {
127
- "type": "string",
128
- "minLength": 1
91
+ "paths": {
92
+ "description": "tsconfig `paths`: aliases the generated imports are written in.",
93
+ "type": "object",
94
+ "propertyNames": {
95
+ "type": "string"
129
96
  },
130
- "minItems": 1
97
+ "additionalProperties": {
98
+ "type": "array",
99
+ "items": {
100
+ "type": "string"
101
+ }
102
+ }
131
103
  },
132
- "excludeName": {
133
- "description": "Glob the class name must NOT match, e.g. \"*Mock\". An anonymous default export is named after its file.",
134
- "type": "string",
135
- "minLength": 1
104
+ "rootDir": {
105
+ "description": "tsconfig `rootDir`: where the default output (<rootDir>/<name>.bundle.ts) goes.",
106
+ "type": "string"
136
107
  }
137
108
  },
138
- "additionalProperties": false,
139
- "description": "Which classes of a parsed file are registered. A class is selected when it is exported, not abstract, and meets every criterion set here; by default that is every exported class decorated with @register."
109
+ "additionalProperties": {},
110
+ "description": "tsconfig `compilerOptions`, plus the bundler's own `importExtension` and `classes`. Every other option is handed to TypeScript on top of the extended tsconfig's, which validates it."
140
111
  }
141
112
  },
142
113
  "additionalProperties": false
package/tpl/index.cjs CHANGED
@@ -1,27 +1,7 @@
1
1
  var Handlebars = require("handlebars"); var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
2
2
  templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,partials,data) {
3
- var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
4
- if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
5
- return parent[propertyName];
6
- }
7
- return undefined
8
- };
9
-
10
- return "// Paths: "
11
- + ((stack1 = (lookupProperty(helpers,"join")||(depth0 && lookupProperty(depth0,"join"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"paths") : depth0),", ",{"name":"join","hash":{},"data":data,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":44}}})) != null ? stack1 : "");
12
- },"1":function(container,depth0,helpers,partials,data) {
13
- var stack1, helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {
14
- if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
15
- return parent[propertyName];
16
- }
17
- return undefined
18
- };
19
-
20
- return "// Files: as compiled by "
21
- + ((stack1 = ((helper = (helper = lookupProperty(helpers,"tsconfigPath") || (depth0 != null ? lookupProperty(depth0,"tsconfigPath") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"tsconfigPath","hash":{},"data":data,"loc":{"start":{"line":2,"column":77},"end":{"line":2,"column":95}}}) : helper))) != null ? stack1 : "");
22
- },"2":function(container,depth0,helpers,partials,data) {
23
3
  return ", Registration";
24
- },"3":function(container,depth0,helpers,partials,data) {
4
+ },"1":function(container,depth0,helpers,partials,data) {
25
5
  var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function(parent, propertyName) {
26
6
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
27
7
  return parent[propertyName];
@@ -30,12 +10,12 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
30
10
  };
31
11
 
32
12
  return "import "
33
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"defaultName") : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":5,"column":7},"end":{"line":5,"column":79}}})) != null ? stack1 : "")
34
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":5,"column":79},"end":{"line":5,"column":131}}})) != null ? stack1 : "")
13
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"defaultName") : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":79}}})) != null ? stack1 : "")
14
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":79},"end":{"line":4,"column":131}}})) != null ? stack1 : "")
35
15
  + " from '"
36
- + ((stack1 = ((helper = (helper = lookupProperty(helpers,"specifier") || (depth0 != null ? lookupProperty(depth0,"specifier") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"specifier","hash":{},"data":data,"loc":{"start":{"line":5,"column":138},"end":{"line":5,"column":153}}}) : helper))) != null ? stack1 : "")
16
+ + ((stack1 = ((helper = (helper = lookupProperty(helpers,"specifier") || (depth0 != null ? lookupProperty(depth0,"specifier") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"specifier","hash":{},"data":data,"loc":{"start":{"line":4,"column":138},"end":{"line":4,"column":153}}}) : helper))) != null ? stack1 : "")
37
17
  + "';\n";
38
- },"4":function(container,depth0,helpers,partials,data) {
18
+ },"2":function(container,depth0,helpers,partials,data) {
39
19
  var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function(parent, propertyName) {
40
20
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
41
21
  return parent[propertyName];
@@ -43,11 +23,11 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
43
23
  return undefined
44
24
  };
45
25
 
46
- return ((stack1 = ((helper = (helper = lookupProperty(helpers,"defaultName") || (depth0 != null ? lookupProperty(depth0,"defaultName") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"defaultName","hash":{},"data":data,"loc":{"start":{"line":5,"column":26},"end":{"line":5,"column":43}}}) : helper))) != null ? stack1 : "")
47
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":5,"column":43},"end":{"line":5,"column":72}}})) != null ? stack1 : "");
48
- },"5":function(container,depth0,helpers,partials,data) {
26
+ return ((stack1 = ((helper = (helper = lookupProperty(helpers,"defaultName") || (depth0 != null ? lookupProperty(depth0,"defaultName") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"defaultName","hash":{},"data":data,"loc":{"start":{"line":4,"column":26},"end":{"line":4,"column":43}}}) : helper))) != null ? stack1 : "")
27
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"named") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":43},"end":{"line":4,"column":72}}})) != null ? stack1 : "");
28
+ },"3":function(container,depth0,helpers,partials,data) {
49
29
  return ", ";
50
- },"6":function(container,depth0,helpers,partials,data) {
30
+ },"4":function(container,depth0,helpers,partials,data) {
51
31
  var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
52
32
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
53
33
  return parent[propertyName];
@@ -56,9 +36,9 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
56
36
  };
57
37
 
58
38
  return "{ "
59
- + ((stack1 = (lookupProperty(helpers,"join")||(depth0 && lookupProperty(depth0,"join"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"named") : depth0),", ",{"name":"join","hash":{},"data":data,"loc":{"start":{"line":5,"column":101},"end":{"line":5,"column":122}}})) != null ? stack1 : "")
39
+ + ((stack1 = (lookupProperty(helpers,"join")||(depth0 && lookupProperty(depth0,"join"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"named") : depth0),", ",{"name":"join","hash":{},"data":data,"loc":{"start":{"line":4,"column":101},"end":{"line":4,"column":122}}})) != null ? stack1 : "")
60
40
  + " }";
61
- },"7":function(container,depth0,helpers,partials,data) {
41
+ },"5":function(container,depth0,helpers,partials,data) {
62
42
  var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
63
43
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
64
44
  return parent[propertyName];
@@ -67,15 +47,15 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
67
47
  };
68
48
 
69
49
  return "export const registrations: IRegistration[] = [\n"
70
- + ((stack1 = lookupProperty(helpers,"each").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"registrations") : depth0),{"name":"each","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":10,"column":0},"end":{"line":12,"column":9}}})) != null ? stack1 : "")
50
+ + ((stack1 = lookupProperty(helpers,"each").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"registrations") : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":9,"column":0},"end":{"line":11,"column":9}}})) != null ? stack1 : "")
71
51
  + "];\n";
72
- },"8":function(container,depth0,helpers,partials,data) {
52
+ },"6":function(container,depth0,helpers,partials,data) {
73
53
  var stack1;
74
54
 
75
55
  return " Registration.fromClass("
76
56
  + ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : "")
77
57
  + "),\n";
78
- },"9":function(container,depth0,helpers,partials,data) {
58
+ },"7":function(container,depth0,helpers,partials,data) {
79
59
  return "export const registrations: IRegistration[] = [];\n";
80
60
  },"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
81
61
  var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", lookupProperty = container.lookupProperty || function(parent, propertyName) {
@@ -87,15 +67,13 @@ templates["Bundle.ts.hbs"] = template({"0":function(container,depth0,helpers,par
87
67
 
88
68
  return "// Generated by `tic build` from "
89
69
  + ((stack1 = ((helper = (helper = lookupProperty(helpers,"configPath") || (depth0 != null ? lookupProperty(depth0,"configPath") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"configPath","hash":{},"data":data,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":49}}}) : helper))) != null ? stack1 : "")
90
- + ". Do not edit by hand.\n"
91
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"paths") : depth0),{"name":"if","hash":{},"fn":container.program(0, data, 0),"inverse":container.program(1, data, 0),"data":data,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":102}}})) != null ? stack1 : "")
92
- + "\nimport { type IContainer, type IContainerModule, type IRegistration"
93
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":67},"end":{"line":3,"column":116}}})) != null ? stack1 : "")
70
+ + ". Do not edit by hand.\nimport { type IContainer, type IContainerModule, type IRegistration"
71
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(0, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":2,"column":67},"end":{"line":2,"column":116}}})) != null ? stack1 : "")
94
72
  + " } from 'ts-ioc-container';\n"
95
- + ((stack1 = lookupProperty(helpers,"each").call(alias1,(depth0 != null ? lookupProperty(depth0,"imports") : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":4,"column":0},"end":{"line":6,"column":9}}})) != null ? stack1 : "")
73
+ + ((stack1 = lookupProperty(helpers,"each").call(alias1,(depth0 != null ? lookupProperty(depth0,"imports") : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":0},"end":{"line":5,"column":9}}})) != null ? stack1 : "")
96
74
  + "\n"
97
- + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.program(9, data, 0),"data":data,"loc":{"start":{"line":8,"column":0},"end":{"line":16,"column":7}}})) != null ? stack1 : "")
75
+ + ((stack1 = lookupProperty(helpers,"if").call(alias1,((stack1 = (depth0 != null ? lookupProperty(depth0,"registrations") : depth0)) != null ? lookupProperty(stack1,"length") : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data,"loc":{"start":{"line":7,"column":0},"end":{"line":15,"column":7}}})) != null ? stack1 : "")
98
76
  + "\nexport class "
99
- + ((stack1 = ((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":18,"column":13},"end":{"line":18,"column":23}}}) : helper))) != null ? stack1 : "")
77
+ + ((stack1 = ((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":17,"column":13},"end":{"line":17,"column":23}}}) : helper))) != null ? stack1 : "")
100
78
  + " implements IContainerModule {\n applyTo(container: IContainer): void {\n for (const registration of registrations) container.addRegistration(registration);\n }\n}\n";
101
79
  },"useData":true});
package/typings/app.d.ts CHANGED
@@ -11,8 +11,7 @@ export declare function run(argv: string[], io?: CliIo): number;
11
11
  * Generates the bundle a config describes — one `tic build` step as a function. Nothing is
12
12
  * written unless generation succeeds.
13
13
  *
14
- * @throws {TicConfigError} when the config or its tsconfig is missing or invalid, or the config has neither `files.paths` nor a tsconfig.
15
- * @throws {NamespaceNotFoundError} when a path is neither a folder nor a tsconfig paths alias of one.
14
+ * @throws {TicConfigError} when the config or the tsconfig it extends is missing or invalid.
16
15
  */
17
16
  export declare function build({ cwd, ...request }?: BuildOptions): BuildResult;
18
17
  /**
@@ -10,10 +10,6 @@ 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
- }
17
13
  /** The command line names no command. */
18
14
  export declare class MissingCommandError extends TicError {
19
15
  constructor(usage: string);
@@ -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,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;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,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"}