Socket
Socket
Sign inDemoInstall

fork-ts-checker-webpack-plugin

Package Overview
Dependencies
132
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-alpha.3 to 7.0.0-alpha.4

lib/reporter/FilesMatch.d.ts

12

lib/ForkTsCheckerWebpackPlugin.d.ts
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginOptions } from './ForkTsCheckerWebpackPluginOptions';
import { Pool } from './utils/async/pool';
declare class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
declare class ForkTsCheckerWebpackPlugin {
/**

@@ -16,7 +16,7 @@ * Current version of the plugin

static getCompilerHooks(compiler: webpack.Compiler): {
start: import("tapable").AsyncSeriesWaterfallHook<import("./reporter/FilesChange").FilesChange, webpack.compilation.Compilation, any>;
waiting: import("tapable").SyncHook<webpack.compilation.Compilation, any, any>;
canceled: import("tapable").SyncHook<webpack.compilation.Compilation, any, any>;
error: import("tapable").SyncHook<Error, webpack.compilation.Compilation, any>;
issues: import("tapable").SyncWaterfallHook<import("./issue/Issue").Issue[], webpack.compilation.Compilation | undefined, void>;
start: import("tapable").AsyncSeriesWaterfallHook<[import("./reporter/FilesChange").FilesChange, webpack.Compilation], import("tapable").UnsetAdditionalOptions>;
waiting: import("tapable").SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
canceled: import("tapable").SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
error: import("tapable").SyncHook<[Error, webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
issues: import("tapable").SyncWaterfallHook<[import("./issue/Issue").Issue[], webpack.Compilation | undefined], void>;
};

@@ -23,0 +23,0 @@ apply(compiler: webpack.Compiler): void;

@@ -62,3 +62,3 @@ "use strict";

*/
ForkTsCheckerWebpackPlugin.version = '7.0.0-alpha.3'; // will be replaced by the @semantic-release/exec
ForkTsCheckerWebpackPlugin.version = '7.0.0-alpha.4'; // will be replaced by the @semantic-release/exec
/**

@@ -65,0 +65,0 @@ * Default pool for the plugin concurrency limit

@@ -1,3 +0,3 @@

import { Tap } from 'tapable';
import { Dependencies, Report } from './reporter';
import { FullTap } from 'tapable';
import { FilesMatch, Report } from './reporter';
import { Issue } from './issue';

@@ -7,9 +7,9 @@ interface ForkTsCheckerWebpackPluginState {

issuesPromise: Promise<Issue[] | undefined>;
dependenciesPromise: Promise<Dependencies | undefined>;
lastDependencies: Dependencies | undefined;
dependenciesPromise: Promise<FilesMatch | undefined>;
lastDependencies: FilesMatch | undefined;
watching: boolean;
initialized: boolean;
webpackDevServerDoneTap: Tap | undefined;
webpackDevServerDoneTap: FullTap | undefined;
}
declare function createForkTsCheckerWebpackPluginState(): ForkTsCheckerWebpackPluginState;
export { ForkTsCheckerWebpackPluginState, createForkTsCheckerWebpackPluginState };

@@ -6,16 +6,16 @@ import * as webpack from 'webpack';

declare function createForkTsCheckerWebpackPluginHooks(): {
start: AsyncSeriesWaterfallHook<FilesChange, webpack.compilation.Compilation, any>;
waiting: SyncHook<webpack.compilation.Compilation, any, any>;
canceled: SyncHook<webpack.compilation.Compilation, any, any>;
error: SyncHook<Error, webpack.compilation.Compilation, any>;
issues: SyncWaterfallHook<Issue[], webpack.compilation.Compilation | undefined, void>;
start: AsyncSeriesWaterfallHook<[FilesChange, webpack.Compilation], import("tapable").UnsetAdditionalOptions>;
waiting: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
canceled: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
error: SyncHook<[Error, webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
issues: SyncWaterfallHook<[Issue[], webpack.Compilation | undefined], void>;
};
declare type ForkTsCheckerWebpackPluginHooks = ReturnType<typeof createForkTsCheckerWebpackPluginHooks>;
declare function getForkTsCheckerWebpackPluginHooks(compiler: webpack.Compiler | webpack.MultiCompiler): {
start: AsyncSeriesWaterfallHook<FilesChange, webpack.compilation.Compilation, any>;
waiting: SyncHook<webpack.compilation.Compilation, any, any>;
canceled: SyncHook<webpack.compilation.Compilation, any, any>;
error: SyncHook<Error, webpack.compilation.Compilation, any>;
issues: SyncWaterfallHook<Issue[], webpack.compilation.Compilation | undefined, void>;
start: AsyncSeriesWaterfallHook<[FilesChange, webpack.Compilation], import("tapable").UnsetAdditionalOptions>;
waiting: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
canceled: SyncHook<[webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
error: SyncHook<[Error, webpack.Compilation], void, import("tapable").UnsetAdditionalOptions>;
issues: SyncWaterfallHook<[Issue[], webpack.Compilation | undefined], void>;
};
export { getForkTsCheckerWebpackPluginHooks, ForkTsCheckerWebpackPluginHooks };

@@ -9,3 +9,5 @@ "use strict";

// wrap original watch file system
compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(watchFileSystem, compiler, state);
compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(
// we use some internals here
watchFileSystem, compiler, state);
}

@@ -12,0 +14,0 @@ });

@@ -81,3 +81,3 @@ "use strict";

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

@@ -84,0 +84,0 @@ }));

@@ -49,3 +49,3 @@ "use strict";

change = reporter_1.getFilesChange(compiler);
configuration.logger.infrastructure.info([
configuration.logger.infrastructure.log([
'Calling reporter service for incremental check.',

@@ -57,3 +57,3 @@ ` Changed files: ${JSON.stringify(change.changedFiles)}`,

else {
configuration.logger.infrastructure.info('Calling reporter service for single check.');
configuration.logger.infrastructure.log('Calling reporter service for single check.');
}

@@ -60,0 +60,0 @@ let resolveDependencies;

@@ -0,8 +1,9 @@

import webpack from 'webpack';
import { Issue } from './Issue';
declare class IssueWebpackError extends Error {
declare class IssueWebpackError extends webpack.WebpackError {
readonly issue: Issue;
readonly hideStack = true;
readonly file: string | undefined;
readonly file: string;
constructor(message: string, issue: Issue);
}
export { IssueWebpackError };

@@ -6,6 +6,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const webpack_1 = __importDefault(require("webpack"));
const path_1 = require("path");
const IssueLocation_1 = require("./IssueLocation");
const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
class IssueWebpackError extends Error {
class IssueWebpackError extends webpack_1.default.WebpackError {
constructor(message, issue) {

@@ -15,2 +16,3 @@ super(message);

this.hideStack = true;
this.file = '';
// to display issue location using `loc` property, webpack requires `error.module` which

@@ -17,0 +19,0 @@ // should be a NormalModule instance.

@@ -6,3 +6,3 @@ "use strict";

return {
infrastructure: LoggerFactory_1.createLogger((options && options.infrastructure) || 'silent', compiler),
infrastructure: LoggerFactory_1.createLogger((options && options.infrastructure) || 'webpack-infrastructure', compiler),
issues: LoggerFactory_1.createLogger((options && options.issues) || 'console', compiler),

@@ -9,0 +9,0 @@ devServer: (options === null || options === void 0 ? void 0 : options.devServer) !== false,

@@ -10,3 +10,3 @@ "use strict";

function getFilesChange(compiler) {
return compilerFilesChangeMap.get(compiler) || {};
return compilerFilesChangeMap.get(compiler) || { changedFiles: [], deletedFiles: [] };
}

@@ -13,0 +13,0 @@ exports.getFilesChange = getFilesChange;

@@ -5,4 +5,4 @@ export * from './Report';

export * from './FilesChange';
export * from './Dependencies';
export * from './FilesMatch';
export * from './reporter-rpc/ReporterRpcClient';
export * from './reporter-rpc/ReporterRpcService';

@@ -1,5 +0,5 @@

import { Dependencies } from './Dependencies';
import { FilesMatch } from './FilesMatch';
import { Issue } from '../issue';
interface Report {
getDependencies(): Promise<Dependencies>;
getDependencies(): Promise<FilesMatch>;
getIssues(): Promise<Issue[]>;

@@ -6,0 +6,0 @@ close(): Promise<void>;

import { RpcProcedure } from '../../rpc';
import { FilesChange } from '../FilesChange';
import { Issue } from '../../issue';
import { Dependencies } from '../Dependencies';
import { FilesMatch } from '../FilesMatch';
declare const configure: RpcProcedure<object, void>;

@@ -10,5 +10,5 @@ declare const getReport: RpcProcedure<{

}, void>;
declare const getDependencies: RpcProcedure<void, Dependencies>;
declare const getDependencies: RpcProcedure<void, FilesMatch>;
declare const getIssues: RpcProcedure<void, Issue[]>;
declare const closeReport: RpcProcedure<void, void>;
export { configure, getReport, getDependencies, getIssues, closeReport };
import * as ts from 'typescript';
import { Issue } from '../../issue';
import { Dependencies } from '../../reporter';
import { FilesMatch } from '../../reporter';
interface TypeScriptHostExtension {

@@ -12,3 +12,3 @@ extendWatchSolutionBuilderHost?<TProgram extends ts.BuilderProgram, THost extends ts.SolutionBuilderWithWatchHost<TProgram>>(host: THost, parsedCommandLine?: ts.ParsedCommandLine): THost;

extendIssues?(issues: Issue[]): Issue[];
extendDependencies?(dependencies: Dependencies): Dependencies;
extendDependencies?(dependencies: FilesMatch): FilesMatch;
}

@@ -15,0 +15,0 @@ interface TypeScriptExtension extends TypeScriptHostExtension, TypeScriptReporterExtension {

@@ -5,6 +5,6 @@ import { FileSystem } from './FileSystem';

*
* @param caseSensitive
* @param memFileSystem
* @param realFileSystem
*/
declare function createPassiveFileSystem(caseSensitive: boolean | undefined, realFileSystem: FileSystem): FileSystem;
declare function createPassiveFileSystem(memFileSystem: FileSystem, realFileSystem: FileSystem): FileSystem;
export { createPassiveFileSystem };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const memfs_1 = require("memfs");
/**
* It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
*
* @param caseSensitive
* @param memFileSystem
* @param realFileSystem
*/
function createPassiveFileSystem(caseSensitive = false, realFileSystem) {
function normalizePath(path) {
return caseSensitive ? path_1.normalize(path) : path_1.normalize(path).toLowerCase();
}
function memExists(path) {
return memfs_1.fs.existsSync(normalizePath(path));
}
function memReadStats(path) {
return memExists(path) ? memfs_1.fs.statSync(normalizePath(path)) : undefined;
}
function memReadFile(path, encoding) {
const stats = memReadStats(path);
if (stats && stats.isFile()) {
return memfs_1.fs
.readFileSync(normalizePath(path), { encoding: encoding })
.toString();
}
}
function memReadDir(path) {
const stats = memReadStats(path);
if (stats && stats.isDirectory()) {
return memfs_1.fs.readdirSync(normalizePath(path), { withFileTypes: true });
}
return [];
}
function createPassiveFileSystem(memFileSystem, realFileSystem) {
function exists(path) {
return realFileSystem.exists(path) || memExists(path);
return realFileSystem.exists(path) || memFileSystem.exists(path);
}
function readFile(path, encoding) {
const fsStats = realFileSystem.readStats(path);
const memStats = memReadStats(path);
const memStats = memFileSystem.readStats(path);
if (fsStats && memStats) {
return fsStats.mtimeMs > memStats.mtimeMs
? realFileSystem.readFile(path, encoding)
: memReadFile(path, encoding);
: memFileSystem.readFile(path, encoding);
}

@@ -51,3 +25,3 @@ else if (fsStats) {

else if (memStats) {
return memReadFile(path, encoding);
return memFileSystem.readFile(path, encoding);
}

@@ -57,3 +31,3 @@ }

const fsDirents = realFileSystem.readDir(path);
const memDirents = memReadDir(path);
const memDirents = memFileSystem.readDir(path);
// merge list of dirents from fs and mem

@@ -66,3 +40,3 @@ return fsDirents

const fsStats = realFileSystem.readStats(path);
const memStats = memReadStats(path);
const memStats = memFileSystem.readStats(path);
if (fsStats && memStats) {

@@ -78,23 +52,3 @@ return fsStats.mtimeMs > memStats.mtimeMs ? fsStats : memStats;

}
function createDir(path) {
memfs_1.fs.mkdirSync(normalizePath(path), { recursive: true });
}
function writeFile(path, data) {
if (!memExists(path_1.dirname(path))) {
createDir(path_1.dirname(path));
}
memfs_1.fs.writeFileSync(normalizePath(path), data);
}
function deleteFile(path) {
if (memExists(path)) {
memfs_1.fs.unlinkSync(normalizePath(path));
}
}
function updateTimes(path, atime, mtime) {
if (memExists(path)) {
memfs_1.fs.utimesSync(normalizePath(path), atime, mtime);
}
}
return {
exists(path) {
return Object.assign(Object.assign({}, memFileSystem), { exists(path) {
return exists(realFileSystem.realPath(path));

@@ -114,22 +68,6 @@ },

},
normalizePath(path) {
return normalizePath(path);
},
writeFile(path, data) {
writeFile(realFileSystem.realPath(path), data);
},
deleteFile(path) {
deleteFile(realFileSystem.realPath(path));
},
createDir(path) {
createDir(realFileSystem.realPath(path));
},
updateTimes(path, atime, mtime) {
updateTimes(realFileSystem.realPath(path), atime, mtime);
},
clearCache() {
realFileSystem.clearCache();
},
};
} });
}
exports.createPassiveFileSystem = createPassiveFileSystem;
import * as ts from 'typescript';
import { FilesMatch } from '../../reporter';
interface ControlledTypeScriptSystem extends ts.System {

@@ -16,2 +17,3 @@ invokeFileCreated(path: string): void;

waitForQueued(): Promise<void>;
setArtifacts(artifacts: FilesMatch): void;
}

@@ -18,0 +20,0 @@ declare type FileSystemMode = 'readonly' | 'write-tsbuildinfo' | 'write-references';

@@ -19,3 +19,10 @@ "use strict";

const RealFileSystem_1 = require("../file-system/RealFileSystem");
const MemFileSystem_1 = require("../file-system/MemFileSystem");
function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
let artifacts = {
files: [],
dirs: [],
extensions: [],
};
let isInitialRun = true;
// watchers

@@ -32,3 +39,4 @@ const fileWatcherCallbacksMap = new Map();

const realFileSystem = RealFileSystem_1.createRealFileSystem(caseSensitive);
const passiveFileSystem = PassiveFileSystem_1.createPassiveFileSystem(caseSensitive, realFileSystem);
const memFileSystem = MemFileSystem_1.createMemFileSystem(realFileSystem);
const passiveFileSystem = PassiveFileSystem_1.createPassiveFileSystem(memFileSystem, realFileSystem);
// based on the ts.ignorePaths

@@ -85,19 +93,31 @@ const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];

}
function isArtifact(path) {
return ((artifacts.dirs.some((dir) => path.includes(dir)) ||
artifacts.files.some((file) => path === file)) &&
artifacts.extensions.some((extension) => path.endsWith(extension)));
}
function getReadFileSystem(path) {
if (!isInitialRun &&
(mode === 'readonly' || mode === 'write-tsbuildinfo') &&
isArtifact(path)) {
return memFileSystem;
}
return passiveFileSystem;
}
function getWriteFileSystem(path) {
if (mode === 'readonly' || (mode === 'write-tsbuildinfo' && !path.endsWith('.tsbuildinfo'))) {
return passiveFileSystem;
}
else {
if (mode === 'write-references' ||
(mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo'))) {
return realFileSystem;
}
return passiveFileSystem;
}
const controlledSystem = Object.assign(Object.assign({}, typescript.sys), { useCaseSensitiveFileNames: caseSensitive, fileExists(path) {
const stats = passiveFileSystem.readStats(path);
const stats = getReadFileSystem(path).readStats(path);
return !!stats && stats.isFile();
},
readFile(path, encoding) {
return passiveFileSystem.readFile(path, encoding);
return getReadFileSystem(path).readFile(path, encoding);
},
getFileSize(path) {
const stats = passiveFileSystem.readStats(path);
const stats = getReadFileSystem(path).readStats(path);
return stats ? stats.size : 0;

@@ -114,3 +134,3 @@ },

directoryExists(path) {
const stats = passiveFileSystem.readStats(path);
const stats = getReadFileSystem(path).readStats(path);
return !!stats && stats.isDirectory();

@@ -123,7 +143,7 @@ },

getDirectories(path) {
const dirents = passiveFileSystem.readDir(path);
const dirents = getReadFileSystem(path).readDir(path);
return dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
},
getModifiedTime(path) {
const stats = passiveFileSystem.readStats(path);
const stats = getReadFileSystem(path).readStats(path);
if (stats) {

@@ -160,2 +180,3 @@ return stats.mtime;

}
isInitialRun = false;
});

@@ -189,4 +210,8 @@ },

clearCache() {
realFileSystem.clearCache();
memFileSystem.clearCache();
passiveFileSystem.clearCache();
realFileSystem.clearCache();
},
setArtifacts(nextArtifacts) {
artifacts = nextArtifacts;
} });

