#Problem with tsc compiled output when using path alias

5 messages · Page 1 of 1 (latest)

timid panther
#

I've been trying to setup path alias for our express app.
Everything works fine in dev mode, but not the compiled version (i'm using tsc).
It seems like tsc straight up just ignore all of the path alias after build.
I tried both tsconfig-paths and ts-alias, both didn't work.

hallow garden
#

!:paths%

tight basaltBOT
#
tjjfvi#0
`!t6:paths-are-not-magic`:

The paths and baseUrl compiler options don't cause any remapping of imports paths, they only inform TS of existing mappings, which you'll have to setup with some other tool.

baseUrl is a pretty well-supported option (e.g. using the NODE_PATH environment variable with node or resolve.modules with webpack).
paths can be trickier to setup, (especially with node see this for node), and you may find it to not be worth the effort.

hallow garden
#

tsc won't resolve path aliases. it assumes something else will.

hallow garden
#

please don't advertise jobs.