Skip to content

Commit 1e936b8

Browse files
authored
fix: handle tsconfig with out paths (#41)
* test: tsconfig without paths should work * fix: handle tsconfig with out paths * ci: fix appveyor
1 parent 8807465 commit 1e936b8

File tree

15 files changed

+74
-27
lines changed

15 files changed

+74
-27
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
"prepare": "npm run build",
3939
"release": "standard-version",
4040
"pretest": "npm run build && rm -rf tests/__result",
41-
"test-original": "tsc -p tests/__fixtures/tsconfig.json --outDir tests/__result/original",
42-
"test-generated": "ttsc -p tests/__fixtures/tsconfig.json --outDir tests/__result/generated",
43-
"test": "npm run test-original && npm run test-generated && jest"
41+
"test": "tsc -p tests/__fixtures/with-path/tsconfig.json --outDir tests/__result/with-path/original && ttsc -p tests/__fixtures/with-path/tsconfig.json --outDir tests/__result/with-path/generated && tsc -p tests/__fixtures/without-path/tsconfig.json --outDir tests/__result/without-path/original && ttsc -p tests/__fixtures/without-path/tsconfig.json --outDir tests/__result/without-path/generated && jest"
4442
},
4543
"jest": {
4644
"preset": "ts-jest",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { dirname, relative, resolve, extname } from "path";
22
import ts from "typescript";
33
import slash from "slash";
44
import { parse } from "url";
5-
import { existsSync, statSync } from "fs";
5+
import { existsSync } from "fs";
66

77
const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
88
sourceFile: ts.SourceFile
@@ -29,7 +29,7 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
2929

3030
const { isDeclarationFile } = sourceFile;
3131

32-
const { baseUrl = "", paths = {} } = compilerOptions;
32+
const { baseUrl = "", paths = { "*": ["*"] } } = compilerOptions;
3333

3434
const binds = Object.keys(paths)
3535
.filter(key => paths[key].length)

tests/__fixtures/tsconfig.json renamed to tests/__fixtures/with-path/tsconfig.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"target": "es5",
44
"module": "commonjs",
55

6-
"strict": true,
7-
86
"declaration": true,
97
"baseUrl": "./",
108
"paths": {
@@ -16,8 +14,8 @@
1614
"esModuleInterop": true,
1715

1816
"plugins": [
19-
{ "transform": "../../" },
20-
{ "transform": "../../", "afterDeclarations": true }
17+
{ "transform": "../../../" },
18+
{ "transform": "../../../", "afterDeclarations": true }
2119
]
2220
}
2321
}

0 commit comments

Comments
 (0)