@@ -193,0 +218,0 @@ return controlledSystem;

import * as ts from 'typescript';
import { TypeScriptConfigurationOverwrite } from '../TypeScriptConfigurationOverwrite';
import { Dependencies } from '../../reporter';
import { FilesMatch } from '../../reporter';
declare function parseTypeScriptConfiguration(typescript: typeof ts, configFileName: string, configFileContext: string, configOverwriteJSON: TypeScriptConfigurationOverwrite, parseConfigFileHost: ts.ParseConfigFileHost): ts.ParsedCommandLine;
declare function getDependenciesFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, configFileContext: string, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): Dependencies;
export { parseTypeScriptConfiguration, getDependenciesFromTypeScriptConfiguration };
declare function getDependenciesFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
export declare function isIncrementalCompilation(options: ts.CompilerOptions): boolean;
declare function getArtifactsFromTypeScriptConfiguration(typescript: typeof ts, parsedConfiguration: ts.ParsedCommandLine, configFileContext: string, parseConfigFileHost: ts.ParseConfigFileHost, processedConfigFiles?: string[]): FilesMatch;
export { parseTypeScriptConfiguration, getDependenciesFromTypeScriptConfiguration, getArtifactsFromTypeScriptConfiguration, };
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const ts = __importStar(require("typescript"));
const path_1 = require("path");

