diff --git a/CHANGELOG.md b/CHANGELOG.md index 3976efccf..c9210dd18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.0.0 + +* [feat: Fixed issue with incorrect output path for declaration files](https://github.com/TypeStrong/ts-loader/pull/822) - thanks @JonWallsten! **BREAKING CHANGE** + ## 4.5.0 * [feat: Added support for TypeScript declaration map](https://github.com/TypeStrong/ts-loader/pull/821) - thanks @JonWallsten! diff --git a/package.json b/package.json index 7b325ba71..41b2bfaf9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "4.5.0", + "version": "5.0.0", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist/types/index.d.ts", diff --git a/src/after-compile.ts b/src/after-compile.ts index 5ba828dcb..105a31fce 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -251,7 +251,7 @@ function provideDeclarationFilesToWebpack( declarationFiles.forEach(declarationFile => { const assetPath = path.relative( - compilation.compiler.context, + compilation.compiler.outputPath, declarationFile.name ); compilation.assets[assetPath] = { diff --git a/src/interfaces.ts b/src/interfaces.ts index a66395fdf..a8283f84b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -149,6 +149,7 @@ export interface WebpackCompilation { export interface WebpackCompiler { isChild(): boolean; context: string; // a guess + outputPath: string; watchFileSystem: WebpackNodeWatchFileSystem; /** key is filepath and value is Date as a number */ fileTimestamps: Map; diff --git a/test/comparison-tests/declarationOutput/tsconfig.json b/test/comparison-tests/declarationOutput/tsconfig.json index 6c9058ec4..6a9e3a116 100644 --- a/test/comparison-tests/declarationOutput/tsconfig.json +++ b/test/comparison-tests/declarationOutput/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { - "declaration": true + "declaration": true, + "declarationDir": ".output" } } diff --git a/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/app.d.ts.map b/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/app.d.ts.map index 98087b66e..48bc3c227 100644 --- a/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/app.d.ts.map +++ b/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/app.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,GAAG,QAAQ,WAAW,CAAC,CAAC;AAElC,cAAM,IAAK,SAAQ,GAAG;IACrB,WAAW;CAGX;AAED,SAAS,IAAI,CAAC"} \ No newline at end of file +{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,GAAG,QAAQ,WAAW,CAAC,CAAC;AAElC,cAAM,IAAK,SAAQ,GAAG;IACrB,WAAW;CAGX;AAED,SAAS,IAAI,CAAC"} \ No newline at end of file diff --git a/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/output.txt b/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/output.txt index 311e5dc7d..eeeb27f95 100644 --- a/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/output.txt +++ b/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/output.txt @@ -1,8 +1,8 @@ Asset Size Chunks Chunk Names bundle.js 5.13 KiB main [emitted] main - app.d.ts.map 194 bytes [emitted] + app.d.ts.map 197 bytes [emitted] app.d.ts 143 bytes [emitted] -sub/dep.d.ts.map 142 bytes [emitted] +sub/dep.d.ts.map 152 bytes [emitted] sub/dep.d.ts 96 bytes [emitted] Entrypoint main = bundle.js [./app.ts] 910 bytes {main} [built] diff --git a/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/sub/dep.d.ts.map b/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/sub/dep.d.ts.map index 6d719d956..9da4dc7f3 100644 --- a/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/sub/dep.d.ts.map +++ b/test/comparison-tests/declarationOutputWithMaps/expectedOutput-3.0/sub/dep.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"dep.d.ts","sourceRoot":"","sources":["dep.ts"],"names":[],"mappings":"AACA,cAAM,IAAI;IACT,WAAW;CAGX;AAED,SAAS,IAAI,CAAC"} \ No newline at end of file +{"version":3,"file":"dep.d.ts","sourceRoot":"","sources":["../../sub/dep.ts"],"names":[],"mappings":"AACA,cAAM,IAAI;IACT,WAAW;CAGX;AAED,SAAS,IAAI,CAAC"} \ No newline at end of file diff --git a/test/comparison-tests/declarationOutputWithMaps/tsconfig.json b/test/comparison-tests/declarationOutputWithMaps/tsconfig.json index 2437beaef..0357b08dc 100644 --- a/test/comparison-tests/declarationOutputWithMaps/tsconfig.json +++ b/test/comparison-tests/declarationOutputWithMaps/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "declaration": true, - "declarationMap": true + "declarationMap": true, + "declarationDir": ".output" } }