Skip to content

Commit

Permalink
Consume typescript apis from typescript nightly (#1016)
Browse files Browse the repository at this point in the history
* Add support to run tests matching regexp

* Consume typescript apis

* Run tests matching criteria across the all tests

* Remove TODO

* Update CHANGELOG.md

* Update package.json
  • Loading branch information
sheetalkamat authored and johnnyreilly committed Sep 21, 2019
1 parent dff1e17 commit ed8d596
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v6.1.2
* [don't emit declaration files for a declaration file](https://github.com/TypeStrong/ts-loader/pull/1015) (#1014) - thanks @gvinaccia!
* [Consume typescript apis from typescript nightly](https://github.com/TypeStrong/ts-loader/pull/1016) - thanks @sheetalkamat!

## v6.1.1
* [Fix SolutionBuilder watches](https://github.com/TypeStrong/ts-loader/pull/1003) and [related fixes](https://github.com/TypeStrong/ts-loader/pull/1011) (#998) - thanks @sheetalkamat!
* [fix: no errors reported if flagged with @ts-check](https://github.com/TypeStrong/ts-loader/pull/1008) (#1004) - thanks @reinholdk!
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-loader",
"version": "6.1.1",
"version": "6.1.2",
"description": "TypeScript loader for webpack",
"main": "index.js",
"types": "dist/types/index.d.ts",
Expand Down
13 changes: 11 additions & 2 deletions src/after-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,15 @@ function provideDeclarationFilesToWebpack(
}
}

function getOutputPathForBuildInfo(
compiler: typeof ts,
options: ts.CompilerOptions
) {
return (compiler as any).getTsBuildInfoEmitOutputFilePath
? (compiler as any).getTsBuildInfoEmitOutputFilePath(options)
: (compiler as any).getOutputPathForBuildInfo(options);
}

/**
* gather all .tsbuildinfo for the project
*/
Expand All @@ -375,8 +384,8 @@ function provideTsBuildInfoFilesToWebpack(
instance.modifiedFiles!.has(path.resolve(f))
)
) {
// TODO:: update compiler to expose this
const buildInfoPath = (instance.compiler as any).getOutputPathForBuildInfo(
const buildInfoPath = getOutputPathForBuildInfo(
instance.compiler,
resolvedRef.commandLine.options
);
if (buildInfoPath) {
Expand Down
11 changes: 8 additions & 3 deletions src/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,15 @@ function getOutputFileNames(
configFile: typescript.ParsedCommandLine,
inputFileName: string
): string[] {
const outputs: string[] = [];
const ignoreCase = !instance.compiler.sys.useCaseSensitiveFileNames;
if ((instance.compiler as any).getOutputFileNames) {
return (instance.compiler as any).getOutputFileNames(
configFile,
inputFileName,
ignoreCase
);
}
const outputs: string[] = [];
const addOutput = (fileName: string | undefined) =>
fileName && outputs.push(fileName);
const js = getOutputJSFileName(
Expand Down Expand Up @@ -539,8 +546,6 @@ function getOutputFilesFromReference(
!options.out &&
fileNames.some(file => path.normalize(file) === filePath)
) {
// TODO api in typescript
// For now copying from typescript
const outputFiles: typescript.OutputFile[] = [];
getOutputFileNames(
instance,
Expand Down
9 changes: 9 additions & 0 deletions test/comparison-tests/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const saveOutputMode = process.argv.indexOf('--save-output') !== -1;
const indexOfSingleTest = process.argv.indexOf('--single-test');
const singleTestToRun =
indexOfSingleTest !== -1 && process.argv[indexOfSingleTest + 1];
const indexOfTestCriteria = process.argv.indexOf('--match-test');
const testCriteria =
indexOfTestCriteria !== -1 && new RegExp(process.argv[indexOfTestCriteria + 1]);

/** @type {string[]} */
let passingTests = [];
Expand Down Expand Up @@ -58,6 +61,12 @@ function runTests() {
const testPath = path.join(testDir, testName);
return fs.statSync(testPath).isDirectory();
}
)
.filter(
/**
* @param {string} testName
*/ testName =>
testCriteria ? !!testName.match(testCriteria) : true
);

// Allow multiple attempts to pass tests as they're flaky
Expand Down
9 changes: 9 additions & 0 deletions test/execution-tests/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ process.env.NODE_ENV = 'test';
var indexOfSingleTest = process.argv.indexOf('--single-test');
var singleTestToRun = indexOfSingleTest !== -1 && process.argv[indexOfSingleTest + 1];
var watch = process.argv.indexOf('--watch') !== -1 && !!singleTestToRun;
const indexOfTestCriteria = process.argv.indexOf('--match-test');
const testCriteria =
indexOfTestCriteria !== -1 && new RegExp(process.argv[indexOfTestCriteria + 1]);

var passingTests = [];
var failingTests = [];
Expand All @@ -32,6 +35,12 @@ else {
.filter(isTestDirectory)
.filter(isHighEnoughTypeScriptVersion)
.filter(isNotHappyPackTest)
.filter(
/**
* @param {string} testName
*/ testName =>
testCriteria ? !!testName.match(testCriteria) : true
)
// .filter(isNotBabelTest)
.forEach(runTests);
}
Expand Down
8 changes: 5 additions & 3 deletions test/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ var webpackVersion = require('webpack/package.json').version;
var typescript = require('typescript');
var execSync = require('child_process').execSync;

console.log('Using webpack version ' + webpackVersion);
const testArgs = process.argv.length > 2 ? ` -- ${process.argv.slice(2).join(" ")}` : "";

console.log('Using webpack version --' + webpackVersion);
console.log('Using typescript version ' + typescript.version);

execSync('yarn run comparison-tests', { stdio: 'inherit' });
execSync('yarn run execution-tests', { stdio: 'inherit' });
execSync(`yarn run comparison-tests${testArgs}`, { stdio: 'inherit' });
execSync(`yarn run execution-tests${testArgs}`, { stdio: 'inherit' });

0 comments on commit ed8d596

Please sign in to comment.