googleapis / googleapis/google-api-nodejs-client

TypeScript typings cause very high memory usage in tsc

Open
#2,187 15 comments 33 reactions 1 assignee Claimed by @bcoe View on GitHub
type: feature request
Dominant language
TypeScript
Stars
12.2k
Forks
2k
Avg merge
1d 9h
Merged PRs (30d)
24

Description

When importing `googleapis` within a TypeScript project, `tsc` takes up a large amount of memory (500 MB+). This appears to be the case because when `googleapis` is imported, it imports the type definition files for every single API that Google has, even if only a single API (e.g. `drive_v3`) is required.

#### Environment details

- OS: Ubuntu 20.04 LTS
- Node.js version: 10.20.1 (LTS)
- npm version: N/A (We don't use npm instally, but we use yarn v1.22.4)
- `googleapis` version: 51.0.0
- `typescript` version: 3.8.3

#### Steps to reproduce

Please see reproduction repository here: https://github.com/yjwong/tsc-googleapis-memory-usage

Essentially, even just a simple:

```typescript
import { google } from 'googleapis';
```

Will result in high memory usage from `tsc`.

There is also a related StackOverflow question:
https://stackoverflow.com/questions/56599477/typescript-googleapis-surge-in-memory-used

#### Workaround

Import the APIs individually, like so (example is Google Drive SDK v3):

```typescript
import { drive_v3 } from 'googleapis/build/src/apis/drive/v3';
import { AuthPlus } from 'googleapis-common/build/src/authplus';
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.