Monday, 17 April 2017

Typescript doesn't resolve modules correctly after compiling to the js

I set the property paths in the tsconfig.json file, like:

"paths": {
  "*": [
    "*",
    "src/*",
    "node_modules/*"
  ],
  "src/*": [ "./src/*" ]
},

And it gets me to be able to take some module more easy: e.g.

- src
  |- moduleA
  |- utils
    |- moduleB

// moduleA
import { something } from 'utils/moduleB'

but after compile I get next path in the moduleB.js:

something = require('utils/moduleB')

instead of relative path:

something = require('./utils/moduleB')

It doesn't work under Node because Node module resolution system knows nothing about utils folder.

So, how can I force tsc to use relative paths here?



via yiooxir

No comments:

Post a Comment