gulp-plugin / alias

Resolve TypeScript import aliases and paths.
MIT License
20 stars 11 forks source link

Plugin doesn't recognize paths from extended configs. #251

Closed juraj98 closed 1 month ago

juraj98 commented 3 years ago

Summary

Gulp build is failing with Unable to find the "paths" property in the supplied configuration! error, if configuration doesn't set compilerOptions.paths, but instead extends another configuration using extends property.

Example

├── lib
│   └── // ts-files
├── src
│   └── // ts-files
├── base.tsconfig.json
├── tsconfig.json
└── gulpfile.js
// tsconfig.json
{
  "extends": "./base.tsconfig.json"
}
// base.tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "~/*": ["./lib/*"]
    }
  }
}
// gulpfile.js
const { src, dest } = require("gulp");
const typescript = require('gulp-typescript');
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(project());

  return compiled.js
    .pipe(dest('build/'))
}
dhkatz commented 3 years ago

Not sure if you still need this working, but if so can you check if it works now by passing in the path to the config instead?

Internally I use TypeScript own config parsing which should automatically handle the "extends" key.

daolou commented 2 years ago

meet the same problem

juraj98 commented 1 month ago

It's been almost 4 years. Closing this issue