Skip to content

Commit

Permalink
stabilise order of generated definitions' imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jahudka committed Nov 8, 2023
1 parent c0f5439 commit 02860cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ioc",
"inversion of control"
],
"version": "0.0.40",
"version": "0.0.41",
"license": "MIT",
"author": {
"name": "Dan Kadera",
Expand Down
12 changes: 9 additions & 3 deletions core/cli/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,15 @@ function compareIDs(a: string, b: string): number {
}

function extractSources(definitions: ServiceDefinitionInfo[]): Map<SourceFile, string> {
return new Map([
...new Set(definitions.flatMap((d) => [d.source, ...d.decorators.map((o) => o.source)])),
].map((s, i) => [s, `defs${i}`]));
const sources = [...new Set(definitions.flatMap((d) => [d.source, ...d.decorators.map((o) => o.source)]))];
sources.sort(compareSourceFiles);
return new Map(sources.map((s, i) => [s, `defs${i}`]));
}

function compareSourceFiles(a: SourceFile, b: SourceFile): number {
const pa = a.getFilePath();
const pb = b.getFilePath();
return pa < pb ? -1 : pa > pb ? 1 : 0;
}

function join(separator: string, ...tokens: (string | 0 | false | undefined)[]): string {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 02860cb

Please sign in to comment.