@@ -11,3 +19,3 @@ function parseTypeScriptConfiguration(typescript, configFileName, configFileContext, configOverwriteJSON, parseConfigFileHost) {

exports.parseTypeScriptConfiguration = parseTypeScriptConfiguration;
function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, processedConfigFiles = []) {
function getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost, processedConfigFiles = []) {
const files = new Set(parsedConfiguration.fileNames);

@@ -18,18 +26,16 @@ if (typeof parsedConfiguration.options.configFilePath === 'string') {

const dirs = new Set(Object.keys(parsedConfiguration.wildcardDirectories || {}));
if (parsedConfiguration.projectReferences) {
parsedConfiguration.projectReferences.forEach((projectReference) => {
const configFile = typescript.resolveProjectReferencePath(projectReference);
if (processedConfigFiles.includes(configFile)) {
// handle circular dependencies
return;
}
const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, configFileContext, {}, parseConfigFileHost);
const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, [...processedConfigFiles, configFile]);
childDependencies.files.forEach((file) => {
files.add(file);
});
childDependencies.dirs.forEach((dir) => {
dirs.add(dir);
});
for (const projectReference of parsedConfiguration.projectReferences || []) {
const configFile = typescript.resolveProjectReferencePath(projectReference);
if (processedConfigFiles.includes(configFile)) {
// handle circular dependencies
continue;
}
const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, path_1.dirname(configFile), {}, parseConfigFileHost);
const childDependencies = getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost, [...processedConfigFiles, configFile]);
childDependencies.files.forEach((file) => {
files.add(file);
});
childDependencies.dirs.forEach((dir) => {
dirs.add(dir);
});
}

@@ -50,1 +56,86 @@ const extensions = [

exports.getDependenciesFromTypeScriptConfiguration = getDependenciesFromTypeScriptConfiguration;
function isIncrementalCompilation(options) {
return Boolean((options.incremental || options.composite) && !options.outFile);
}
exports.isIncrementalCompilation = isIncrementalCompilation;
function removeJsonExtension(path) {
if (path.endsWith('.json')) {
return path.slice(0, -'.json'.length);
}
else {
return path;
}
}
function getTsBuildInfoEmitOutputFilePath(options) {
if (typeof ts.getTsBuildInfoEmitOutputFilePath === 'function') {
// old TypeScript version doesn't provides this method
return ts.getTsBuildInfoEmitOutputFilePath(options);
}
// based on the implementation from typescript
const configFile = options.configFilePath;
if (!isIncrementalCompilation(options)) {
return undefined;
}
if (options.tsBuildInfoFile) {
return options.tsBuildInfoFile;
}
const outPath = options.outFile || options.out;
let buildInfoExtensionLess;
if (outPath) {
buildInfoExtensionLess = removeJsonExtension(outPath);
}
else {
if (!configFile) {
return undefined;
}
const configFileExtensionLess = removeJsonExtension(configFile);
buildInfoExtensionLess = options.outDir
? options.rootDir
? path_1.resolve(options.outDir, path_1.relative(options.rootDir, configFileExtensionLess))
: path_1.resolve(options.outDir, path_1.basename(configFileExtensionLess))
: configFileExtensionLess;
}
return buildInfoExtensionLess + '.tsbuildinfo';
}
function getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, processedConfigFiles = []) {
const files = new Set();
const dirs = new Set();
if (parsedConfiguration.fileNames.length > 0) {
if (parsedConfiguration.options.outFile) {
files.add(path_1.resolve(configFileContext, parsedConfiguration.options.outFile));
}
const tsBuildInfoPath = getTsBuildInfoEmitOutputFilePath(parsedConfiguration.options);
if (tsBuildInfoPath) {
files.add(path_1.resolve(configFileContext, tsBuildInfoPath));
}
if (parsedConfiguration.options.outDir) {
dirs.add(path_1.resolve(configFileContext, parsedConfiguration.options.outDir));
}
}
for (const projectReference of parsedConfiguration.projectReferences || []) {
const configFile = typescript.resolveProjectReferencePath(projectReference);
if (processedConfigFiles.includes(configFile)) {
// handle circular dependencies
continue;
}
const parsedConfiguration = parseTypeScriptConfiguration(typescript, configFile, path_1.dirname(configFile), {}, parseConfigFileHost);
const childArtifacts = getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configFileContext, parseConfigFileHost, [...processedConfigFiles, configFile]);
childArtifacts.files.forEach((file) => {
files.add(file);
});
childArtifacts.dirs.forEach((dir) => {
dirs.add(dir);
});
}
const extensions = [
typescript.Extension.Dts,
typescript.Extension.Js,
typescript.Extension.TsBuildInfo,
];
return {
files: Array.from(files).map((file) => path_1.normalize(file)),
dirs: Array.from(dirs).map((dir) => path_1.normalize(dir)),
extensions,
};
}
exports.getArtifactsFromTypeScriptConfiguration = getArtifactsFromTypeScriptConfiguration;

@@ -37,2 +37,3 @@ "use strict";

let dependencies;
let artifacts;
let configurationChanged = false;

@@ -92,3 +93,3 @@ let compilerHost;

parsedConfiguration &&
parsedConfiguration.options.incremental) {
TypeScriptConfigurationParser_1.isIncrementalCompilation(parsedConfiguration.options)) {
const program = builderProgram.getProgram();

@@ -131,3 +132,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

const [parseConfigFileHost] = getParseConfigFileHost();
let dependencies = TypeScriptConfigurationParser_1.getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, configuration.context, parseConfigFileHost);
let dependencies = TypeScriptConfigurationParser_1.getDependenciesFromTypeScriptConfiguration(typescript, parsedConfiguration, parseConfigFileHost);
for (const extension of extensions) {

@@ -140,2 +141,13 @@ if (extension.extendDependencies) {

}
function getArtifacts() {
parsedConfiguration = parseConfigurationIfNeeded();
const [parseConfigFileHost] = getParseConfigFileHost();
return TypeScriptConfigurationParser_1.getArtifactsFromTypeScriptConfiguration(typescript, parsedConfiguration, configuration.context, parseConfigFileHost);
}
function getArtifactsIfNeeded() {
if (!artifacts) {
artifacts = getArtifacts();
}
return artifacts;
}
function startProfilingIfNeeded() {

@@ -182,2 +194,3 @@ if (configuration.profile) {

dependencies = undefined;
artifacts = undefined;
compilerHost = undefined;

@@ -198,4 +211,5 @@ watchCompilerHost = undefined;

JSON.stringify(parsedConfiguration.fileNames)) {
// root files changed - we need to recompute dependencies
// root files changed - we need to recompute dependencies and artifacts
dependencies = getDependencies();
artifacts = getArtifacts();
shouldUpdateRootFiles = true;

@@ -205,2 +219,3 @@ }

parsedConfiguration = parseConfigurationIfNeeded();
system.setArtifacts(getArtifactsIfNeeded());
if (configurationChanged) {

@@ -207,0 +222,0 @@ configurationChanged = false;

import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
import { FSWatcher } from 'chokidar';
import { Watcher, WatchFileSystem, WatchFileSystemOptions } from './WatchFileSystem';
import { WatchFileSystem } from './WatchFileSystem';
import { Compiler } from 'webpack';

@@ -13,4 +13,4 @@ declare class InclusiveNodeWatchFileSystem implements WatchFileSystem {

private paused;
watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>, startTime?: number, options?: Partial<WatchFileSystemOptions>, callback?: Function, callbackUndelayed?: Function): Watcher;
watch: WatchFileSystem['watch'];
}
export { InclusiveNodeWatchFileSystem };

@@ -18,5 +18,2 @@ "use strict";

}
else if (typeof pattern === 'function') {
return pattern;
}
else if (pattern instanceof RegExp) {

@@ -41,2 +38,89 @@ return (path) => pattern.test(path);

this.paused = true;
this.watch = (files, dirs, missing, startTime, options, callback, callbackUndelayed) => {
var _a, _b, _c;
reporter_1.clearFilesChange(this.compiler);
const isIgnored = createIsIgnored(options === null || options === void 0 ? void 0 : options.ignored);
// use standard watch file system for files and missing
const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
(_a = this.watcher) === null || _a === void 0 ? void 0 : _a.on('change', (file) => {
if (typeof file === 'string' && !isIgnored(file)) {
reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
}
});
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('remove', (file) => {
if (typeof file === 'string' && !isIgnored(file)) {
reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
}
});
// calculate what to change
const prevDirs = Array.from(this.dirsWatchers.keys());
const nextDirs = Array.from(((_c = this.pluginState.lastDependencies) === null || _c === void 0 ? void 0 : _c.dirs) || []);
const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
// update dirs watcher
dirsToUnwatch.forEach((dirToUnwatch) => {
var _a;
(_a = this.dirsWatchers.get(dirToUnwatch)) === null || _a === void 0 ? void 0 : _a.close();
this.dirsWatchers.delete(dirToUnwatch);
});
dirsToWatch.forEach((dirToWatch) => {
const interval = typeof (options === null || options === void 0 ? void 0 : options.poll) === 'number' ? options.poll : undefined;
const dirWatcher = chokidar_1.default.watch(dirToWatch, {
ignoreInitial: true,
ignorePermissionErrors: true,
ignored: (path) => isIgnored(path),
usePolling: (options === null || options === void 0 ? void 0 : options.poll) ? true : undefined,
interval: interval,
binaryInterval: interval,
alwaysStat: true,
atomic: true,
awaitWriteFinish: true,
});
dirWatcher.on('add', (file, stats) => {
var _a, _b;
if (this.paused) {
return;
}
const extension = path_1.extname(file);
const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
if (!supportedExtensions.includes(extension)) {
return;
}
reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
const mtime = (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1;
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, mtime, file, 'rename');
});
dirWatcher.on('unlink', (file) => {
var _a, _b;
if (this.paused) {
return;
}
const extension = path_1.extname(file);
const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
if (!supportedExtensions.includes(extension)) {
return;
}
reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
});
this.dirsWatchers.set(dirToWatch, dirWatcher);
});
this.paused = false;
return Object.assign(Object.assign({}, standardWatcher), { close: () => {
reporter_1.clearFilesChange(this.compiler);
if (standardWatcher) {
standardWatcher.close();
}
this.dirsWatchers.forEach((dirWatcher) => {
dirWatcher === null || dirWatcher === void 0 ? void 0 : dirWatcher.close();
});
this.dirsWatchers.clear();
this.paused = true;
}, pause: () => {
if (standardWatcher) {
standardWatcher.pause();
}
this.paused = true;
} });
};
this.dirsWatchers = new Map();

@@ -48,90 +132,3 @@ }

}
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
var _a, _b, _c;
reporter_1.clearFilesChange(this.compiler);
const isIgnored = createIsIgnored(options === null || options === void 0 ? void 0 : options.ignored);
// use standard watch file system for files and missing
const standardWatcher = this.watchFileSystem.watch(files, dirs, missing, startTime, options, callback, callbackUndelayed);
(_a = this.watcher) === null || _a === void 0 ? void 0 : _a.on('change', (file) => {
if (typeof file === 'string' && !isIgnored(file)) {
reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
}
});
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b.on('remove', (file) => {
if (typeof file === 'string' && !isIgnored(file)) {
reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
}
});
// calculate what to change
const prevDirs = Array.from(this.dirsWatchers.keys());
const nextDirs = Array.from(((_c = this.pluginState.lastDependencies) === null || _c === void 0 ? void 0 : _c.dirs) || []);
const dirsToUnwatch = prevDirs.filter((prevDir) => !nextDirs.includes(prevDir));
const dirsToWatch = nextDirs.filter((nextDir) => !prevDirs.includes(nextDir) && !isIgnored(nextDir));
// update dirs watcher
dirsToUnwatch.forEach((dirToUnwatch) => {
var _a;
(_a = this.dirsWatchers.get(dirToUnwatch)) === null || _a === void 0 ? void 0 : _a.close();
this.dirsWatchers.delete(dirToUnwatch);
});
dirsToWatch.forEach((dirToWatch) => {
const interval = typeof (options === null || options === void 0 ? void 0 : options.poll) === 'number' ? options.poll : undefined;
const dirWatcher = chokidar_1.default.watch(dirToWatch, {
ignoreInitial: true,
ignorePermissionErrors: true,
ignored: (path) => isIgnored(path),
usePolling: (options === null || options === void 0 ? void 0 : options.poll) ? true : undefined,
interval: interval,
binaryInterval: interval,
alwaysStat: true,
atomic: true,
awaitWriteFinish: true,
});
dirWatcher.on('add', (file, stats) => {
var _a, _b;
if (this.paused) {
return;
}
const extension = path_1.extname(file);
const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
if (!supportedExtensions.includes(extension)) {
return;
}
reporter_1.updateFilesChange(this.compiler, { changedFiles: [file] });
const mtime = (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) || (stats === null || stats === void 0 ? void 0 : stats.ctimeMs) || 1;
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onChange(dirToWatch, mtime, file, 'rename');
});
dirWatcher.on('unlink', (file) => {
var _a, _b;
if (this.paused) {
return;
}
const extension = path_1.extname(file);
const supportedExtensions = ((_a = this.pluginState.lastDependencies) === null || _a === void 0 ? void 0 : _a.extensions) || [];
if (!supportedExtensions.includes(extension)) {
return;
}
reporter_1.updateFilesChange(this.compiler, { deletedFiles: [file] });
(_b = this.watcher) === null || _b === void 0 ? void 0 : _b._onRemove(dirToWatch, file, 'rename');
});
this.dirsWatchers.set(dirToWatch, dirWatcher);
});
this.paused = false;
return Object.assign(Object.assign({}, standardWatcher), { close: () => {
reporter_1.clearFilesChange(this.compiler);
if (standardWatcher) {
standardWatcher.close();
}
this.dirsWatchers.forEach((dirWatcher) => {
dirWatcher === null || dirWatcher === void 0 ? void 0 : dirWatcher.close();
});
this.dirsWatchers.clear();
this.paused = true;
}, pause: () => {
if (standardWatcher) {
standardWatcher.pause();
}
this.paused = true;
} });
}
}
exports.InclusiveNodeWatchFileSystem = InclusiveNodeWatchFileSystem;
/// <reference types="node" />
import { EventEmitter } from 'events';
interface WatchFileSystemOptions {
aggregateTimeout: number;
poll: boolean;
followSymlinks: boolean;
ignored: string | RegExp | Function | (string | RegExp | Function)[];
}
import webpack from 'webpack';
interface Watchpack extends EventEmitter {

@@ -13,15 +8,3 @@ _onChange(item: string, mtime: number, file: string, type?: string): void;

}
interface WatcherV4 {
close(): void;
pause(): void;
getFileTimestamps(): Map<string, number>;
getContextTimestamps(): Map<string, number>;
}
interface WatcherV5 {
close(): void;
pause(): void;
getFileTimeInfoEntries(): Map<string, number>;
getContextTimeInfoEntries(): Map<string, number>;
}
declare type Watcher = WatcherV4 | WatcherV5;
declare type Watch = webpack.Compiler['watchFileSystem']['watch'];
interface WatchFileSystem {

@@ -32,4 +15,4 @@ watcher: Watchpack;

};
watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>, startTime?: number, options?: Partial<WatchFileSystemOptions>, callback?: Function, callbackUndelayed?: Function): Watcher;
watch: Watch;
}
export { WatchFileSystem, WatchFileSystemOptions, Watchpack, WatcherV4, WatcherV5, Watcher };
export { WatchFileSystem, Watchpack };
{
"name": "fork-ts-checker-webpack-plugin",
"version": "7.0.0-alpha.3",
"version": "7.0.0-alpha.4",
"description": "Runs typescript type checker and linter on separate process.",

@@ -75,4 +75,7 @@ "keywords": [

"semver": "^7.3.2",
"tapable": "^1.0.0"
"tapable": "^2.0.0"
},
"peerDependencies": {
"webpack": "^5.11.0"
},
"devDependencies": {

@@ -94,3 +97,2 @@ "@commitlint/config-conventional": "^11.0.0",

"@types/semver": "^7.3.4",
"@types/webpack": "^4.41.22",
"@typescript-eslint/eslint-plugin": "^2.27.0",

@@ -110,2 +112,3 @@ "@typescript-eslint/parser": "^2.27.0",

"jest-environment-node": "^26.5.2",
"karton": "^0.4.1",
"lint-staged": "^10.4.2",

@@ -120,3 +123,3 @@ "mock-fs": "^4.13.0",

"typescript": "^3.8.3",
"webpack": "^4.42.1"
"webpack": "^5.11.0"
},

@@ -123,0 +126,0 @@ "engines": {

@@ -24,3 +24,3 @@ <div align="center">

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

@@ -27,0 +27,0 @@ * 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.

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