Skip to content

Commit b365478

Browse files
initial commit adding test and fix
1 parent 18151d5 commit b365478

File tree

10 files changed

+111
-2
lines changed

10 files changed

+111
-2
lines changed

src/config.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,18 @@ function findConfigFile(
125125
export function getConfigParseResult(
126126
compiler: typeof typescript,
127127
configFile: ConfigFile,
128-
basePath: string
128+
basePath: string,
129+
configFilePath: string | undefined
129130
) {
130131
const configParseResult = compiler.parseJsonConfigFileContent(
131132
configFile.config,
132133
compiler.sys,
133134
basePath
134135
);
136+
// set internal options.configFilePath flag on options to denote that we read this from a file
137+
configParseResult.options = Object.assign({}, configParseResult.options, {
138+
configFilePath
139+
});
135140

136141
return configParseResult;
137142
}

src/instances.ts

+2-1
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) {
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+
};
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);
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+
}
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;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import main from '../src/main';
2+
3+
describe("main", () => {
4+
it("should compile successfully", () => {
5+
// blank expectation, actual failure is in build
6+
expect(main).not.toBeNull();
7+
});
8+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"noEmitOnError": true,
4+
"noErrorTruncation": true,
5+
"incremental": true,
6+
"outDir": "./dist",
7+
"target": "es5",
8+
"module": "es6"
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable no-var, strict, prefer-arrow-callback */
2+
'use strict';
3+
4+
var path = require('path');
5+
var webpack = require('webpack');
6+
var path = require('path');
7+
8+
module.exports = {
9+
mode: 'development',
10+
entry: './src/main.ts',
11+
output: {
12+
filename: 'bundle.js'
13+
},
14+
module: {
15+
rules: [{
16+
test: /\.ts(x?)$/,
17+
exclude: /node_modules/,
18+
use: [{
19+
loader: 'ts-loader',
20+
}]
21+
}]
22+
},
23+
resolve: {
24+
// Add `.ts` and `.tsx` as a resolvable extension.
25+
extensions: ['.ts', '.tsx', '.js']
26+
},
27+
};
28+
29+
// for test harness purposes only, you would not need this in a normal project
30+
module.exports.resolveLoader = {
31+
alias: {
32+
'ts-loader': path.join(__dirname, "../../../index.js")
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@types/jasmine@^2.5.35":
6+
version "2.8.16"
7+
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.16.tgz#a6cb24b1149d65293bd616923500014838e14e7d"
8+
9+
jasmine-core@^2.3.4:
10+
version "2.99.1"
11+
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15"

0 commit comments

Comments
 (0)