npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

rollup-plugin-api-extractor

v0.2.5

Published

A rollupjs plugin for integrating with @microsoft/api-extractor

Readme

rollup-plugin-api-extractor

Build Status codecov

This is a rollup plugin to integrate @microsoft/api-extractor into the rollup build system.

Usage

Install the package and @microsoft/api-extractor with npm (or yarn):

npm

npm install --save-dev rollup-plugin-api-extractor @microsoft/api-extractor

yarn

yarn add --dev rollup-plugin-api-extractor @microsoft/api-extractor

Add to rollup config:

import typescript from "@rollup/plugin-typescript";
import { apiExtractor } from "rollup-plugin-api-extractor";

export default [
  {
    input: "src/index.ts",
    output: [(dir: "dist"), (format: "esm")],
    plugins: [typescript(), apiExtractor()],
  },
];

Configure for api-extractor

The below is based on the example at https://api-extractor.com/pages/setup/invoking/:

Add the typings or types field to package.json:

{
  // ...
  "types": "lib/index.d.ts"
  // ...
}

Make sure "declaration": true and "declarationMap": true are in set in your tsconfig.json.

Generate the api-extractor configuration:

npx

npx api-extractor init

or

yarn

yarn api-extractor init

Update the generated api-extractor.json so that mainEntryPointFilePath matches the typings/types field in package.json

"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",

If api-extractor.json is not in the config folder update the apiExtractor() in your rollup.config.js to reference it:

import typescript from "@rollup/plugin-typescript";
import apiExtractor from "rollup-plugin-api-extractor";

export default [
  {
    input: "src/index.ts",
    output: [(dir: "dist"), (format: "esm")],
    plugins: [
      typescript(),
      apiExtractor({
        configFile: "./api-extractor.json",
      }),
    ],
  },
];

Plugin Configuration Options

The plugin Options are as follows:

| Option | Default | Description | | ---------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | configFile | './config/api-extractor.json' | The path to the api extractor configuration file. | | configuration | | the configuration for @microsoft/api-extractor. If both configFile and this are specified, parameters specified here will override those in the configuration file. | | local | false | Indicates that API Extractor is running as part of a local build. Equates to --local in api-extractor run command line. | | verbose | false | Show additional informational messages in the output. Equates to --verbose in api-extractor run command line. | | diagnostics | false | Show diagnostic messages used for troubleshooting problems with API Extractor. Equates to --diagnostics in api-extractor run command line. | | typescriptFolder | | Used to override the typescript compiler folder for @microsoft/api-extractor. Equates to --typescript-compiler-folder in api-extractor run command line. |

configuration and configFile parameters

As mentioned above, the plugin can take the @microsoft/api-extractor configuration as part of the options for it. If no configFile is specified the below are the minimum configuration parameters currently require by @microsoft/api-extractor:

import typescript from "@rollup/plugin-typescript";
import apiExtractor from "rollup-plugin-api-extractor";

export default [
  {
    input: "src/index.ts",
    output: [(dir: "dist"), (format: "esm")],
    plugins: [
      typescript(),
      apiExtractor({
        configuration: {
          projectFolder: ".",
          compiler: {
            tsconfigFilePath: "<projectFolder>/tsconfig.json",
          },
        },
      }),
    ],
  },
];

If configFile and configuration are both specified, the configuration file is read with the configuration acting as an overlay or override of the parameters that are in the file.

Why?

While there are already rollup plugins for rolling up the type definitions in a package, @microsoft/api-extractor does more. In addition, @microsoft/api-extractor has the ability to "trim" the type definitions to excluded APIs not meant for external consumption.

Alternatives

License

This code is licensed under the MIT License.