Skip to content

Reduce number of d.ts files and types published in packages #1121

Description

@mjbvz

Problem

The published npm package for vscode-languageclient currently includes a d.ts file for every .js file under lib:

Screen Shot 2022-11-10 at 4 34 13 PM

This is problematic for two reasons:

  • It bloats the package size. All the d.ts files in vscode-languageclient take up 300KB or so

  • We are likely publishing interfaces and types that are not meant to be exposed externally. For example, there are files like utils/async.d.ts.

Proposed fix

To fix this, I suggest adopting a tool such as api extractor. This lets you bundle all the types for a project into a single d.ts file. You can also control which types are exposed and which ones stay internal

I adopted this for the markdown language service: https://github.com/microsoft/vscode-markdown-languageservice/blob/main/api-extractor.json

This helped me make sure I only exposed a well defined API to library consumers

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions