Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit 71d01b1

Browse files
committed
fix: proper initial fileNames injection, refs #205
1 parent b18ab9a commit 71d01b1

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"watch:ts": "npm run build:ts -- --watch --diagnostics",
1111
"watch:babel": "babel dist --watch --out-dir dist.babel",
1212
"prebuild": "npm run lint",
13-
"build": "npm run build:ts",
13+
"build": "npm run build:ts && npm run build:tests && npm run build:babel",
1414
"build:ts": "tsc -p src --pretty",
15+
"build:tests": "cd src/test && tsc --pretty",
1516
"build:babel": "babel dist --out-dir dist.babel",
1617
"lint": "tslint src/*.ts",
1718
"release": "standard-version"

src/defines.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference path='../node_modules/typescript/lib/typescriptServices.d.ts' />
2+
/// <reference path='../typings/tsd.d.ts' />

src/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/// <reference path='../node_modules/typescript/lib/typescriptServices.d.ts' />
2-
/// <reference path="./defines.d.ts"/>
3-
/// <reference path='../typings/tsd.d.ts' />
1+
/// <reference path="./defines.d.ts" />
42

53
import * as _ from 'lodash';
64
import * as path from 'path';
@@ -201,6 +199,7 @@ function transform(webpack: IWebPack, instance: ICompilerInstance, fileName: str
201199

202200
function invokeKnownFilesOneTime(instance: ICompilerInstance) {
203201
if (instance.loaderConfig.externals && !instance.externalsInvoked) {
202+
204203
instance.loaderConfig.externals
205204
.filter(isTypeDeclaration)
206205
.forEach(ext => instance.tsState.fileAnalyzer.checkDependencies(ext));

src/instance.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export function ensureInstance(webpack: IWebPack, query: QueryOptions, instanceN
142142

143143
let { configFilePath, compilerConfig, loaderConfig } = readConfigFile(process.cwd(), query, tsImpl);
144144

145-
applyDefaults(compilerConfig, loaderConfig);
145+
applyDefaults(configFilePath, compilerConfig, loaderConfig);
146146
let babelImpl = setupBabel(loaderConfig);
147147
let cacheIdentifier = setupCache(loaderConfig, tsImpl, webpack, babelImpl);
148148

@@ -262,9 +262,10 @@ function setupBabel(loaderConfig: LoaderConfig): any {
262262
return babelImpl;
263263
}
264264

265-
function applyDefaults(compilerConfig: TsConfig, loaderConfig: LoaderConfig) {
265+
function applyDefaults(configFilePath: string, compilerConfig: TsConfig, loaderConfig: LoaderConfig) {
266266
compilerConfig.typingOptions.exclude = compilerConfig.typingOptions.exclude || [];
267-
let initialFiles = compilerConfig.fileNames;
267+
let configDirname = path.dirname(configFilePath);
268+
let initialFiles = compilerConfig.fileNames.map(f => path.join(configDirname, f));
268269

269270
_.defaults(compilerConfig.options, {
270271
sourceMap: true,
@@ -310,7 +311,7 @@ export function readConfigFile(baseDir: string, query: QueryOptions, tsImpl: typ
310311

311312
if (!configFilePath || query.tsconfigContent) {
312313
return {
313-
configFilePath: configFilePath || process.cwd(),
314+
configFilePath: configFilePath || path.join(process.cwd(), 'tsconfig.json'),
314315
compilerConfig: tsImpl.parseJsonConfigFileContent(
315316
query.tsconfigContent || {},
316317
tsImpl.sys,
@@ -332,6 +333,8 @@ export function readConfigFile(baseDir: string, query: QueryOptions, tsImpl: typ
332333
configFilePath
333334
);
334335

336+
configFilePath = path.join(process.cwd(), configFilePath);
337+
335338
return {
336339
configFilePath,
337340
compilerConfig,

src/test/tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"target": "es6",
44
"moduleResolution": "node",
55
"sourceMap": true,
6+
"outDir": "../../dist/test",
67
"lib": [ "es6", "dom" ]
78
},
89
"exclude": [
9-
"*"
10+
"fixtures",
11+
"output"
1012
]
1113
}

src/test/utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference path="../defines.d.ts" />
2+
13
import * as path from 'path';
24
import * as fs from 'fs';
35
import * as _ from 'lodash';

0 commit comments

Comments
 (0)