Skip to content

Commit cdb531f

Browse files
authored
feat: drop support for webpack 4 (#638)
BREAKING CHANGE: 🧨 Webpack 4 is no longer supported. Please upgrade to Webpack ^5.11.0 or use an older version of the plugin.
1 parent 3e23b88 commit cdb531f

36 files changed

+737
-1438
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
## Installation
2323

24-
This plugin requires minimum **Node.js 12**, **Webpack 5**, **TypeScript 3.6**
24+
This plugin requires minimum **Node.js 12+**, **Webpack ^5.11.0**, **TypeScript ^3.6.0**
2525

2626
* If you depend on **TypeScript 2.1 - 2.6.2**, please use [version 4](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v4.1.4) of the plugin.
2727
* If you depend on **Webpack 4**, **TypeScript 2.7 - 3.5.3** or **ESLint** feature, please use [version 6](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v6.2.6) of the plugin.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@
7272
"minimatch": "^3.0.4",
7373
"schema-utils": "2.7.0",
7474
"semver": "^7.3.2",
75-
"tapable": "^1.0.0"
75+
"tapable": "^2.0.0"
76+
},
77+
"peerDependencies": {
78+
"webpack": "^5.11.0"
7679
},
7780
"devDependencies": {
7881
"@commitlint/config-conventional": "^11.0.0",
@@ -90,7 +93,6 @@
9093
"@types/node": "^14.11.10",
9194
"@types/rimraf": "^3.0.0",
9295
"@types/semver": "^7.3.4",
93-
"@types/webpack": "^4.41.22",
9496
"@typescript-eslint/eslint-plugin": "^2.27.0",
9597
"@typescript-eslint/parser": "^2.27.0",
9698
"commitlint": "^11.0.0",
@@ -115,7 +117,7 @@
115117
"tree-kill": "^1.2.2",
116118
"ts-jest": "^26.4.1",
117119
"typescript": "^3.8.3",
118-
"webpack": "^4.42.1"
120+
"webpack": "^5.11.0"
119121
},
120122
"engines": {
121123
"node": ">=10",

src/ForkTsCheckerWebpackPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { tapAfterEnvironmentToPatchWatching } from './hooks/tapAfterEnvironmentT
2121
import { createPool, Pool } from './utils/async/pool';
2222
import os from 'os';
2323

24-
class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
24+
class ForkTsCheckerWebpackPlugin {
2525
/**
2626
* Current version of the plugin
2727
*/

src/ForkTsCheckerWebpackPluginState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Tap } from 'tapable';
1+
import { FullTap } from 'tapable';
22
import { FilesMatch, Report } from './reporter';
33
import { Issue } from './issue';
44

@@ -9,7 +9,7 @@ interface ForkTsCheckerWebpackPluginState {
99
lastDependencies: FilesMatch | undefined;
1010
watching: boolean;
1111
initialized: boolean;
12-
webpackDevServerDoneTap: Tap | undefined;
12+
webpackDevServerDoneTap: FullTap | undefined;
1313
}
1414

1515
function createForkTsCheckerWebpackPluginState(): ForkTsCheckerWebpackPluginState {

src/hooks/pluginHooks.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const compilerHookMap = new WeakMap<
1010

1111
function createForkTsCheckerWebpackPluginHooks() {
1212
return {
13-
start: new AsyncSeriesWaterfallHook<FilesChange, webpack.compilation.Compilation>([
13+
start: new AsyncSeriesWaterfallHook<[FilesChange, webpack.Compilation]>([
1414
'change',
1515
'compilation',
1616
]),
17-
waiting: new SyncHook<webpack.compilation.Compilation>(['compilation']),
18-
canceled: new SyncHook<webpack.compilation.Compilation>(['compilation']),
19-
error: new SyncHook<Error, webpack.compilation.Compilation>(['error', 'compilation']),
20-
issues: new SyncWaterfallHook<Issue[], webpack.compilation.Compilation | undefined, void>([
17+
waiting: new SyncHook<[webpack.Compilation]>(['compilation']),
18+
canceled: new SyncHook<[webpack.Compilation]>(['compilation']),
19+
error: new SyncHook<[Error, webpack.Compilation]>(['error', 'compilation']),
20+
issues: new SyncWaterfallHook<[Issue[], webpack.Compilation | undefined], void>([
2121
'issues',
2222
'compilation',
2323
]),

src/hooks/tapAfterEnvironmentToPatchWatching.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import webpack from 'webpack';
22
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
33
import { InclusiveNodeWatchFileSystem } from '../watch/InclusiveNodeWatchFileSystem';
4-
import { CompilerWithWatchFileSystem } from '../watch/CompilerWithWatchFileSystem';
4+
import { WatchFileSystem } from '../watch/WatchFileSystem';
55

66
function tapAfterEnvironmentToPatchWatching(
77
compiler: webpack.Compiler,
88
state: ForkTsCheckerWebpackPluginState
99
) {
1010
compiler.hooks.afterEnvironment.tap('ForkTsCheckerWebpackPlugin', () => {
11-
const watchFileSystem = (compiler as CompilerWithWatchFileSystem).watchFileSystem;
11+
const watchFileSystem = compiler.watchFileSystem;
1212
if (watchFileSystem) {
1313
// wrap original watch file system
14-
(compiler as CompilerWithWatchFileSystem).watchFileSystem = new InclusiveNodeWatchFileSystem(
15-
watchFileSystem,
14+
compiler.watchFileSystem = new InclusiveNodeWatchFileSystem(
15+
// we use some internals here
16+
watchFileSystem as WatchFileSystem,
1617
compiler,
1718
state
1819
);

src/hooks/tapDoneToAsyncGetIssues.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function tapDoneToAsyncGetIssues(
8383
}
8484

8585
if (stats.startTime) {
86-
configuration.logger.infrastructure.info(
86+
configuration.logger.infrastructure.log(
8787
`Time: ${Math.round(Date.now() - stats.startTime).toString()} ms`
8888
);
8989
}

src/hooks/tapStartToConnectAndRunReporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ function tapStartToConnectAndRunReporter(
5252
if (state.watching) {
5353
change = getFilesChange(compiler);
5454

55-
configuration.logger.infrastructure.info(
55+
configuration.logger.infrastructure.log(
5656
[
5757
'Calling reporter service for incremental check.',
5858
` Changed files: ${JSON.stringify(change.changedFiles)}`,
5959
` Deleted files: ${JSON.stringify(change.deletedFiles)}`,
6060
].join('\n')
6161
);
6262
} else {
63-
configuration.logger.infrastructure.info('Calling reporter service for single check.');
63+
configuration.logger.infrastructure.log('Calling reporter service for single check.');
6464
}
6565

6666
let resolveDependencies: (dependencies: FilesMatch | undefined) => void;

src/issue/IssueWebpackError.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import webpack from 'webpack';
12
import { relative } from 'path';
23
import { Issue } from './Issue';
34
import { formatIssueLocation } from './IssueLocation';
45
import forwardSlash from '../utils/path/forwardSlash';
56

6-
class IssueWebpackError extends Error {
7+
class IssueWebpackError extends webpack.WebpackError {
78
readonly hideStack = true;
8-
readonly file: string | undefined;
9+
readonly file: string = '';
910

1011
constructor(message: string, readonly issue: Issue) {
1112
super(message);

src/logger/LoggerConfiguration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ function createLoggerConfiguration(
1414
options: LoggerOptions | undefined
1515
): LoggerConfiguration {
1616
return {
17-
infrastructure: createLogger((options && options.infrastructure) || 'silent', compiler),
17+
infrastructure: createLogger(
18+
(options && options.infrastructure) || 'webpack-infrastructure',
19+
compiler
20+
),
1821
issues: createLogger((options && options.issues) || 'console', compiler),
1922
devServer: options?.devServer !== false,
2023
};

0 commit comments

Comments
 (0)