diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 2a06e3ec3e..545230cb51 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -6,6 +6,7 @@ // Tommy Troy Lin // Mohsen Azimi // Jonathan Creamer +// Ahmed T. Ali // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -36,7 +37,7 @@ declare namespace webpack { * If `output.pathinfo` is set, the included pathinfo is shortened to this directory. */ context?: string; - entry?: string | string[] | Entry; + entry?: string | string[] | Entry | EntryFunc; /** Choose a style of source mapping to enhance the debugging process. These values can affect build and rebuild speed dramatically. */ devtool?: Options.Devtool; /** Options affecting the output. */ @@ -103,6 +104,8 @@ declare namespace webpack { [name: string]: string | string[]; } + type EntryFunc = () => (string | string[] | Promise); + interface DevtoolModuleFilenameTemplateInfo { identifier: string; shortIdentifier: string; diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 6b7a7e0cb1..b453e304b4 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -76,6 +76,26 @@ configuration = { } }; +// +// https://webpack.js.org/configuration/entry-context/#dynamic-entry +// + +configuration = { + entry: () => './demo' +}; + +configuration = { + entry: () => ['./demo', './demo2'] +}; + +configuration = { + entry: () => new Promise((resolve) => resolve('./demo')) +}; + +configuration = { + entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])) +}; + // // https://webpack.github.io/docs/code-splitting.html //