duffman / tspath

TypeScript path alias resolver
GNU Lesser General Public License v2.1
151 stars 33 forks source link

Output dir should relative to root, not source dir #14

Closed ghost closed 6 years ago

ghost commented 6 years ago

There's an issue here and next line: https://github.com/duffman/tspath/blob/59dc5655ca954cfbc4e9c26f8af9ba2889efd404/src/parser-engine.ts#L125

The outDir parameter should be added relative to the original location of tsconfig.json, not the baseUrl, which is used for module resolution.

The current version works accidentally for "baseUrl": "./", but changing it to e.g. "baseUrl": "./src" cause the following exception: Error: ENOENT: no such file or directory, scandir 'F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\src\dist\out-tsc' at Object.readdirSync (fs.js:759:3) at ParserEngine.walkSync (F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\node_modules\tspath\src\parser-engine.js:260:24) at ParserEngine.execute (F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\node_modules\tspath\src\parser-engine.js:101:14) at TSPath.processPath (F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\node_modules\tspath\src\tspath.js:39:25) at Confirm.callback (F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\node_modules\tspath\src\tspath.js:29:27) at Confirm.<anonymous> (F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\node_modules\prompt-base\index.js:625:10) at runCallback (timers.js:696:18) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5)

while the output path here is still F:\Repos\magiczny-miecz\MagicSword.Core\MagicSword.Core.Logic\ClientApp\dist\out-tsc

ghost commented 6 years ago

Ups, I see there's a PR already pending, please add it and release a new version - your package is cool but this bug is a blocker.

nilswx commented 6 years ago

Still broken and PR still pending. As @pgorczynski-df said: it doesn't work when you have a 'src' directory. That's unfortunate. 'Fortunately' enough, it 'accidentally works' without.

I ended up going with tsconfig-paths instead: https://github.com/dividab/tsconfig-paths. By adding a node require hook at runtime it gives you a way out of path hell as well, without needing to post-process your files. 🙂

ghost commented 6 years ago

@nilswxa FYI I ended up using https://www.npmjs.com/package/module-alias - did the job as well :)

duffman commented 6 years ago

If anyone of you can reproduce this bug in the current version, please let me know how you did it

tors 20 sep. 2018 kl. 09:23 skrev Paweł Gorczyński <notifications@github.com

:

@nilswxa https://github.com/nilswxa FYI I ended up using https://www.npmjs.com/package/module-alias - did the job as well :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/duffman/tspath/issues/14#issuecomment-423070079, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAy_wfzrgY6pUyAaeLrzcjdurQra70_ks5uc0KPgaJpZM4V_inT .