Skip to content

@types included in dependencies #392

@niksoper

Description

@niksoper

Environment details

  • OS: Mac Mojave
  • Node.js version: 8.9.1 | 8.15.0 | 10.14.0
  • npm version: 5.5.1 | 6.4.1
  • @google-cloud/common version: 0.31.1

Steps to reproduce

  1. Create empty npm package:npm init
  2. Add @google-cloud/common as a dependency: yarn add @google-cloud/common@0.31.1

We now have this package.json:

{
  "name": "temp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@google-cloud/common": "0.31.1"
  }
}
  1. List all TypeScript typings from dependencies: ls node_modules/@types:
caseless     duplexify    form-data    node         request      tough-cookie
  1. Check why we have these:
yarn why @types/request

yarn why v1.13.0
[1/4] 🤔  Why do we have the module "@types/request"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@types/request@2.48.1"
info Reasons this module exists
   - "@google-cloud#common" depends on it
   - Hoisted from "@google-cloud#common#@types#request"
info Disk size without dependencies: "28KB"
info Disk size with unique dependencies: "796KB"
info Disk size with transitive dependencies: "796KB"
info Number of shared dependencies: 4
✨  Done in 0.11s.
yarn why @types/duplexify

yarn why v1.13.0
[1/4] 🤔  Why do we have the module "@types/duplexify"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@types/duplexify@3.6.0"
info Reasons this module exists
   - "@google-cloud#common" depends on it
   - Hoisted from "@google-cloud#common#@types#duplexify"
info Disk size without dependencies: "16KB"
info Disk size with unique dependencies: "732KB"
info Disk size with transitive dependencies: "732KB"
info Number of shared dependencies: 1
✨  Done in 0.11s.

This adds 100's of KB of dependencies which could be avoided ifthe @types were in devDependencies instead of dependencies.

This is significant if you're using Cloud Functions because it will impact cold start times.

Metadata

Metadata

Labels

type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions