Skip to content

Commit

Permalink
feat: reduce build time (VF-2968) (#208)
Browse files Browse the repository at this point in the history
<!-- You can erase any parts of this template not applicable to your Pull Request. -->

**Fixes or implements VF-2968**

### Brief description. What is this change?

- fo not check the `.d.ts` files via `skipLibCheck`
- remove built-in types (node, mocha, etc) definitions via `"types": []`
- include only used googleapis types
- build metrics package into commonjs and esm

```logs
lerna success run Ran npm script 'build' in 10 packages in 29.3s:
lerna success - @voiceflow/alexa-types
lerna success - @voiceflow/api-sdk
lerna success - @voiceflow/base-types
lerna success - @voiceflow/chat-types
lerna success - @voiceflow/common
lerna success - @voiceflow/google-dfes-types
lerna success - @voiceflow/google-types
lerna success - @voiceflow/metrics
lerna success - @voiceflow/voice-types
lerna success - @voiceflow/voiceflow-types
✨  Done in 29.94s.
```

vs 

```
lerna success run Ran npm script 'build' in 10 packages in 88.5s:
lerna success - @voiceflow/alexa-types
lerna success - @voiceflow/api-sdk
lerna success - @voiceflow/base-types
lerna success - @voiceflow/chat-types
lerna success - @voiceflow/common
lerna success - @voiceflow/google-dfes-types
lerna success - @voiceflow/google-types
lerna success - @voiceflow/metrics
lerna success - @voiceflow/voice-types
lerna success - @voiceflow/voiceflow-types
✨  Done in 89.12s.
```
  • Loading branch information
z4o4z committed Mar 1, 2022
1 parent 6a16cc4 commit aa2a41c
Show file tree
Hide file tree
Showing 26 changed files with 752 additions and 733 deletions.
15 changes: 6 additions & 9 deletions packages/alexa-types/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"baseUrl": ".",
"rootDir": "src",
"outDir": "build/common",
"paths": {
"@alexa-types/*": [
"src/*"
]
"@alexa-types/*": ["src/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
]
],
"traceResolution": false,
"skipLibCheck": true,
"types": []
},
"include": [
"src/**/*",
"typings/**/*"
]
"include": ["src", "typings"]
}
55 changes: 19 additions & 36 deletions packages/alexa-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
{
"extends": "@voiceflow/tsconfig",
"compilerOptions": {
"baseUrl": "..",
"lib": ["es2020"],
"strict": true,
"baseUrl": ".",
"sourceMap": false,
"paths": {
"@voiceflow/common": [
"common/src"
],
"@alexa-types/*": ["src/*"],

"@voiceflow/common": ["../common/src"],
"@voiceflow/base-types": ["../base-types/src"],
"@voiceflow/voice-types": ["../voice-types/src"],
"@voiceflow/voiceflow-types": ["../voiceflow-types/src"],

// only used to fix intra-monorepo resolution
"@common/*": [
"common/src/*"
],
"@voiceflow/base-types": [
"base-types/src"
],
// only used to fix intra-monorepo resolution
"@base-types/*": [
"base-types/src/*"
],
"@voiceflow/voice-types": [
"voice-types/src"
],
// only used to fix intra-monorepo resolution
"@voice-types/*": [
"voice-types/src/*"
],
"@voiceflow/voiceflow-types": [
"voiceflow-types/src"
],
// only used to fix intra-monorepo resolution
"@voiceflow-types/*": [
"voiceflow-types/src/*"
],
"@alexa-types/*": [
"alexa-types/src/*"
]
}
"@common/*": ["../common/src/*"],
"@base-types/*": ["../base-types/src/*"],
"@voice-types/*": ["../voice-types/src/*"],
"@voiceflow-types/*": ["../voiceflow-types/src/*"]
},
"types": ["mocha"]
},
"exclude": [
"node_modules/**/*",
"build/**/*"
]
"include": ["src", "tests", "typings"],
"exclude": ["**/node_modules", "**/.*/"]
}
15 changes: 6 additions & 9 deletions packages/api-sdk/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"baseUrl": ".",
"rootDir": "src",
"outDir": "build/common",
"paths": {
"@api-sdk/*": [
"src/*"
]
"@api-sdk/*": ["src/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
]
],
"traceResolution": false,
"skipLibCheck": true,
"types": []
},
"include": [
"src/**/*",
"typings/**/*"
]
"include": ["src", "typings"]
}
33 changes: 14 additions & 19 deletions packages/api-sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{
"extends": "@voiceflow/tsconfig",
"compilerOptions": {
"baseUrl": "..",
"lib": ["es2020"],
"strict": true,
"baseUrl": ".",
"sourceMap": false,
"paths": {
"@api-sdk/*": ["src/*"],

"@voiceflow/base-types": ["../base-types/src"],

// only used to fix intra-monorepo resolution
"@common/*": [
"common/src/*"
],
"@voiceflow/base-types": [
"base-types/src"
],
// only used to fix intra-monorepo resolution
"@base-types/*": [
"base-types/src/*"
],
"@api-sdk/*": [
"api-sdk/src/*"
]
}
"@common/*": ["../common/src/*"],
"@base-types/*": ["../base-types/src/*"]
},
"types": ["mocha"]
},
"exclude": [
"node_modules/**/*",
"build/**/*"
]
"include": ["src", "tests", "typings"],
"exclude": ["**/node_modules", "**/.*/"]
}
15 changes: 6 additions & 9 deletions packages/base-types/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"baseUrl": ".",
"rootDir": "src",
"outDir": "build/common",
"paths": {
"@base-types/*": [
"src/*"
]
"@base-types/*": ["src/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
]
],
"traceResolution": false,
"skipLibCheck": true,
"types": []
},
"include": [
"src/**/*",
"typings/**/*"
]
"include": ["src", "typings"]
}
28 changes: 13 additions & 15 deletions packages/base-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
{
"extends": "@voiceflow/tsconfig",
"compilerOptions": {
"baseUrl": "..",
"lib": ["es2020"],
"strict": true,
"baseUrl": ".",
"sourceMap": false,
"paths": {
"@voiceflow/common": [
"common/src"
],
"@base-types/*": ["src/*"],

"@voiceflow/common": ["../common/src"],

// only used to fix intra-monorepo resolution
"@common/*": [
"common/src/*"
],
"@base-types/*": [
"base-types/src/*"
]
}
"@common/*": ["../common/src/*"]
},
"types": ["mocha"]
},
"exclude": [
"node_modules/**/*",
"build/**/*"
]
"include": ["src", "tests", "typings"],
"exclude": ["**/node_modules", "**/.*/"]
}
15 changes: 6 additions & 9 deletions packages/chat-types/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"baseUrl": ".",
"rootDir": "src",
"outDir": "build/common",
"paths": {
"@chat-types/*": [
"src/*"
]
"@chat-types/*": ["src/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
]
],
"traceResolution": false,
"skipLibCheck": true,
"types": []
},
"include": [
"src/**/*",
"typings/**/*"
]
"include": ["src", "typings"]
}
33 changes: 14 additions & 19 deletions packages/chat-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{
"extends": "@voiceflow/tsconfig",
"compilerOptions": {
"baseUrl": "..",
"lib": ["es2020"],
"strict": true,
"baseUrl": ".",
"sourceMap": false,
"paths": {
"@chat-types/*": ["src/*"],

"@voiceflow/base-types": ["../base-types/src"],

// only used to fix intra-monorepo resolution
"@common/*": [
"common/src/*"
],
"@voiceflow/base-types": [
"base-types/src"
],
// only used to fix intra-monorepo resolution
"@base-types/*": [
"base-types/src/*"
],
"@chat-types/*": [
"chat-types/src/*"
]
}
"@common/*": ["../common/src/*"],
"@base-types/*": ["../base-types/src/*"]
},
"types": ["mocha"]
},
"exclude": [
"node_modules/**/*",
"build/**/*"
]
"include": ["src", "tests", "typings"],
"exclude": ["**/node_modules", "**/.*/"]
}
6 changes: 4 additions & 2 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export type WithRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K

