JSPM

  • Created
  • Published
  • Downloads 268931
  • Score
    100M100P100Q169861F
  • License ISC

Transforms absolute imports to relative

Package Exports

  • typescript-transform-paths

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typescript-transform-paths) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

typescript-transform-paths

npm version Conventional Commits code style: prettier Built with Spacemacs

Transforms absolute imports to relative from paths in your tsconfig.json

Install

$ npm i -D typescript-transform-paths

Usage with ttypescript

Add it to plugins in your tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@utils/*": ["utils/*"]
    },
    "plugins": [{ "transform": "typescript-transform-paths" }]
  }
}

Example

// tsconfig.json
{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@utils/*": ["utils/*"]
    }
  }
}
// core/index.ts
import { sum } from "@utils/sum";

sum(2, 3);

Gets compiled to:

// core/index.js
var sum_1 = require("../utils/sum");
sum_1.sum(2, 3);

Contributing

If you have any question or idea of a feature create an issue in github or make an PR.