mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[webpack-deadcode-plugin]: New definition (#46260)
This commit is contained in:
parent
732fcd7f7c
commit
52391b452d
38
types/webpack-deadcode-plugin/index.d.ts
vendored
Normal file
38
types/webpack-deadcode-plugin/index.d.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Type definitions for webpack-deadcode-plugin 0.1
|
||||
// Project: https://github.com/MQuy/webpack-deadcode-plugin#readme
|
||||
// Definitions by: Ciarán Ingle <https://github.com/inglec-arista>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { compilation, Plugin } from 'webpack';
|
||||
|
||||
interface Options {
|
||||
/** Current working directoy for patterns above. If you don't set explicitly, your webpack context will be used. */
|
||||
context?: string;
|
||||
/** Whether to run unsed export detection or not. */
|
||||
detectUnusedExport?: boolean;
|
||||
/** Whether to run unused files detection or not. */
|
||||
detectUnusedFiles?: boolean;
|
||||
/** The array of patterns to not look at. */
|
||||
exclude?: string[];
|
||||
/**
|
||||
* Deadcode does not interrupt the compilation by default.
|
||||
* If you want to cancel the compilation, set it `true`, it throws a fatal error and stops the compilation.
|
||||
*/
|
||||
failOnHint?: boolean;
|
||||
outputFile?: string;
|
||||
/**
|
||||
* The array of patterns to look for unused files and unused export in used files.
|
||||
* Directly passed to [`fast-glob`](https://github.com/mrmlnc/fast-glob).
|
||||
*/
|
||||
patterns?: string[];
|
||||
}
|
||||
|
||||
declare class WebpackDeadcodePlugin extends Plugin {
|
||||
options: Options;
|
||||
|
||||
constructor(options?: Options);
|
||||
|
||||
handleAfterEmit(options: Required<Options>, compilation: compilation.Compilation, callback: () => void): void;
|
||||
}
|
||||
|
||||
export = WebpackDeadcodePlugin;
|
||||
19
types/webpack-deadcode-plugin/tsconfig.json
Normal file
19
types/webpack-deadcode-plugin/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"lib": ["es6"],
|
||||
"module": "commonjs",
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"typeRoots": ["../"],
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"webpack-deadcode-plugin-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/webpack-deadcode-plugin/tslint.json
Normal file
1
types/webpack-deadcode-plugin/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@ -0,0 +1,22 @@
|
||||
import { Configuration, Plugin } from 'webpack';
|
||||
import DeadCodePlugin = require('webpack-deadcode-plugin');
|
||||
|
||||
const webpackConfig: Configuration = {
|
||||
plugins: [
|
||||
new DeadCodePlugin({
|
||||
patterns: ['src/**/*.(js|jsx|css)'],
|
||||
exclude: ['**/*.(stories|spec).(js|jsx)'],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const plugin1: Plugin = new DeadCodePlugin();
|
||||
const plugin2: Plugin = new DeadCodePlugin({});
|
||||
const plugin3: Plugin = new DeadCodePlugin({
|
||||
patterns: ['src/**/*.(js|jsx|css)'],
|
||||
exclude: ['**/*.(stories|spec).(js|jsx)'],
|
||||
context: '~/foo/bar',
|
||||
detectUnusedExport: false,
|
||||
detectUnusedFiles: false,
|
||||
failOnHint: true,
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user