export type Writeable<T> = { -readonly [P in keyof T]: T[P] };

export type NullableRecord<T extends object> = { [K in keyof T]: Nullable<T[K]> };
export type PartialRecord<K extends PropertyKey, T> = Partial<Record<K, T>>;

export type NonNullishRecord<T extends object> = Required<{ [K in keyof T]: NonNullable<T[K]> }>;
export type NullableRecord<T> = { [K in keyof T]: Nullable<T[K]> };

export type NonNullishRecord<T> = Required<{ [K in keyof T]: NonNullable<T[K]> }>;

export type Struct = Record<string, unknown>;
export type AnyRecord = Record<string, any>;
Expand Down
6 changes: 0 additions & 6 deletions packages/common/tests/tsconfig.json

This file was deleted.

10 changes: 5 additions & 5 deletions packages/common/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
{
"transform": "@zerollup/ts-transform-paths"
}
]
],
"traceResolution": false,
"skipLibCheck": true,
"types": []
},
"include": [
"src/**/*",
"typings/**/*"
]
"include": ["src", "typings"]
}
19 changes: 8 additions & 11 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"extends": "@voiceflow/tsconfig",
"compilerOptions": {
"lib": [
"es2020"
],
"lib": ["es2020"],
"strict": true,
"baseUrl": ".",
"sourceMap": false,
"paths": {
"@common/*": [
"src/*"
]
}
"@common/*": ["src/*"]
},
"types": ["mocha"]
},
"exclude": [
"node_modules/**/*",
"build/**/*"
]
"include": ["src", "tests", "typings"],
"exclude": ["**/node_modules", "**/.*/"]
}
4 changes: 3 additions & 1 deletion packages/google-dfes-types/src/constants/locales.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PartialRecord } from '@voiceflow/common';

export enum Language {
BN = 'bn',
DA = 'da',
Expand Down Expand Up @@ -207,7 +209,7 @@ export enum VoiceLanguageCode {
DA_DK = 'da-DK',
}

export const LocaleToVoiceLanguageCode: { [keyof in Locale]?: VoiceLanguageCode } = {
export const LocaleToVoiceLanguageCode: PartialRecord<Locale, VoiceLanguageCode> = {
[Locale.ZH_HK]: VoiceLanguageCode.YUE_HK,
[Locale.ZH_CN]: VoiceLanguageCode.CMN_CN,
[Locale.DA_DK]: VoiceLanguageCode.DA_DK,
Expand Down
Loading

0 comments on commit aa2a41c

Please sign in to comment.