Skip to content

Commit adf6b3c

Browse files
konpikwastakenjohnnyreilly
authored andcommitted
Fix Issue 939 (#942)
* initial commit adding test and fix * PR feedback, test fixes * changelog, requeue
1 parent 18151d5 commit adf6b3c

File tree

14 files changed

+121
-3
lines changed

14 files changed

+121
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ install:
1414
- yarn lint
1515
- yarn add $TYPESCRIPT
1616
env:
17+
1718
1819
- TYPESCRIPT=typescript@next
1920

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v6.0.2
4+
* [Set configFilePath when reading config file](https://github.com/TypeStrong/ts-loader/pull/942) (#939) - thanks @konpikwastaken!
5+
36
## v6.0.1
47

58
* [Fix issue with `resolveTypeReferenceDirective` causing errors like `Cannot find name 'it'` with Jest](https://github.com/TypeStrong/ts-loader/pull/936) (#934) (#919) - thanks @andrewbranch!

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ environment:
33
FORCE_COLOR: 1
44
nodejs_version: "10"
55
matrix:
6+
- TYPESCRIPT: [email protected]
67
- TYPESCRIPT: [email protected]
78
- TYPESCRIPT: typescript@next
89
- TYPESCRIPT: [email protected]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "6.0.1",
3+
"version": "6.0.2",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist/types/index.d.ts",

src/config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Chalk } from 'chalk';
22
import * as path from 'path';
3+
import * as semver from 'semver';
34
import * as typescript from 'typescript';
45
import * as webpack from 'webpack';
56

@@ -125,13 +126,21 @@ function findConfigFile(
125126
export function getConfigParseResult(
126127
compiler: typeof typescript,
127128
configFile: ConfigFile,
128-
basePath: string
129+
basePath: string,
130+
configFilePath: string | undefined
129131
) {
130132
const configParseResult = compiler.parseJsonConfigFileContent(
131133
configFile.config,
132134
compiler.sys,
133135
basePath
134136
);
135137

138+
if (semver.gte(compiler.version, '3.5.0')) {
139+
// set internal options.configFilePath flag on options to denote that we read this from a file
140+
configParseResult.options = Object.assign({}, configParseResult.options, {
141+
configFilePath
142+
});
143+
}
144+
136145
return configParseResult;
137146
}

src/instances.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ function successfulTypeScriptInstance(
9999
const configParseResult = getConfigParseResult(
100100
compiler,
101101
configFile,
102-
basePath
102+
basePath,
103+
configFilePath
103104
);
104105

105106
if (configParseResult.errors.length > 0 && !loaderOptions.happyPackMode) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable no-var, strict */
2+
'use strict';
3+
var webpackConfig = require('./webpack.config.js');
4+
var makeKarmaConfig = require('../../karmaConfig');
5+
6+
module.exports = function(config) {
7+
config.set(
8+
makeKarmaConfig({
9+
config,
10+
webpackConfig,
11+
files: [
12+
// This ensures we have the es6 shims in place from babel and then loads all the tests
13+
'main.js'
14+
]
15+
})
16+
);
17+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const testsContext = require.context('./', true, /\.tests\.ts(x?)$/);
2+
testsContext.keys().forEach(testsContext);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "3.5.0_incremental",
3+
"license": "MIT",
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"devDependencies": {
7+
"@types/jasmine": "^2.5.35",
8+
"jasmine-core": "^2.3.4"
9+
}
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Foo {
2+
private message: string;
3+
constructor() {
4+
this.message = 'hello world';
5+
}
6+
public write() {
7+
// tslint:disable-next-line:no-console
8+
console.log(this.message);
9+
}
10+
}
11+
export default Foo;

0 commit comments

Comments
 (0)