jonkwheeler / tsconfig-replace-paths

Replace absolute paths to relative paths for package compilation
MIT License
72 stars 11 forks source link

Pass patterns with forward-slashes #34

Closed DiegoVictor closed 1 year ago

DiegoVictor commented 2 years ago

The globby library doesn't accept backward-slashes on sync function:

Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.

Ref: https://github.com/sindresorhus/globby#api

This is the reason to the path replacement doesn't work properly on some Windows consoles/terminals. Windows uses backward slashes:

D:\git\tsconfig-replace-paths\dist/**/*.{js,jsx,ts,tsx}

This PR makes sure to always pass a pattern with forward-slashes:

D:/git/tsconfig-replace-paths/dist/**/*.{js,jsx,ts,tsx}
Autofan1992 commented 1 year ago

@jonkwheeler please merge this pr. Everything works fine on mac os , but on windows it doesn’t work at all. Thank you!

DiegoVictor commented 1 year ago

@jonkwheeler please merge this pr. Everything works fine on mac os , but on windows it doesn’t work at all. Thank you!

@Autofan1992 I created a fork (actually a new library) with the fix and other stuff: https://github.com/DiegoVictor/tsc-path-replacer

jonkwheeler commented 1 year ago

Happy you found a work around. I just haven't had time to test this.

jonkwheeler commented 1 year ago

I just tested this and it failed on one of my repos. It said it replaced 0 paths... ?

$ tsc --project tsconfig.types.cjs.json && tsconfig-replace-paths --project tsconfig.types.cjs.json
Replaced 0 paths in 0 files
$ tsc --project tsconfig.types.esm.json && tsconfig-replace-paths --project tsconfig.types.esm.json
Replaced 0 paths in 0 files

I'll happily reopen if a different fix is presented.