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

Commit 54ae5fe

Browse files
committed
fix: absolutize initialFiles paths, fixes #230
1 parent 486354b commit 54ae5fe

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

src/instance.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,7 @@ function setupBabel(loaderConfig: LoaderConfig): any {
264264

265265
function applyDefaults(configFilePath: string, compilerConfig: TsConfig, loaderConfig: LoaderConfig) {
266266
compilerConfig.typingOptions.exclude = compilerConfig.typingOptions.exclude || [];
267-
let configDirname = path.dirname(configFilePath);
268-
let initialFiles = compilerConfig.fileNames.map(f => {
269-
if (path.isAbsolute(f)) {
270-
return f;
271-
} else {
272-
return path.join(configDirname, f);
273-
}
274-
});
267+
let initialFiles = compilerConfig.fileNames;
275268

276269
_.defaults(compilerConfig.options, {
277270
sourceMap: true,
@@ -305,10 +298,18 @@ export interface Configs {
305298
loaderConfig: LoaderConfig;
306299
}
307300

301+
function absolutize(fileName) {
302+
if (path.isAbsolute(fileName)) {
303+
return fileName;
304+
} else {
305+
return path.join(process.cwd(), fileName);
306+
}
307+
}
308+
308309
export function readConfigFile(baseDir: string, query: QueryOptions, tsImpl: typeof ts): Configs {
309310
let configFilePath: string;
310311
if (query.tsconfig && query.tsconfig.match(/\.json$/)) {
311-
configFilePath = query.tsconfig;
312+
configFilePath = absolutize(query.tsconfig);
312313
} else {
313314
configFilePath = tsImpl.findConfigFile(process.cwd(), tsImpl.sys.fileExists);
314315
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare module 'jstz' {
2+
interface Timezone {
3+
name(): string;
4+
}
5+
6+
export function determine(): Timezone;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as jstz from 'jstz';
2+
3+
console.log(jstz.determine().name());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

src/test/initialFiles.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
cleanAndCompile, expect,
3+
fixturePath, createConfig, chroot
4+
} from './utils';
5+
6+
describe('main test', function() {
7+
it('should compile proejct with initialFiles', async function() {
8+
const config = createConfig(
9+
{
10+
entry: fixturePath(['initialFiles', 'Client', 'src', 'main.ts'])
11+
},
12+
{
13+
loaderQuery: {
14+
tsconfigContent: undefined,
15+
tsconfig: fixturePath(['initialFiles', 'Client', 'tsconfig.json'])
16+
}
17+
}
18+
);
19+
20+
let stats = await chroot(fixturePath('initialFiles'), async () => {
21+
return await cleanAndCompile(config);
22+
});
23+
24+
console.log(stats.compilation.errors)
25+
26+
expect(stats.compilation.errors.length).eq(1);
27+
expect(stats.compilation.errors[0].toString().indexOf('ModuleNotFoundError: Module not found:')).eq(0);
28+
});
29+
});

0 commit comments

Comments
 (0)