Skip to content

Commit 9db85d7

Browse files
committed
Revert commits for TypeStrong#260 and TypeStrong#250 to re-apply them manually after merging
Revert "Enables custom resolver only if they're used in incremental mode (TypeStrong#260)" This reverts commit 3990a13. Revert "Adds support for custom resolvers to CompilerHost (TypeStrong#250) - fixes TypeStrong#181" This reverts commit dfd8933.
1 parent 4bde6f1 commit 9db85d7

17 files changed

+30
-348
lines changed

CHANGELOG.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
# [1.2.0-beta.4](https://github.com/Realytics/fork-ts-checker-webpack-plugin/compare/[email protected]@beta) (2019-04-23)
22

3-
43
### Bug Fixes
54

6-
* **tests:** fix linter tests that were doing nothing ([d078278](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/d078278))
7-
* **tests:** linter tests - useTypescriptIncrementalApi usage ([e0020d6](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/e0020d6))
8-
5+
- **tests:** fix linter tests that were doing nothing ([d078278](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/d078278))
6+
- **tests:** linter tests - useTypescriptIncrementalApi usage ([e0020d6](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/e0020d6))
97

108
### Features
119

12-
* **apiincrementalchecker:** improve generation of diagnostics ([ae80e5f](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/ae80e5f)), closes [#257](https://github.com/Realytics/fork-ts-checker-webpack-plugin/issues/257)
10+
- **apiincrementalchecker:** improve generation of diagnostics ([ae80e5f](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/ae80e5f)), closes [#257](https://github.com/Realytics/fork-ts-checker-webpack-plugin/issues/257)
1311

1412
# [1.2.0-beta.3](https://github.com/Realytics/fork-ts-checker-webpack-plugin/compare/[email protected]@beta) (2019-04-22)
1513

16-
1714
### Bug Fixes
1815

19-
* **tests:** rework vue integration tests ([5ad2568](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/5ad2568))
16+
- **tests:** rework vue integration tests ([5ad2568](https://github.com/Realytics/fork-ts-checker-webpack-plugin/commit/5ad2568))
2017

2118
# [1.2.0-beta.2](https://github.com/Realytics/fork-ts-checker-webpack-plugin/compare/[email protected]@beta) (2019-04-22)
2219

src/ApiIncrementalChecker.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from './linterConfigHelpers';
1414
import { NormalizedMessage } from './NormalizedMessage';
1515
import { CompilerHost } from './CompilerHost';
16-
import { ResolveModuleName, ResolveTypeReferenceDirective } from './resolution';
1716
import { FsHelper } from './FsHelper';
1817

1918
export class ApiIncrementalChecker implements IncrementalCheckerInterface {
@@ -42,9 +41,7 @@ export class ApiIncrementalChecker implements IncrementalCheckerInterface {
4241
private context: string,
4342
private linterConfigFile: string | boolean,
4443
private linterAutoFix: boolean,
45-
checkSyntacticErrors: boolean,
46-
resolveModuleName: ResolveModuleName | undefined,
47-
resolveTypeReferenceDirective: ResolveTypeReferenceDirective | undefined
44+
checkSyntacticErrors: boolean
4845
) {
4946
this.hasFixedConfig = typeof this.linterConfigFile === 'string';
5047

@@ -54,9 +51,7 @@ export class ApiIncrementalChecker implements IncrementalCheckerInterface {
5451
typescript,
5552
programConfigFile,
5653
compilerOptions,
57-
checkSyntacticErrors,
58-
resolveModuleName,
59-
resolveTypeReferenceDirective
54+
checkSyntacticErrors
6055
);
6156
}
6257

src/CompilerHost.ts

+1-54
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import * as ts from 'typescript'; // Imported for types alone
33
import { LinkedList } from './LinkedList';
44
import { VueProgram } from './VueProgram';
5-
import { ResolveModuleName, ResolveTypeReferenceDirective } from './resolution';
65

76
interface DirectoryWatchDelaySlot {
87
events: { fileName: string }[];
@@ -52,29 +51,11 @@ export class CompilerHost
5251

5352
private compilationStarted = false;
5453

55-
public resolveModuleNames:
56-
| ((
57-
moduleNames: string[],
58-
containingFile: string,
59-
reusedNames?: string[] | undefined,
60-
redirectedReference?: ts.ResolvedProjectReference | undefined
61-
) => (ts.ResolvedModule | undefined)[])
62-
| undefined;
63-
public resolveTypeReferenceDirectives:
64-
| ((
65-
typeReferenceDirectiveNames: string[],
66-
containingFile: string,
67-
redirectedReference?: ts.ResolvedProjectReference | undefined
68-
) => (ts.ResolvedTypeReferenceDirective | undefined)[])
69-
| undefined;
70-
7154
constructor(
7255
private typescript: typeof ts,
7356
programConfigFile: string,
7457
compilerOptions: ts.CompilerOptions,
75-
checkSyntacticErrors: boolean,
76-
userResolveModuleName?: ResolveModuleName,
77-
userResolveTypeReferenceDirective?: ResolveTypeReferenceDirective
58+
checkSyntacticErrors: boolean
7859
) {
7960
this.tsHost = typescript.createWatchCompilerHost(
8061
programConfigFile,
@@ -94,40 +75,6 @@ export class CompilerHost
9475

9576
this.configFileName = this.tsHost.configFileName;
9677
this.optionsToExtend = this.tsHost.optionsToExtend || {};
97-
98-
if (userResolveModuleName) {
99-
this.resolveModuleNames = (
100-
moduleNames: string[],
101-
containingFile: string
102-
) => {
103-
return moduleNames.map(moduleName => {
104-
return userResolveModuleName(
105-
this.typescript,
106-
moduleName,
107-
containingFile,
108-
this.optionsToExtend,
109-
this
110-
).resolvedModule;
111-
});
112-
};
113-
}
114-
115-
if (userResolveTypeReferenceDirective) {
116-
this.resolveTypeReferenceDirectives = (
117-
typeDirectiveNames: string[],
118-
containingFile: string
119-
) => {
120-
return typeDirectiveNames.map(typeDirectiveName => {
121-
return userResolveTypeReferenceDirective(
122-
this.typescript,
123-
typeDirectiveName,
124-
containingFile,
125-
this.optionsToExtend,
126-
this
127-
).resolvedTypeReferenceDirective;
128-
});
129-
};
130-
}
13178
}
13279

13380
public async processChanges(): Promise<{

src/IncrementalChecker.ts

+4-54
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ import {
1414
import { WorkSet } from './WorkSet';
1515
import { NormalizedMessage } from './NormalizedMessage';
1616
import { CancellationToken } from './CancellationToken';
17-
import {
18-
ResolveModuleName,
19-
ResolveTypeReferenceDirective,
20-
makeResolutionFunctions
21-
} from './resolution';
2217
import * as minimatch from 'minimatch';
2318
import { VueProgram } from './VueProgram';
2419
import { FsHelper } from './FsHelper';
@@ -64,11 +59,7 @@ export class IncrementalChecker implements IncrementalCheckerInterface {
6459
private workNumber: number = 0,
6560
private workDivision: number = 1,
6661
private checkSyntacticErrors: boolean = false,
67-
private vue: boolean = false,
68-
private resolveModuleName: ResolveModuleName | undefined,
69-
private resolveTypeReferenceDirective:
70-
| ResolveTypeReferenceDirective
71-
| undefined
62+
private vue: boolean = false
7263
) {
7364
this.hasFixedConfig = typeof this.linterConfigFile === 'string';
7465
}
@@ -111,48 +102,11 @@ export class IncrementalChecker implements IncrementalCheckerInterface {
111102
programConfig: ts.ParsedCommandLine,
112103
files: FilesRegister,
113104
watcher: FilesWatcher,
114-
oldProgram: ts.Program,
115-
userResolveModuleName: ResolveModuleName | undefined,
116-
userResolveTypeReferenceDirective: ResolveTypeReferenceDirective | undefined
105+
oldProgram: ts.Program
117106
) {
118107
const host = typescript.createCompilerHost(programConfig.options);
119108
const realGetSourceFile = host.getSourceFile;
120109

121-
const {
122-
resolveModuleName,
123-
resolveTypeReferenceDirective
124-
} = makeResolutionFunctions(
125-
userResolveModuleName,
126-
userResolveTypeReferenceDirective
127-
);
128-
129-
host.resolveModuleNames = (moduleNames, containingFile) => {
130-
return moduleNames.map(moduleName => {
131-
return resolveModuleName(
132-
typescript,
133-
moduleName,
134-
containingFile,
135-
programConfig.options,
136-
host
137-
).resolvedModule;
138-
});
139-
};
140-
141-
host.resolveTypeReferenceDirectives = (
142-
typeDirectiveNames,
143-
containingFile
144-
) => {
145-
return typeDirectiveNames.map(typeDirectiveName => {
146-
return resolveTypeReferenceDirective(
147-
typescript,
148-
typeDirectiveName,
149-
containingFile,
150-
programConfig.options,
151-
host
152-
).resolvedTypeReferenceDirective;
153-
});
154-
};
155-
156110
host.getSourceFile = (filePath, languageVersion, onError) => {
157111
// first check if watcher is watching file - if not - check it's mtime
158112
if (!watcher.isWatchingFile(filePath)) {
@@ -261,9 +215,7 @@ export class IncrementalChecker implements IncrementalCheckerInterface {
261215
path.dirname(this.programConfigFile),
262216
this.files,
263217
this.watcher!,
264-
this.program!,
265-
this.resolveModuleName,
266-
this.resolveTypeReferenceDirective
218+
this.program!
267219
);
268220
}
269221

@@ -281,9 +233,7 @@ export class IncrementalChecker implements IncrementalCheckerInterface {
281233
this.programConfig,
282234
this.files,
283235
this.watcher!,
284-
this.program!,
285-
this.resolveModuleName,
286-
this.resolveTypeReferenceDirective
236+
this.program!
287237
);
288238
}
289239

src/VueProgram.ts

+1-43
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import * as path from 'path';
44
import * as ts from 'typescript'; // import for types alone
55
import { FilesRegister } from './FilesRegister';
66
import { FilesWatcher } from './FilesWatcher';
7-
import {
8-
ResolveModuleName,
9-
ResolveTypeReferenceDirective,
10-
makeResolutionFunctions
11-
} from './resolution';
127
// tslint:disable-next-line:no-implicit-dependencies
138
import * as vueCompiler from 'vue-template-compiler';
149

@@ -125,48 +120,11 @@ export class VueProgram {
125120
basedir: string,
126121
files: FilesRegister,
127122
watcher: FilesWatcher,
128-
oldProgram: ts.Program,
129-
userResolveModuleName: ResolveModuleName | undefined,
130-
userResolveTypeReferenceDirective: ResolveTypeReferenceDirective | undefined
123+
oldProgram: ts.Program
131124
) {
132125
const host = typescript.createCompilerHost(programConfig.options);
133126
const realGetSourceFile = host.getSourceFile;
134127

135-
const {
136-
resolveModuleName,
137-
resolveTypeReferenceDirective
138-
} = makeResolutionFunctions(
139-
userResolveModuleName,
140-
userResolveTypeReferenceDirective
141-
);
142-
143-
host.resolveModuleNames = (moduleNames, containingFile) => {
144-
return moduleNames.map(moduleName => {
145-
return resolveModuleName(
146-
typescript,
147-
moduleName,
148-
containingFile,
149-
programConfig.options,
150-
host
151-
).resolvedModule;
152-
});
153-
};
154-
155-
host.resolveTypeReferenceDirectives = (
156-
typeDirectiveNames,
157-
containingFile
158-
) => {
159-
return typeDirectiveNames.map(typeDirectiveName => {
160-
return resolveTypeReferenceDirective(
161-
typescript,
162-
typeDirectiveName,
163-
containingFile,
164-
programConfig.options,
165-
host
166-
).resolvedTypeReferenceDirective;
167-
});
168-
};
169-
170128
// We need a host that can parse Vue SFCs (single file components).
171129
host.getSourceFile = (filePath, languageVersion, onError) => {
172130
// first check if watcher is watching file - if not - check it's mtime

src/index.ts

+15-37
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ interface Options {
5353
vue: boolean;
5454
useTypescriptIncrementalApi: boolean;
5555
measureCompilationTime: boolean;
56-
resolveModuleNameModule: string;
57-
resolveTypeReferenceDirectiveModule: string;
5856
}
5957

6058
/**
@@ -101,8 +99,6 @@ class ForkTsCheckerWebpackPlugin {
10199
private colors: Chalk;
102100
private formatter: Formatter;
103101
private useTypescriptIncrementalApi: boolean;
104-
private resolveModuleNameModule: string | undefined;
105-
private resolveTypeReferenceDirectiveModule: string | undefined;
106102

107103
private tsconfigPath?: string;
108104
private tslintPath?: string;
@@ -162,9 +158,6 @@ class ForkTsCheckerWebpackPlugin {
162158
this.silent = options.silent === true; // default false
163159
this.async = options.async !== false; // default true
164160
this.checkSyntacticErrors = options.checkSyntacticErrors === true; // default false
165-
this.resolveModuleNameModule = options.resolveModuleNameModule;
166-
this.resolveTypeReferenceDirectiveModule =
167-
options.resolveTypeReferenceDirectiveModule;
168161
this.workersNumber = options.workers || ForkTsCheckerWebpackPlugin.ONE_CPU;
169162
this.memoryLimit =
170163
options.memoryLimit || ForkTsCheckerWebpackPlugin.DEFAULT_MEMORY_LIMIT;
@@ -576,50 +569,35 @@ class ForkTsCheckerWebpackPlugin {
576569
}
577570

578571
private spawnService() {
579-
const env: { [key: string]: string | undefined } = {
580-
...process.env,
581-
TYPESCRIPT_PATH: this.typescriptPath,
582-
TSCONFIG: this.tsconfigPath,
583-
COMPILER_OPTIONS: JSON.stringify(this.compilerOptions),
584-
TSLINT: this.tslintPath || (this.tslint ? 'true' : ''),
585-
CONTEXT: this.compiler.options.context,
586-
TSLINTAUTOFIX: String(this.tslintAutoFix),
587-
WATCH: this.isWatching ? this.watchPaths.join('|') : '',
588-
WORK_DIVISION: String(Math.max(1, this.workersNumber)),
589-
MEMORY_LIMIT: String(this.memoryLimit),
590-
CHECK_SYNTACTIC_ERRORS: String(this.checkSyntacticErrors),
591-
USE_INCREMENTAL_API: String(this.useTypescriptIncrementalApi === true),
592-
VUE: String(this.vue)
593-
};
594-
595-
if (typeof this.resolveModuleNameModule !== 'undefined') {
596-
env.RESOLVE_MODULE_NAME = this.resolveModuleNameModule;
597-
} else {
598-
delete env.RESOLVE_MODULE_NAME;
599-
}
600-
601-
if (typeof this.resolveTypeReferenceDirectiveModule !== 'undefined') {
602-
env.RESOLVE_TYPE_REFERENCE_DIRECTIVE = this.resolveTypeReferenceDirectiveModule;
603-
} else {
604-
delete env.RESOLVE_TYPE_REFERENCE_DIRECTIVE;
605-
}
606-
607572
this.service = childProcess.fork(
608573
path.resolve(
609574
__dirname,
610575
this.workersNumber > 1 ? './cluster.js' : './service.js'
611576
),
612577
[],
613578
{
614-
env,
615579
execArgv: (this.workersNumber > 1
616580
? []
617581
: ['--max-old-space-size=' + this.memoryLimit]
618582
).concat(this.nodeArgs),
583+
env: {
584+
...process.env,
585+
TYPESCRIPT_PATH: this.typescriptPath,
586+
TSCONFIG: this.tsconfigPath,
587+
COMPILER_OPTIONS: JSON.stringify(this.compilerOptions),
588+
TSLINT: this.tslintPath || (this.tslint ? 'true' : ''),
589+
CONTEXT: this.compiler.options.context,
590+
TSLINTAUTOFIX: this.tslintAutoFix,
591+
WATCH: this.isWatching ? this.watchPaths.join('|') : '',
592+
WORK_DIVISION: Math.max(1, this.workersNumber),
593+
MEMORY_LIMIT: this.memoryLimit,
594+
CHECK_SYNTACTIC_ERRORS: this.checkSyntacticErrors,
595+
USE_INCREMENTAL_API: this.useTypescriptIncrementalApi === true,
596+
VUE: this.vue
597+
},
619598
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
620599
}
621600
);
622-
623601
this.serviceRpc = new RpcProvider(message => this.service!.send(message));
624602
this.service.on('message', message => this.serviceRpc!.dispatch(message));
625603

0 commit comments

Comments
 (0)