New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@halkeye/tscpaths

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@halkeye/tscpaths

Replace absolute paths to relative paths after typescript compilation

latest
Source
npmnpm
Version
0.0.9
Version published
Maintainers
1
Created
Source

tscpaths

Replace absolute paths to relative paths after typescript compilation (tsc) during compile-time.

npm version Dependency Status License

Comparison to tsconfig-paths

+ Compile time (no runtime dependencies)

Getting Started

First, install tscpaths as devDependency using npm or yarn.

npm install --save-dev tscpaths
# or
yarn add -D tscpaths

Add it to your build scripts in package.json

"scripts": {
  "build": "tsc --project tsconfig.json && tscpaths --project tsconfig.json",
}

Building only the types

You can also setup a seperate tsconfig file just for types like tsconfig.types.json if you are also compiling with Babel.

// tsconfig.types.json
{
  "extends": "./tsconfig",
  "compilerOptions": {
    "module": "amd",
    "outDir": "dist",
    "rootDir": "./src",
    "declaration": true,
    "declarationMap": false,
    "isolatedModules": false,
    "noEmit": false,
    "allowJs": false,
    "emitDeclarationOnly": true
  },
  "exclude": ["**/*.test.ts"]
}

And then target that

"scripts": {
  "build:types": "tsc --project tsconfig.types.json && tscpaths -project tsconfig.types.json",
}

Your final build script might look like

"scripts": {
  "build": "yarn build:commonjs && yarn build:types",
}

Options

flagdescription
-p --projectproject configuration file (tsconfig.json)
-s --srcsource code root directory (overrides the tsconfig provided)
-o --outoutput directory of transpiled code (tsc --outDir) (overrides the tsconfig provided)
-v --verboseconsole.log all the events

Disclaimer

This is not a mature project yet. Pull Requests are welcome!

It works for my setup so far.

It may not work correctly if your setup is too complicated, so please do some testing before pushing it to production!!!

Changelog

You need to provide -s (--src) and -o (--out), because it's hard to predict source and output paths based on tsconfig.json.

I've tried a little and failed. :(

The above is no longer neccesary <-- got you fam: @jonkwheeler

Keywords

typescript

FAQs

Package last updated on 10 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts