fork-ts-checker-webpack-plugin 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -34
- package/lib/formatter/stats-formatter.d.ts +3 -0
- package/lib/formatter/stats-formatter.js +28 -0
- package/lib/hooks/tap-done-to-async-get-issues.js +6 -6
- package/lib/plugin.js +1 -1
- package/lib/typescript/type-script-worker-config.d.ts +1 -1
- package/lib/typescript/type-script-worker-config.js +1 -11
- package/lib/typescript/worker/lib/config.d.ts +1 -2
- package/lib/typescript/worker/lib/config.js +38 -18
- package/lib/typescript/worker/lib/emit.d.ts +2 -0
- package/lib/typescript/worker/lib/emit.js +13 -0
- package/lib/typescript/worker/lib/program/program.js +2 -0
- package/lib/typescript/worker/lib/program/watch-program.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,41 +86,41 @@ you can place your configuration in the:
|
|
|
86
86
|
|
|
87
87
|
Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
|
|
88
88
|
|
|
89
|
-
| Name
|
|
90
|
-
|
|
91
|
-
| `async`
|
|
92
|
-
| `typescript`
|
|
93
|
-
| `issue`
|
|
94
|
-
| `formatter`
|
|
95
|
-
| `logger`
|
|
96
|
-
| `devServer`
|
|
89
|
+
| Name | Type | Default value | Description |
|
|
90
|
+
|--------------|--------------------------------------|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
91
|
+
| `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode. |
|
|
92
|
+
| `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options). |
|
|
93
|
+
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
|
|
94
|
+
| `formatter` | `string` or `object` or `function` | `codeframe` | Available formatters are `basic`, `codeframe` and a custom `function`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
|
|
95
|
+
| `logger` | `{ log: function, error: function }` | `console` | Console-like object to print issues in `async` mode. |
|
|
96
|
+
| `devServer` | `boolean` | `true` | If set to `false`, errors will not be reported to Webpack Dev Server. |
|
|
97
97
|
|
|
98
98
|
### TypeScript options
|
|
99
99
|
|
|
100
100
|
Options for the TypeScript checker (`typescript` option object).
|
|
101
101
|
|
|
102
|
-
| Name
|
|
103
|
-
|
|
104
|
-
| `memoryLimit`
|
|
105
|
-
| `configFile`
|
|
106
|
-
| `configOverwrite`
|
|
107
|
-
| `context`
|
|
108
|
-
| `build`
|
|
109
|
-
| `mode`
|
|
110
|
-
| `diagnosticOptions`
|
|
111
|
-
| `extensions`
|
|
112
|
-
| `profile`
|
|
113
|
-
| `typescriptPath`
|
|
102
|
+
| Name | Type | Default value | Description |
|
|
103
|
+
|---------------------|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
104
|
+
| `memoryLimit` | `number` | `2048` | Memory limit for the checker process in MB. If the process exits with the allocation failed error, try to increase this number. |
|
|
105
|
+
| `configFile` | `string` | `'tsconfig.json'` | Path to the `tsconfig.json` file (path relative to the `compiler.options.context` or absolute path) |
|
|
106
|
+
| `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }` | This configuration will overwrite configuration from the `tsconfig.json` file. Supported fields are: `extends`, `compilerOptions`, `include`, `exclude`, `files`, and `references`. |
|
|
107
|
+
| `context` | `string` | `dirname(configuration.configFile)` | The base path for finding files specified in the `tsconfig.json`. Same as the `context` option from the [ts-loader](https://github.com/TypeStrong/ts-loader#context). Useful if you want to keep your `tsconfig.json` in an external package. Keep in mind that **not** having a `tsconfig.json` in your project root can cause different behaviour between `fork-ts-checker-webpack-plugin` and `tsc`. When using editors like `VS Code` it is advised to add a `tsconfig.json` file to the root of the project and extend the config file referenced in option `configFile`. |
|
|
108
|
+
| `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
|
|
109
|
+
| `mode` | `'readonly'` or `'write-dts'` or `'write-tsbuildinfo'` or `'write-references'` | `build === true ? 'write-tsbuildinfo' ? 'readonly'` | Use `readonly` if you don't want to write anything on the disk, `write-dts` to write only `.d.ts` files, `write-tsbuildinfo` to write only `.tsbuildinfo` files, `write-references` to write both `.js` and `.d.ts` files of project references (last 2 modes requires `build: true`). |
|
|
110
|
+
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
|
|
111
|
+
| `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
|
|
112
|
+
| `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
|
|
113
|
+
| `typescriptPath` | `string` | `require.resolve('typescript')` | If supplied this is a custom path where TypeScript can be found. |
|
|
114
114
|
|
|
115
115
|
#### TypeScript extensions options
|
|
116
116
|
|
|
117
117
|
Options for the TypeScript checker extensions (`typescript.extensions` option object).
|
|
118
118
|
|
|
119
|
-
| Name
|
|
120
|
-
|
|
121
|
-
| `vue`
|
|
122
|
-
| `vue.enabled`
|
|
123
|
-
| `vue.compiler`
|
|
119
|
+
| Name | Type | Default value | Description |
|
|
120
|
+
|----------------|-----------------------|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
121
|
+
| `vue` | `object` or `boolean` | `false` | If `true`, it enables Vue [Single File Component](https://vuejs.org/v2/guide/single-file-components.html) support. |
|
|
122
|
+
| `vue.enabled` | `boolean` | `false` | Same as the `vue` option |
|
|
123
|
+
| `vue.compiler` | `string` | `'vue-template-compiler'` | The package name of the compiler that will be used to parse `.vue` files. You can use `'nativescript-vue-template-compiler'` if you use [nativescript-vue](https://github.com/nativescript-vue/nativescript-vue) |
|
|
124
124
|
|
|
125
125
|
### Issues options
|
|
126
126
|
|
|
@@ -139,10 +139,10 @@ type IssuePredicate = (issue: Issue) => boolean;
|
|
|
139
139
|
type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[];
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
| Name | Type | Default value | Description
|
|
143
|
-
|
|
142
|
+
| Name | Type | Default value | Description |
|
|
143
|
+
|-----------|---------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
144
144
|
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](src/issue/issue-match.ts). If `function`, acts as a predicate where `issue` is an argument. |
|
|
145
|
-
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded.
|
|
145
|
+
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
|
|
146
146
|
|
|
147
147
|
<details>
|
|
148
148
|
<summary>Expand example</summary>
|
|
@@ -286,13 +286,13 @@ declare module "*.vue" {
|
|
|
286
286
|
|
|
287
287
|
This plugin provides some custom webpack hooks:
|
|
288
288
|
|
|
289
|
-
| Hook key | Type | Params | Description
|
|
290
|
-
|
|
289
|
+
| Hook key | Type | Params | Description |
|
|
290
|
+
|------------|----------------------------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
291
291
|
| `start` | `AsyncSeriesWaterfallHook` | `change, compilation` | Starts issues checking for a compilation. It's an async waterfall hook, so you can modify the list of changed and removed files or delay the start of the service. |
|
|
292
|
-
| `waiting` | `SyncHook` | `compilation` | Waiting for the issues checking.
|
|
293
|
-
| `canceled` | `SyncHook` | `compilation` | Issues checking for the compilation has been canceled.
|
|
294
|
-
| `error` | `SyncHook` | `compilation` | An error occurred during issues checking.
|
|
295
|
-
| `issues` | `SyncWaterfallHook` | `issues, compilation` | Issues have been received and will be reported. It's a waterfall hook, so you can modify the list of received issues.
|
|
292
|
+
| `waiting` | `SyncHook` | `compilation` | Waiting for the issues checking. |
|
|
293
|
+
| `canceled` | `SyncHook` | `compilation` | Issues checking for the compilation has been canceled. |
|
|
294
|
+
| `error` | `SyncHook` | `compilation` | An error occurred during issues checking. |
|
|
295
|
+
| `issues` | `SyncWaterfallHook` | `issues, compilation` | Issues have been received and will be reported. It's a waterfall hook, so you can modify the list of received issues. |
|
|
296
296
|
|
|
297
297
|
To access plugin hooks and tap into the event, we need to use the `getCompilerHooks` static method.
|
|
298
298
|
When we call this method with a [webpack compiler instance](https://webpack.js.org/api/node/), it returns the object with
|
|
@@ -373,3 +373,4 @@ This plugin was created in [Realytics](https://www.realytics.io/) in 2017. Thank
|
|
|
373
373
|
## License
|
|
374
374
|
|
|
375
375
|
MIT License
|
|
376
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.statsFormatter = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
// mimics webpack's stats summary formatter
|
|
9
|
+
function statsFormatter(issues, stats) {
|
|
10
|
+
const errorsNumber = issues.filter((issue) => issue.severity === 'error').length;
|
|
11
|
+
const warningsNumber = issues.filter((issue) => issue.severity === 'warning').length;
|
|
12
|
+
const errorsFormatted = errorsNumber
|
|
13
|
+
? chalk_1.default.red.bold(`${errorsNumber} ${errorsNumber === 1 ? 'error' : 'errors'}`)
|
|
14
|
+
: '';
|
|
15
|
+
const warningsFormatted = warningsNumber
|
|
16
|
+
? chalk_1.default.yellow.bold(`${warningsNumber} ${warningsNumber === 1 ? 'warning' : 'warnings'}`)
|
|
17
|
+
: '';
|
|
18
|
+
const timeFormatted = Math.round(Date.now() - stats.startTime);
|
|
19
|
+
return [
|
|
20
|
+
'Found ',
|
|
21
|
+
errorsFormatted,
|
|
22
|
+
errorsFormatted && warningsFormatted ? ' and ' : '',
|
|
23
|
+
warningsFormatted,
|
|
24
|
+
` in ${timeFormatted} ms`,
|
|
25
|
+
'.',
|
|
26
|
+
].join('');
|
|
27
|
+
}
|
|
28
|
+
exports.statsFormatter = statsFormatter;
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.tapDoneToAsyncGetIssues = void 0;
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const stats_formatter_1 = require("../formatter/stats-formatter");
|
|
17
18
|
const webpack_formatter_1 = require("../formatter/webpack-formatter");
|
|
18
19
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
19
20
|
const issue_webpack_error_1 = require("../issue/issue-webpack-error");
|
|
@@ -22,7 +23,7 @@ const is_pending_1 = require("../utils/async/is-pending");
|
|
|
22
23
|
const wait_1 = require("../utils/async/wait");
|
|
23
24
|
function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
24
25
|
const hooks = (0, plugin_hooks_1.getPluginHooks)(compiler);
|
|
25
|
-
const {
|
|
26
|
+
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
|
|
26
27
|
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', (stats) => __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
if (stats.compilation.compiler !== compiler) {
|
|
28
29
|
// run only for the compiler that the plugin was registered for
|
|
@@ -33,7 +34,7 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
33
34
|
try {
|
|
34
35
|
if (yield (0, is_pending_1.isPending)(issuesPromise)) {
|
|
35
36
|
hooks.waiting.call(stats.compilation);
|
|
36
|
-
config.logger.log(chalk_1.default.cyan('
|
|
37
|
+
config.logger.log(chalk_1.default.cyan('Type-checking in progress...'));
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
40
|
// wait 10ms to log issues after webpack stats
|
|
@@ -58,9 +59,11 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
58
59
|
if (issues.length) {
|
|
59
60
|
// follow webpack's approach - one process.write to stderr with all errors and warnings
|
|
60
61
|
config.logger.error(issues.map((issue) => formatter(issue)).join('\n'));
|
|
62
|
+
// print stats of the compilation
|
|
63
|
+
config.logger.log((0, stats_formatter_1.statsFormatter)(issues, stats));
|
|
61
64
|
}
|
|
62
65
|
else {
|
|
63
|
-
config.logger.log(chalk_1.default.green('No
|
|
66
|
+
config.logger.log(chalk_1.default.green('No errors found.'));
|
|
64
67
|
}
|
|
65
68
|
// report issues to webpack-dev-server, if it's listening
|
|
66
69
|
// skip reporting if there are no issues, to avoid an extra hot reload
|
|
@@ -77,9 +80,6 @@ function tapDoneToAsyncGetIssues(compiler, config, state) {
|
|
|
77
80
|
debug('Sending issues to the webpack-dev-server.');
|
|
78
81
|
state.webpackDevServerDoneTap.fn(stats);
|
|
79
82
|
}
|
|
80
|
-
if (stats.startTime) {
|
|
81
|
-
log(`Time: ${Math.round(Date.now() - stats.startTime).toString()} ms`);
|
|
82
|
-
}
|
|
83
83
|
}));
|
|
84
84
|
}
|
|
85
85
|
exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;
|
package/lib/plugin.js
CHANGED
|
@@ -70,7 +70,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
|
70
70
|
/**
|
|
71
71
|
* Current version of the plugin
|
|
72
72
|
*/
|
|
73
|
-
ForkTsCheckerWebpackPlugin.version = '7.
|
|
73
|
+
ForkTsCheckerWebpackPlugin.version = '7.1.0'; // will be replaced by the @semantic-release/exec
|
|
74
74
|
/**
|
|
75
75
|
* Default pools for the plugin concurrency limit
|
|
76
76
|
*/
|
|
@@ -10,7 +10,7 @@ interface TypeScriptWorkerConfig {
|
|
|
10
10
|
configOverwrite: TypeScriptConfigOverwrite;
|
|
11
11
|
build: boolean;
|
|
12
12
|
context: string;
|
|
13
|
-
mode: 'readonly' | 'write-
|
|
13
|
+
mode: 'readonly' | 'write-dts' | 'write-tsbuildinfo' | 'write-references';
|
|
14
14
|
diagnosticOptions: TypeScriptDiagnosticsOptions;
|
|
15
15
|
extensions: {
|
|
16
16
|
vue: TypeScriptVueExtensionConfig;
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createTypeScriptWorkerConfig = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const semver_1 = __importDefault(require("semver"));
|
|
9
8
|
const type_script_vue_extension_config_1 = require("./extension/vue/type-script-vue-extension-config");
|
|
10
9
|
function createTypeScriptWorkerConfig(compiler, options) {
|
|
11
10
|
let configFile = typeof options === 'object' ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
|
|
@@ -15,16 +14,7 @@ function createTypeScriptWorkerConfig(compiler, options) {
|
|
|
15
14
|
: path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
|
|
16
15
|
const optionsAsObject = typeof options === 'object' ? options : {};
|
|
17
16
|
const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
|
|
18
|
-
|
|
19
|
-
skipLibCheck: true,
|
|
20
|
-
sourceMap: false,
|
|
21
|
-
inlineSourceMap: false,
|
|
22
|
-
};
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
|
-
if (semver_1.default.gte(require(typescriptPath).version, '2.9.0')) {
|
|
25
|
-
defaultCompilerOptions.declarationMap = false;
|
|
26
|
-
}
|
|
27
|
-
return Object.assign(Object.assign({ enabled: options !== false, memoryLimit: 2048, build: false, mode: 'write-tsbuildinfo', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: Object.assign(Object.assign({}, (optionsAsObject.configOverwrite || {})), { compilerOptions: Object.assign(Object.assign({}, defaultCompilerOptions), ((optionsAsObject.configOverwrite || {}).compilerOptions || {})) }), context: optionsAsObject.context || path_1.default.dirname(configFile), extensions: {
|
|
17
|
+
return Object.assign(Object.assign({ enabled: options !== false, memoryLimit: 2048, build: false, mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: optionsAsObject.configOverwrite || {}, context: optionsAsObject.context || path_1.default.dirname(configFile), extensions: {
|
|
28
18
|
vue: (0, type_script_vue_extension_config_1.createTypeScriptVueExtensionConfig)(optionsAsObject.extensions ? optionsAsObject.extensions.vue : undefined),
|
|
29
19
|
}, diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})), typescriptPath: typescriptPath });
|
|
30
20
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
import type { FilesChange } from '../../../files-change';
|
|
3
3
|
import type { Issue } from '../../../issue';
|
|
4
|
-
|
|
5
|
-
export declare function parseConfig(configFileName: string, configFileContext: string, configOverwriteJSON?: TypeScriptConfigOverwrite): ts.ParsedCommandLine;
|
|
4
|
+
export declare function parseConfig(configFileName: string, configFileContext: string): ts.ParsedCommandLine;
|
|
6
5
|
export declare function getParseConfigIssues(): Issue[];
|
|
7
6
|
export declare function getParsedConfig(force?: boolean): ts.ParsedCommandLine;
|
|
8
7
|
export declare function parseNextConfig(): readonly [ts.ParsedCommandLine | undefined, ts.ParsedCommandLine];
|
|
@@ -38,12 +38,43 @@ for (const extension of extensions_1.extensions) {
|
|
|
38
38
|
parseConfigFileHost = extension.extendParseConfigFileHost(parseConfigFileHost);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function getUserProvidedConfigOverwrite() {
|
|
42
|
+
return worker_config_1.config.configOverwrite || {};
|
|
43
|
+
}
|
|
44
|
+
function getImplicitConfigOverwrite() {
|
|
45
|
+
const baseCompilerOptionsOverwrite = {
|
|
46
|
+
skipLibCheck: true,
|
|
47
|
+
sourceMap: false,
|
|
48
|
+
inlineSourceMap: false,
|
|
49
|
+
};
|
|
50
|
+
switch (worker_config_1.config.mode) {
|
|
51
|
+
case 'write-dts':
|
|
52
|
+
return {
|
|
53
|
+
compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: true, noEmit: false }),
|
|
54
|
+
};
|
|
55
|
+
case 'write-tsbuildinfo':
|
|
56
|
+
case 'write-references':
|
|
57
|
+
return {
|
|
58
|
+
compilerOptions: Object.assign(Object.assign({}, baseCompilerOptionsOverwrite), { declaration: true, emitDeclarationOnly: false, noEmit: false }),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
compilerOptions: baseCompilerOptionsOverwrite,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function applyConfigOverwrite(baseConfig, ...overwriteConfigs) {
|
|
66
|
+
let config = baseConfig;
|
|
67
|
+
for (const overwriteConfig of overwriteConfigs) {
|
|
68
|
+
config = Object.assign(Object.assign(Object.assign({}, (config || {})), (overwriteConfig || {})), { compilerOptions: Object.assign(Object.assign({}, ((config === null || config === void 0 ? void 0 : config.compilerOptions) || {})), ((overwriteConfig === null || overwriteConfig === void 0 ? void 0 : overwriteConfig.compilerOptions) || {})) });
|
|
69
|
+
}
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
function parseConfig(configFileName, configFileContext) {
|
|
42
73
|
const configFilePath = (0, forward_slash_1.forwardSlash)(configFileName);
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(
|
|
46
|
-
return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFilePath }), errors:
|
|
74
|
+
const { config: baseConfig, error: readConfigError } = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
|
|
75
|
+
const overwrittenConfig = applyConfigOverwrite(baseConfig || {}, getImplicitConfigOverwrite(), getUserProvidedConfigOverwrite());
|
|
76
|
+
const parsedConfigFile = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfig, parseConfigFileHost, configFileContext);
|
|
77
|
+
return Object.assign(Object.assign({}, parsedConfigFile), { options: Object.assign(Object.assign({}, parsedConfigFile.options), { configFilePath: configFilePath }), errors: readConfigError ? [readConfigError] : parsedConfigFile.errors });
|
|
47
78
|
}
|
|
48
79
|
exports.parseConfig = parseConfig;
|
|
49
80
|
function getParseConfigIssues() {
|
|
@@ -58,19 +89,8 @@ function getParseConfigIssues() {
|
|
|
58
89
|
exports.getParseConfigIssues = getParseConfigIssues;
|
|
59
90
|
function getParsedConfig(force = false) {
|
|
60
91
|
if (!parsedConfig || force) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const configFilePath = (0, forward_slash_1.forwardSlash)(worker_config_1.config.configFile);
|
|
64
|
-
const parsedConfigFileJSON = typescript_1.typescript.readConfigFile(configFilePath, parseConfigFileHost.readFile);
|
|
65
|
-
const overwrittenConfigFileJSON = Object.assign(Object.assign(Object.assign({}, (parsedConfigFileJSON.config || {})), worker_config_1.config.configOverwrite), { compilerOptions: Object.assign(Object.assign({}, ((parsedConfigFileJSON.config || {}).compilerOptions || {})), (worker_config_1.config.configOverwrite.compilerOptions || {})) });
|
|
66
|
-
parsedConfig = typescript_1.typescript.parseJsonConfigFileContent(overwrittenConfigFileJSON, parseConfigFileHost, worker_config_1.config.context);
|
|
67
|
-
parsedConfig.options.configFilePath = configFilePath;
|
|
68
|
-
parsedConfig.errors = parsedConfigFileJSON.error
|
|
69
|
-
? [parsedConfigFileJSON.error]
|
|
70
|
-
: parsedConfig.errors;
|
|
71
|
-
if (parsedConfig.errors) {
|
|
72
|
-
parseConfigDiagnostics.push(...parsedConfig.errors);
|
|
73
|
-
}
|
|
92
|
+
parsedConfig = parseConfig(worker_config_1.config.configFile, worker_config_1.config.context);
|
|
93
|
+
parseConfigDiagnostics = parsedConfig.errors || [];
|
|
74
94
|
}
|
|
75
95
|
return parsedConfig;
|
|
76
96
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitDtsIfNeeded = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const worker_config_1 = require("./worker-config");
|
|
6
|
+
function emitDtsIfNeeded(program) {
|
|
7
|
+
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
8
|
+
if (worker_config_1.config.mode === 'write-dts' && parsedConfig.options.declaration) {
|
|
9
|
+
// emit .d.ts files only
|
|
10
|
+
program.emit(undefined, undefined, undefined, true);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.emitDtsIfNeeded = emitDtsIfNeeded;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.invalidateProgram = exports.useProgram = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const diagnostics_1 = require("../diagnostics");
|
|
6
|
+
const emit_1 = require("../emit");
|
|
6
7
|
const compiler_host_1 = require("../host/compiler-host");
|
|
7
8
|
const typescript_1 = require("../typescript");
|
|
8
9
|
let compilerHost;
|
|
@@ -21,6 +22,7 @@ function useProgram() {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
(0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromProgram)(program), (0, diagnostics_1.getDiagnosticsOfProgram)(program));
|
|
25
|
+
(0, emit_1.emitDtsIfNeeded)(program);
|
|
24
26
|
}
|
|
25
27
|
exports.useProgram = useProgram;
|
|
26
28
|
function invalidateProgram(withHost = false) {
|
|
@@ -4,6 +4,7 @@ exports.invalidateWatchProgramRootFileNames = exports.invalidateWatchProgram = e
|
|
|
4
4
|
const config_1 = require("../config");
|
|
5
5
|
const dependencies_1 = require("../dependencies");
|
|
6
6
|
const diagnostics_1 = require("../diagnostics");
|
|
7
|
+
const emit_1 = require("../emit");
|
|
7
8
|
const watch_compiler_host_1 = require("../host/watch-compiler-host");
|
|
8
9
|
const tracing_1 = require("../tracing");
|
|
9
10
|
const tsbuildinfo_1 = require("../tsbuildinfo");
|
|
@@ -21,6 +22,7 @@ function useWatchProgram() {
|
|
|
21
22
|
return typescript_1.typescript.createSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
22
23
|
}, undefined, undefined, (builderProgram) => {
|
|
23
24
|
(0, diagnostics_1.updateDiagnostics)((0, config_1.getConfigFilePathFromBuilderProgram)(builderProgram), (0, diagnostics_1.getDiagnosticsOfProgram)(builderProgram));
|
|
25
|
+
(0, emit_1.emitDtsIfNeeded)(builderProgram);
|
|
24
26
|
(0, tsbuildinfo_1.emitTsBuildInfoIfNeeded)(builderProgram);
|
|
25
27
|
(0, tracing_1.stopTracingIfNeeded)(builderProgram);
|
|
26
28
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-ts-checker-webpack-plugin",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"jest": "^27.4.7",
|
|
108
108
|
"jest-circus": "^27.4.6",
|
|
109
109
|
"jest-environment-node": "^27.4.6",
|
|
110
|
-
"json-schema": "^0.
|
|
110
|
+
"json-schema": "^0.4.0",
|
|
111
111
|
"karton": "^0.4.1",
|
|
112
112
|
"lint-staged": "^11.1.2",
|
|
113
113
|
"mock-fs": "^5.1.2",
|