diff --git a/types/wordpress__dependency-extraction-webpack-plugin/index.d.ts b/types/wordpress__dependency-extraction-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..319583a3d5 --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for @wordpress/dependency-extraction-webpack-plugin 1.0 +// Project: https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin/README.md +// Definitions by: Derek Sifford +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.5 + +import { Plugin } from "webpack"; + +interface Options { + useDefaults?: boolean; + injectPolyfill?: boolean; + requestToExternal?(request: string): string | string[] | void; + requestToHandle?(request: string): string | void; +} + +declare class DependencyExtractionWebpackPlugin extends Plugin { + constructor(options?: Options); +} + +export = DependencyExtractionWebpackPlugin; diff --git a/types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json b/types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..943b0ac3ac --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@wordpress/dependency-extraction-webpack-plugin": [ + "wordpress__dependency-extraction-webpack-plugin" + ] + } + }, + "files": [ + "index.d.ts", + "wordpress__dependency-extraction-webpack-plugin-tests.ts" + ] +} diff --git a/types/wordpress__dependency-extraction-webpack-plugin/tslint.json b/types/wordpress__dependency-extraction-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts b/types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts new file mode 100644 index 0000000000..48bccb227c --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts @@ -0,0 +1,23 @@ +import DependencyExtractionPlugin = require('@wordpress/dependency-extraction-webpack-plugin'); + +new DependencyExtractionPlugin(); + +new DependencyExtractionPlugin({ + useDefaults: false, +}); + +new DependencyExtractionPlugin({ + requestToExternal(request) { + if (request === "foo-bar") { + return "FooBar"; + } + if (request === "baz-qux") { + return ["baz", "qux"]; + } + }, + requestToHandle: request => { + if (request === "foo-bar") { + return "FooBar"; + } + } +});