From 6ee2ddead5d38b433f54cc7a197ff60244157b1b Mon Sep 17 00:00:00 2001 From: David Mehren Date: Thu, 29 Apr 2021 22:47:18 +0200 Subject: [PATCH] Use node12 TypeScript base config TypeScript recommends using a base config from https://github.com/tsconfig/bases. Using this config reduces compile times by ~30% and the size of the dist folder by ~45%. It also enables the recommended `esModuleInterop` option, which necessitated some changes to imports. See also https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-from-commonjs-modules-with---esmoduleinterop Signed-off-by: David Mehren --- package.json | 1 + src/api/utils/markdownbody-decorator.ts | 2 +- test/private-api/history.e2e-spec.ts | 2 +- test/private-api/me.e2e-spec.ts | 2 +- test/private-api/media.e2e-spec.ts | 2 +- test/private-api/notes.e2e-spec.ts | 2 +- test/public-api/me.e2e-spec.ts | 2 +- test/public-api/media.e2e-spec.ts | 2 +- test/public-api/notes.e2e-spec.ts | 2 +- tsconfig.json | 6 +++--- yarn.lock | 5 +++++ 11 files changed, 17 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3ccccea59..c284a241e 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@nestjs/cli": "7.6.0", "@nestjs/schematics": "7.3.1", "@nestjs/testing": "7.6.15", + "@tsconfig/node12": "^1.0.7", "@types/cli-color": "2.0.0", "@types/express": "4.17.11", "@types/jest": "26.0.23", diff --git a/src/api/utils/markdownbody-decorator.ts b/src/api/utils/markdownbody-decorator.ts index 98dcf0836..4c55256a4 100644 --- a/src/api/utils/markdownbody-decorator.ts +++ b/src/api/utils/markdownbody-decorator.ts @@ -11,7 +11,7 @@ import { InternalServerErrorException, } from '@nestjs/common'; import { ApiBody, ApiConsumes } from '@nestjs/swagger'; -import * as getRawBody from 'raw-body'; +import getRawBody from 'raw-body'; /** * Extract the raw markdown from the request body and create a new note with it diff --git a/test/private-api/history.e2e-spec.ts b/test/private-api/history.e2e-spec.ts index 192c8964d..59a5d0a5c 100644 --- a/test/private-api/history.e2e-spec.ts +++ b/test/private-api/history.e2e-spec.ts @@ -8,7 +8,7 @@ import { INestApplication } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { Test } from '@nestjs/testing'; import { TypeOrmModule } from '@nestjs/typeorm'; -import * as request from 'supertest'; +import request from 'supertest'; import mediaConfigMock from '../../src/config/mock/media.config.mock'; import appConfigMock from '../../src/config/mock/app.config.mock'; import authConfigMock from '../../src/config/mock/auth.config.mock'; diff --git a/test/private-api/me.e2e-spec.ts b/test/private-api/me.e2e-spec.ts index 77245e9f0..79166f13b 100644 --- a/test/private-api/me.e2e-spec.ts +++ b/test/private-api/me.e2e-spec.ts @@ -13,7 +13,7 @@ import { INestApplication } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; import { TypeOrmModule } from '@nestjs/typeorm'; -import * as request from 'supertest'; +import request from 'supertest'; import appConfigMock from '../../src/config/mock/app.config.mock'; import authConfigMock from '../../src/config/mock/auth.config.mock'; import mediaConfigMock from '../../src/config/mock/media.config.mock'; diff --git a/test/private-api/media.e2e-spec.ts b/test/private-api/media.e2e-spec.ts index 890ca9f48..2a78cd028 100644 --- a/test/private-api/media.e2e-spec.ts +++ b/test/private-api/media.e2e-spec.ts @@ -9,7 +9,7 @@ import { NestExpressApplication } from '@nestjs/platform-express'; import { Test } from '@nestjs/testing'; import { TypeOrmModule } from '@nestjs/typeorm'; import { promises as fs } from 'fs'; -import * as request from 'supertest'; +import request from 'supertest'; import mediaConfigMock from '../../src/config/mock/media.config.mock'; import appConfigMock from '../../src/config/mock/app.config.mock'; import authConfigMock from '../../src/config/mock/auth.config.mock'; diff --git a/test/private-api/notes.e2e-spec.ts b/test/private-api/notes.e2e-spec.ts index 1c29682a2..aca2f5a30 100644 --- a/test/private-api/notes.e2e-spec.ts +++ b/test/private-api/notes.e2e-spec.ts @@ -8,7 +8,7 @@ import { INestApplication } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; import { TypeOrmModule } from '@nestjs/typeorm'; -import * as request from 'supertest'; +import request from 'supertest'; import mediaConfigMock from '../../src/config/mock/media.config.mock'; import appConfigMock from '../../src/config/mock/app.config.mock'; import authConfigMock from '../../src/config/mock/auth.config.mock'; diff --git a/test/public-api/me.e2e-spec.ts b/test/public-api/me.e2e-spec.ts index 62d8e6413..53e810eae 100644 --- a/test/public-api/me.e2e-spec.ts +++ b/test/public-api/me.e2e-spec.ts @@ -6,7 +6,7 @@ import { INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; -import * as request from 'supertest'; +import request from 'supertest'; import { HistoryService } from '../../src/history/history.service'; import { NotesService } from '../../src/notes/notes.service'; import { HistoryEntryUpdateDto } from '../../src/history/history-entry-update.dto'; diff --git a/test/public-api/media.e2e-spec.ts b/test/public-api/media.e2e-spec.ts index b2687591f..b2dc81b8a 100644 --- a/test/public-api/media.e2e-spec.ts +++ b/test/public-api/media.e2e-spec.ts @@ -9,7 +9,7 @@ import { NestExpressApplication } from '@nestjs/platform-express'; import { Test } from '@nestjs/testing'; import { TypeOrmModule } from '@nestjs/typeorm'; import { promises as fs } from 'fs'; -import * as request from 'supertest'; +import request from 'supertest'; import { PublicApiModule } from '../../src/api/public/public-api.module'; import mediaConfigMock from '../../src/config/mock/media.config.mock'; import appConfigMock from '../../src/config/mock/app.config.mock'; diff --git a/test/public-api/notes.e2e-spec.ts b/test/public-api/notes.e2e-spec.ts index ea2901506..024c3d0de 100644 --- a/test/public-api/notes.e2e-spec.ts +++ b/test/public-api/notes.e2e-spec.ts @@ -8,7 +8,7 @@ import { INestApplication } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; import { TypeOrmModule } from '@nestjs/typeorm'; -import * as request from 'supertest'; +import request from 'supertest'; import { PublicApiModule } from '../../src/api/public/public-api.module'; import mediaConfigMock from '../../src/config/mock/media.config.mock'; import appConfigMock from '../../src/config/mock/app.config.mock'; diff --git a/tsconfig.json b/tsconfig.json index 49abe30bc..c925859f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,11 @@ { + "extends": "@tsconfig/node12/tsconfig.json", "compilerOptions": { - "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, - "target": "es2017", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", @@ -14,6 +13,7 @@ "typeRoots": [ "./types", "./node_modules/@types" - ] + ], + "strict": false } } diff --git a/yarn.lock b/yarn.lock index 8eab3026e..a44948ea1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -910,6 +910,11 @@ resolved "https://registry.yarnpkg.com/@tokenizer/token/-/token-0.1.1.tgz#f0d92c12f87079ddfd1b29f614758b9696bc29e3" integrity sha512-XO6INPbZCxdprl+9qa/AAbFFOMzzwqYxpjPgLICrMD6C2FCw6qfJOPcBk6JqqPLSaZ/Qx87qn4rpPmPMwaAK6w== +"@tsconfig/node12@^1.0.7": + version "1.0.7" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.7.tgz#677bd9117e8164dc319987dd6ff5fc1ba6fbf18b" + integrity sha512-dgasobK/Y0wVMswcipr3k0HpevxFJLijN03A8mYfEPvWvOs14v0ZlYTR4kIgMx8g4+fTyTFv8/jLCIfRqLDJ4A== + "@types/accepts@*": version "1.3.5" resolved "https://registry.yarnpkg.com/@types/accepts/-/accepts-1.3.5.tgz#c34bec115cfc746e04fe5a059df4ce7e7b391575"