Skip to content

Commit ad466df

Browse files
authored
feat: port changes from main branch (#649)
This commit contains fixes from the main branch
1 parent 82e8448 commit ad466df

22 files changed

+259
-178
lines changed

.github/stale.yml

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
# Configuration for probot-stale - https://github.com/probot/stale
2-
3-
# Number of days of inactivity before an Issue or Pull Request becomes stale
1+
# Number of days of inactivity before an issue becomes stale
42
daysUntilStale: 60
5-
6-
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7-
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8-
daysUntilClose: 14
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- pinned
8+
- security
9+
# Label to use when marking an issue as stale
10+
staleLabel: wontfix
11+
# Comment to post when marking an issue as stale. Set to `false` to disable
12+
markComment: >
13+
This issue has been automatically marked as stale because it has not had
14+
recent activity. It will be closed if no further activity occurs. Thank you
15+
for your contributions.
16+
# Comment to post when closing a stale issue. Set to `false` to disable
17+
closeComment: false

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,17 @@ Options passed to the plugin constructor will overwrite options from the cosmico
8888
| Name | Type | Default value | Description |
8989
| ----------------- | ---------------------------------- | ------------------------------------------------------------------ | ----------- |
9090
| `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. |
91-
| `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
91+
| `typescript` | `object` | `{}` | See [TypeScript options](#typescript-options). |
9292
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
9393
| `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> } }`. |
94-
| `logger` | `object` | `{ infrastructure: 'silent', issues: 'console', devServer: true }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. If `devServer` is set to `false`, errors will not be reported to Webpack Dev Server. |
94+
| `logger` | `object` | `{ infrastructure: 'silent', issues: 'console', devServer: true }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. If `devServer` is set to `false`, errors will not be reported to Webpack Dev Server. |
9595

9696
### TypeScript options
9797

9898
Options for the TypeScript checker (`typescript` option object).
9999

100100
| Name | Type | Default value | Description |
101101
| -------------------- | --------- | -------------------------------------------------------------------------------------------------------------- | ----------- |
102-
| `enabled` | `boolean` | `true` | If `true`, it enables TypeScript checker. |
103102
| `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. |
104103
| `configFile` | `string` | `'tsconfig.json'` | Path to the `tsconfig.json` file (path relative to the `compiler.options.context` or absolute path) |
105104
| `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`. |

src/ForkTsCheckerWebpackPlugin.ts

+25-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import schema from './ForkTsCheckerWebpackPluginOptions.json';
99
import { ForkTsCheckerWebpackPluginOptions } from './ForkTsCheckerWebpackPluginOptions';
1010
import { createForkTsCheckerWebpackPluginConfiguration } from './ForkTsCheckerWebpackPluginConfiguration';
1111
import { createForkTsCheckerWebpackPluginState } from './ForkTsCheckerWebpackPluginState';
12-
import { composeReporterRpcClients, createAggregatedReporter, ReporterRpcClient } from './reporter';
1312
import { assertTypeScriptSupport } from './typescript-reporter/TypeScriptSupport';
1413
import { createTypeScriptReporterRpcClient } from './typescript-reporter/reporter/TypeScriptReporterRpcClient';
1514
import { tapStartToConnectAndRunReporter } from './hooks/tapStartToConnectAndRunReporter';
@@ -27,9 +26,18 @@ class ForkTsCheckerWebpackPlugin {
2726
*/
2827
static readonly version: string = '{{VERSION}}'; // will be replaced by the @semantic-release/exec
2928
/**
30-
* Default pool for the plugin concurrency limit
29+
* Default pools for the plugin concurrency limit
3130
*/
32-
static readonly pool: Pool = createPool(Math.max(1, os.cpus().length));
31+
static readonly issuesPool: Pool = createPool(Math.max(1, os.cpus().length));
32+
static readonly dependenciesPool: Pool = createPool(Math.max(1, os.cpus().length));
33+
34+
/**
35+
* @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
36+
*/
37+
static get pool(): Pool {
38+
// for backward compatibility
39+
return ForkTsCheckerWebpackPlugin.issuesPool;
40+
}
3341

3442
private readonly options: ForkTsCheckerWebpackPluginOptions;
3543

@@ -54,26 +62,22 @@ class ForkTsCheckerWebpackPlugin {
5462
apply(compiler: webpack.Compiler) {
5563
const configuration = createForkTsCheckerWebpackPluginConfiguration(compiler, this.options);
5664
const state = createForkTsCheckerWebpackPluginState();
57-
const reporters: ReporterRpcClient[] = [];
58-
59-
if (configuration.typescript.enabled) {
60-
assertTypeScriptSupport(configuration.typescript);
61-
reporters.push(createTypeScriptReporterRpcClient(configuration.typescript));
62-
}
6365

64-
if (reporters.length) {
65-
const reporter = createAggregatedReporter(composeReporterRpcClients(reporters));
66+
assertTypeScriptSupport(configuration.typescript);
67+
const issuesReporter = createTypeScriptReporterRpcClient(configuration.typescript);
68+
const dependenciesReporter = createTypeScriptReporterRpcClient(configuration.typescript);
6669

67-
tapAfterEnvironmentToPatchWatching(compiler, state);
68-
tapStartToConnectAndRunReporter(compiler, reporter, configuration, state);
69-
tapAfterCompileToAddDependencies(compiler, configuration, state);
70-
tapStopToDisconnectReporter(compiler, reporter, state);
71-
tapErrorToLogMessage(compiler, configuration);
72-
} else {
73-
throw new Error(
74-
`ForkTsCheckerWebpackPlugin is configured to not use any issue reporter. It's probably a configuration issue.`
75-
);
76-
}
70+
tapAfterEnvironmentToPatchWatching(compiler, state);
71+
tapStartToConnectAndRunReporter(
72+
compiler,
73+
issuesReporter,
74+
dependenciesReporter,
75+
configuration,
76+
state
77+
);
78+
tapAfterCompileToAddDependencies(compiler, configuration, state);
79+
tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state);
80+
tapErrorToLogMessage(compiler, configuration);
7781
}
7882
}
7983

src/ForkTsCheckerWebpackPluginOptions.json

+74-70
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,26 @@
3535
"additionalProperties": true
3636
}
3737
},
38-
"required": ["type"]
38+
"required": [
39+
"type"
40+
]
3941
},
40-
"FormatterType": {
42+
"FormatterType": {
4143
"type": "string",
42-
"enum": ["basic", "codeframe"]
44+
"enum": [
45+
"basic",
46+
"codeframe"
47+
]
4348
},
4449
"IssueMatch": {
4550
"type": "object",
4651
"properties": {
4752
"severity": {
4853
"type": "string",
49-
"enum": ["error", "warning"]
54+
"enum": [
55+
"error",
56+
"warning"
57+
]
5058
},
5159
"code": {
5260
"type": "string"
@@ -84,7 +92,11 @@
8492
},
8593
"LoggerType": {
8694
"type": "string",
87-
"enum": ["console", "webpack-infrastructure", "silent"]
95+
"enum": [
96+
"console",
97+
"webpack-infrastructure",
98+
"silent"
99+
]
88100
},
89101
"Logger": {
90102
"type": "object",
@@ -101,81 +113,73 @@
101113
}
102114
},
103115
"TypeScriptReporterOptions": {
104-
"oneOf": [
105-
{
116+
"type": "object",
117+
"properties": {
118+
"memoryLimit": {
119+
"type": "number",
120+
"description": "Memory limit for TypeScript reporter process."
121+
},
122+
"configFile": {
123+
"type": "string",
124+
"description": "Path to tsconfig.json. By default plugin uses context or process.cwd() to localize tsconfig.json file."
125+
},
126+
"context": {
127+
"type": "string",
128+
"description": "The base path for finding files specified in the tsconfig.json. Same as context option from the ts-loader."
129+
},
130+
"build": {
106131
"type": "boolean",
107-
"description": "Enable TypeScript reporter."
132+
"description": "The equivalent of the `--build` flag from the `tsc`."
108133
},
109-
{
134+
"mode": {
135+
"type": "string",
136+
"enum": [
137+
"readonly",
138+
"write-tsbuildinfo",
139+
"write-references"
140+
],
141+
"description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files and `write-references` which writes both .tsbuildinfo and referenced projects output"
142+
},
143+
"compilerOptions": {
144+
"type": "object",
145+
"description": "Custom compilerOptions to be passed to the TypeScript compiler.",
146+
"additionalProperties": true
147+
},
148+
"diagnosticOptions": {
110149
"type": "object",
150+
"description": "Types of diagnostics to be reported.",
111151
"properties": {
112-
"enabled": {
113-
"type": "boolean",
114-
"description": "Enable TypeScript reporter."
152+
"syntactic": {
153+
"type": "boolean"
115154
},
116-
"memoryLimit": {
117-
"type": "number",
118-
"description": "Memory limit for TypeScript reporter process."
155+
"semantic": {
156+
"type": "boolean"
119157
},
120-
"configFile": {
121-
"type": "string",
122-
"description": "Path to tsconfig.json. By default plugin uses context or process.cwd() to localize tsconfig.json file."
123-
},
124-
"context": {
125-
"type": "string",
126-
"description": "The base path for finding files specified in the tsconfig.json. Same as context option from the ts-loader."
158+
"declaration": {
159+
"type": "boolean"
127160
},
128-
"build": {
129-
"type": "boolean",
130-
"description": "The equivalent of the `--build` flag from the `tsc`."
131-
},
132-
"mode": {
133-
"type": "string",
134-
"enum": ["readonly", "write-tsbuildinfo", "write-references"],
135-
"description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files and `write-references` which writes both .tsbuildinfo and referenced projects output"
136-
},
137-
"compilerOptions": {
138-
"type": "object",
139-
"description": "Custom compilerOptions to be passed to the TypeScript compiler.",
140-
"additionalProperties": true
141-
},
142-
"diagnosticOptions": {
143-
"type": "object",
144-
"description": "Types of diagnostics to be reported.",
145-
"properties": {
146-
"syntactic": {
147-
"type": "boolean"
148-
},
149-
"semantic": {
150-
"type": "boolean"
151-
},
152-
"declaration": {
153-
"type": "boolean"
154-
},
155-
"global": {
156-
"type": "boolean"
157-
}
158-
}
159-
},
160-
"extensions": {
161-
"type": "object",
162-
"properties": {
163-
"vue": {
164-
"$ref": "#/definitions/TypeScriptVueExtensionOptions"
165-
}
166-
}
167-
},
168-
"profile": {
169-
"type": "boolean",
170-
"description": "Measures and prints timings related to the TypeScript performance."
171-
},
172-
"typescriptPath": {
173-
"type": "string",
174-
"description": "If supplied this is a custom path where TypeScript can be found."
161+
"global": {
162+
"type": "boolean"
175163
}
176164
}
165+
},
166+
"extensions": {
167+
"type": "object",
168+
"properties": {
169+
"vue": {
170+
"$ref": "#/definitions/TypeScriptVueExtensionOptions"
171+
}
172+
}
173+
},
174+
"profile": {
175+
"type": "boolean",
176+
"description": "Measures and prints timings related to the TypeScript performance."
177+
},
178+
"typescriptPath": {
179+
"type": "string",
180+
"description": "If supplied this is a custom path where TypeScript can be found."
177181
}
178-
]
182+
}
179183
},
180184
"TypeScriptVueExtensionOptions": {
181185
"oneOf": [

src/ForkTsCheckerWebpackPluginState.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { FilesMatch, Report } from './reporter';
33
import { Issue } from './issue';
44

55
interface ForkTsCheckerWebpackPluginState {
6-
reportPromise: Promise<Report | undefined>;
6+
issuesReportPromise: Promise<Report | undefined>;
7+
dependenciesReportPromise: Promise<Report | undefined>;
78
issuesPromise: Promise<Issue[] | undefined>;
89
dependenciesPromise: Promise<FilesMatch | undefined>;
910
lastDependencies: FilesMatch | undefined;
@@ -14,7 +15,8 @@ interface ForkTsCheckerWebpackPluginState {
1415

1516
function createForkTsCheckerWebpackPluginState(): ForkTsCheckerWebpackPluginState {
1617
return {
17-
reportPromise: Promise.resolve(undefined),
18+
issuesReportPromise: Promise.resolve(undefined),
19+
dependenciesReportPromise: Promise.resolve(undefined),
1820
issuesPromise: Promise.resolve(undefined),
1921
dependenciesPromise: Promise.resolve(undefined),
2022
lastDependencies: undefined,

src/hooks/tapDoneToAsyncGetIssues.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function tapDoneToAsyncGetIssues(
2222
return;
2323
}
2424

25-
const reportPromise = state.reportPromise;
25+
const reportPromise = state.issuesReportPromise;
2626
const issuesPromise = state.issuesPromise;
2727
let issues: Issue[] | undefined;
2828

@@ -46,7 +46,7 @@ function tapDoneToAsyncGetIssues(
4646
return;
4747
}
4848

49-
if (reportPromise !== state.reportPromise) {
49+
if (reportPromise !== state.issuesReportPromise) {
5050
// there is a newer report - ignore this one
5151
return;
5252
}

0 commit comments

Comments
 (0)