Merge pull request #1157 from threehams/faster-builds

Switch ts and babel for swc-loader
This commit is contained in:
hydroflame 2021-09-04 20:05:51 -04:00 committed by GitHub
commit 4011542b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1085 additions and 902 deletions

1930
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -44,6 +44,8 @@
"react-dom": "^16.8.3",
"react-modal": "^3.12.1",
"sprintf-js": "^1.1.1",
"swc": "^1.0.11",
"swc-loader": "^0.1.14",
"tapable": "^1.0.0",
"treant-js": "^1.0.1",
"uuid": "^3.2.1",

@ -241,7 +241,7 @@ export class ResearchTree {
continue;
}
const mult: any = (<any>research)[propName];
const mult: any = (research as any)[propName];
if (mult == null) {
console.warn(
`Invalid propName specified in ResearchTree.getMultiplierHelper: ${propName}`,

@ -113,12 +113,12 @@ export abstract class Person {
*/
applyAugmentation(aug: Augmentation): void {
for (const mult in aug.mults) {
if ((<any>this)[mult] == null) {
if ((this as any)[mult] == null) {
console.warn(
`Augmentation has unrecognized multiplier property: ${mult}`,
);
} else {
(<any>this)[mult] *= aug.mults[mult];
(this as any)[mult] *= aug.mults[mult];
}
}
}

@ -214,9 +214,9 @@ export class Sleeve extends Person {
// Success
const successGainRates: ITaskTracker = createTaskTracker();
const keysForIteration: (keyof ITaskTracker)[] = <
(keyof ITaskTracker)[]
>Object.keys(successGainRates);
const keysForIteration: (keyof ITaskTracker)[] = Object.keys(
successGainRates,
) as (keyof ITaskTracker)[];
for (let i = 0; i < keysForIteration.length; ++i) {
const key = keysForIteration[i];
successGainRates[key] = this.gainRatesForTask[key] * 2;

@ -37,10 +37,10 @@ function toNumber(n: number | IMinMaxRange): number {
let value: number;
switch (typeof n) {
case "number": {
return <number>n;
return n;
}
case "object": {
const range = <IMinMaxRange>n;
const range = n as IMinMaxRange;
value = getRandomInt(range.min, range.max);
break;
}

@ -49,7 +49,7 @@ export function tabCompletion(
);
return;
}
const textBox = <HTMLInputElement>textBoxElem;
const textBox = textBoxElem as HTMLInputElement;
const oldValue = textBox.value;
const semiColonIndex = oldValue.lastIndexOf(";");

@ -575,8 +575,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
},
{
desc: (data: any[]): string => {
const k: number = <number>data[0];
const prices: number[] = <number[]>data[1];
const k: number = data[0];
const prices: number[] = data[1];
return [
"You are given the following array with two elements:\n\n",
`[${k}, [${prices}]]\n\n`,
@ -606,8 +606,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
name: "Algorithmic Stock Trader IV",
numTries: 10,
solver: (data: any[], ans: string): boolean => {
const k: number = <number>data[0];
const prices: number[] = <number[]>data[1];
const k: number = data[0];
const prices: number[] = data[1];
const len = prices.length;
if (len < 2) {

@ -38,7 +38,7 @@ export class MoneySourceTracker {
return;
}
(<number>this[sanitizedSource]) += amt;
(this[sanitizedSource] as number) += amt;
this.total += amt;
}

@ -2,6 +2,7 @@
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es2016", "dom", "es2017.object", "es2019"],
"module": "commonjs",

@ -15,8 +15,8 @@ export function compareArrays<T>(a1: T[], a2: T[]): boolean {
return false;
}
const elem1 = <any[]>(<any>a1[i]);
const elem2 = <any[]>(<any>a2[i]);
const elem1 = a1[i] as any;
const elem2 = a2[i] as any;
if (!compareArrays(elem1, elem2)) {
return false;
}

@ -109,14 +109,32 @@ module.exports = (env, argv) => {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
use: {
loader: "swc-loader",
options: {
jsc: {
parser: {
syntax: "typescript",
tsx: true,
},
},
},
},
},
{
test: /\.(jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
loader: "swc-loader",
options: {
jsc: {
parser: {
syntax: "ecmascript",
jsx: true,
},
},
},
},
},
{