From 58300cf58cdfee4f674fd50aa4cd5edb25c5f490 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 24 Oct 2017 18:02:09 -0400 Subject: [PATCH] Add babel-webpack-plugin and clean-webpack-plugin --- .../babel-webpack-plugin-tests.ts | 10 ++++ types/babel-webpack-plugin/index.d.ts | 22 +++++++++ types/babel-webpack-plugin/tsconfig.json | 23 +++++++++ types/babel-webpack-plugin/tslint.json | 1 + .../clean-webpack-plugin-tests.ts | 17 +++++++ types/clean-webpack-plugin/index.d.ts | 47 +++++++++++++++++++ types/clean-webpack-plugin/tsconfig.json | 23 +++++++++ types/clean-webpack-plugin/tslint.json | 1 + 8 files changed, 144 insertions(+) create mode 100644 types/babel-webpack-plugin/babel-webpack-plugin-tests.ts create mode 100644 types/babel-webpack-plugin/index.d.ts create mode 100644 types/babel-webpack-plugin/tsconfig.json create mode 100644 types/babel-webpack-plugin/tslint.json create mode 100644 types/clean-webpack-plugin/clean-webpack-plugin-tests.ts create mode 100644 types/clean-webpack-plugin/index.d.ts create mode 100644 types/clean-webpack-plugin/tsconfig.json create mode 100644 types/clean-webpack-plugin/tslint.json diff --git a/types/babel-webpack-plugin/babel-webpack-plugin-tests.ts b/types/babel-webpack-plugin/babel-webpack-plugin-tests.ts new file mode 100644 index 0000000000..89b8efc6e6 --- /dev/null +++ b/types/babel-webpack-plugin/babel-webpack-plugin-tests.ts @@ -0,0 +1,10 @@ +import BabelWebpackPlugin = require('babel-webpack-plugin'); + +new BabelWebpackPlugin(); +new BabelWebpackPlugin({}); +new BabelWebpackPlugin({ + test: /\.js$/, + presets: ['es2015'], + sourceMaps: false, + compact: false +}); diff --git a/types/babel-webpack-plugin/index.d.ts b/types/babel-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..cbba2cd4e6 --- /dev/null +++ b/types/babel-webpack-plugin/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for clean-webpack-plugin 0.1 +// Project: https://github.com/johnagan/clean-webpack-plugin +// Definitions by: Jed Fox +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'webpack'; +import { TransformOptions } from 'babel-core'; + +export = BabelWebpackPlugin; + +declare class BabelWebpackPlugin extends Plugin { + constructor(options?: BabelWebpackPlugin.Options); +} + +declare namespace BabelWebpackPlugin { + type Matcher = RegExp | string | Array; + interface Options extends TransformOptions { + test?: Matcher; + include?: Matcher; + exclude?: Matcher; + } +} diff --git a/types/babel-webpack-plugin/tsconfig.json b/types/babel-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..3e73343283 --- /dev/null +++ b/types/babel-webpack-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "babel-webpack-plugin-tests.ts" + ] +} diff --git a/types/babel-webpack-plugin/tslint.json b/types/babel-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/babel-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/clean-webpack-plugin/clean-webpack-plugin-tests.ts b/types/clean-webpack-plugin/clean-webpack-plugin-tests.ts new file mode 100644 index 0000000000..1ccafb31f6 --- /dev/null +++ b/types/clean-webpack-plugin/clean-webpack-plugin-tests.ts @@ -0,0 +1,17 @@ +import * as CleanWebpackPlugin from 'clean-webpack-plugin'; + +const paths = [ + 'path', + 'glob/**/*.js', +]; + +new CleanWebpackPlugin(paths); +new CleanWebpackPlugin(paths, 'root-directory'); +new CleanWebpackPlugin(paths, {}); +new CleanWebpackPlugin(paths, { + root: 'root-directory', + verbose: true, + dry: true, + watch: true, + exclude: ['a, b'], +}); diff --git a/types/clean-webpack-plugin/index.d.ts b/types/clean-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..7fc45cc3e4 --- /dev/null +++ b/types/clean-webpack-plugin/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for clean-webpack-plugin 0.1 +// Project: https://github.com/johnagan/clean-webpack-plugin +// Definitions by: Jed Fox +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'webpack'; + +export = CleanWebpackPlugin; + +declare class CleanWebpackPlugin extends Plugin { + /** + * @param paths A glob or array of globs to delete + */ + constructor(paths: string | ReadonlyArray, options?: string | CleanWebpackPlugin.Options); +} + +declare namespace CleanWebpackPlugin { + interface Options { + /** + * Absolute path to your webpack root folder (paths appended to this) + * Default: root of your package + */ + root?: string; + /** + * Write logs to the console. + */ + verbose?: boolean; + /** + * Set to `true` to emulate deletion without actually removing any files. + */ + dry?: boolean; + /** + * If true, remove files on recompile. + */ + watch?: boolean; + /** + * Instead of removing whole path recursively, + * remove all path's content with exclusion of provided immediate children. + * Good for not removing shared files from build directories. + */ + exclude?: ReadonlyArray; + /** + * Allow the plugin to clean folders outside of the webpack root + */ + allowExternal?: boolean; + } +} diff --git a/types/clean-webpack-plugin/tsconfig.json b/types/clean-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..2f342b4d42 --- /dev/null +++ b/types/clean-webpack-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clean-webpack-plugin-tests.ts" + ] +} diff --git a/types/clean-webpack-plugin/tslint.json b/types/clean-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/clean-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }