@ts-ioc-container/bundler 8.0.0 → 8.1.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.
- package/cjm/cli/usage.js +1 -1
- package/cjm/features/bundle/BundleController.js +4 -3
- package/cjm/features/bundle/services/BundleService.js +1 -0
- package/package.json +1 -1
- package/typings/features/bundle/BundleController.d.ts +3 -2
- package/typings/features/bundle/BundleController.d.ts.map +1 -1
- package/typings/features/bundle/services/BundleService.d.ts +9 -0
- package/typings/features/bundle/services/BundleService.d.ts.map +1 -1
- package/typings/index.d.ts +1 -1
package/cjm/cli/usage.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.USAGE = [
|
|
|
16
16
|
' -h, --help show this help',
|
|
17
17
|
' -v, --version show the version',
|
|
18
18
|
'',
|
|
19
|
-
'The bundle goes to stdout; the
|
|
19
|
+
'The bundle goes to stdout; the classes in it (name and file) and warnings to stderr.',
|
|
20
20
|
'Saving it is up to you:',
|
|
21
21
|
' tic build app.bundle.json > src/di/app.bundle.ts',
|
|
22
22
|
' tic build common.bundle.yml prod.bundle.yml > src/di/prod.bundle.ts # merged left to right',
|
|
@@ -60,9 +60,10 @@ let BundleController = class BundleController {
|
|
|
60
60
|
const config = stdin
|
|
61
61
|
? this.configService.parse(this.stdin(), this.io.cwd)
|
|
62
62
|
: this.configService.load(configs.map((file) => node_path_1.default.resolve(this.io.cwd, file)));
|
|
63
|
-
const { content,
|
|
64
|
-
for (const file of
|
|
65
|
-
this.logger.info((0, glob_1.toPosix)(node_path_1.default.relative(this.io.cwd, file)));
|
|
63
|
+
const { content, classes, warnings } = this.bundleService.bundle(config);
|
|
64
|
+
for (const { file, className } of classes) {
|
|
65
|
+
this.logger.info(`${className}: ${(0, glob_1.toPosix)(node_path_1.default.relative(this.io.cwd, file))}`);
|
|
66
|
+
}
|
|
66
67
|
for (const warning of warnings)
|
|
67
68
|
this.logger.warn(`${label}: ${warning}`);
|
|
68
69
|
this.output.write(content.replace(/\n$/, ''));
|
|
@@ -68,6 +68,7 @@ let BundleService = class BundleService {
|
|
|
68
68
|
bundle: config.bundleClassName,
|
|
69
69
|
registrations: classes.length,
|
|
70
70
|
files: [...new Set(classes.map((cls) => cls.file))],
|
|
71
|
+
classes: classes.map(({ file, className }) => ({ file, className })),
|
|
71
72
|
content,
|
|
72
73
|
warnings: [...config.warnings, ...(0, tokenCollisions_1.tokenCollisions)(classes)],
|
|
73
74
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-ioc-container/bundler",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.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",
|
|
@@ -29,8 +29,9 @@ export declare class BundleController {
|
|
|
29
29
|
* stdout. Saving it is the shell's job: `tic build app.bundle.json > src/di/app.bundle.ts`,
|
|
30
30
|
* `tic build common.bundle.yml prod.bundle.yml > src/di/prod.bundle.ts`,
|
|
31
31
|
* `cat app.bundle.yml | tic build > out.ts`.
|
|
32
|
-
* The
|
|
33
|
-
* go to stderr, so they
|
|
32
|
+
* The classes in the bundle, one per line as its name and its file's path relative to the
|
|
33
|
+
* working directory (`Clock: src/infra/Clock.ts`), and warnings go to stderr, so they
|
|
34
|
+
* never end up in the bundle; an error names the configs.
|
|
34
35
|
*
|
|
35
36
|
* @throws {UsageError} when an option is unknown, `-` is given with config files, or the config should come from stdin and nothing is piped in.
|
|
36
37
|
* @throws {TicConfigError} when a config file is missing or unreadable, several are in different folders, the config or its tsconfig is invalid, the bundle has no name, or no tsconfig paths alias covers a selected class's file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleController.d.ts","sourceRoot":"","sources":["../../../lib/features/bundle/BundleController.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iB,EAAwB,MAAM,6BAA6B,CAAC;AAE3F,eAAO,MAAM,aAAa;;;;;;GAWxB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAI7D;;;GAGG;AACH,qBACa,gBAAgB;IAEH,OAAO,CAAC,QAAQ,CAAC,EAAE;IACP,OAAO,CAAC,QAAQ,CAAC,aAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAJR,EAAE,EAAE,KAAK,EACG,aAAa,EAAE,iBAAiB,EACnC,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,cAAc,EAC7B,MAAM,EAAE,OAAO;IAG1D;;;;;;;;;;;;;OAaG;IAEH,MAAM,CAAgE,EAAE,OAAO,EAAE,EAAE,eAAe,GAAG,IAAI;IAoBzG;;OAEG;IACH,OAAO,CAAC,KAAK;CAOd"}
|
|
@@ -8,6 +8,8 @@ export interface Bundle {
|
|
|
8
8
|
registrations: number;
|
|
9
9
|
/** Absolute paths of the files the bundle imports from, sorted. */
|
|
10
10
|
files: string[];
|
|
11
|
+
/** The classes the bundle registers, sorted by file and then by declaration order. */
|
|
12
|
+
classes: BundledClass[];
|
|
11
13
|
/** The generated bundle. Nothing is written: saving it is the caller's job (`tic build app.bundle.json > src/di/app.bundle.ts`). */
|
|
12
14
|
content: string;
|
|
13
15
|
/**
|
|
@@ -16,6 +18,13 @@ export interface Bundle {
|
|
|
16
18
|
*/
|
|
17
19
|
warnings: string[];
|
|
18
20
|
}
|
|
21
|
+
/** A class the bundle registers. */
|
|
22
|
+
export interface BundledClass {
|
|
23
|
+
/** Absolute path of the file it is declared in. */
|
|
24
|
+
file: string;
|
|
25
|
+
/** The declared class name; an anonymous default export is named after its file. */
|
|
26
|
+
className: string;
|
|
27
|
+
}
|
|
19
28
|
export interface IBundleService {
|
|
20
29
|
/**
|
|
21
30
|
* Generates the bundle a resolved config describes and returns it; nothing is written.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleService.d.ts","sourceRoot":"","sources":["../../../../lib/features/bundle/services/BundleService.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,yCAAyC,CAAC;AAEzG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAoB,KAAK,WAAW,EAAkB,MAAM,cAAc,CAAC;AAMlF,MAAM,WAAW,MAAM;IACrB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oIAAoI;IACpI,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;CACtC;AAED,eAAO,MAAM,iBAAiB,6BAAoD,CAAC;AAEnF,qBACa,aAAc,YAAW,cAAc;IAEb,OAAO,CAAC,QAAQ,CAAC,EAAE;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADG,EAAE,EAAE,kBAAkB,EAC7B,IAAI,EAAE,WAAW;IAGhE;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"BundleService.d.ts","sourceRoot":"","sources":["../../../../lib/features/bundle/services/BundleService.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,yCAAyC,CAAC;AAEzG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAoB,KAAK,WAAW,EAAkB,MAAM,cAAc,CAAC;AAMlF,MAAM,WAAW,MAAM;IACrB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sFAAsF;IACtF,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,oIAAoI;IACpI,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;CACtC;AAED,eAAO,MAAM,iBAAiB,6BAAoD,CAAC;AAEnF,qBACa,aAAc,YAAW,cAAc;IAEb,OAAO,CAAC,QAAQ,CAAC,EAAE;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADG,EAAE,EAAE,kBAAkB,EAC7B,IAAI,EAAE,WAAW;IAGhE;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM;CA8CrC"}
|
package/typings/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { type GlobalConfig, GlobalConfigKey, globalConfig } from './domain/Globa
|
|
|
4
4
|
export { Application, action, onDefault, DEFAULT_ACTION, commandArgs, parseOptions, validate, type IErrorHandler, IErrorHandlerKey, USAGE, } from './cli.js';
|
|
5
5
|
export { BuildModule } from './features/bundle/BuildModule.js';
|
|
6
6
|
export { BundleController, BUILD_OPTIONS, type BuildCliOptions } from './features/bundle/BundleController.js';
|
|
7
|
-
export { BundleService, IBundleServiceKey, type IBundleService, type Bundle, } from './features/bundle/services/BundleService.js';
|
|
7
|
+
export { BundleService, IBundleServiceKey, type IBundleService, type Bundle, type BundledClass, } from './features/bundle/services/BundleService.js';
|
|
8
8
|
export { TicConfigService, ITicConfigServiceKey, type ITicConfigService, } from './features/bundle/services/TicConfigService.js';
|
|
9
9
|
export { resolveConfig, BUNDLE_CONFIG_SCHEMA, BUNDLE_CONFIG_FILE_SCHEMA, mergeConfigs, parseConfig, CONFIG_FILE_SUFFIXES, STDIN, configFormat, DEFAULT_TSCONFIG, DEFAULT_EXCLUDE, DEFAULT_DECORATORS, toClassName, type BundleConfigFile, type ClassSelector, type ExportKind, type ResolvedClassSelector, type PathSelector, type ResolvedPathSelector, type BundleConfig, type ConfigFormat, } from './features/bundle/BuildConfig.js';
|
|
10
10
|
export { ticConfigJsonSchema } from './schema/ticConfigSchema.js';
|