mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Add types for webpack-chain
This commit is contained in:
Vendored
+212
@@ -0,0 +1,212 @@
|
||||
// Type definitions for webpack-chain 3.0
|
||||
// Project: https://github.com/mozilla-neutrino/webpack-chain
|
||||
// Definitions by: Eirikur Nilsson <https://github.com/eirikurn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as webpack from 'webpack';
|
||||
import * as https from 'https';
|
||||
|
||||
export = Config;
|
||||
|
||||
declare class Config {
|
||||
devServer: Config.DevServer
|
||||
entryPoints: Config.EntryPoints
|
||||
module: Config.Module
|
||||
node: Config.ChainedMap<this>
|
||||
output: Config.Output
|
||||
performance: Config.Performance
|
||||
plugins: Config.Plugins<this>
|
||||
resolve: Config.Resolve
|
||||
resolveLoader: Config.ResolveLoader
|
||||
|
||||
amd(value: { [moduleName: string]: boolean }): this
|
||||
bail(value: boolean): this
|
||||
cache(value: boolean | any): this
|
||||
devtool(value: Config.DevTool): this
|
||||
context(value: string): this
|
||||
externals(value: webpack.ExternalsElement | webpack.ExternalsElement[]): this
|
||||
loader(value: any): this
|
||||
profile(value: boolean): this
|
||||
recordsPath(value: string): this
|
||||
recordsInputPath(value: string): this
|
||||
recordsOutputPath(value: string): this
|
||||
stats(value: webpack.Options.Stats): this
|
||||
target(value: string): this
|
||||
watch(value: boolean): this
|
||||
watchOptions(value: webpack.Options.WatchOptions): this
|
||||
|
||||
entry(name: string): Config.ChainedSet<this>
|
||||
plugin(name: string): Config.Plugin<this>
|
||||
|
||||
toConfig(): webpack.Configuration
|
||||
merge(obj: any): this
|
||||
}
|
||||
|
||||
declare namespace Config {
|
||||
export class Chained<Parent> {
|
||||
end(): Parent
|
||||
}
|
||||
|
||||
export class TypedChainedMap<Parent, Value> extends Chained<Parent> {
|
||||
clear(): this
|
||||
delete(key: string): this
|
||||
has(key: string): boolean
|
||||
get(key: string): Value
|
||||
set(key: string, value: Value): this
|
||||
merge(obj: { [key: string]: Value }): this
|
||||
entries(): { [key: string]: Value }
|
||||
values(): Array<Value>
|
||||
}
|
||||
|
||||
export class ChainedMap<Parent> extends TypedChainedMap<Parent, any> {}
|
||||
|
||||
export class TypedChainedSet<Parent, Value> extends Chained<Parent> {
|
||||
add(value: Value): this
|
||||
prepend(value: Value): this
|
||||
clear(): this
|
||||
delete(key: string): this
|
||||
has(key: string): boolean
|
||||
merge(arr: Array<Value>): this
|
||||
values(): Array<Value>
|
||||
}
|
||||
|
||||
export class ChainedSet<Parent> extends TypedChainedSet<Parent, any> {}
|
||||
|
||||
export class Plugins<Parent> extends TypedChainedMap<Parent, Plugin<Parent>> {}
|
||||
|
||||
export class Plugin<Parent> extends ChainedMap<Parent> {
|
||||
init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this
|
||||
use(plugin: PluginClass, args?: any[]): this
|
||||
tap(f: (args: any[]) => any[]): this
|
||||
}
|
||||
|
||||
export class Module extends ChainedMap<Config> {
|
||||
rules: TypedChainedMap<this, Rule>
|
||||
rule(name: string): Rule
|
||||
}
|
||||
|
||||
export class Output extends ChainedMap<Config> {
|
||||
chunkFilename(value: string): this
|
||||
crossOriginLoading(value: boolean | string): this
|
||||
filename(value: string): this
|
||||
library(value: string): this
|
||||
libraryTarget(value: string): this
|
||||
devtoolFallbackModuleFilenameTemplate(value: any): this
|
||||
devtoolLineToLine(value: any): this
|
||||
devtoolModuleFilenameTemplate(value: any): this
|
||||
hashFunction(value: string): this
|
||||
hashDigest(value: string): this
|
||||
hashDigestLength(value: number): this
|
||||
hashSalt(value: any): this
|
||||
hotUpdateChunkFilename(value: string): this
|
||||
hotUpdateFunction(value: any): this
|
||||
hotUpdateMainFilename(value: string): this
|
||||
jsonpFunction(value: string): this
|
||||
path(value: string): this
|
||||
pathinfo(value: boolean): this
|
||||
publicPath(value: string): this
|
||||
sourceMapFilename(value: string): this
|
||||
sourcePrefix(value: string): this
|
||||
strictModuleExceptionHandling(value: boolean): this
|
||||
umdNamedDefine(value: boolean): this
|
||||
}
|
||||
|
||||
export class DevServer extends ChainedMap<Config> {
|
||||
clientLogLevel(value: 'none' | 'error' | 'warning' | 'info'): this
|
||||
compress(value: boolean): this
|
||||
contentBase(value: boolean | string | string[]): this
|
||||
filename(value: string): this
|
||||
headers(value: { [header: string]: string }): this
|
||||
historyApiFallback(value: boolean | any): this
|
||||
host(value: string): this
|
||||
hot(value: boolean): this
|
||||
hotOnly(value: boolean): this
|
||||
https(value: boolean | https.ServerOptions): this
|
||||
inline(value: boolean): this
|
||||
lazy(value: boolean): this
|
||||
noInfo(value: boolean): this
|
||||
overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this
|
||||
port(value: number): this
|
||||
proxy(value: any): this
|
||||
quiet(value: boolean): this
|
||||
setup(value: (expressApp: any) => void): this
|
||||
stats(value: webpack.Options.Stats): this
|
||||
watchContentBase(value: boolean): this
|
||||
}
|
||||
|
||||
export class Performance extends ChainedMap<Config> {
|
||||
hints(value: boolean | 'error' | 'warning'): this
|
||||
maxEntrypointSize(value: number): this
|
||||
maxAssetSize(value: number): this
|
||||
assetFilter(value: (assetFilename: string) => boolean): this
|
||||
}
|
||||
|
||||
export class EntryPoints extends TypedChainedMap<Config, ChainedMap<Config>> {}
|
||||
|
||||
export class Resolve extends ChainedMap<Config> {
|
||||
alias: TypedChainedMap<this, string>
|
||||
aliasFields: TypedChainedSet<this, string>
|
||||
descriptionFiles: TypedChainedSet<this, string>
|
||||
extensions: TypedChainedSet<this, string>
|
||||
mainFields: TypedChainedSet<this, string>
|
||||
mainFiles: TypedChainedSet<this, string>
|
||||
modules: TypedChainedSet<this, string>
|
||||
plugins: TypedChainedMap<this, Plugin<this>>
|
||||
|
||||
enforceExtension(value: boolean): this
|
||||
enforceModuleExtension(value: boolean): this
|
||||
unsafeCache(value: boolean | RegExp | RegExp[]): this
|
||||
symlinks(value: boolean): this
|
||||
cachePredicate(value: (data: { path: string, request: string }) => boolean): this
|
||||
|
||||
plugin(name: string): Plugin<this>
|
||||
}
|
||||
|
||||
export class ResolveLoader extends ChainedMap<Config> {
|
||||
extensions: TypedChainedSet<this, string>
|
||||
modules: TypedChainedSet<this, string>
|
||||
moduleExtensions: TypedChainedSet<this, string>
|
||||
packageMains: TypedChainedSet<this, string>
|
||||
}
|
||||
|
||||
export class Rule extends ChainedMap<Module> {
|
||||
uses: TypedChainedMap<this, Use>
|
||||
include: TypedChainedSet<this, webpack.Condition>
|
||||
exclude: TypedChainedSet<this, webpack.Condition>
|
||||
|
||||
parser(value: { [optName: string]: any }): this
|
||||
test(value: webpack.Condition | webpack.Condition[]): this
|
||||
enforce(value: 'pre' | 'post'): this
|
||||
|
||||
use(name: string): Use
|
||||
pre(): this
|
||||
post(): this
|
||||
}
|
||||
|
||||
type LoaderOptions = { [name: string]: any }
|
||||
|
||||
export class Use extends ChainedMap<Rule> {
|
||||
loader(value: string): this
|
||||
options(value: LoaderOptions): this
|
||||
|
||||
tap(f: (options: LoaderOptions) => LoaderOptions): this
|
||||
}
|
||||
|
||||
type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' |
|
||||
'cheap-module-eval-source-map' | 'cheap-module-source-map' | 'eval-source-map' | 'source-map' |
|
||||
'nosources-source-map' | 'hidden-source-map' | 'nosources-source-map' | '@eval' |
|
||||
'@inline-source-map' | '@cheap-eval-source-map' | '@cheap-source-map' |
|
||||
'@cheap-module-eval-source-map' | '@cheap-module-source-map' | '@eval-source-map' |
|
||||
'@source-map' | '@nosources-source-map' | '@hidden-source-map' | '@nosources-source-map' |
|
||||
'#eval' | '#inline-source-map' | '#cheap-eval-source-map' | '#cheap-source-map' |
|
||||
'#cheap-module-eval-source-map' | '#cheap-module-source-map' | '#eval-source-map' |
|
||||
'#source-map' | '#nosources-source-map' | '#hidden-source-map' | '#nosources-source-map' |
|
||||
'#@eval' | '#@inline-source-map' | '#@cheap-eval-source-map' | '#@cheap-source-map' |
|
||||
'#@cheap-module-eval-source-map' | '#@cheap-module-source-map' | '#@eval-source-map' |
|
||||
'#@source-map' | '#@nosources-source-map' | '#@hidden-source-map' | '#@nosources-source-map' |
|
||||
boolean
|
||||
|
||||
interface PluginClass {
|
||||
new (...opts: any[]): webpack.Plugin
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"webpack-chain-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -0,0 +1,205 @@
|
||||
import * as Config from 'webpack-chain';
|
||||
import * as webpack from 'webpack';
|
||||
|
||||
const config = new Config();
|
||||
|
||||
config
|
||||
.amd({ foo: true })
|
||||
.bail(true)
|
||||
.cache(false)
|
||||
.cache({})
|
||||
.devtool('hidden-source-map')
|
||||
.devtool(false)
|
||||
.context('')
|
||||
.externals('foo')
|
||||
.externals(/node_modules/)
|
||||
.externals({ 'test': false, 'foo': 'bar' })
|
||||
.externals(['foo', 'bar'])
|
||||
.externals((context, request, cb) => cb(null, true))
|
||||
.loader({})
|
||||
.profile(false)
|
||||
.recordsPath('')
|
||||
.recordsInputPath('')
|
||||
.recordsOutputPath('')
|
||||
.stats({
|
||||
assets: false,
|
||||
publicPath: true,
|
||||
modules: false
|
||||
})
|
||||
.target('web')
|
||||
.watch(true)
|
||||
.watchOptions({})
|
||||
|
||||
.entry('main')
|
||||
.add('index.js')
|
||||
.delete('index.js')
|
||||
.clear()
|
||||
.end()
|
||||
|
||||
.entryPoints
|
||||
.delete('main')
|
||||
.end()
|
||||
|
||||
.plugin('foo')
|
||||
.use(webpack.DefinePlugin, [])
|
||||
.end()
|
||||
|
||||
.plugins
|
||||
.delete('foo')
|
||||
.end()
|
||||
|
||||
.devServer
|
||||
.clientLogLevel('error')
|
||||
.compress(false)
|
||||
.contentBase('/')
|
||||
.contentBase(['foo', 'bar'])
|
||||
.filename('hello')
|
||||
.headers({
|
||||
'Content-Type': 'text/css',
|
||||
})
|
||||
.historyApiFallback(true)
|
||||
.host('localhost')
|
||||
.hot(true)
|
||||
.hotOnly(true)
|
||||
.https(true)
|
||||
.inline(true)
|
||||
.lazy(true)
|
||||
.noInfo(true)
|
||||
.overlay(true)
|
||||
.overlay({
|
||||
warnings: true,
|
||||
errors: true,
|
||||
})
|
||||
.port(8080)
|
||||
.proxy({})
|
||||
.quiet(false)
|
||||
.setup(app => {})
|
||||
.stats({
|
||||
reasons: true,
|
||||
errors: true,
|
||||
warnings: false,
|
||||
})
|
||||
.watchContentBase(true)
|
||||
.end()
|
||||
|
||||
.module
|
||||
.rule('compile')
|
||||
.test(/.js$/)
|
||||
.include
|
||||
.add(/.js$/)
|
||||
.end()
|
||||
.exclude
|
||||
.add(/node_modules/)
|
||||
.end()
|
||||
.parser({
|
||||
opt: 'foo',
|
||||
})
|
||||
.enforce('pre')
|
||||
.use('babel')
|
||||
.loader('babel-loader')
|
||||
.options({})
|
||||
.end()
|
||||
.uses
|
||||
.delete('babel')
|
||||
.end()
|
||||
.pre()
|
||||
.post()
|
||||
.end()
|
||||
.rules
|
||||
.delete('compile')
|
||||
.end()
|
||||
.end()
|
||||
|
||||
.node
|
||||
.set('__dirname', true)
|
||||
.delete('__dirname')
|
||||
.clear()
|
||||
.end()
|
||||
|
||||
.output
|
||||
.chunkFilename('')
|
||||
.crossOriginLoading(true)
|
||||
.filename('main.js')
|
||||
.library('var')
|
||||
.libraryTarget('var')
|
||||
.devtoolFallbackModuleFilenameTemplate('')
|
||||
.devtoolLineToLine('')
|
||||
.devtoolModuleFilenameTemplate('')
|
||||
.hashFunction('md5')
|
||||
.hashDigest('md5')
|
||||
.hashDigestLength(15)
|
||||
.hashSalt('')
|
||||
.hotUpdateChunkFilename('update')
|
||||
.hotUpdateFunction(() => {})
|
||||
.hotUpdateMainFilename('main')
|
||||
.jsonpFunction('callback')
|
||||
.path('/')
|
||||
.pathinfo(true)
|
||||
.publicPath('/')
|
||||
.sourceMapFilename('index.js.map')
|
||||
.sourcePrefix('~')
|
||||
.strictModuleExceptionHandling(true)
|
||||
.umdNamedDefine(true)
|
||||
.end()
|
||||
|
||||
.performance
|
||||
.hints(true)
|
||||
.hints('warning')
|
||||
.maxEntrypointSize(20000)
|
||||
.maxAssetSize(20000)
|
||||
.assetFilter(filename => true)
|
||||
.end()
|
||||
|
||||
.resolve
|
||||
.alias
|
||||
.set('foo', 'bar')
|
||||
.end()
|
||||
.aliasFields
|
||||
.add('foo')
|
||||
.end()
|
||||
.descriptionFiles
|
||||
.add('foo')
|
||||
.end()
|
||||
.extensions
|
||||
.add('.js')
|
||||
.end()
|
||||
.mainFields
|
||||
.add('browser')
|
||||
.end()
|
||||
.mainFiles
|
||||
.add('index.js')
|
||||
.end()
|
||||
.modules
|
||||
.add('index.js')
|
||||
.end()
|
||||
.enforceExtension(true)
|
||||
.enforceModuleExtension(true)
|
||||
.unsafeCache(false)
|
||||
.unsafeCache(/foo/)
|
||||
.symlinks(true)
|
||||
.cachePredicate(({ path, request }) => true)
|
||||
.plugin('foo')
|
||||
.use(webpack.DefinePlugin, [])
|
||||
.end()
|
||||
.plugins
|
||||
.delete('foo')
|
||||
.end()
|
||||
.end()
|
||||
|
||||
.resolveLoader
|
||||
.extensions
|
||||
.add('.js')
|
||||
.end()
|
||||
.modules
|
||||
.add('index.js')
|
||||
.end()
|
||||
.moduleExtensions
|
||||
.add('.js')
|
||||
.end()
|
||||
.packageMains
|
||||
.add('index.js')
|
||||
.end()
|
||||
.end()
|
||||
|
||||
.merge({})
|
||||
.toConfig();
|
||||
Reference in New Issue
Block a user