# gulp-ts-alias-plus

> Use Gulp to resolve Typescript path aliases during compilation.

Latest version **1.1.0** (published 2020-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-ts-alias-plus
pnpm add gulp-ts-alias-plus
yarn add gulp-ts-alias-plus
bun add gulp-ts-alias-plus
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-09-23 |
| First published | 2020-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | David Katz |
| Maintainers | lixuan |
| Keywords | gulpplugin, gulp, typescript, ts, resolve, relative, paths |

## Links

- npm: https://www.npmjs.com/package/gulp-ts-alias-plus
- Repository: https://github.com/dhkatz/gulp-ts-alias
- Homepage: https://github.com/dhkatz/gulp-ts-alias#readme
- Issues: https://github.com/dhkatz/gulp-ts-alias/issues
- npm.io page: https://npm.io/package/gulp-ts-alias-plus

## Dependencies (3)

- [o-stream](https://npm.io/package/o-stream.md) ^0.2.2
- [string.prototype.matchall](https://npm.io/package/string.prototype.matchall.md) ^4.0.2
- [string.prototype.replaceall](https://npm.io/package/string.prototype.replaceall.md) ^1.0.3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2020-09-23

## README

# gulp-ts-alias-plus ![npm](https://img.shields.io/npm/v/gulp-ts-alias-status)

Forked of [gulp-ts-alias](https://github.com/dhkatz/gulp-ts-alias)

Support multiple imports on the same line.

## Install

``` sh
npm i -D gulp-ts-alias-plus

# yarn add -D gulp-ts-alias-plus
```

## Usage

```javascript
const typescript = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const alias = require('gulp-ts-alias');

const project = typescript.createProject('tsconfig.json');

function build() {
  const compiled = src('./src/**/*.ts')
    .pipe(alias({ configuration: project.config }))
    .pipe(sourcemaps.init())
    .pipe(project());

  return compiled.js
    .pipe(sourcemaps.write({ sourceRoot: file => path.relative(path.join(file.cwd, file.path), file.base) }))
    .pipe(dest('build/'))
}
```

## Example

The following configuration is common in `tsconfig` configuration files

```json
{
  "rootDir": "./src",
  "baseUrl": ".",
  "paths": {
    "@/*": ["src/*"],
  }
}
```

In practice, these path aliases are often used in this fashion

Input:

```typescript
import express from 'express';

import A from './file'; // Normal relative import

// Aliased import, resolves to some relative path to rootDir
import B from '@/components';
```

Output:

```typescript
import express from 'express';

import A from './file';

// gulp-ts-alias finds the correct relative path
// and replaces it before compilation
import B from '../../components';
```

---
_Source: https://npm.io/package/gulp-ts-alias-plus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
