-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ts-loader generating definition file in wrong directory #190
Comments
Same issue |
Actually even with 0.8.0 it outputs far more of the directory structure than I would expect. Instead of
I get:
Strangely though, this problem only happens if I specify files other than |
So I did some further testing. It turned out I can do this but I needed to create a In 0.8.2 this is definitely broken though, it expands the full original root path for each |
I have the same problem with |
Can confirm (since 0.8.2). This was reported on #186. |
Yep, seeing this too. Stuck on 0.8.1 for now (really wish I could comment package.json but oh well) |
I can confirm I'm seeing this issue on 0.8.2. The d.ts files are being generated in a full absolute on the file system, rather than the relative path in the project. Is there any ETA on a resolution? Expected:
Actual:
|
#238 is a duplicate issue that includes a minimal example demonstrating this bug |
Any workarounds? Maybe somehow explicitly set the path? |
Workaround for now is give path as Number of backslashes = directory depth from root (/) till your project |
That sounds terrible, but maybe we are getting close to a solution. If you On Sun, Sep 4, 2016, 16:25 Shubhendu Shekhar Singh notifications@github.com
|
+1 |
Fixed on 0.9.3 |
Same issue in 4.2.0 |
Same issue in 4.3.0 |
Would someone like to supply a minimal repro repo and investigate this? |
@johnnyreilly OK. I've created it. Here: https://github.com/gluons/ts-loader-declaration-issue Should I raise new issue? |
Thanks - it's fine to use this issue! Now, let's see how dedicated you are... Would you be up for doing some investigation? To give you a heads up, here's the pr that fixed the issue last time: https://github.com/TypeStrong/ts-loader/pull/307/files Looks like the important stuff was in the Of course that was a long time ago, the relevant code now seems to be in the Possibly worth investigating what Also worth checking: when did this functionality stop working? Which version of ts-loader first presents the problem? |
I don't know which version that this problem begin. How can I help you? Maybe I will help you when I'm free. |
Adding something like |
I think I have this same problem — I have reproduced it here: https://github.com/jamesots/ts-loader-test In my case, it seems to be because my tsconfig.json isn't in the root directory. In this simple test case I could move the tsconfig.json, but I can't in my real (much more complex) project. The problem appears to be in provideDeclarationFilesToWebpack() in after-compile.ts, where it uses path.relative() to compare the webpack context directory with the declaration file name. It should be using the typescript project directory instead. I'm not sure how to fix it though, without potentially breaking other things. |
Thanks for sharing the workaround @gluons!
My advice: get something that seems to work for you. Ignore failing tests and submit a PR. I'll take a look and advise. If it's promising I'll try and help you get it over the finish line |
Got the same issue with ts-loader 4.4.1. my tsconfig.json for webpack looks like this.
webpack.config.js
This will create following folder structure:
What worked for me now was to add compilerOptions to ts-loader options and set the outDir to the basename of my output directory ( /absolute/path/to/dist/umd -> umd )
|
I have the same problem. The path's base when generating declaration seems to be the outDir. But for the typescript compiler it's the project root. I can take a look at this and submit a PR if I find a solution. |
@johnnyreilly I've investigated
So, after If I set Maybe I should |
Hello, for me the issue seems to be back since 5.0.0. Versions 4.3.0 and 4.5.0 were fine. I made a minimal repo to reproduce the problem: Running "npm run build" will correctly place the .d.ts files in the dist folder since I'm using 4.5.0 in the example repo. However, if I run "npm i ts-loader@latest" (which is 5.3.0 at the time of posting this) and then build, it puts the d.ts files at the root of the project rather than inside the dist folder. |
Hey @tedchirvasiu I'm pretty sure the changed behaviour is intentional - see the details here: |
@tedchirvasiu It works as intended in From @JonWallsten in #882 :
|
@johnnyreilly @gluons Sorry, my bad, you are right. Added the outDir to the compilerOptions and it works as expected. module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
compilerOptions: {
outDir: './dist'
}
}
}
]
} Thank you! |
I am creating a new issue here as discussed in typescript Issue
I am using typescript version 1.9.0-dev.20160412 and ts-loader version 0.8.2 as below
My tsconfig.json is as below:
My project folder structure is as below:
I am trying to compile and generate .d.ts files inside the 'lib' dir but this creates the .d.ts file inside folder with parent attached to lib i.e
I was expecting it to be as :
dist dir above is given in the webpack.config.js as below:
Sample project with the above mentioned error Sample Project.
It works as expected with the version 0.8.0 of ts-loader
The text was updated successfully, but these errors were encountered: