duffman/tspath

outDir should be independent of baseUrl

bekker opened this issue · 12 comments

Consider the following tsconfig.json.

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2016",
        "outDir": "./dist",
        "baseUrl": "./src",
        "paths": {
            "core/*": ["core/*"]
        }
    },
    "exclude": [
        "node_modules",
        "dist"
    ]
}

outDir should be independent of baseUrl, so that resulting output directory is projectRoot/dist, not projectRoot/src/dist.

AFAIK, current implementation searchs for projectRoot/src/dist and throw errors.

Hi bekker! Thanks for your feedback! You are absolutely correct! outDir should by no means have to reflect the dist dir! The reason for this to have happened is lack of testing by that I mean it have done what it´s supposed to in my projects :) I will definitely push a fix for this asap!

et commented

Hi @duffman, any update to this?

Same on my case. It tries to find dist inside src which is obviously wrong. It would be nice if the executable accepts parameters instead of asking runtime questions. This way the process can be automated. For example, it can be easily added as a command/task into the "scripts" section in package.json which is a common practice.

Excellent package! Once this issue is corrected, this should help me finalize a pretty intertwined Serverless deployment I've been trying to figure out for days. Glad I stumbled upon this :)

Looking forward to this fix!

I'm hitting this same issue.

ilDon commented

I'm hitting the same issue, for a different scenario.

My baseUrl points to the parent folder "../" (for various reasons), while the out dir points to the dist folder within the main project:

"outDir": "dist",
"baseUrl": "../",

Running tsc produces the correct output in the dist folder, but then tspath looks for the dist folder in the parent folder, e.g.:

tsc points to: ../parent-folder/project-folder/dist
tspath points to: ../parent-folder/dist
ilDon commented

I've created pull request #12 that fixes this issue :-)

Resolved in version 1.3.5

gsusI commented

Possibly back in 1.3.7?

Got

project
  \
    - tsconfig.json
    - package.json
    - src\        //  code
    - build\        //  created by tsc

In tsconfig.json:

    "outDir": "build",
    "baseUrl": "src",

I'm getting the following error:

fs.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '<path_to_project>\src\build'

I'm using Windows with Node 10

gsusI commented

Ended up migrating to https://github.com/joonhocho/tscpaths, syntax is very clear and works out-of-the-box.