Skip to content

Commit ed8d596

Browse files
sheetalkamatjohnnyreilly
authored andcommitted
Consume typescript apis from typescript nightly (#1016)
* 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
1 parent dff1e17 commit ed8d596

File tree

7 files changed

+47
-9
lines changed

7 files changed

+47
-9
lines changed

CHANGELOG.md

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

3+
## v6.1.2
4+
* [don't emit declaration files for a declaration file](https://github.com/TypeStrong/ts-loader/pull/1015) (#1014) - thanks @gvinaccia!
5+
* [Consume typescript apis from typescript nightly](https://github.com/TypeStrong/ts-loader/pull/1016) - thanks @sheetalkamat!
6+
37
## v6.1.1
48
* [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!
59
* [fix: no errors reported if flagged with @ts-check](https://github.com/TypeStrong/ts-loader/pull/1008) (#1004) - thanks @reinholdk!

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.1.1",
3+
"version": "6.1.2",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist/types/index.d.ts",

src/after-compile.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ function provideDeclarationFilesToWebpack(
357357
}
358358
}
359359

360+
function getOutputPathForBuildInfo(
361+
compiler: typeof ts,
362+
options: ts.CompilerOptions
363+
) {
364+
return (compiler as any).getTsBuildInfoEmitOutputFilePath
365+
? (compiler as any).getTsBuildInfoEmitOutputFilePath(options)
366+
: (compiler as any).getOutputPathForBuildInfo(options);
367+
}
368+
360369
/**
361370
* gather all .tsbuildinfo for the project
362371
*/
@@ -375,8 +384,8 @@ function provideTsBuildInfoFilesToWebpack(
375384
instance.modifiedFiles!.has(path.resolve(f))
376385
)
377386
) {
378-
// TODO:: update compiler to expose this
379-
const buildInfoPath = (instance.compiler as any).getOutputPathForBuildInfo(
387+
const buildInfoPath = getOutputPathForBuildInfo(
388+
instance.compiler,
380389
resolvedRef.commandLine.options
381390
);
382391
if (buildInfoPath) {

src/instances.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,15 @@ function getOutputFileNames(
490490
configFile: typescript.ParsedCommandLine,
491491
inputFileName: string
492492
): string[] {
493-
const outputs: string[] = [];
494493
const ignoreCase = !instance.compiler.sys.useCaseSensitiveFileNames;
494+
if ((instance.compiler as any).getOutputFileNames) {
495+
return (instance.compiler as any).getOutputFileNames(
496+
configFile,
497+
inputFileName,
498+
ignoreCase
499+
);
500+
}
501+
const outputs: string[] = [];
495502
const addOutput = (fileName: string | undefined) =>
496503
fileName && outputs.push(fileName);
497504
const js = getOutputJSFileName(
@@ -539,8 +546,6 @@ function getOutputFilesFromReference(
539546
!options.out &&
540547
fileNames.some(file => path.normalize(file) === filePath)
541548
) {
542-
// TODO api in typescript
543-
// For now copying from typescript
544549
const outputFiles: typescript.OutputFile[] = [];
545550
getOutputFileNames(
546551
instance,

test/comparison-tests/run-tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const saveOutputMode = process.argv.indexOf('--save-output') !== -1;
1717
const indexOfSingleTest = process.argv.indexOf('--single-test');
1818
const singleTestToRun =
1919
indexOfSingleTest !== -1 && process.argv[indexOfSingleTest + 1];
20+
const indexOfTestCriteria = process.argv.indexOf('--match-test');
21+
const testCriteria =
22+
indexOfTestCriteria !== -1 && new RegExp(process.argv[indexOfTestCriteria + 1]);
2023

2124
/** @type {string[]} */
2225
let passingTests = [];
@@ -58,6 +61,12 @@ function runTests() {
5861
const testPath = path.join(testDir, testName);
5962
return fs.statSync(testPath).isDirectory();
6063
}
64+
)
65+
.filter(
66+
/**
67+
* @param {string} testName
68+
*/ testName =>
69+
testCriteria ? !!testName.match(testCriteria) : true
6170
);
6271

6372
// Allow multiple attempts to pass tests as they're flaky

test/execution-tests/run-tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ process.env.NODE_ENV = 'test';
1414
var indexOfSingleTest = process.argv.indexOf('--single-test');
1515
var singleTestToRun = indexOfSingleTest !== -1 && process.argv[indexOfSingleTest + 1];
1616
var watch = process.argv.indexOf('--watch') !== -1 && !!singleTestToRun;
17+
const indexOfTestCriteria = process.argv.indexOf('--match-test');
18+
const testCriteria =
19+
indexOfTestCriteria !== -1 && new RegExp(process.argv[indexOfTestCriteria + 1]);
1720

1821
var passingTests = [];
1922
var failingTests = [];
@@ -32,6 +35,12 @@ else {
3235
.filter(isTestDirectory)
3336
.filter(isHighEnoughTypeScriptVersion)
3437
.filter(isNotHappyPackTest)
38+
.filter(
39+
/**
40+
* @param {string} testName
41+
*/ testName =>
42+
testCriteria ? !!testName.match(testCriteria) : true
43+
)
3544
// .filter(isNotBabelTest)
3645
.forEach(runTests);
3746
}

test/run-tests.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ var webpackVersion = require('webpack/package.json').version;
44
var typescript = require('typescript');
55
var execSync = require('child_process').execSync;
66

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

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

0 commit comments

Comments
 (0)