@notjustcoders/ioc-arise 1.0.11 → 1.0.12
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/dist/generator/file-writer.d.ts +1 -0
- package/dist/generator/file-writer.d.ts.map +1 -1
- package/dist/generator/file-writer.js +3 -0
- package/dist/generator/file-writer.js.map +1 -1
- package/dist/generator/modular/modular-container-generator.d.ts +5 -0
- package/dist/generator/modular/modular-container-generator.d.ts.map +1 -1
- package/dist/generator/modular/modular-container-generator.js +17 -2
- package/dist/generator/modular/modular-container-generator.js.map +1 -1
- package/dist/generator/modular/split-file-writer.d.ts +46 -0
- package/dist/generator/modular/split-file-writer.d.ts.map +1 -0
- package/dist/generator/modular/split-file-writer.js +133 -0
- package/dist/generator/modular/split-file-writer.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-writer.d.ts","sourceRoot":"","sources":["../../src/generator/file-writer.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,EAAE,MAAM;IAI9B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"file-writer.d.ts","sourceRoot":"","sources":["../../src/generator/file-writer.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,EAAE,MAAM;IAI9B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IASrC,aAAa,IAAI,MAAM;CAGxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-writer.js","sourceRoot":"","sources":["../../src/generator/file-writer.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,+BAA+B;AAE/B,MAAa,UAAU;IAGrB,YAAY,UAAkB;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,cAAc,CAAC,OAAe;QAC5B,iCAAiC;QACjC,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAA,cAAS,EAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1C,2BAA2B;QAC3B,IAAA,kBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"file-writer.js","sourceRoot":"","sources":["../../src/generator/file-writer.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,+BAA+B;AAE/B,MAAa,UAAU;IAGrB,YAAY,UAAkB;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,cAAc,CAAC,OAAe;QAC5B,iCAAiC;QACjC,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAA,cAAS,EAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1C,2BAA2B;QAC3B,IAAA,kBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAnBD,gCAmBC"}
|
|
@@ -20,5 +20,10 @@ export declare class ModularContainerGenerator extends BaseContainerGenerator {
|
|
|
20
20
|
generate(): void;
|
|
21
21
|
protected generateContainerCode(sortedModules?: string[], moduleDependencies?: Map<string, Set<string>>): string;
|
|
22
22
|
private generateModuleContainers;
|
|
23
|
+
/**
|
|
24
|
+
* Generates split files when there are more than 3 modules.
|
|
25
|
+
* Each module gets its own file, plus a main aggregator file.
|
|
26
|
+
*/
|
|
27
|
+
private generateSplitFiles;
|
|
23
28
|
}
|
|
24
29
|
//# sourceMappingURL=modular-container-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modular-container-generator.d.ts","sourceRoot":"","sources":["../../../src/generator/modular/modular-container-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"modular-container-generator.d.ts","sourceRoot":"","sources":["../../../src/generator/modular/modular-container-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,oBAAoB,CAA2B;IACvD,OAAO,CAAC,wBAAwB,CAA2B;IAC3D,OAAO,CAAC,gCAAgC,CAAmC;IAC3E,OAAO,CAAC,4BAA4B,CAA+B;IACnE,OAAO,CAAC,mBAAmB,CAAsB;gBAG/C,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,eAAe,EAAE,eAAe,EAChC,gCAAgC,EAAE,gCAAgC,EAClE,4BAA4B,EAAE,4BAA4B,EAC1D,mBAAmB,EAAE,mBAAmB;IAU1C,QAAQ,IAAI,IAAI;IA0BhB,SAAS,CAAC,qBAAqB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM;IAehH,OAAO,CAAC,wBAAwB;IAOhC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAY3B"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ModularContainerGenerator = void 0;
|
|
4
4
|
const dependency_resolver_1 = require("../../analyser/dependency-resolver");
|
|
5
5
|
const base_container_generator_1 = require("../base-container-generator");
|
|
6
|
+
const split_file_writer_1 = require("./split-file-writer");
|
|
6
7
|
/**
|
|
7
8
|
* Generator for modular container structure.
|
|
8
9
|
* Handles module-based dependency injection with inter-module dependencies.
|
|
@@ -29,8 +30,14 @@ class ModularContainerGenerator extends base_container_generator_1.BaseContainer
|
|
|
29
30
|
if (sortResult.cycles.length > 0) {
|
|
30
31
|
throw new Error(`Circular dependencies detected within classes: ${JSON.stringify(sortResult.cycles)}`);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
// Check if we need to split files (more than 2 modules)
|
|
34
|
+
if (moduleResult.sortedModules.length >= 2) {
|
|
35
|
+
this.generateSplitFiles(moduleResult.sortedModules, moduleResult.moduleDependencies);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const containerCode = this.generateContainerCode(moduleResult.sortedModules, moduleResult.moduleDependencies);
|
|
39
|
+
this.writeContainer(containerCode);
|
|
40
|
+
}
|
|
34
41
|
}
|
|
35
42
|
generateContainerCode(sortedModules, moduleDependencies) {
|
|
36
43
|
if (!sortedModules || !moduleDependencies) {
|
|
@@ -49,6 +56,14 @@ class ModularContainerGenerator extends base_container_generator_1.BaseContainer
|
|
|
49
56
|
const moduleInstantiations = this.moduleInstantiationGenerator.generateModuleInstantiations(sortedModules, moduleDependencies);
|
|
50
57
|
return moduleContainerFunctions.join('\n\n') + '\n\n' + moduleInstantiations.join('\n');
|
|
51
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Generates split files when there are more than 3 modules.
|
|
61
|
+
* Each module gets its own file, plus a main aggregator file.
|
|
62
|
+
*/
|
|
63
|
+
generateSplitFiles(sortedModules, moduleDependencies) {
|
|
64
|
+
const splitFileWriter = new split_file_writer_1.SplitFileWriter(this.fileWriter.getOutputPath());
|
|
65
|
+
splitFileWriter.writeSplitModules(this.moduleGroupedClasses, sortedModules, moduleDependencies, this.moduleContainerFunctionGenerator, this.moduleInstantiationGenerator, this.importGenerator);
|
|
66
|
+
}
|
|
52
67
|
}
|
|
53
68
|
exports.ModularContainerGenerator = ModularContainerGenerator;
|
|
54
69
|
//# sourceMappingURL=modular-container-generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modular-container-generator.js","sourceRoot":"","sources":["../../../src/generator/modular/modular-container-generator.ts"],"names":[],"mappings":";;;AAAA,4EAAwE;AAIxE,0EAAqE;
|
|
1
|
+
{"version":3,"file":"modular-container-generator.js","sourceRoot":"","sources":["../../../src/generator/modular/modular-container-generator.ts"],"names":[],"mappings":";;;AAAA,4EAAwE;AAIxE,0EAAqE;AAKrE,2DAAsD;AAEtD;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,iDAAsB;IAOnE,YACE,UAAsB,EACtB,oBA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CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IAED;;;OAGG;IACK,kBAAkB,CAAC,aAAuB,EAAE,kBAA4C;QAC9F,MAAM,eAAe,GAAG,IAAI,mCAAe,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;QAE7E,eAAe,CAAC,iBAAiB,CAC/B,IAAI,CAAC,oBAAoB,EACzB,aAAa,EACb,kBAAkB,EAClB,IAAI,CAAC,gCAAgC,EACrC,IAAI,CAAC,4BAA4B,EACjC,IAAI,CAAC,eAAe,CACrB,CAAC;IACJ,CAAC;CACF;AAxFD,8DAwFC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ClassInfo } from '../../types';
|
|
2
|
+
import { ImportGenerator } from '../import-generator';
|
|
3
|
+
import { ModuleContainerFunctionGenerator } from './module-container-function-generator';
|
|
4
|
+
import { ModuleInstantiationGenerator } from './module-instantiation-generator';
|
|
5
|
+
/**
|
|
6
|
+
* Handles writing split module files when there are more than 3 modules.
|
|
7
|
+
* Each module gets its own <moduleName>.gen.ts file, plus a main container.gen.ts aggregator.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SplitFileWriter {
|
|
10
|
+
private outputPath;
|
|
11
|
+
private outputDir;
|
|
12
|
+
constructor(outputPath: string);
|
|
13
|
+
/**
|
|
14
|
+
* Writes split module files and main aggregator file.
|
|
15
|
+
*/
|
|
16
|
+
writeSplitModules(moduleGroupedClasses: Map<string, ClassInfo[]>, sortedModules: string[], moduleDependencies: Map<string, Set<string>>, moduleContainerFunctionGenerator: ModuleContainerFunctionGenerator, moduleInstantiationGenerator: ModuleInstantiationGenerator, globalImportGenerator: ImportGenerator): void;
|
|
17
|
+
/**
|
|
18
|
+
* Generates content for an individual module file.
|
|
19
|
+
*/
|
|
20
|
+
private generateModuleFileContent;
|
|
21
|
+
/**
|
|
22
|
+
* Generates dependency import statements for a module.
|
|
23
|
+
*/
|
|
24
|
+
private generateDependencyImports;
|
|
25
|
+
/**
|
|
26
|
+
* Generates type export for a module.
|
|
27
|
+
*/
|
|
28
|
+
private generateModuleTypeExport;
|
|
29
|
+
/**
|
|
30
|
+
* Generates content for the main aggregator file.
|
|
31
|
+
*/
|
|
32
|
+
private generateAggregatorFileContent;
|
|
33
|
+
/**
|
|
34
|
+
* Generates module instantiations for the aggregator file.
|
|
35
|
+
*/
|
|
36
|
+
private generateModuleInstantiationsForAggregator;
|
|
37
|
+
/**
|
|
38
|
+
* Generates the aggregated container for split files.
|
|
39
|
+
*/
|
|
40
|
+
private generateAggregatedContainerForSplit;
|
|
41
|
+
/**
|
|
42
|
+
* Converts a string to camelCase.
|
|
43
|
+
*/
|
|
44
|
+
private toCamelCase;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=split-file-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-file-writer.d.ts","sourceRoot":"","sources":["../../../src/generator/modular/split-file-writer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAEhF;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;gBAEd,UAAU,EAAE,MAAM;IAK9B;;OAEG;IACH,iBAAiB,CACf,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAC9C,aAAa,EAAE,MAAM,EAAE,EACvB,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EAC5C,gCAAgC,EAAE,gCAAgC,EAClE,4BAA4B,EAAE,4BAA4B,EAC1D,qBAAqB,EAAE,eAAe,GACrC,IAAI;IA2BP;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAmCjC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAUjC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAMhC;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAgCrC;;OAEG;IACH,OAAO,CAAC,yCAAyC;IAyBjD;;OAEG;IACH,OAAO,CAAC,mCAAmC;IAU3C;;OAEG;IACH,OAAO,CAAC,WAAW;CAGpB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SplitFileWriter = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const import_generator_1 = require("../import-generator");
|
|
7
|
+
/**
|
|
8
|
+
* Handles writing split module files when there are more than 3 modules.
|
|
9
|
+
* Each module gets its own <moduleName>.gen.ts file, plus a main container.gen.ts aggregator.
|
|
10
|
+
*/
|
|
11
|
+
class SplitFileWriter {
|
|
12
|
+
constructor(outputPath) {
|
|
13
|
+
this.outputPath = outputPath;
|
|
14
|
+
this.outputDir = (0, path_1.dirname)(outputPath);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Writes split module files and main aggregator file.
|
|
18
|
+
*/
|
|
19
|
+
writeSplitModules(moduleGroupedClasses, sortedModules, moduleDependencies, moduleContainerFunctionGenerator, moduleInstantiationGenerator, globalImportGenerator) {
|
|
20
|
+
// Ensure output directory exists
|
|
21
|
+
(0, fs_1.mkdirSync)(this.outputDir, { recursive: true });
|
|
22
|
+
// Write individual module files
|
|
23
|
+
for (const moduleName of sortedModules) {
|
|
24
|
+
const moduleClasses = moduleGroupedClasses.get(moduleName);
|
|
25
|
+
if (!moduleClasses)
|
|
26
|
+
continue;
|
|
27
|
+
const moduleFilePath = (0, path_1.join)(this.outputDir, `${moduleName}.gen.ts`);
|
|
28
|
+
const moduleContent = this.generateModuleFileContent(moduleName, moduleClasses, moduleDependencies, moduleContainerFunctionGenerator, moduleInstantiationGenerator, globalImportGenerator);
|
|
29
|
+
(0, fs_1.writeFileSync)(moduleFilePath, moduleContent, 'utf-8');
|
|
30
|
+
}
|
|
31
|
+
// Write main aggregator file
|
|
32
|
+
const aggregatorContent = this.generateAggregatorFileContent(sortedModules, moduleDependencies);
|
|
33
|
+
(0, fs_1.writeFileSync)(this.outputPath, aggregatorContent, 'utf-8');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generates content for an individual module file.
|
|
37
|
+
*/
|
|
38
|
+
generateModuleFileContent(moduleName, moduleClasses, moduleDependencies, moduleContainerFunctionGenerator, moduleInstantiationGenerator, globalImportGenerator) {
|
|
39
|
+
// Create a module-specific import generator
|
|
40
|
+
const moduleImportGenerator = new import_generator_1.ImportGenerator(moduleClasses);
|
|
41
|
+
const moduleImports = moduleImportGenerator.generateImports();
|
|
42
|
+
// Generate module container function
|
|
43
|
+
const moduleContainerFunctions = moduleContainerFunctionGenerator.generateModuleContainerFunctions([moduleName], moduleDependencies);
|
|
44
|
+
// Generate module dependencies import statements
|
|
45
|
+
const moduleDeps = moduleDependencies.get(moduleName) || new Set();
|
|
46
|
+
const dependencyImports = this.generateDependencyImports(moduleDeps);
|
|
47
|
+
// Generate module type definitions
|
|
48
|
+
const moduleTypeExport = this.generateModuleTypeExport(moduleName);
|
|
49
|
+
return [
|
|
50
|
+
moduleImports,
|
|
51
|
+
dependencyImports,
|
|
52
|
+
'',
|
|
53
|
+
moduleContainerFunctions.join('\n\n'),
|
|
54
|
+
'',
|
|
55
|
+
moduleTypeExport
|
|
56
|
+
].filter(line => line.trim() !== '').join('\n');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generates dependency import statements for a module.
|
|
60
|
+
*/
|
|
61
|
+
generateDependencyImports(moduleDeps) {
|
|
62
|
+
if (moduleDeps.size === 0)
|
|
63
|
+
return '';
|
|
64
|
+
const imports = Array.from(moduleDeps).map(depModule => `import { create${depModule}Container } from './${depModule}.gen';`);
|
|
65
|
+
return imports.join('\n');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generates type export for a module.
|
|
69
|
+
*/
|
|
70
|
+
generateModuleTypeExport(moduleName) {
|
|
71
|
+
const functionName = `create${moduleName}Container`;
|
|
72
|
+
return `export { ${functionName} };
|
|
73
|
+
export type ${moduleName}Container = ReturnType<typeof ${functionName}>;`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generates content for the main aggregator file.
|
|
77
|
+
*/
|
|
78
|
+
generateAggregatorFileContent(sortedModules, moduleDependencies) {
|
|
79
|
+
// Generate imports for all module files
|
|
80
|
+
const moduleImports = sortedModules.map(moduleName => `import { create${moduleName}Container } from './${moduleName}.gen';`).join('\n');
|
|
81
|
+
// Generate module instantiations in dependency order
|
|
82
|
+
const moduleInstantiations = this.generateModuleInstantiationsForAggregator(sortedModules, moduleDependencies);
|
|
83
|
+
// Generate aggregated container
|
|
84
|
+
const aggregatedContainer = this.generateAggregatedContainerForSplit(sortedModules);
|
|
85
|
+
// Generate type export
|
|
86
|
+
const typeExport = 'export type Container = typeof container;';
|
|
87
|
+
return [
|
|
88
|
+
moduleImports,
|
|
89
|
+
'',
|
|
90
|
+
moduleInstantiations.join('\n'),
|
|
91
|
+
'',
|
|
92
|
+
aggregatedContainer,
|
|
93
|
+
'',
|
|
94
|
+
typeExport
|
|
95
|
+
].join('\n');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generates module instantiations for the aggregator file.
|
|
99
|
+
*/
|
|
100
|
+
generateModuleInstantiationsForAggregator(sortedModules, moduleDependencies) {
|
|
101
|
+
const instantiations = [];
|
|
102
|
+
for (const moduleName of sortedModules) {
|
|
103
|
+
const moduleDeps = moduleDependencies.get(moduleName) || new Set();
|
|
104
|
+
const moduleVarName = this.toCamelCase(moduleName) + 'Container';
|
|
105
|
+
const moduleFunctionName = `create${moduleName}Container`;
|
|
106
|
+
const functionArgs = Array.from(moduleDeps).map(depModule => this.toCamelCase(depModule) + 'Container');
|
|
107
|
+
const functionCall = functionArgs.length > 0
|
|
108
|
+
? `${moduleFunctionName}(${functionArgs.join(', ')})`
|
|
109
|
+
: `${moduleFunctionName}()`;
|
|
110
|
+
instantiations.push(`const ${moduleVarName} = ${functionCall};`);
|
|
111
|
+
}
|
|
112
|
+
return instantiations;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Generates the aggregated container for split files.
|
|
116
|
+
*/
|
|
117
|
+
generateAggregatedContainerForSplit(sortedModules) {
|
|
118
|
+
const moduleExports = sortedModules.map(moduleName => {
|
|
119
|
+
const moduleVarName = this.toCamelCase(moduleName) + 'Container';
|
|
120
|
+
const moduleKey = this.toCamelCase(moduleName);
|
|
121
|
+
return ` ${moduleKey}: ${moduleVarName}`;
|
|
122
|
+
});
|
|
123
|
+
return `export const container = {\n${moduleExports.join(',\n')}\n};`;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Converts a string to camelCase.
|
|
127
|
+
*/
|
|
128
|
+
toCamelCase(str) {
|
|
129
|
+
return str.charAt(0).toLowerCase() + str.slice(1).replace(/[^a-zA-Z0-9]/g, '');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.SplitFileWriter = SplitFileWriter;
|
|
133
|
+
//# sourceMappingURL=split-file-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-file-writer.js","sourceRoot":"","sources":["../../../src/generator/modular/split-file-writer.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,+BAAqC;AAErC,0DAAsD;AAItD;;;GAGG;AACH,MAAa,eAAe;IAI1B,YAAY,UAAkB;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,iBAAiB,CACf,oBAA8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AAC;IAED;;OAEG;IACK,mCAAmC,CAAC,aAAuB;QACjE,MAAM,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACnD,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC;YACjE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAC/C,OAAO,KAAK,SAAS,KAAK,aAAa,EAAE,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,OAAO,+BAA+B,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IACxE,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,GAAW;QAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC;CACF;AA5LD,0CA4LC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,yCAAoC;AACpC,kDAAsD;AACtD,gDAAoD;AACpD,oDAAwD;AAIxD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,2DAA2D,CAAC;KACxE,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB;AACpB,OAAO,CAAC,UAAU,CAAC,0BAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,wBAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,4BAAgB,CAAC,CAAC;AAErC,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,uCAAuC;AACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
package/package.json
CHANGED