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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cds-plugin-typescript

v0.1.6

Published

A CDS build plugin for SAP CAP that compiles TypeScript sources to JavaScript as part of cds build.

Readme

cds-plugin-typescript

A CDS build plugin for SAP CAP that compiles TypeScript sources to JavaScript as part of cds build.

It is similar to cds-typer but focused exclusively on TypeScript compilation. It also supports resolving TypeScript path aliases via tsc-alias.

Prerequisites

  • Node.js >=22
  • npm >=10
  • @sap/cds >=8
  • typescript >=5
  • tsc-alias >=1 (optional — automatically detected and used if listed in your project's package.json)

Installation

npm install --save-dev cds-plugin-typescript

Usage

Once installed, the plugin is automatically discovered and activated — no manual registration needed. It's a cds-plugin and will be loaded by CAP automatically.

Simply run cds build and the plugin will:

  1. Detect your tsconfig file (see tsconfig resolution below)
  2. Compile TypeScript sources with tsc
  3. Resolve path aliases with tsc-alias (automatic — runs if tsc-alias is found in your project's dependencies or devDependencies)
  4. Remove .ts source files from the build output

Configuration

Zero configuration is required by default. Simply:

  1. Install the plugin (npm install --save-dev cds-plugin-typescript)
  2. Maintain a tsconfig file — the plugin automatically looks for tsconfig.cdsbuild.json, tsconfig.build.json, or tsconfig.json (first found wins)
  3. Run cds build

That's it — no package.json changes needed.

Custom tsConfig path

The cds.build.tasks configuration in package.json is only needed if you want to point the plugin at a tsconfig file with a non-standard name (i.e. something other than the three files listed above):

{
  "cds": {
    "build": {
      "tasks": [
        { "for": "nodejs" },
        {
          "for": "typescript",
          "options": {
            "tsConfig": "tsconfig.custom.json"
          }
        }
      ]
    }
  }
}

| Option | Type | Default | Description | | ---------- | -------- | ------- | -------------------------------------------------------------------------------------------------- | | tsConfig | string | — | Custom TypeScript config file path. When provided, this takes highest priority in the resolution order. |

tsconfig resolution

The plugin resolves the tsconfig file using the following priority order:

  1. Custom path via the tsConfig option (if provided in the build task configuration)
  2. tsconfig.cdsbuild.json — a CDS-build-specific config
  3. tsconfig.build.json — a general build-specific config
  4. tsconfig.json — the standard TypeScript config

The plugin uses the first file found in this order. This allows you to maintain separate TypeScript configurations for CDS builds, general builds, and development without conflicts.

The default/recommended tsconfig for the default CDS folder structure is:

{
  "compilerOptions": {
    "rootDir": "srv",
    "outDir": "gen/srv/srv",
    "declaration": true,
    "sourceMap": true,
    "removeComments": true
  },
  "include": [
    "srv/**/*"
  ]
}

The outDir in your tsconfig determines where compiled output lands — make sure it aligns with your CDS build target (default: gen).

Path aliases

If your project uses TypeScript path aliases (e.g. @/*src/*), simply add tsc-alias to your project's dependencies or devDependencies:

npm install --save-dev tsc-alias

The plugin automatically detects whether tsc-alias is listed in your package.json (under dependencies or devDependencies) and runs it after tsc to rewrite the aliases in the compiled JavaScript. No additional configuration is needed.

If tsc-alias is not listed in your package.json, the path alias resolution step is skipped entirely.

How it works

The plugin extends cds.build.Plugin and is registered under the task type typescript.

Build steps:

  1. Resolve the tsconfig path (priority: tsConfig option → tsconfig.cdsbuild.jsontsconfig.build.jsontsconfig.json)
  2. Run npx tsc -p <tsconfig> from the task source directory — logs: "Compiling TypeScript using <tsconfig>"
  3. If tsc-alias is detected in package.json: run npx tsc-alias -p <tsconfig> — logs: "Resolving path aliases"
  4. Delete all .ts files (excluding .d.ts) from the build output — logs: "Removing TypeScript sources"

Clean step:

cds build --clean removes all .js and .map files emitted by this plugin from the destination directory.

Related

License

MIT