Skip to content

Commit

Permalink
feat: drop support for webpack 1 and 3
Browse files Browse the repository at this point in the history
We drop support for webpack < 4.0 to simplify our codebase and prepare for further refactoring.

BREAKING CHANGE: 🧨 Dropped support for webpack 2.0 and webpack 3.0
  • Loading branch information
piotr-oles committed Dec 20, 2019
1 parent a7dd2a2 commit 157aa02
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 2,649 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ jobs:
packages:
- webpack@5.0.0-alpha.5 ts-loader@^5.0.0 vue-loader@^15.2.4
- webpack@^4.0.0 ts-loader@^5.0.0 vue-loader@^15.2.4
- webpack@^3.10.0 ts-loader@^3.4.0 vue-loader@^13.5.0
- webpack@^2.7.0 ts-loader@^3.4.0 vue-loader@^13.5.0

steps:
- uses: actions/checkout@v1
Expand Down Expand Up @@ -117,11 +115,14 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Install semantic-release
run: yarn global add semantic-release@16.0.0-beta.18

- name: Download build artifact
uses: actions/download-artifact@v1
with:
name: lib

- name: Release
run: yarn exec semantic-release
run: semantic-release
33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

## Installation

This plugin requires minimum **webpack 2.3**, **TypeScript 2.1** and optionally **ESLint 6.0.0** or **TSLint 4.0**
This plugin requires minimum **webpack 4.0**, **TypeScript 2.1** and optionally **ESLint 6.0.0** or **TSLint 4.0**

If you depend on **webpack 2.0** or **webpack 3.0**, please use [older version](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.

```sh
# with npm
Expand Down Expand Up @@ -273,26 +275,21 @@ We hope this will be resolved in future; the issue can be tracked [here](https:/

This plugin provides some custom webpack hooks (all are sync):

| Event name | Hook Access Key | Description | Params |
| --------------------------------------- | -------------------- | ------------------------------------------------------------------------------ | ------------------------------------------- |
| `fork-ts-checker-cancel` | `cancel` | Cancellation has been requested | `cancellationToken` |
| `fork-ts-checker-waiting` | `waiting` | Waiting for results | `hasTsLint` |
| `fork-ts-checker-service-before-start` | `serviceBeforeStart` | Async plugin that can be used for delaying `fork-ts-checker-service-start` | - |
| `fork-ts-checker-service-start` | `serviceStart` | Service will be started | `tsconfigPath`, `tslintPath`, `memoryLimit` |
| `fork-ts-checker-service-start-error` | `serviceStartError` | Cannot start service | `error` |
| `fork-ts-checker-service-out-of-memory` | `serviceOutOfMemory` | Service is out of memory | - |
| `fork-ts-checker-receive` | `receive` | Plugin receives diagnostics and lints from service | `diagnostics`, `lints` |
| `fork-ts-checker-emit` | `emit` | Service will add errors and warnings to webpack compilation ('build' mode) | `diagnostics`, `lints`, `elapsed` |
| `fork-ts-checker-done` | `done` | Service finished type checking and webpack finished compilation ('watch' mode) | `diagnostics`, `lints`, `elapsed` |

The **Event name** is there for backward compatibility with webpack 2/3. Regardless
of the version of webpack (2, 3 or 4) you are using, we will always access plugin hooks with **Hook Access Keys** as
described below.
| Hook Access Key | Description | Params |
| -------------------- | ------------------------------------------------------------------------------ | ------------------------------------------- |
| `cancel` | Cancellation has been requested | `cancellationToken` |
| `waiting` | Waiting for results | `hasTsLint` |
| `serviceBeforeStart` | Async plugin that can be used for delaying `fork-ts-checker-service-start` | - |
| `serviceStart` | Service will be started | `tsconfigPath`, `tslintPath`, `memoryLimit` |
| `serviceStartError` | Cannot start service | `error` |
| `serviceOutOfMemory` | Service is out of memory | - |
| `receive` | Plugin receives diagnostics and lints from service | `diagnostics`, `lints` |
| `emit` | Service will add errors and warnings to webpack compilation ('build' mode) | `diagnostics`, `lints`, `elapsed` |
| `done` | Service finished type checking and webpack finished compilation ('watch' mode) | `diagnostics`, `lints`, `elapsed` |

### Accessing plugin hooks

All plugin hooks are compatible with both [webpack](https://webpack.js.org) version
4 and version 2. To access plugin hooks and tap into the event, we need to use
To access plugin hooks and tap into the event, we need to use
the `getCompilerHooks` static method. When we call this method with a [webpack compiler instance](https://webpack.js.org/api/node/),
it returns the series of [tapable](https://github.com/webpack/tapable)
hooks where you can pass in your callbacks.
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
"nativescript-vue-template-compiler": "^2.4.0",
"prettier": "^1.14.3",
"rimraf": "^3.0.0",
"semantic-release": "^16.0.0-beta.18",
"ts-loader": "^5.0.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.16.0",
Expand Down
13 changes: 0 additions & 13 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,9 @@ type ForkTsCheckerHookMap = Record<
ForkTsCheckerHooks,
SyncHook | AsyncSeriesHook
>;
type ForkTsCheckerLegacyHookMap = Record<ForkTsCheckerHooks, string>;

const compilerHookMap = new WeakMap<webpack.Compiler, ForkTsCheckerHookMap>();

export const legacyHookMap: ForkTsCheckerLegacyHookMap = {
serviceBeforeStart: 'fork-ts-checker-service-before-start',
cancel: 'fork-ts-checker-cancel',
serviceStartError: 'fork-ts-checker-service-start-error',
waiting: 'fork-ts-checker-waiting',
serviceStart: 'fork-ts-checker-service-start',
receive: 'fork-ts-checker-receive',
serviceOutOfMemory: 'fork-ts-checker-service-out-of-memory',
emit: 'fork-ts-checker-emit',
done: 'fork-ts-checker-done'
};

function createForkTsCheckerWebpackPluginHooks(): ForkTsCheckerHookMap {
return {
serviceBeforeStart: new AsyncSeriesHook([]),
Expand Down
Loading

0 comments on commit 157aa02

Please sign in to comment.