• Stars
    star
    804
  • Rank 56,681 (Top 2 %)
  • Language
    TypeScript
  • License
    GNU Lesser Genera...
  • Created about 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A rollup plugin to generate .d.ts rollup files for your typescript project

rollup-plugin-dts

Build Status Coverage Status

This is a plugin that lets you roll-up your .d.ts definition files.

Usage

Install the package from npm:

$ npm install --save-dev rollup-plugin-dts

Add it to your rollup.config.js:

import { dts } from "rollup-plugin-dts";

const config = [
  // …
  {
    input: "./my-input/index.d.ts",
    output: [{ file: "dist/my-library.d.ts", format: "es" }],
    plugins: [dts()],
  },
];

export default config;

NOTE A default import of the plugin using import dts from "rollup-plugin-dts"; is still supported for existing implementations of this package. However, a named import is suggested to avoid the error [!] TypeError: dts is not a function12 in certain rollup config file implementations.

And then instruct typescript where to find your definitions inside your package.json:

  "types": "dist/my-library.d.ts",

NOTE that the plugin will automatically mark any external library (@types for example) as external, so those will be excluded from bundling.

Maintenance Mode

This project is in maintenance mode. That means there will be no more active feature development. There will still be occasional releases to maintain compatibility with future TypeScript releases. Pull Requests are always welcome, however reaction time on both Issues and PRs can be slow.

What to expect

While this plugin is fairly complete, it does not support all imaginable use-cases. In particular, the plugin works best with already existing .d.ts files generated by the typescript compiler from idiomatic code.

Working with .ts(x) or even .js(x) (when setting allowJs: true) does work, but is not recommended.

The plugin does its own import resolution through the typescript compiler, and usage together with other resolution plugins, such as node-resolve can lead to errors and is not recommended.

All external dependencies from node_modules are automatically excluded from bundling. This can be overridden using the respectExternal setting, but it is generally not recommended. While rollup of external @types generally works, it is not recommended.

Why?

Well, ideally TypeScript should just do all this itself, and it even has a proposal to do that. But there hasn’t been any progress in ~3 years.

Some projects, like rollup itself go the route of completely separating their public interfaces in a separate file.

Alternatives

See some discussions about some of these projects and their tradeoffs.

How does it work

License

The code is licensed under the copyleft LGPL-3.0. I have no intention to license this under any non-copyleft license.

Footnotes

  1. StackOverflow thread of issue ↩

  2. Github issue ↩

More Repositories

1

rust-cache

A GitHub Action that implements smart caching for rust/cargo projects
TypeScript
1,275
star
2

esgraph

creates a control flow graph from an esprima abstract syntax tree
JavaScript
168
star
3

diff

implementation of myers diff algorithm
JavaScript
82
star
4

virtualdom

tools to work with a virtual dom
JavaScript
31
star
5

jade-virtualdom

compile jade templates to virtualdom
JavaScript
21
star
6

proxy

Small shim providing `new Proxy(target, handler)`
JavaScript
14
star
7

walkes

very simple walker for estree AST
JavaScript
12
star
8

scroll-beyond

Very simple gedit plugin to scroll past the end of documents
Python
12
star
9

cow

copy on write deep, cyclic js objects
JavaScript
9
star
10

analyses

basic data flow analyses framework based on esprima
JavaScript
9
star
11

fucov

A GitHub Action that does single-action code coverage generation.
TypeScript
8
star
12

scrollbars

An efficient overflow area with custom scrollbars
JavaScript
8
star
13

wamp1

Very simple WAMP v1 implementation
JavaScript
7
star
14

perf-cpuprofile

Converts linux `perf` tool output to .cpuprofile files readable by chromiums devtools
JavaScript
7
star
15

tern_for_gedit

This is a simple gedit plugin that provides code completion results based on tern
Python
6
star
16

next-monorepo

reproduction for some problems with monorepos
TypeScript
4
star
17

analyses-old

Static Analysis based on Esprima
JavaScript
3
star
18

inferences

type inference for js
JavaScript
3
star
19

rust-maintain

A GitHub Action to do crate maintenance
Rust
3
star
20

stream-utils

some utilities for whatwg streams
JavaScript
2
star
21

hexite

TypeScript
2
star
22

psy

Rust
2
star
23

yavd

yet another virtual dom library
JavaScript
2
star
24

codingcontest-2018-11-16

https://register.codingcontest.org/listing/6-2018-11-16
TypeScript
2
star
25

model

transparent ES5 models
JavaScript
2
star
26

fondoeh

Rust
2
star
27

channel-utils

1
star
28

motorina

too early to reveal :-)
TypeScript
1
star
29

fast-babel-register

Temporary fork until @babel/register upstream is fast enough
JavaScript
1
star
30

model-cast

Automatically cast properties for Swatinem/model
JavaScript
1
star
31

dotfiles

Vim Script
1
star
32

style-canvas

Component to apply CSS styles to a canvas
JavaScript
1
star
33

pinch

experiments with csp
JavaScript
1
star
34

normalize-serve-jade

Opinionated jade server for frontend development workflow using Normalize.IO
JavaScript
1
star
35

depstalk

Scrape the dependents of a GitHub repository
Rust
1
star
36

component-istanbul

instruments component files with istanbul coverage
JavaScript
1
star
37

observ-delegate

A observable value representation that delegates to a different observable value
JavaScript
1
star
38

crid

Crid - The cryptographic ID serializer
Rust
1
star
39

websocket-buffering

small wrapper around websocket that does message buffering and reconnects
JavaScript
1
star
40

component-linknpm

Link downloaded components into node_modules
JavaScript
1
star
41

co-promisify

Seems like I have duplicated this. So just use
JavaScript
1
star