Socket
Socket
Sign inDemoInstall

fork-ts-checker-webpack-plugin

Package Overview
Dependencies
9
Maintainers
4
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.2 to 1.0.0-alpha.0

lib/hooks.d.ts

16

CHANGELOG.md

@@ -0,1 +1,17 @@

## v1.0.0-alpha.0
* [Add support for webpack 5](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/166)
### Breaking Changes
Version `1.x` additionally supports webpack 5 alongside webpack 4, whose hooks are now tapped differently:
```diff
- compiler.hooks.forkTsCheckerDone.tap(...args)
+ const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler)
+ forkTsCheckerHooks.done.tap(...args)
```
v1.0.0-alpha.0 drops support for node 6.
## v0.5.2

@@ -2,0 +18,0 @@

2

lib/index.d.ts

@@ -42,2 +42,3 @@ import * as webpack from 'webpack';

static readonly TWO_CPUS_FREE: number;
static getCompilerHooks(compiler: webpack.Compiler): Record<"waiting" | "cancel" | "done" | "serviceBeforeStart" | "serviceStartError" | "serviceStart" | "receive" | "serviceOutOfMemory" | "emit", import("tapable").SyncHook<any, any, any> | import("tapable").AsyncSeriesHook<any, any, any>>;
readonly options: Partial<Options>;

@@ -85,3 +86,2 @@ private tsconfig;

private pluginStop;
private registerCustomHooks;
private pluginCompile;

@@ -88,0 +88,0 @@ private pluginEmit;

@@ -13,15 +13,4 @@ "use strict";

