S
S
Svyatoslav Khusamov2018-08-30 18:14:58
typescript
Svyatoslav Khusamov, 2018-08-30 18:14:58

How to force the compiler to recalculate paths (compilerOptions.paths) into relative ones?

I made a component library for React in TypeScript. I wrote the following in the tsconfig.json file:

{
  "compilerOptions": {
    ...
    "paths": {
      "@lib": ["src/lib"],
      "@lib/*": ["src/lib/*"]
    }

Now, instead, I write more concisely: During development, these paths are normally calculated. But after building and publishing the package in another project where this library is connected, an error appears:
import {} from '../../../from/field/ComboBox';
import {} from '@lib/from/field/ComboBox';
build/dist/lib/form/combo/ComboBox.d.ts
(3,40): Cannot find module '@lib/form/list/List'.

How can I make the compiler recalculate these paths to relative ones during assembly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Svyatoslav Khusamov, 2018-08-30
@khusamov

Possible solutions to the problem: goenning.net/2017/07/21/how-to-avoid-relative-path
...
last answer:
https://stackoverflow.com/questions/37606571/absol...
Homemade from chat (note that ts-simple-ast is used):
https://gist.github.com/rifler/e6123e90e172814fe23...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question