# gulp-ts-base-url

> Use Gulp to resolve Typescript baseUrl during compilation.

Latest version **1.0.0** (published 2023-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-ts-base-url
pnpm add gulp-ts-base-url
yarn add gulp-ts-base-url
bun add gulp-ts-base-url
```

## 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.0.0 |
| Published | 2023-05-05 |
| First published | 2023-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 28.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eprincev Egor |
| Maintainers | eprincev.egor |
| Keywords | gulpplugin, gulp, typescript, ts, resolve, relative, paths, baseurl |

## Links

- npm: https://www.npmjs.com/package/gulp-ts-base-url
- Repository: https://github.com/eprincev-egor/alias
- Homepage: https://github.com/eprincev-egor/alias#readme
- Issues: https://github.com/eprincev-egor/alias/issues
- npm.io page: https://npm.io/package/gulp-ts-base-url

## Dependencies (1)

- [typescript](https://npm.io/package/typescript.md) ^4.3.5

## 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.0.0 (latest) — 2023-05-05

## README

# gulp-ts-base-url

Resolve TypeScript import baseUrl defined in `tsconfig`.

## Install

`npm install --save-dev gulp-ts-bae-url`

## Information

Based on package https://github.com/gulp-plugin/alias

### Features

* Supports all import types: `import`, `require`, `await import()`
* Supports wild card aliases
* Supports non-relative import

## Usage

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

const { config } = typescript.createProject('tsconfig.json');

function build() {
  const compiled = src('./src/**/*.ts')
    .pipe(alias(config))
    // or .pipe(alias('tsconfig.json'))
    // or even .pipe(alias())
    .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": "./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

// non-relative import based on baseUrl
import B from 'component/Grid';
```

Output:

```typescript
import express from 'express';

import A from './file';

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

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