Skip to content

Commit

Permalink
add incremental outDir ts_out
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Apr 7, 2019
1 parent 9478c45 commit 84ad9ed
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 117 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ Signum.React/node_modules/*.js
/Signum.TSGenerator/Binaries/*
/Signum.React/node_modules/@types/react/node_modules*
/Signum.React/node_modules/**/*.md
/Signum.React/ts_out/*
115 changes: 0 additions & 115 deletions Signum.React/Scripts/Globals.d.ts

This file was deleted.

117 changes: 117 additions & 0 deletions Signum.React/Scripts/Globals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,121 @@
declare global {

function require<T>(path: string): T;
function require<T>(paths: string[], callback: (...modules: any[]) => void): void;

interface Promise<T> {
done(this: Promise<T>): void;
}

interface Window {
__baseUrl: string;
dataForChildWindow?: any;
}

interface Array<T> {
groupBy<K extends string | number>(this: Array<T>, keySelector: (element: T) => K): { key: K; elements: T[] }[];
groupToObject(this: Array<T>, keySelector: (element: T) => string): { [key: string]: T[] };
groupWhen(this: Array<T>, condition: (element: T) => boolean): { key: T, elements: T[] }[];
groupWhenChange<K extends string | number>(this: Array<T>, keySelector: (element: T) => K): { key: K, elements: T[] }[];

orderBy<V>(this: Array<T>, keySelector: (element: T) => V): T[];
orderByDescending<V>(this: Array<T>, keySelector: (element: T) => V): T[];


toObject(this: Array<T>, keySelector: (element: T) => string): { [key: string]: T };
toObject<V>(this: Array<T>, keySelector: (element: T) => string, valueSelector: (element: T) => V): { [key: string]: V };
toObjectDistinct(this: Array<T>, keySelector: (element: T) => string): { [key: string]: T };
toObjectDistinct<V>(this: Array<T>, keySelector: (element: T) => string, valueSelector: (element: T) => V): { [key: string]: V };
distinctBy(this: Array<T>, keySelector?: (element: T) => string): T[];

flatMap<R>(this: Array<T>, selector: (element: T, index: number, array: T[]) => R[]): R[];

clear(this: Array<T>): void;
groupsOf(this: Array<T>, groupSize: number, elementSize?: (item: T) => number): T[][];

withMin<V>(this: Array<T>, keySelector: (element: T) => V): T | undefined;
withMax<V>(this: Array<T>, keySelector: (element: T) => V): T | undefined;
max(this: Array<number | null | undefined>): number | null;
max(this: Array<T>, selector: (element: T, index: number, array: T[]) => number | null | undefined): number | null;
min(this: Array<number | null | undefined>): number | null;
min(this: Array<T>, selector: (element: T, index: number, array: T[]) => number | null | undefined): number | null;

sum(this: Array<number>): number;
sum(this: Array<T>, selector: (element: T, index: number, array: T[]) => number): number;

first(this: Array<T>, errorContext?: string): T;
first(this: Array<T>, predicate?: (element: T, index: number, array: T[]) => boolean): T;

firstOrNull(this: Array<T>): T | null;
firstOrNull(this: Array<T>, predicate?: (element: T, index: number, array: T[]) => boolean): T | null;

last(this: Array<T>, errorContext?: string): T;
last(this: Array<T>, predicate?: (element: T, index: number, array: T[]) => boolean): T;

lastOrNull(this: Array<T>, ): T | null;
lastOrNull(this: Array<T>, predicate?: (element: T, index: number, array: T[]) => boolean): T | null;

single(this: Array<T>, errorContext?: string): T;
single(this: Array<T>, predicate?: (element: T, index: number, array: T[]) => boolean): T;

singleOrNull(this: Array<T>, errorContext?: string): T | null;
singleOrNull(this: Array<T>, predicate?: (element: T, index: number, array: T[]) => boolean): T | null;

contains(this: Array<T>, element: T): boolean;
remove(this: Array<T>, element: T): boolean;
removeAt(this: Array<T>, index: number): void;
moveUp(this: Array<T>, index: number): number;
moveDown(this: Array<T>, index: number): number;
insertAt(this: Array<T>, index: number, element: T): void;

notNull(this: Array<T>): NonNullable<T>[];
clone(this: Array<T>, ): T[];
joinComma(this: Array<T>, lastSeparator: string): string;
extract(this: Array<T>, filter: (element: T) => boolean): T[];
findIndex(this: Array<T>, filter: (element: T, index: number, obj: Array<T>) => boolean): number;
findLastIndex(this: Array<T>, filter: (element: T) => boolean): number;
}

interface ArrayConstructor {

range(min: number, maxNotIncluded: number): number[];
toArray<T>(arrayish: { length: number;[index: number]: T }): T[];
repeat<T>(count: number, value: T): T[];
}

interface String {
contains(this: string, str: string): boolean;
startsWith(this: string, str: string): boolean;
endsWith(this: string, str: string): boolean;
formatWith(this: string, ...parameters: any[]): string;
forGenderAndNumber(this: string, number: number): string;
forGenderAndNumber(this: string, gender: string | undefined): string;
forGenderAndNumber(this: string, gender: any, number?: number): string;
replaceAll(this: string, from: string, to: string): string;
indent(this: string, numChars: number): string;
after(this: string, separator: string): string;
before(this: string, separator: string): string;
tryAfter(this: string, separator: string): string | undefined;
tryBefore(this: string, separator: string): string | undefined;
afterLast(this: string, separator: string): string;
beforeLast(this: string, separator: string): string;
tryAfterLast(this: string, separator: string): string | undefined;
tryBeforeLast(this: string, separator: string): string | undefined;
etc(this: string, maxLength: number, etcString?: string): string;

firstUpper(this: string): string;
firstLower(this: string, ): string;

trimEnd(this: string, char?: string): string;
trimStart(this: string, char?: string): string;

repeat(this: string, n: number): string;
}

interface RequestInit {
abortSignal?: AbortSignal;
}
}
Array.prototype.clear = function (): void {
this.length = 0;
};
Expand Down
1 change: 1 addition & 0 deletions Signum.React/Signum.React.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<ItemGroup>
<None Remove="node_modules\**" />
<None Remove="ts_out\**" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions Signum.React/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"noEmit": true,
"incremental": true,
"outDir": "./ts_out",
//"noEmit": true,
"strict": true,
"baseUrl": ".",
"lib": [
Expand All @@ -14,5 +16,5 @@
"dom"
]
},
"exclude": [ "node_modules" ]
"exclude": [ "node_modules", "ts_out" ]
}

2 comments on commit 84ad9ed

@olmobrutall
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve TypeScript compilation performance

Till no, we have had typescript compiler splitted in two:

  • In Visual Studio, noEmit was set, since e are only interesting in the type checking (error generation).
  • In WebPack, noEmit was disabled but transpileOnly as enabled, since we are only interested in the generated javascript as fast as possible.

Since TS 3.4 there is a new incremental feature that promises to improve performance on rebuilds. Unfortunately it doesn't work with noEmit yet, so I've:

  • Comment out "noEmit": true to disabled it.
  • Set outDir: "/ts_out" to keep the generated .js files in a different folder. This JS files are not used by webpack in any way!!
  • Set "incremental":true
  • Exclude tsOut in .tsconfig
  • Add tsOut to git ignore.

I recommend you to do the same in your application too, to improve performance. In my test a rebuild went from 30s to 10s

@olmobrutall
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried in a biggest solution and rebuild all the React projects (Signum.React, Signum.React.Extensions, App.React) went from 120s to 30s in total.

An incredible 4x speedup! 🥇

Please sign in to comment.