const FsHelper_1 = require("./FsHelper");
const tapable_1 = require("tapable");
const hooks_1 = require("./hooks");
const checkerPluginName = 'fork-ts-checker-webpack-plugin';
const customHooks = {
forkTsCheckerServiceBeforeStart: 'fork-ts-checker-service-before-start',
forkTsCheckerCancel: 'fork-ts-checker-cancel',
forkTsCheckerServiceStartError: 'fork-ts-checker-service-start-error',
forkTsCheckerWaiting: 'fork-ts-checker-waiting',
forkTsCheckerServiceStart: 'fork-ts-checker-service-start',
forkTsCheckerReceive: 'fork-ts-checker-receive',
forkTsCheckerServiceOutOfMemory: 'fork-ts-checker-service-out-of-memory',
forkTsCheckerEmit: 'fork-ts-checker-emit',
forkTsCheckerDone: 'fork-ts-checker-done'
};
/**

@@ -87,2 +76,5 @@ * ForkTsCheckerWebpackPlugin

}
static getCompilerHooks(compiler) {
return hooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
}
static createFormatter(type, options) {

@@ -115,5 +107,2 @@ switch (type) {

if (tsconfigOk && tslintOk) {
if ('hooks' in compiler) {
this.registerCustomHooks();
}
this.pluginStart();

@@ -165,3 +154,3 @@ this.pluginStop();

if ('hooks' in this.compiler) {
// webpack 4
// webpack 4+
this.compiler.hooks.run.tapAsync(checkerPluginName, run);

@@ -186,3 +175,3 @@ this.compiler.hooks.watchRun.tapAsync(checkerPluginName, watchRun);

if ('hooks' in this.compiler) {
// webpack 4
// webpack 4+
this.compiler.hooks.watchClose.tap(checkerPluginName, watchClose);

@@ -200,73 +189,13 @@ this.compiler.hooks.done.tap(checkerPluginName, done);

}
registerCustomHooks() {
if (this.compiler.hooks.forkTsCheckerServiceBeforeStart ||
this.compiler.hooks.forkTsCheckerCancel ||
this.compiler.hooks.forkTsCheckerServiceStartError ||
this.compiler.hooks.forkTsCheckerWaiting ||
this.compiler.hooks.forkTsCheckerServiceStart ||
this.compiler.hooks.forkTsCheckerReceive ||
this.compiler.hooks.forkTsCheckerServiceOutOfMemory ||
this.compiler.hooks.forkTsCheckerDone ||
this.compiler.hooks.forkTsCheckerEmit) {
throw new Error('fork-ts-checker-webpack-plugin hooks are already in use');
}
this.compiler.hooks.forkTsCheckerServiceBeforeStart = new tapable_1.AsyncSeriesHook([]);
this.compiler.hooks.forkTsCheckerCancel = new tapable_1.SyncHook([
'cancellationToken'
]);
this.compiler.hooks.forkTsCheckerServiceStartError = new tapable_1.SyncHook([
'error'
]);
this.compiler.hooks.forkTsCheckerWaiting = new tapable_1.SyncHook(['hasTsLint']);
this.compiler.hooks.forkTsCheckerServiceStart = new tapable_1.SyncHook([
'tsconfigPath',
'tslintPath',
'watchPaths',
'workersNumber',
'memoryLimit'
]);
this.compiler.hooks.forkTsCheckerReceive = new tapable_1.SyncHook([
'diagnostics',
'lints'
]);
this.compiler.hooks.forkTsCheckerServiceOutOfMemory = new tapable_1.SyncHook([]);
this.compiler.hooks.forkTsCheckerEmit = new tapable_1.SyncHook([
'diagnostics',
'lints',
'elapsed'
]);
this.compiler.hooks.forkTsCheckerDone = new tapable_1.SyncHook([
'diagnostics',
'lints',
'elapsed'
]);
// for backwards compatibility
this.compiler._pluginCompat.tap(checkerPluginName, (options) => {
switch (options.name) {
case customHooks.forkTsCheckerServiceBeforeStart:
options.async = true;
break;
case customHooks.forkTsCheckerCancel:
case customHooks.forkTsCheckerServiceStartError:
case customHooks.forkTsCheckerWaiting:
case customHooks.forkTsCheckerServiceStart:
case customHooks.forkTsCheckerReceive:
case customHooks.forkTsCheckerServiceOutOfMemory:
case customHooks.forkTsCheckerEmit:
case customHooks.forkTsCheckerDone:
return true;
}
return undefined;
});
}
pluginCompile() {
if ('hooks' in this.compiler) {
// webpack 4
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
this.compiler.hooks.compile.tap(checkerPluginName, () => {
this.compilationDone = false;
this.compiler.hooks.forkTsCheckerServiceBeforeStart.callAsync(() => {
forkTsCheckerHooks.serviceBeforeStart.callAsync(() => {
if (this.cancellationToken) {
// request cancellation if there is not finished job
this.cancellationToken.requestCancellation();
this.compiler.hooks.forkTsCheckerCancel.call(this.cancellationToken);
forkTsCheckerHooks.cancel.call(this.cancellationToken);
}

@@ -288,3 +217,3 @@ this.checkDone = false;

}
this.compiler.hooks.forkTsCheckerServiceStartError.call(error);
forkTsCheckerHooks.serviceStartError.call(error);
}

@@ -298,7 +227,7 @@ });

this.compilationDone = false;
this.compiler.applyPluginsAsync('fork-ts-checker-service-before-start', () => {
this.compiler.applyPluginsAsync(hooks_1.legacyHookMap.serviceBeforeStart, () => {
if (this.cancellationToken) {
// request cancellation if there is not finished job
this.cancellationToken.requestCancellation();
this.compiler.applyPlugins('fork-ts-checker-cancel', this.cancellationToken);
this.compiler.applyPlugins(hooks_1.legacyHookMap.cancel, this.cancellationToken);
}

@@ -320,3 +249,3 @@ this.checkDone = false;

}
this.compiler.applyPlugins('fork-ts-checker-service-start-error', error);
this.compiler.applyPlugins(hooks_1.legacyHookMap.serviceStartError, error);
}

@@ -340,3 +269,3 @@ });

if ('hooks' in this.compiler) {
// webpack 4
// webpack 4+
this.compiler.hooks.emit.tapAsync(checkerPluginName, emit);

@@ -351,3 +280,4 @@ }

if ('hooks' in this.compiler) {
// webpack 4
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
this.compiler.hooks.done.tap(checkerPluginName, (_stats) => {

@@ -362,3 +292,3 @@ if (!this.isWatching || !this.async) {

if (this.compiler) {
this.compiler.hooks.forkTsCheckerWaiting.call(this.tslint !== false);
forkTsCheckerHooks.waiting.call(this.tslint !== false);
}

@@ -385,3 +315,3 @@ if (!this.silent && this.logger) {

if (this.compiler) {
this.compiler.applyPlugins('fork-ts-checker-waiting', this.tslint !== false);
this.compiler.applyPlugins(hooks_1.legacyHookMap.waiting, this.tslint !== false);
}

@@ -417,8 +347,9 @@ if (!this.silent && this.logger) {

if ('hooks' in this.compiler) {
// webpack 4
this.compiler.hooks.forkTsCheckerServiceStart.call(this.tsconfigPath, this.tslintPath, this.watchPaths, this.workersNumber, this.memoryLimit);
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
forkTsCheckerHooks.serviceStart.call(this.tsconfigPath, this.tslintPath, this.watchPaths, this.workersNumber, this.memoryLimit);
}
else {
// webpack 2 / 3
this.compiler.applyPlugins('fork-ts-checker-service-start', this.tsconfigPath, this.tslintPath, this.watchPaths, this.workersNumber, this.memoryLimit);
this.compiler.applyPlugins(hooks_1.legacyHookMap.serviceStart, this.tsconfigPath, this.tslintPath, this.watchPaths, this.workersNumber, this.memoryLimit);
}

@@ -493,8 +424,9 @@ if (!this.silent && this.logger) {

if ('hooks' in this.compiler) {
// webpack 4
this.compiler.hooks.forkTsCheckerReceive.call(this.diagnostics, this.lints);
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
forkTsCheckerHooks.receive.call(this.diagnostics, this.lints);
}
else {
// webpack 2 / 3
this.compiler.applyPlugins('fork-ts-checker-receive', this.diagnostics, this.lints);
this.compiler.applyPlugins(hooks_1.legacyHookMap.receive, this.diagnostics, this.lints);
}

@@ -512,8 +444,9 @@ if (this.compilationDone) {

if ('hooks' in this.compiler) {
// webpack 4
this.compiler.hooks.forkTsCheckerServiceOutOfMemory.call();
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
forkTsCheckerHooks.serviceOutOfMemory.call();
}
else {
// webpack 2 / 3
this.compiler.applyPlugins('fork-ts-checker-service-out-of-memory');
this.compiler.applyPlugins(hooks_1.legacyHookMap.serviceOutOfMemory);
}

@@ -533,8 +466,9 @@ }

if ('hooks' in this.compiler) {
// webpack 4
this.compiler.hooks.forkTsCheckerEmit.call(this.diagnostics, this.lints, elapsed);
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
forkTsCheckerHooks.emit.call(this.diagnostics, this.lints, elapsed);
}
else {
// webpack 2 / 3
this.compiler.applyPlugins('fork-ts-checker-emit', this.diagnostics, this.lints, elapsed);
this.compiler.applyPlugins(hooks_1.legacyHookMap.emit, this.diagnostics, this.lints, elapsed);
}

@@ -578,8 +512,9 @@ this.diagnostics.concat(this.lints).forEach(message => {

if ('hooks' in this.compiler) {
// webpack 4
this.compiler.hooks.forkTsCheckerDone.call(this.diagnostics, this.lints, elapsed);
// webpack 4+
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(this.compiler);
forkTsCheckerHooks.done.call(this.diagnostics, this.lints, elapsed);
}
else {
// webpack 2 / 3
this.compiler.applyPlugins('fork-ts-checker-done', this.diagnostics, this.lints, elapsed);
this.compiler.applyPlugins(hooks_1.legacyHookMap.done, this.diagnostics, this.lints, elapsed);
}

@@ -586,0 +521,0 @@ }

{
"name": "fork-ts-checker-webpack-plugin",
"version": "0.5.2",
"version": "1.0.0-alpha.0",
"description": "Runs typescript type checker and linter on separate process.",

@@ -40,3 +40,3 @@ "main": "lib/index.js",

"engines": {
"node": ">=6.11.5"
"node": ">=8.9.0"
},

@@ -79,3 +79,3 @@ "author": "Piotr Oleś <piotrek.oles@gmail.com>",

"vue-template-compiler": "^2.5.16",
"webpack": "^4.0.0"
"webpack": "^5.0.0-alpha.0"
},

@@ -82,0 +82,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc