From b365478fa3194d73bd272e23e6f2abc44fc130a2 Mon Sep 17 00:00:00 2001 From: konpikwastaken <485881+konpikwastaken@users.noreply.github.com> Date: Tue, 28 May 2019 19:48:13 -0700 Subject: [PATCH 1/3] initial commit adding test and fix --- src/config.ts | 7 +++- src/instances.ts | 3 +- .../3.5.0-dev.0_incremental/karma.conf.js | 17 ++++++++++ .../3.5.0-dev.0_incremental/main.js | 2 ++ .../3.5.0-dev.0_incremental/package.json | 10 ++++++ .../3.5.0-dev.0_incremental/src/main.ts | 11 ++++++ .../test/main.tests.ts | 8 +++++ .../3.5.0-dev.0_incremental/tsconfig.json | 10 ++++++ .../3.5.0-dev.0_incremental/webpack.config.js | 34 +++++++++++++++++++ .../3.5.0-dev.0_incremental/yarn.lock | 11 ++++++ 10 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/karma.conf.js create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/main.js create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/package.json create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/src/main.ts create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/test/main.tests.ts create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/tsconfig.json create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/webpack.config.js create mode 100644 test/execution-tests/3.5.0-dev.0_incremental/yarn.lock diff --git a/src/config.ts b/src/config.ts index 0fb4a556a..a89c25662 100644 --- a/src/config.ts +++ b/src/config.ts @@ -125,13 +125,18 @@ 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 ); + // 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; } diff --git a/src/instances.ts b/src/instances.ts index 4cbe64642..c745687b3 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -99,7 +99,8 @@ function successfulTypeScriptInstance( const configParseResult = getConfigParseResult( compiler, configFile, - basePath + basePath, + configFilePath ); if (configParseResult.errors.length > 0 && !loaderOptions.happyPackMode) { diff --git a/test/execution-tests/3.5.0-dev.0_incremental/karma.conf.js b/test/execution-tests/3.5.0-dev.0_incremental/karma.conf.js new file mode 100644 index 000000000..a38a197f0 --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_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' + ] + }) + ); +}; diff --git a/test/execution-tests/3.5.0-dev.0_incremental/main.js b/test/execution-tests/3.5.0-dev.0_incremental/main.js new file mode 100644 index 000000000..118f90112 --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_incremental/main.js @@ -0,0 +1,2 @@ +const testsContext = require.context('./', true, /\.tests\.ts(x?)$/); +testsContext.keys().forEach(testsContext); diff --git a/test/execution-tests/3.5.0-dev.0_incremental/package.json b/test/execution-tests/3.5.0-dev.0_incremental/package.json new file mode 100644 index 000000000..bf5cc6f84 --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_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" + } +} \ No newline at end of file diff --git a/test/execution-tests/3.5.0-dev.0_incremental/src/main.ts b/test/execution-tests/3.5.0-dev.0_incremental/src/main.ts new file mode 100644 index 000000000..59535e048 --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_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; \ No newline at end of file diff --git a/test/execution-tests/3.5.0-dev.0_incremental/test/main.tests.ts b/test/execution-tests/3.5.0-dev.0_incremental/test/main.tests.ts new file mode 100644 index 000000000..6242008ef --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_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(); + }); +}); diff --git a/test/execution-tests/3.5.0-dev.0_incremental/tsconfig.json b/test/execution-tests/3.5.0-dev.0_incremental/tsconfig.json new file mode 100644 index 000000000..37cadf6c7 --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_incremental/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "noEmitOnError": true, + "noErrorTruncation": true, + "incremental": true, + "outDir": "./dist", + "target": "es5", + "module": "es6" + } +} diff --git a/test/execution-tests/3.5.0-dev.0_incremental/webpack.config.js b/test/execution-tests/3.5.0-dev.0_incremental/webpack.config.js new file mode 100644 index 000000000..aef2c421f --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_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") + } +} \ No newline at end of file diff --git a/test/execution-tests/3.5.0-dev.0_incremental/yarn.lock b/test/execution-tests/3.5.0-dev.0_incremental/yarn.lock new file mode 100644 index 000000000..4102f8f14 --- /dev/null +++ b/test/execution-tests/3.5.0-dev.0_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" From 45b19105b9fd2e1a3d642587bd96b4293c67edf7 Mon Sep 17 00:00:00 2001 From: konpikwastaken <485881+konpikwastaken@users.noreply.github.com> Date: Thu, 30 May 2019 12:16:40 -0700 Subject: [PATCH 2/3] PR feedback, test fixes --- .travis.yml | 1 + CHANGELOG.md | 3 +++ appveyor.yml | 1 + package.json | 2 +- src/config.ts | 12 ++++++++---- .../karma.conf.js | 0 .../main.js | 0 .../package.json | 0 .../src/main.ts | 0 .../test/main.tests.ts | 0 .../tsconfig.json | 0 .../webpack.config.js | 0 .../yarn.lock | 0 13 files changed, 14 insertions(+), 5 deletions(-) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/karma.conf.js (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/main.js (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/package.json (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/src/main.ts (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/test/main.tests.ts (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/tsconfig.json (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/webpack.config.js (100%) rename test/execution-tests/{3.5.0-dev.0_incremental => 3.5.1_incremental}/yarn.lock (100%) diff --git a/.travis.yml b/.travis.yml index 1ada50d11..b9b5b1631 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 31948bcb8..2b062c481 100644 --- a/CHANGELOG.md +++ b/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 + ## 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! diff --git a/appveyor.yml b/appveyor.yml index 8e0445037..67faad0d8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/package.json b/package.json index 95fd69457..184e92a4d 100644 --- a/package.json +++ b/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", diff --git a/src/config.ts b/src/config.ts index a89c25662..d0cef0206 100644 --- a/src/config.ts +++ b/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'; @@ -133,10 +134,13 @@ export function getConfigParseResult( compiler.sys, basePath ); - // set internal options.configFilePath flag on options to denote that we read this from a file - configParseResult.options = Object.assign({}, configParseResult.options, { - configFilePath - }); + + 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; } diff --git a/test/execution-tests/3.5.0-dev.0_incremental/karma.conf.js b/test/execution-tests/3.5.1_incremental/karma.conf.js similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/karma.conf.js rename to test/execution-tests/3.5.1_incremental/karma.conf.js diff --git a/test/execution-tests/3.5.0-dev.0_incremental/main.js b/test/execution-tests/3.5.1_incremental/main.js similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/main.js rename to test/execution-tests/3.5.1_incremental/main.js diff --git a/test/execution-tests/3.5.0-dev.0_incremental/package.json b/test/execution-tests/3.5.1_incremental/package.json similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/package.json rename to test/execution-tests/3.5.1_incremental/package.json diff --git a/test/execution-tests/3.5.0-dev.0_incremental/src/main.ts b/test/execution-tests/3.5.1_incremental/src/main.ts similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/src/main.ts rename to test/execution-tests/3.5.1_incremental/src/main.ts diff --git a/test/execution-tests/3.5.0-dev.0_incremental/test/main.tests.ts b/test/execution-tests/3.5.1_incremental/test/main.tests.ts similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/test/main.tests.ts rename to test/execution-tests/3.5.1_incremental/test/main.tests.ts diff --git a/test/execution-tests/3.5.0-dev.0_incremental/tsconfig.json b/test/execution-tests/3.5.1_incremental/tsconfig.json similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/tsconfig.json rename to test/execution-tests/3.5.1_incremental/tsconfig.json diff --git a/test/execution-tests/3.5.0-dev.0_incremental/webpack.config.js b/test/execution-tests/3.5.1_incremental/webpack.config.js similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/webpack.config.js rename to test/execution-tests/3.5.1_incremental/webpack.config.js diff --git a/test/execution-tests/3.5.0-dev.0_incremental/yarn.lock b/test/execution-tests/3.5.1_incremental/yarn.lock similarity index 100% rename from test/execution-tests/3.5.0-dev.0_incremental/yarn.lock rename to test/execution-tests/3.5.1_incremental/yarn.lock From cc74091c84b57b337b6260781998bef52b58de1b Mon Sep 17 00:00:00 2001 From: konpikwastaken <485881+konpikwastaken@users.noreply.github.com> Date: Thu, 30 May 2019 15:33:16 -0700 Subject: [PATCH 3/3] changelog, requeue --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b062c481..908a1b0d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## v6.0.2 -* [Set configFilePath when reading config file](https://github.com/TypeStrong/ts-loader/pull/942) (#939) @konpikwastaken +* [Set configFilePath when reading config file](https://github.com/TypeStrong/ts-loader/pull/942) (#939) - thanks @konpikwastaken! ## v6.0.1