#Unwieldy import from referenced module

12 messages · Page 1 of 1 (latest)

sand fiber
#

My tsconfig.json has the following reference:

"references": [
  {
    "path": "../serviceLib",
  }
]

however if I want to use anything from this ref, I need to use an import like

import { Callable } from "../../serviceLib/dist/src/serviceHandler.js";

This format is confusing, and unwieldy to work with. Is this the intended import structure? Is there an easier way to do this? The dream would be to be able to use it like a node module, so I could just use

import { Callable } from "serviceLib";
#

Layout of my project:

sand fiber
#

It also is not giving me automatic import support, and when I start typing it dosn't show that its an importable value

sand fiber
#

For now, I am resorting to using the typescript-transform-paths transformer

#

which works well enough, but id rather do it stock

fossil comet
#

@sand fiber do you have a exports or main property set in the serviceLib package.json?

sand fiber
fossil comet
#

I have found that to be easier to do than using the references and paths settings in the tsconfig for this. You can then add the serviceLib as a dep of service and ts should resolve it

#

It also helps to set the types field in the serviceLib as well

#

@sand fiber is serviceLib js or ts?

sand fiber
#

TS