justkey007 / tsc-alias

Replace alias paths with relative paths after typescript compilation
MIT License
902 stars 62 forks source link

How does this, uh, work? #139

Closed matthew-dean closed 1 year ago

matthew-dean commented 2 years ago

I have definition files generated by tsc. I'm trying to use tsc-alias remap paths in the exported types to relative paths, because otherwise other projects have no idea what those paths mean.

However, tsc-alias does nothing. npx tsc-alias does nothing npx tsc-alias -p tsconfig.json does nothing.

I tried changing settings in package.json, and I set verbose to true and silent to false, and STILL, I would have expected some kind of log message, but this package does absolutely nothing. No output, no errors, no status, nothing.

matthew-dean commented 2 years ago

Okay! I found something that said to try --debug

Now I'm getting output, and it it looks like it's traversing files, but it looks at module references like @/theme/nativeTheme and does not replace it with its relative equivalent.

raouldeheer commented 2 years ago

@matthew-dean tsc-alias first scans for files, after that it wil try to replace those files. It wil scan every file for import statements and try to replace the aliases, but it wil only replace the aliases of which the destination file exists.

but it looks at module references like @/theme/nativeTheme and does not replace it with its relative equivalent.

Does the destination file exist?

willyboy commented 2 years ago

Similar issue. Let's say I have alias:

"@abc/bcd": ["libs/abc/index.ts"]

It recognizes the alias (after putting in some logs) but doesn't do the replacement. Maybe it's because I don't use outDir? I compile the files in place.

raouldeheer commented 2 years ago

@willyboy tsc-alias needs an outDir. The outDir is used to look if the resolved alias exists on the filesystem, if it isn't found tsc-alias won't replace the alias. Could you provide a debug log of the issue?

raouldeheer commented 1 year ago

@justkey007 This issue could be marked as stale