Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 939 #942

Merged
merged 3 commits into from May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -14,6 +14,7 @@ install:
- yarn lint
- yarn add $TYPESCRIPT
env:
- TYPESCRIPT=typescript@3.5.1
- TYPESCRIPT=typescript@3.4.4
- TYPESCRIPT=typescript@next
- TYPESCRIPT=typescript@3.3.3
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog

## v6.0.2
* [Set configFilePath when reading config file](https://github.com/TypeStrong/ts-loader/pull/942) (#939) @konpikwastaken
konpikwastaken marked this conversation as resolved.
Show resolved Hide resolved

## v6.0.1

* [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!
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Expand Up @@ -3,6 +3,7 @@ environment:
FORCE_COLOR: 1
nodejs_version: "10"
matrix:
- TYPESCRIPT: typescript@3.5.1
- TYPESCRIPT: typescript@3.4.4
- TYPESCRIPT: typescript@next
- TYPESCRIPT: typescript@3.3.3
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ts-loader",
"version": "6.0.1",
"version": "6.0.2",
"description": "TypeScript loader for webpack",
"main": "index.js",
"types": "dist/types/index.d.ts",
Expand Down
11 changes: 10 additions & 1 deletion src/config.ts
@@ -1,5 +1,6 @@
import { Chalk } from 'chalk';
import * as path from 'path';
import * as semver from 'semver';
import * as typescript from 'typescript';
import * as webpack from 'webpack';

Expand Down Expand Up @@ -125,13 +126,21 @@ function findConfigFile(
export function getConfigParseResult(
compiler: typeof typescript,
configFile: ConfigFile,
basePath: string
basePath: string,
configFilePath: string | undefined
) {
const configParseResult = compiler.parseJsonConfigFileContent(
configFile.config,
compiler.sys,
basePath
);

if (semver.gte(compiler.version, '3.5.0')) {
// set internal options.configFilePath flag on options to denote that we read this from a file
configParseResult.options = Object.assign({}, configParseResult.options, {
configFilePath
});
}

return configParseResult;
}
3 changes: 2 additions & 1 deletion src/instances.ts
Expand Up @@ -99,7 +99,8 @@ function successfulTypeScriptInstance(
const configParseResult = getConfigParseResult(
compiler,
configFile,
basePath
basePath,
configFilePath
);

if (configParseResult.errors.length > 0 && !loaderOptions.happyPackMode) {
Expand Down
17 changes: 17 additions & 0 deletions test/execution-tests/3.5.1_incremental/karma.conf.js
@@ -0,0 +1,17 @@
/* eslint-disable no-var, strict */
'use strict';
var webpackConfig = require('./webpack.config.js');
var makeKarmaConfig = require('../../karmaConfig');

module.exports = function(config) {
config.set(
makeKarmaConfig({
config,
webpackConfig,
files: [
// This ensures we have the es6 shims in place from babel and then loads all the tests
'main.js'
]
})
);
};
2 changes: 2 additions & 0 deletions test/execution-tests/3.5.1_incremental/main.js
@@ -0,0 +1,2 @@
const testsContext = require.context('./', true, /\.tests\.ts(x?)$/);
testsContext.keys().forEach(testsContext);
10 changes: 10 additions & 0 deletions test/execution-tests/3.5.1_incremental/package.json
@@ -0,0 +1,10 @@
{
"name": "3.5.0_incremental",
"license": "MIT",
"version": "1.0.0",
"main": "index.js",
"devDependencies": {
"@types/jasmine": "^2.5.35",
"jasmine-core": "^2.3.4"
}
}
11 changes: 11 additions & 0 deletions test/execution-tests/3.5.1_incremental/src/main.ts
@@ -0,0 +1,11 @@
class Foo {
private message: string;
constructor() {
this.message = 'hello world';
}
public write() {
// tslint:disable-next-line:no-console
console.log(this.message);
}
}
export default Foo;
8 changes: 8 additions & 0 deletions test/execution-tests/3.5.1_incremental/test/main.tests.ts
@@ -0,0 +1,8 @@
import main from '../src/main';

describe("main", () => {
it("should compile successfully", () => {
// blank expectation, actual failure is in build
expect(main).not.toBeNull();
});
});
10 changes: 10 additions & 0 deletions test/execution-tests/3.5.1_incremental/tsconfig.json
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"noEmitOnError": true,
"noErrorTruncation": true,
"incremental": true,
"outDir": "./dist",
"target": "es5",
"module": "es6"
}
}
34 changes: 34 additions & 0 deletions test/execution-tests/3.5.1_incremental/webpack.config.js
@@ -0,0 +1,34 @@
/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';

var path = require('path');
var webpack = require('webpack');
var path = require('path');

module.exports = {
mode: 'development',
entry: './src/main.ts',
output: {
filename: 'bundle.js'
},
module: {
rules: [{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [{
loader: 'ts-loader',
}]
}]
},
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.ts', '.tsx', '.js']
},
};

// for test harness purposes only, you would not need this in a normal project
module.exports.resolveLoader = {
alias: {
'ts-loader': path.join(__dirname, "../../../index.js")
}
}
11 changes: 11 additions & 0 deletions test/execution-tests/3.5.1_incremental/yarn.lock
@@ -0,0 +1,11 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@types/jasmine@^2.5.35":
version "2.8.16"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.16.tgz#a6cb24b1149d65293bd616923500014838e14e7d"

jasmine-core@^2.3.4:
version "2.99.1"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15"