Merge pull request #14496 from bumbleblym/webpack

[webpack] update typings for webpack 2
This commit is contained in:
Arthur Ozga
2017-02-07 12:47:09 -08:00
committed by GitHub
17 changed files with 758 additions and 890 deletions
@@ -58,7 +58,10 @@ configuration = {
configuration = {
// ...
plugins: [
new optimize.CommonsChunkPlugin("commons", "commons.js"),
new optimize.CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
}),
new ExtractTextPlugin("[name].css")
]
};
@@ -1,34 +1,24 @@
import HtmlWebpackPlugin = require("html-webpack-plugin");
import { Configuration } from "webpack";
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
const a: Configuration = {
plugins: [
new HtmlWebpackPlugin()
]
};
new HtmlWebpackPlugin();
const b: Configuration = {
plugins: [
new HtmlWebpackPlugin({
title: "test"
})
]
};
const optionsArray: HtmlWebpackPlugin.Options[] = [
{
title: 'test',
},
{
minify: {
caseSensitive: true,
},
},
{
chunksSortMode: function compare(a, b) {
return 1;
},
},
{
arbitrary: 'data',
},
];
const minify: HtmlWebpackPlugin.MinifyConfig = {
caseSensitive: true
};
new HtmlWebpackPlugin({
minify
});
new HtmlWebpackPlugin({
chunksSortMode: function compare(a, b) {
return 1;
}
});
new HtmlWebpackPlugin({
arbitrary: "data"
});
const plugins: HtmlWebpackPlugin[] = optionsArray.map(options => new HtmlWebpackPlugin(options));
+72 -92
View File
@@ -3,106 +3,86 @@
// Definitions by: Simon Hartcher <https://github.com/deevus>, Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from "webpack";
import { Options } from "html-minifier";
import { Plugin } from 'webpack';
import { Options as HtmlMinifierOptions } from 'html-minifier';
export = HtmlWebpackPlugin;
declare class HtmlWebpackPlugin implements Plugin {
constructor(options?: HtmlWebpackPlugin.Config);
apply(thisArg: Webpack, ...args: any[]): void;
declare class HtmlWebpackPlugin extends Plugin {
constructor(options?: HtmlWebpackPlugin.Options);
}
declare namespace HtmlWebpackPlugin {
export type MinifyConfig = Options;
type MinifyOptions = HtmlMinifierOptions;
/**
* It is assumed that each [chunk] contains at least the properties "id"
* (containing the chunk id) and "parents" (array containing the ids of the
* parent chunks).
*/
export interface Chunk { // TODO: Import from webpack?
id: string;
parents: string[];
[propName: string]: any; // TODO: Narrow type
}
/**
* It is assumed that each [chunk] contains at least the properties "id"
* (containing the chunk id) and "parents" (array containing the ids of the
* parent chunks).
*
* @todo define in webpack
*/
interface Chunk {
id: string;
parents: string[];
[propName: string]: any;
}
export type ChunkComparator = (a: Chunk, b: Chunk) => number;
type ChunkComparator = (a: Chunk, b: Chunk) => number;
export interface Config {
/**
* The title to use for the generated HTML document.
*/
title?: string;
interface Options {
/** `true | false` if `true` (default) try to emit the file only if it was changed. */
cache?: boolean;
/**
* Allows to control how chunks should be sorted before they are included to the html.
* Allowed values: `'none' | 'auto' | 'dependency' | {function}` - default: `'auto'`
*/
chunksSortMode?: 'none' | 'auto' | 'dependency' | ChunkComparator;
/** Allows you to add only some chunks (e.g. only the unit-test chunk) */
chunks?: string[];
/** Allows you to skip some chunks (e.g. don't add the unit-test chunk) */
excludeChunks?: string[];
/** Adds the given favicon path to the output html. */
favicon?: string;
/**
* The file to write the HTML to.
* Defaults to index.html. You can specify a subdirectory here too (eg: `assets/admin.html`).
*/
filename?: string;
/**
* `true | false` if `true` then append a unique webpack compilation hash to all included scripts and css files.
* This is useful for cache busting.
*/
hash?: boolean;
/**
* `true | 'head' | 'body' | false`
* Inject all assets into the given template or templateContent.
* When passing true or 'body' all javascript resources will be placed at the bottom of the body element.
* 'head' will place the scripts in the head element.
*/
inject?: 'body' | 'head' | boolean;
/**
* `{...} | false` Pass a html-minifier options object to minify the output.
* https://github.com/kangax/html-minifier#options-quick-reference
*/
minify?: false | MinifyOptions;
/** `true | false` if `true` (default) errors details will be written into the html page. */
showErrors?: boolean;
/** Webpack require path to the template. Please see the docs for details. */
template?: string;
/** The title to use for the generated HTML document. */
title?: string;
/** `true | false` If `true` render the link tags as self-closing, XHTML compliant. Default is `false` */
xhtml?: boolean;
/**
* In addition to the options actually used by this plugin, you can use this hash to pass arbitrary data through
* to your template.
*/
[option: string]: any;
}
/**
* The file to write the HTML to. Defaults to index.html. You can specify a subdirectory here too (eg: `assets/admin.html`).
*/
filename?: string;
/**
* Webpack require path to the template. Please see the docs for details.
*/
template?: string;
/**
* `true | 'head' | 'body' | false`
*
* Inject all assets into the given template or templateContent - When passing true or 'body' all javascript resources will be placed at the bottom of the body element. 'head' will place the scripts in the head element.
*/
inject?: boolean | "head" | "body";
/**
* Adds the given favicon path to the output html.
*/
favicon?: string;
/**
* `{...} | false` Pass a html-minifier options object to minify the output.
*
* https://github.com/kangax/html-minifier#options-quick-reference
*/
minify?: MinifyConfig | false;
/**
* `true | false` if `true` then append a unique webpack compilation hash to all included scripts and css files. This is useful for cache busting.
*/
hash?: boolean;
/**
* `true | false` if `true` (default) try to emit the file only if it was changed.
*/
cache?: boolean;
/**
* `true | false` if `true` (default) errors details will be written into the html page.
*/
showErrors?: boolean;
/**
* Allows you to add only some chunks (e.g. only the unit-test chunk)
*/
chunks?: string[];
/**
* Allows to control how chunks should be sorted before they are included to the html. Allowed values: `'none' | 'auto' | 'dependency' | {function}` - default: `'auto'`
*/
chunksSortMode?: "none" | "auto" | "dependency" | ChunkComparator;
/**
* Allows you to skip some chunks (e.g. don't add the unit-test chunk)
*/
excludeChunks?: string[];
/**
* `true | false` If `true` render the link tags as self-closing, XHTML compliant. Default is `false`
*/
xhtml?: boolean;
/**
* In addition to the options actually used by this plugin, you can use
* this hash to pass arbitrary data through to your template.
*/
[option: string]: any;
}
/** @deprecated use MinifyOptions */
type MinifyConfig = MinifyOptions;
/** @deprecated use Options */
type Config = Options;
}
@@ -1,65 +1,65 @@
import HtmlWebpackPlugin = require('html-webpack-plugin');
import template = require('html-webpack-template');
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as template from 'html-webpack-template';
const configs: Array<template.Config> = [
{
// Required
inject: false,
template,
// template: 'node_modules/html-webpack-template/index.ejs',
const optionsArray: template.Options[] = [
{
/** Required */
inject: false,
template,
// template: 'node_modules/html-webpack-template/index.ejs',
// Optional
appMountId: 'app',
appMountIds: [
'root0',
'root1',
],
baseHref: 'http://example.com/awesome',
devServer: 'http://localhost:3001',
googleAnalytics: {
trackingId: 'UA-XXXX-XX',
pageViewOnLoad: true,
},
links: [
'https://fonts.googleapis.com/css?family=Roboto',
{
href: '/apple-touch-icon.png',
rel: 'apple-touch-icon',
sizes: '180x180',
},
{
href: '/favicon-32x32.png',
rel: 'icon',
sizes: '32x32',
type: 'image/png',
},
],
meta: [
{
description: 'A better default template for html-webpack-plugin.',
},
],
mobile: true,
inlineManifestWebpackName: 'webpackManifest',
scripts: [
'http://example.com/somescript.js',
{
src: '/myModule.js',
type: 'module',
},
],
window: {
env: {
apiHost: 'http://myapi.com/api/v1',
},
},
/** Optional */
appMountId: 'app',
appMountIds: [
'root0',
'root1',
],
baseHref: 'http://example.com/awesome',
devServer: 'http://localhost:3001',
googleAnalytics: {
trackingId: 'UA-XXXX-XX',
pageViewOnLoad: true,
},
links: [
'https://fonts.googleapis.com/css?family=Roboto',
{
href: '/apple-touch-icon.png',
rel: 'apple-touch-icon',
sizes: '180x180',
},
{
href: '/favicon-32x32.png',
rel: 'icon',
sizes: '32x32',
type: 'image/png',
},
],
meta: [
{
description: 'A better default template for html-webpack-plugin.',
},
],
mobile: true,
inlineManifestWebpackName: 'webpackManifest',
scripts: [
'http://example.com/somescript.js',
{
src: '/myModule.js',
type: 'module',
},
],
window: {
env: {
apiHost: 'http://myapi.com/api/v1',
},
},
// And any other config options from html-webpack-plugin:
// https://github.com/ampedandwired/html-webpack-plugin#configuration
title: 'My App',
},
/**
* And any other config options from html-webpack-plugin:
* https://github.com/ampedandwired/html-webpack-plugin#configuration
*/
title: 'My App',
},
];
const plugins: Array<HtmlWebpackPlugin> = configs.map(config =>
new HtmlWebpackPlugin(config)
);
const plugins: HtmlWebpackPlugin[] = optionsArray.map(options => new HtmlWebpackPlugin(options));
+58 -78
View File
@@ -3,94 +3,74 @@
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Config as HtmlWebpackPluginConfig } from 'html-webpack-plugin';
import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
export = HtmlWebpackTemplate;
declare const HtmlWebpackTemplate: string;
declare namespace HtmlWebpackTemplate {
export interface GoogleAnalyticsConfig {
trackingId: string;
// Log a pageview event after the analytics code loads.
pageViewOnLoad?: boolean;
}
interface GoogleAnalyticsOptions {
/** Log a pageview event after the analytics code loads. */
pageViewOnLoad?: boolean;
trackingId: string;
}
export interface Attributes {
[name: string]: any;
}
interface Attributes {
[name: string]: any;
}
type Resource = string | Attributes;
type Resource = string | Attributes;
/**
* string: value is assigned to the href attribute and the rel attribute is
* set to "stylesheet"
*
* object: properties and values are used as the attribute names and values,
* respectively:
*/
export type Link = Resource;
/**
* string: value is assigned to the href attribute and the rel attribute is set to "stylesheet"
* object: properties and values are used as the attribute names and values, respectively.
*/
type Link = Resource;
/**
* string: value is assigned to the src attribute and the type attribute is
* set to "text/javascript";
*
* object: properties and values are used as the attribute names and values,
* respectively.
*/
export type Script = Resource;
/**
* string: value is assigned to the src attribute and the type attribute is set to "text/javascript".
* object: properties and values are used as the attribute names and values, respectively.
*/
type Script = Resource;
export interface Config extends HtmlWebpackPluginConfig {
/**
* Set to false. Controls asset addition to the template. This template
* takes care of that.
*/
inject: false;
interface Options extends HtmlWebpackPluginOptions {
/** The <div> element id on which you plan to mount a JavaScript app. */
appMountId?: string;
/** An array of application element ids. */
appMountIds?: string[];
/**
* Adjust the URL for relative URLs in the document (MDN).
* https://developer.mozilla.org/en/docs/Web/HTML/Element/base
*/
baseHref?: string;
/** Insert the webpack-dev-server hot reload script at this host:port/path; e.g., http://localhost:3000. */
devServer?: string;
/** Track usage of your site via Google Analytics. */
googleAnalytics?: GoogleAnalyticsOptions;
/** Set to false. Controls asset addition to the template. This template takes care of that. */
inject: false;
/**
* For use with inline-manifest-webpack-plugin.
* https://github.com/szrenwei/inline-manifest-webpack-plugin
*/
inlineManifestWebpackName?: string;
/** Array of <link> elements. */
links?: Link[];
/** Array of objects containing key value pairs to be included as meta tags. */
meta?: Attributes[];
/** Sets appropriate meta tag for page scaling. */
mobile?: boolean;
/** Array of external script imports to include on page. */
scripts?: Script[];
/** Specify this module's index.ejs file. */
template: string;
/** Object that defines data you need to bootstrap a JavaScript app. */
window?: {};
}
// Specify this module's index.ejs file.
template: string;
// The <div> element id on which you plan to mount a JavaScript app.
appMountId?: string;
// An array of application element ids.
appMountIds?: string[];
/**
* Adjust the URL for relative URLs in the document (MDN).
* https://developer.mozilla.org/en/docs/Web/HTML/Element/base
*/
baseHref?: string;
/**
* Insert the webpack-dev-server hot reload script at this
* host:port/path; e.g., http://localhost:3000.
*/
devServer?: string;
// Track usage of your site via Google Analytics.
googleAnalytics?: GoogleAnalyticsConfig;
// Array of <link> elements.
links?: Link[];
// Array of objects containing key value pairs to be included as meta tags.
meta?: Attributes[];
// Sets appropriate meta tag for page scaling.
mobile?: boolean;
/**
* For use with inline-manifest-webpack-plugin.
*
* https://github.com/szrenwei/inline-manifest-webpack-plugin
*/
inlineManifestWebpackName?: string;
// Array of external script imports to include on page.
scripts?: Script[];
// Object that defines data you need to bootstrap a JavaScript app.
window?: {};
}
/** @deprecated use GoogleAnalyticsOptions */
type GoogleAnalyticsConfig = GoogleAnalyticsOptions;
/** @deprecated use Options */
type Config = Options;
}
+3 -4
View File
@@ -3,17 +3,16 @@
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from 'webpack';
import { Plugin } from 'webpack';
export = LodashModuleReplacementPlugin;
declare class LodashModuleReplacementPlugin implements Plugin {
declare class LodashModuleReplacementPlugin extends Plugin {
constructor(options?: LodashModuleReplacementPlugin.Options);
apply(thisArg: Webpack, ...args: any[]): void;
}
declare namespace LodashModuleReplacementPlugin {
export interface Options {
interface Options {
caching?: boolean;
chaining?: boolean;
cloning?: boolean;
@@ -1,27 +1,31 @@
import * as LodashModuleReplacementPlugin from 'lodash-webpack-plugin'
import * as LodashModuleReplacementPlugin from 'lodash-webpack-plugin';
new LodashModuleReplacementPlugin()
new LodashModuleReplacementPlugin();
new LodashModuleReplacementPlugin({
collections: true,
paths: true,
})
const optionsArray: LodashModuleReplacementPlugin.Options[] = [
{
collections: true,
paths: true,
},
{
caching: true,
chaining: true,
cloning: true,
coercions: true,
collections: true,
currying: true,
deburring: true,
exotics: true,
flattening: true,
guards: true,
memoizing: true,
metadata: true,
paths: true,
placeholders: true,
shorthands: true,
unicode: true,
},
];
new LodashModuleReplacementPlugin({
caching: true,
chaining: true,
cloning: true,
coercions: true,
collections: true,
currying: true,
deburring: true,
exotics: true,
flattening: true,
guards: true,
memoizing: true,
metadata: true,
paths: true,
placeholders: true,
shorthands: true,
unicode: true,
})
const plugins: LodashModuleReplacementPlugin[] = optionsArray
.map(options => new LodashModuleReplacementPlugin(options));
+13 -11
View File
@@ -3,21 +3,23 @@
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from 'webpack';
import { Plugin } from 'webpack';
export = WebpackNotifierPlugin;
declare class WebpackNotifierPlugin implements Plugin {
constructor(options?: WebpackNotifierPlugin.Config);
apply(thisArg: Webpack, ...args: any[]): void;
declare class WebpackNotifierPlugin extends Plugin {
constructor(options?: WebpackNotifierPlugin.Options);
}
declare namespace WebpackNotifierPlugin {
export interface Config {
title?: string;
contentImage?: string;
excludeWarnings?: boolean;
alwaysNotify?: boolean;
skipFirstNotification?: boolean;
}
interface Options {
alwaysNotify?: boolean;
contentImage?: string;
excludeWarnings?: boolean;
skipFirstNotification?: boolean;
title?: string;
}
/** @deprecated use Options */
type Config = Options;
}
+10 -10
View File
@@ -1,14 +1,14 @@
import WebpackNotifierPlugin = require('webpack-notifier');
import { Plugin } from 'webpack';
import * as WebpackNotifierPlugin from 'webpack-notifier';
const configs: Array<WebpackNotifierPlugin.Config> = [
{
title: 'Webpack',
contentImage: 'logo.png',
excludeWarnings: true,
alwaysNotify: true,
skipFirstNotification: true,
},
const optionsArray: WebpackNotifierPlugin.Options[] = [
{
title: 'Webpack',
contentImage: 'logo.png',
excludeWarnings: true,
alwaysNotify: true,
skipFirstNotification: true,
},
];
const plugins: Array<Plugin> = configs.map(config => new WebpackNotifierPlugin(config));
const plugins: Plugin[] = optionsArray.map(options => new WebpackNotifierPlugin(options));
+17 -39
View File
@@ -1,48 +1,26 @@
// Type definitions for webpack-stream v3.2.0
// Type definitions for webpack-stream 3.2
// Project: https://github.com/shama/webpack-stream
// Definitions by: Ian Clanton-Thuon <https://github.com/iclanton>
// Definitions by: Ian Clanton-Thuon <https://github.com/iclanton>, Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="webpack" />
///<reference types="node" />
declare module "webpack-stream" {
import webpack = require("webpack");
import * as webpack from 'webpack';
interface WebpackStreamStatic {
/**
* Run webpack with the default configuration.
*/
(): NodeJS.ReadWriteStream;
export = webpackStream;
/**
* Run webpack with the specified configuration.
*
* @param {config} Webpack configuration
*/
(config: webpack.Configuration): NodeJS.ReadWriteStream;
/**
* Run webpack with the specified configuration and webpack instance
*
* @param {webpack.Configuration} config - Webpack configuration
* @param {webpack} wp - A webpack object
* @param {webpack.Compiler.Handler} callback - A callback with the webpack stats and error objects.
*/
declare function webpackStream(
config?: webpack.Configuration,
wp?: typeof webpack,
callback?: webpack.Compiler.Handler,
): NodeJS.ReadWriteStream;
/**
* Run webpack with the specified configuration and webpack instance
*
* @param {config} Webpack configuration
* @param {webpack} A webpack object
*/
(config: webpack.Configuration, webpack: webpack.Webpack): NodeJS.ReadWriteStream;
/**
* Run webpack with the specified configuration and webpack instance
*
* @param {config} Webpack configuration
* @param {webpack} A webpack object
* @param {callback} A callback with the webpack stats and error objects.
*/
(config: webpack.Configuration,
webpack: webpack.Webpack,
callback?: (err: Error, stats: webpack.compiler.Stats) => void): NodeJS.ReadWriteStream;
}
var webpackStream: WebpackStreamStatic;
export = webpackStream;
declare namespace webpackStream {
}
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -19,4 +19,4 @@
"index.d.ts",
"webpack-stream-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+2 -2
View File
@@ -1,5 +1,5 @@
import webpackStream = require("webpack-stream");
import webpack = require("webpack");
import * as webpack from 'webpack';
import * as webpackStream from 'webpack-stream';
let output: NodeJS.ReadWriteStream;
+357 -408
View File
@@ -5,8 +5,22 @@
/// <reference types="node" />
import * as Tapable from 'tapable';
import * as UglifyJS from 'uglify-js';
import * as tapable from 'tapable';
export = webpack;
declare function webpack(
options: webpack.Configuration,
handler: webpack.Compiler.Handler
): webpack.Compiler.Watching | webpack.Compiler;
declare function webpack(options?: webpack.Configuration): webpack.Compiler;
declare function webpack(
options: webpack.Configuration[],
handler: webpack.MultiCompiler.Handler
): webpack.MultiWatching | webpack.MultiCompiler;
declare function webpack(options: webpack.Configuration[]): webpack.MultiCompiler;
declare namespace webpack {
interface Configuration {
@@ -46,7 +60,7 @@ declare namespace webpack {
cache?: boolean | any;
/** Enter watch mode, which rebuilds on file change. */
watch?: boolean;
watchOptions?: WatchOptions;
watchOptions?: Options.WatchOptions;
/** Switch loaders to debug mode. */
debug?: boolean;
/** Can be used to configure the behaviour of webpack-dev-server when the webpack config is passed to webpack-dev-server CLI. */
@@ -64,9 +78,9 @@ declare namespace webpack {
/** Add additional plugins to the compiler. */
plugins?: Plugin[];
/** Stats options for logging */
stats?: compiler.StatsToStringOptions;
stats?: Options.Stats;
/** Performance options */
performance?: PerformanceOptions;
performance?: Options.Performance;
}
interface Entry {
@@ -324,15 +338,6 @@ declare namespace webpack {
type ExternalsFunctionElement = (context: any, request: any, callback: (error: any, result: any) => void) => any;
interface WatchOptions {
/** Delay the rebuilt after the first change. Value is a time in ms. */
aggregateTimeout?: number;
/** For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like node_modules. It is also possible to use anymatch patterns. */
ignored?: RegExp | string;
/** true: use polling, number: use polling with specified interval */
poll?: boolean | number;
}
interface Node {
console?: boolean;
global?: boolean;
@@ -468,283 +473,335 @@ declare namespace webpack {
}
type Rule = LoaderRule | UseRule | RulesRule | OneOfRule;
interface Plugin extends tapable.Plugin {
apply(thisArg: Webpack, ...args: any[]): void;
namespace Options {
interface Performance {
/** This property allows webpack to control what files are used to calculate performance hints. */
assetFilter?(assetFilename: string): boolean;
/**
* Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are
* found. This property is set to "warning" by default.
*/
hints?: 'warning' | 'error' | boolean;
/**
* An asset is any emitted file from webpack. This option controls when webpack emits a performance hint
* based on individual asset size. The default value is 250000 (bytes).
*/
maxAssetSize?: number;
/**
* An entrypoint represents all assets that would be utilized during initial load time for a specific entry.
* This option controls when webpack should emit performance hints based on the maximum entrypoint size.
* The default value is 250000 (bytes).
*/
maxEntrypointSize?: number;
}
type Stats = webpack.Stats.ToStringOptions;
type WatchOptions = ICompiler.WatchOptions;
}
type UglifyCommentFunction = (astNode: any, comment: any) => boolean
interface UglifyPluginOptions extends UglifyJS.MinifyOptions {
beautify?: boolean;
comments?: boolean | RegExp | UglifyCommentFunction;
sourceMap?: boolean;
test?: Condition | Condition[];
include?: Condition | Condition[];
exclude?: Condition | Condition[];
// tslint:disable-next-line:interface-name
interface ICompiler {
run(handler: ICompiler.Handler): void;
watch(watchOptions: ICompiler.WatchOptions, handler: ICompiler.Handler): Watching;
}
interface Webpack {
(config: Configuration, callback?: compiler.CompilerCallback): compiler.Compiler;
/**
* optimize namespace
*/
optimize: Optimize;
/**
* dependencies namespace
*/
dependencies: Dependencies;
/**
* Replace resources that matches resourceRegExp with newResource.
* If newResource is relative, it is resolve relative to the previous resource.
* If newResource is a function, it is expected to overwrite the request attribute of the supplied object.
*/
NormalModuleReplacementPlugin: NormalModuleReplacementPluginStatic;
/**
* Replaces the default resource, recursive flag or regExp generated by parsing with newContentResource,
* newContentRecursive resp. newContextRegExp if the resource (directory) matches resourceRegExp.
* If newContentResource is relative, it is resolve relative to the previous resource.
* If newContentResource is a function, it is expected to overwrite the request attribute of the supplied object.
*/
ContextReplacementPlugin: ContextReplacementPluginStatic;
/**
* Dont generate modules for requests matching the provided RegExp.
*/
IgnorePlugin: IgnorePluginStatic;
/**
* A request for a normal module, which is resolved and built even before a require to it occurs.
* This can boost performance. Try to profile the build first to determine clever prefetching points.
*/
PrefetchPlugin: PrefetchPluginStatic;
/**
* Apply a plugin (or array of plugins) to one or more resolvers (as specified in types).
*/
ResolverPlugin: ResolverPluginStatic;
/**
* Adds a banner to the top of each generated chunk.
*/
BannerPlugin: BannerPluginStatic;
/**
* Define free variables. Useful for having development builds with debug logging or adding global constants.
*/
DefinePlugin: DefinePluginStatic;
/**
* Automatically loaded modules.
* Module (value) is loaded when the identifier (key) is used as free variable in a module.
* The identifier is filled with the exports of the loaded module.
*/
ProvidePlugin: ProvidePluginStatic;
/**
* Adds SourceMaps for assets.
*/
SourceMapDevToolPlugin: SourceMapDevToolPluginStatic;
/**
* Adds SourceMaps for assets, but wrapped inside eval statements.
* Much faster incremental build speed, but harder to debug.
*/
EvalSourceMapDevToolPlugin: EvalSourceMapDevToolPluginStatic;
/**
* Enables Hot Module Replacement. (This requires records data if not in dev-server mode, recordsPath)
* Generates Hot Update Chunks of each chunk in the records.
* It also enables the API and makes __webpack_hash__ available in the bundle.
*/
HotModuleReplacementPlugin: HotModuleReplacementPluginStatic;
/**
* Adds useful free vars to the bundle.
*/
ExtendedAPIPlugin: ExtendedAPIPluginStatic;
/**
* When there are errors while compiling this plugin skips the emitting phase (and recording phase),
* so there are no assets emitted that include errors. The emitted flag in the stats is false for all assets.
*/
NoEmitOnErrorsPlugin: NoEmitOnErrorsPluginStatic;
/**
* Alias for NoEmitOnErrorsPlugin
* @deprecated
*/
NoErrorsPlugin: NoEmitOnErrorsPluginStatic;
/**
* Does not watch specified files matching provided paths or RegExps.
*/
WatchIgnorePlugin: WatchIgnorePluginStatic;
/**
* Uses the module name as the module id inside the bundle, instead of a number.
* Helps with debugging, but increases bundle size.
*/
NamedModulesPlugin: NamedModulesPluginStatic;
/**
* Some loaders need context information and read them from the configuration.
* This need to be passed via loader options in the long-term. See loader documentation for relevant options.
* To keep compatibility with old loaders, these options can be passed via this plugin.
*/
LoaderOptionsPlugin: LoaderOptionsPluginStatic;
namespace ICompiler {
type Handler = (err: Error, stats: Stats) => void;
interface WatchOptions {
/**
* Add a delay before rebuilding once the first file changed. This allows webpack to aggregate any other
* changes made during this time period into one rebuild.
* Pass a value in milliseconds. Default: 300.
*/
aggregateTimeout?: number;
/**
* For some systems, watching many file systems can result in a lot of CPU or memory usage.
* It is possible to exclude a huge folder like node_modules.
* It is also possible to use anymatch patterns.
*/
ignored?: string | RegExp;
/** Turn on polling by passing true, or specifying a poll interval in milliseconds. */
poll?: boolean | number;
}
}
interface Optimize {
/**
* Search for equal or similar files and deduplicate them in the output.
* This comes with some overhead for the entry chunk, but can reduce file size effectively.
* This is experimental and may crash, because of some missing implementations. (Report an issue)
*/
DedupePlugin: optimize.DedupePluginStatic;
/**
* Limit the chunk count to a defined value. Chunks are merged until it fits.
*/
LimitChunkCountPlugin: optimize.LimitChunkCountPluginStatic;
/**
* Merge small chunks that are lower than this min size (in chars). Size is approximated.
*/
MinChunkSizePlugin: optimize.MinChunkSizePluginStatic;
/**
* Assign the module and chunk ids by occurrence count. Ids that are used often get lower (shorter) ids.
* This make ids predictable, reduces to total file size and is recommended.
*/
// TODO: This is a typo, and will be removed in Webpack 2.
OccurenceOrderPlugin: optimize.OccurenceOrderPluginStatic;
OccurrenceOrderPlugin: optimize.OccurenceOrderPluginStatic;
/**
* Minimize all JavaScript output of chunks. Loaders are switched into minimizing mode.
* You can pass an object containing UglifyJs options.
*/
UglifyJsPlugin: optimize.UglifyJsPluginStatic;
CommonsChunkPlugin: optimize.CommonsChunkPluginStatic;
/**
* A plugin for a more aggressive chunk merging strategy.
* Even similar chunks are merged if the total size is reduced enough.
* As an option modules that are not common in these chunks can be moved up the chunk tree to the parents.
*/
AggressiveMergingPlugin: optimize.AggressiveMergingPluginStatic;
interface Watching {
close(callback: () => void): void;
invalidate(): void;
}
interface Dependencies {
/**
* Support Labeled Modules.
*/
LabeledModulesPlugin: dependencies.LabeledModulesPluginStatic;
class Compiler extends Tapable implements ICompiler {
constructor();
name: string;
options: Configuration;
outputFileSystem: any;
run(handler: Compiler.Handler): void;
watch(watchOptions: Compiler.WatchOptions, handler: Compiler.Handler): Compiler.Watching;
}
interface DirectoryDescriptionFilePluginStatic {
new (file: string, files: string[]): Plugin;
namespace Compiler {
type Handler = ICompiler.Handler;
type WatchOptions = ICompiler.WatchOptions;
class Watching implements webpack.Watching {
constructor(compiler: Compiler, watchOptions: Watching.WatchOptions, handler: Watching.Handler);
close(callback: () => void): void;
invalidate(): void;
}
namespace Watching {
type WatchOptions = ICompiler.WatchOptions;
type Handler = ICompiler.Handler;
}
}
interface NormalModuleReplacementPluginStatic {
new (resourceRegExp: any, newResource: any): Plugin;
abstract class MultiCompiler implements ICompiler {
run(handler: MultiCompiler.Handler): void;
watch(watchOptions: MultiCompiler.WatchOptions, handler: MultiCompiler.Handler): MultiWatching;
}
interface ContextReplacementPluginStatic {
new (resourceRegExp: any, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): Plugin;
namespace MultiCompiler {
type Handler = ICompiler.Handler;
type WatchOptions = ICompiler.WatchOptions;
}
interface IgnorePluginStatic {
new (requestRegExp: any, contextRegExp?: any): Plugin;
abstract class MultiWatching implements Watching {
close(callback: () => void): void;
invalidate(): void;
}
interface PrefetchPluginStatic {
abstract class Plugin implements Tapable.Plugin {
apply(compiler: Compiler): void;
}
abstract class Stats {
/** Returns true if there were errors while compiling. */
hasErrors(): boolean;
/** Returns true if there were warnings while compiling. */
hasWarnings(): boolean;
/** Returns compilation information as a JSON object. */
toJson(options?: Stats.ToJsonOptions): any;
/** Returns a formatted string of the compilation information (similar to CLI output). */
toString(options?: Stats.ToStringOptions): string;
}
namespace Stats {
type Preset
= boolean
| 'errors-only'
| 'minimal'
| 'none'
| 'normal'
| 'verbose';
interface ToJsonOptionsObject {
/** Add asset Information */
assets?: boolean;
/** Sort assets by a field */
assetsSort?: string;
/** Add information about cached (not built) modules */
cached?: boolean;
/** Add children information */
children?: boolean;
/** Add built modules information to chunk information */
chunkModules?: boolean;
/** Add the origins of chunks and chunk merging info */
chunkOrigins?: boolean;
/** Add chunk information (setting this to `false` allows for a less verbose output) */
chunks?: boolean;
/** Sort the chunks by a field */
chunksSort?: string;
/** Context directory for request shortening */
context?: string;
/** Add details to errors (like resolving log) */
errorDetails?: boolean;
/** Add errors */
errors?: boolean;
/** Add the hash of the compilation */
hash?: boolean;
/** Add built modules information */
modules?: boolean;
/** Sort the modules by a field */
modulesSort?: string;
/** Add public path information */
publicPath?: boolean;
/** Add information about the reasons why modules are included */
reasons?: boolean;
/** Add the source code of modules */
source?: boolean;
/** Add timing information */
timings?: boolean;
/** Add webpack version information */
version?: boolean;
/** Add warnings */
warnings?: boolean;
}
type ToJsonOptions = Preset | ToJsonOptionsObject;
interface ToStringOptionsObject extends ToJsonOptionsObject {
/** `webpack --colors` equivalent */
colors?: boolean;
}
type ToStringOptions = Preset | ToStringOptionsObject;
}
/**
* Plugins
*/
class BannerPlugin extends Plugin {
constructor(banner: any, options: any);
}
class ContextReplacementPlugin extends Plugin {
constructor(resourceRegExp: any, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any);
}
class DefinePlugin extends Plugin {
constructor(definitions: {[key: string]: any});
}
class EvalSourceMapDevToolPlugin extends Plugin {
constructor(options?: false | string | EvalSourceMapDevToolPlugin.Options);
}
namespace EvalSourceMapDevToolPlugin {
interface Options {
append?: false | string;
columns?: boolean;
lineToLine?: boolean | {
exclude?: Condition | Condition[];
include?: Condition | Condition[];
test?: Condition | Condition[];
};
module?: boolean;
moduleFilenameTemplate?: string;
sourceRoot?: string;
}
}
class ExtendedAPIPlugin extends Plugin {
constructor();
}
class HotModuleReplacementPlugin extends Plugin {
constructor(options?: any);
}
class IgnorePlugin extends Plugin {
constructor(requestRegExp: any, contextRegExp?: any);
}
class LoaderOptionsPlugin extends Plugin {
constructor(options: any);
}
class NamedModulesPlugin extends Plugin {
constructor();
}
class NoEmitOnErrorsPlugin extends Plugin {
constructor();
}
/** @deprecated use webpack.NoEmitOnErrorsPlugin */
class NoErrorsPlugin extends Plugin {
constructor();
}
class NormalModuleReplacementPlugin extends Plugin {
constructor(resourceRegExp: any, newResource: any);
}
class PrefetchPlugin extends Plugin {
// tslint:disable-next-line:unified-signatures
new (context: any, request: any): Plugin;
new (request: any): Plugin;
constructor(context: any, request: any);
constructor(request: any);
}
interface ResolverPluginStatic {
new (plugins: Plugin[], files?: string[]): Plugin;
DirectoryDescriptionFilePlugin: DirectoryDescriptionFilePluginStatic;
/**
* This plugin will append a path to the module directory to find a match,
* which can be useful if you have a module which has an incorrect “main” entry in its package.json/bower.json etc (e.g. "main": "Gruntfile.js").
* You can use this plugin as a special case to load the correct file for this module. Example:
*/
FileAppendPlugin: FileAppendPluginStatic;
class ProvidePlugin extends Plugin {
constructor(definitions: {[key: string]: any});
}
interface FileAppendPluginStatic {
new (files: string[]): Plugin;
class SourceMapDevToolPlugin extends Plugin {
constructor(options?: null | false | string | SourceMapDevToolPlugin.Options);
}
interface BannerPluginStatic {
new (banner: any, options: any): Plugin;
}
interface DefinePluginStatic {
new (definitions: {[key: string]: any}): Plugin;
}
interface ProvidePluginStatic {
new (definitions: {[key: string]: any}): Plugin;
}
interface SourceMapDevToolPluginStatic {
// if string | false | null, maps to the filename option
new (options?: string | false | null | SourceMapDevToolPluginOptions): Plugin;
}
interface SourceMapDevToolPluginOptions {
// output filename pattern (false/null to append)
filename?: string | false | null;
// source map comment pattern (false to not append)
append?: false | string;
// template for the module filename inside the source map
moduleFilenameTemplate?: string;
// fallback used when the moduleFilenameTemplate produces a collision
fallbackModuleFilenameTemplate?: string;
// test/include/exclude files
test?: Condition | Condition[];
include?: Condition | Condition[];
exclude?: Condition | Condition[];
// whether to include the footer comment with source information
noSources?: boolean;
// the source map sourceRoot ("The URL root from which all sources are relative.")
sourceRoot?: string | null;
// whether to generate per-module source map
module?: boolean;
// whether to include column information in the source map
columns?: boolean;
// whether to preserve line numbers between source and source map
lineToLine?: boolean | {
test?: Condition | Condition[];
include?: Condition | Condition[];
namespace SourceMapDevToolPlugin {
/** @todo extend EvalSourceMapDevToolPlugin.Options */
interface Options {
append?: false | string;
columns?: boolean;
exclude?: Condition | Condition[];
};
}
interface EvalSourceMapDevToolPluginStatic {
// if string | false, maps to the append option
new (options?: string | false | EvalSourceMapDevToolPluginOptions): Plugin;
}
interface EvalSourceMapDevToolPluginOptions {
append?: false | string;
moduleFilenameTemplate?: string;
sourceRoot?: string;
module?: boolean;
columns?: boolean;
lineToLine?: boolean | {
test?: Condition | Condition[];
fallbackModuleFilenameTemplate?: string;
filename?: null | false | string;
include?: Condition | Condition[];
exclude?: Condition | Condition[];
};
lineToLine?: boolean | {
exclude?: Condition | Condition[];
include?: Condition | Condition[];
test?: Condition | Condition[];
};
module?: boolean;
moduleFilenameTemplate?: string;
noSources?: boolean;
sourceRoot?: null | string;
test?: Condition | Condition[];
}
}
interface HotModuleReplacementPluginStatic {
new (options?: any): Plugin;
class WatchIgnorePlugin extends Plugin {
constructor(paths: RegExp[]);
}
interface ExtendedAPIPluginStatic {
new (): Plugin;
namespace optimize {
class AggressiveMergingPlugin extends Plugin {
constructor(options: any);
}
class CommonsChunkPlugin extends Plugin {
constructor(options?: any);
}
/** @deprecated */
class DedupePlugin extends Plugin {
constructor();
}
class LimitChunkCountPlugin extends Plugin {
constructor(options: any);
}
class MinChunkSizePlugin extends Plugin {
constructor(options: any);
}
class OccurrenceOrderPlugin extends Plugin {
constructor(preferEntry: boolean);
}
class UglifyJsPlugin extends Plugin {
constructor(options?: UglifyJsPlugin.Options);
}
namespace UglifyJsPlugin {
type CommentFilter = (astNode: any, comment: any) => boolean;
interface Options extends UglifyJS.MinifyOptions {
beautify?: boolean;
comments?: boolean | RegExp | CommentFilter;
exclude?: Condition | Condition[];
include?: Condition | Condition[];
sourceMap?: boolean;
test?: Condition | Condition[];
}
}
}
interface NoEmitOnErrorsPluginStatic {
new (): Plugin;
}
interface WatchIgnorePluginStatic {
new (paths: RegExp[]): Plugin;
}
interface NamedModulesPluginStatic {
new (): Plugin;
}
interface LoaderOptionsPluginStatic {
new (options: any): Plugin;
namespace dependencies {
}
namespace loader {
@@ -810,7 +867,7 @@ declare namespace webpack {
data?: any;
callback: loaderCallback | void;
callback: loaderCallback;
/**
@@ -832,16 +889,16 @@ declare namespace webpack {
* In the example:
* [
* { request: "/abc/loader1.js?xyz",
* path: "/abc/loader1.js",
* query: "?xyz",
* module: [Function]
* },
* path: "/abc/loader1.js",
* query: "?xyz",
* module: [Function]
* },
* { request: "/abc/node_modules/loader2/index.js",
* path: "/abc/node_modules/loader2/index.js",
* query: "",
* module: [Function]
* }
*]
* path: "/abc/node_modules/loader2/index.js",
* query: "",
* module: [Function]
* }
* ]
*/
loaders: any[];
@@ -861,7 +918,7 @@ declare namespace webpack {
* The resource file.
* In the example: "/abc/resource.js"
*/
resourcePath: string
resourcePath: string;
/**
* The query of the resource.
@@ -898,14 +955,14 @@ declare namespace webpack {
* @param request
* @param callback
*/
resolve(context: string, request: string, callback: (err: Error, result: string) => void): any
resolve(context: string, request: string, callback: (err: Error, result: string) => void): any;
/**
* Resolve a request like a require expression.
* @param context
* @param request
*/
resolveSync(context: string, request: string): string
resolveSync(context: string, request: string): string;
/**
@@ -928,7 +985,7 @@ declare namespace webpack {
* Add a directory as dependency of the loader result.
* @param directory
*/
addContextDependency(directory: string): void
addContextDependency(directory: string): void;
/**
* Remove all dependencies of the loader result. Even initial dependencies and these of other loaders. Consider using pitch.
@@ -991,7 +1048,7 @@ declare namespace webpack {
* @param content
* @param sourceMap
*/
emitFile(name: string, content: Buffer|String, sourceMap: any): void
emitFile(name: string, content: Buffer|string, sourceMap: any): void;
/**
@@ -1007,7 +1064,7 @@ declare namespace webpack {
/**
* Hacky access to the Compiler object of webpack.
*/
_compiler: compiler.Compiler;
_compiler: Compiler;
/**
@@ -1017,148 +1074,40 @@ declare namespace webpack {
}
}
namespace optimize {
interface DedupePluginStatic {
new (): Plugin;
}
interface LimitChunkCountPluginStatic {
new (options: any): Plugin;
}
interface MinChunkSizePluginStatic {
new (options: any): Plugin;
}
interface OccurenceOrderPluginStatic {
new (preferEntry: boolean): Plugin;
}
interface UglifyJsPluginStatic {
new (options?: UglifyPluginOptions): Plugin;
}
interface CommonsChunkPluginStatic {
new (chunkName: string, filenames?: string | string[]): Plugin;
new (options?: any): Plugin;
}
interface AggressiveMergingPluginStatic {
new (options: any): Plugin;
}
}
namespace dependencies {
interface LabeledModulesPluginStatic {
new (): Plugin;
}
}
/** @deprecated */
namespace compiler {
interface Compiler {
/** Builds the bundle(s). */
run(callback: CompilerCallback): void;
/**
* Builds the bundle(s) then starts the watcher, which rebuilds bundles whenever their source files change.
* Returns a Watching instance. Note: since this will automatically run an initial build, so you only need to run watch (and not run).
*/
watch(watchOptions: WatchOptions, handler: CompilerCallback): Watching;
//TODO: below are some of the undocumented properties. needs typings
outputFileSystem: any;
name: string;
options: Configuration;
}
/** @deprecated use webpack.Compiler */
type Compiler = webpack.Compiler;
interface Watching {
close(callback: () => void): void;
}
/** @deprecated use webpack.Compiler.Watching */
type Watching = webpack.Compiler.Watching;
interface WatchOptions {
/** After a change the watcher waits that time (in milliseconds) for more changes. Default: 300. */
aggregateTimeout?: number;
/** For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like node_modules. It is also possible to use anymatch patterns. */
ignored?: RegExp | string;
/** The watcher uses polling instead of native watchers. true uses the default interval, a number specifies a interval in milliseconds. Default: undefined (automatic). */
poll?: number | boolean;
}
/** @deprecated use webpack.Compiler.WatchOptions */
type WatchOptions = webpack.Compiler.WatchOptions;
interface Stats {
/** Returns true if there were errors while compiling */
hasErrors(): boolean;
/** Returns true if there were warnings while compiling. */
hasWarnings(): boolean;
/** Return information as json object */
toJson(options?: StatsOptions): any; //TODO: type this
/** Returns a formatted string of the result. */
toString(options?: StatsToStringOptions): string;
}
/** @deprecated use webpack.Stats */
type Stats = webpack.Stats;
interface StatsOptions {
/** Add asset Information */
assets?: boolean;
/** Sort assets by a field */
assetsSort?: string;
/** Add information about cached (not built) modules */
cached?: boolean;
/** Add children information */
children?: boolean;
/** Add chunk information (setting this to `false` allows for a less verbose output) */
chunks?: boolean;
/** Add built modules information to chunk information */
chunkModules?: boolean;
/** Add the origins of chunks and chunk merging info */
chunkOrigins?: boolean;
/** Sort the chunks by a field */
chunksSort?: string;
/** Context directory for request shortening */
context?: string;
/** Add errors */
errors?: boolean;
/** Add details to errors (like resolving log) */
errorDetails?: boolean;
/** Add the hash of the compilation */
hash?: boolean;
/** Add built modules information */
modules?: boolean;
/** Sort the modules by a field */
modulesSort?: string;
/** Add public path information */
publicPath?: boolean;
/** Add information about the reasons why modules are included */
reasons?: boolean;
/** Add the source code of modules */
source?: boolean;
/** Add timing information */
timings?: boolean;
/** Add webpack version information */
version?: boolean;
/** Add warnings */
warnings?: boolean;
}
/** @deprecated use webpack.Stats.ToJsonOptions */
type StatsOptions = webpack.Stats.ToJsonOptions;
interface StatsToStringOptions extends StatsOptions {
/** With console colors */
colors?: boolean;
}
/** @deprecated use webpack.Stats.ToStringOptions */
type StatsToStringOptions = webpack.Stats.ToStringOptions;
type CompilerCallback = (err: Error, stats: Stats) => void;
/** @deprecated use webpack.Compiler.Handler */
type CompilerCallback = webpack.Compiler.Handler;
}
interface PerformanceOptions {
/**
* Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are found. This property is set to "warning" by default.
*/
hints?: boolean | 'error' | 'warning';
/**
* An entrypoint represents all assets that would be utilized during initial load time for a specific entry. This option controls when webpack should emit performance hints based on the maximum entrypoint size. The default value is 250000 (bytes).
*/
maxEntrypointSize?: number;
/**
* An asset is any emitted file from webpack. This option controls when webpack emits a performance hint based on individual asset size. The default value is 250000 (bytes).
*/
maxAssetSize?: number;
/**
* This property allows webpack to control what files are used to calculate performance hints.
*/
assetFilter?: (assetFilename: string) => boolean;
}
/** @deprecated use webpack.Options.Performance */
type PerformanceOptions = webpack.Options.Performance;
/** @deprecated use webpack.Options.WatchOptions */
type WatchOptions = webpack.Options.WatchOptions;
/** @deprecated use webpack.EvalSourceMapDevToolPlugin.Options */
type EvalSourceMapDevToolPluginOptions = webpack.EvalSourceMapDevToolPlugin.Options;
/** @deprecated use webpack.SourceMapDevToolPlugin.Options */
type SourceMapDevToolPluginOptions = webpack.SourceMapDevToolPlugin.Options;
/** @deprecated use webpack.optimize.UglifyJsPlugin.CommentFilter */
type UglifyCommentFunction = webpack.optimize.UglifyJsPlugin.CommentFilter;
/** @deprecated use webpack.optimize.UglifyJsPlugin.Options */
type UglifyPluginOptions = webpack.optimize.UglifyJsPlugin.Options;
}
declare var webpack: webpack.Webpack;
//export default webpack;
export = webpack;
+2 -2
View File
@@ -5,7 +5,7 @@
"es6"
],
"noImplicitAny": true,
"noImplicitThis": false,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
@@ -19,4 +19,4 @@
"index.d.ts",
"webpack-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+107 -126
View File
@@ -32,18 +32,6 @@ rule = {
query: { mimetype: "image/png" }
};
//
// https://webpack.github.io/docs/using-plugins.html
//
configuration = {
plugins: [
new webpack.ResolverPlugin([
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
], ["normal", "loader"])
]
};
//
// http://webpack.github.io/docs/tutorials/getting-started/
//
@@ -74,7 +62,10 @@ configuration = {
filename: "bundle.js"
},
plugins: [
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
filename: "vendor.bundle.js",
}),
]
};
@@ -138,10 +129,6 @@ configuration = {
output: {
filename: "[name].js"
},
plugins: [
new CommonsChunkPlugin("admin-commons.js", ["ap1", "ap2"]),
new CommonsChunkPlugin("commons.js", ["p1", "p2", "admin-commons.js"])
]
};
// <script>s required:
// page1.html: commons.js, p1.js
@@ -157,7 +144,10 @@ configuration = {
commons: "./entry-for-the-commons-chunk"
},
plugins: [
new CommonsChunkPlugin("commons", "commons.js")
new CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
}),
]
};
@@ -196,9 +186,9 @@ configuration = {
};
configuration = {
resolve: {
root: __dirname
}
resolve: {
root: __dirname
}
};
rule = {
@@ -217,7 +207,7 @@ declare var require: any;
declare var path: any;
configuration = {
plugins: [
function() {
function(this: webpack.Compiler) {
this.plugin("done", function(stats: any) {
require("fs").writeFileSync(
path.join(__dirname, "...", "stats.json"),
@@ -267,19 +257,11 @@ plugin = new webpack.IgnorePlugin(requestRegExp, contextRegExp);
plugin = new webpack.PrefetchPlugin(context, request);
plugin = new webpack.PrefetchPlugin(request);
plugin = new webpack.ResolverPlugin(plugins, types);
plugin = new webpack.ResolverPlugin(plugins);
plugin = new webpack.ResolverPlugin([
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
], ["normal", "loader"]);
plugin = new webpack.ResolverPlugin([
new webpack.ResolverPlugin.FileAppendPlugin(['/dist/compiled-moduled.js'])
]);
plugin = new webpack.BannerPlugin(banner, options);
plugin = new webpack.optimize.DedupePlugin();
plugin = new webpack.optimize.LimitChunkCountPlugin(options);
plugin = new webpack.optimize.MinChunkSizePlugin(options);
plugin = new webpack.optimize.OccurenceOrderPlugin(preferEntry);
plugin = new webpack.optimize.OccurrenceOrderPlugin(preferEntry);
plugin = new webpack.optimize.OccurrenceOrderPlugin(preferEntry);
plugin = new webpack.optimize.UglifyJsPlugin(options);
plugin = new webpack.optimize.UglifyJsPlugin();
@@ -289,12 +271,12 @@ plugin = new webpack.optimize.UglifyJsPlugin({
}
});
plugin = new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
comments: true,
beautify: true,
test: 'foo',
exclude: /node_modules/,
include: 'test'
sourceMap: false,
comments: true,
beautify: true,
test: 'foo',
exclude: /node_modules/,
include: 'test'
});
plugin = new webpack.optimize.UglifyJsPlugin({
mangle: {
@@ -302,9 +284,9 @@ plugin = new webpack.optimize.UglifyJsPlugin({
}
});
plugin = new webpack.optimize.UglifyJsPlugin({
comments: function(astNode: any, comment: any) {
return false;
}
comments: function(astNode: any, comment: any) {
return false;
}
});
plugin = new webpack.optimize.CommonsChunkPlugin(options);
plugin = new CommonsChunkPlugin({
@@ -344,7 +326,6 @@ plugin = new CommonsChunkPlugin({
// (3 children must share the module before it's separated)
});
plugin = new webpack.optimize.AggressiveMergingPlugin(options);
plugin = new webpack.dependencies.LabeledModulesPlugin();
plugin = new webpack.DefinePlugin(definitions);
plugin = new webpack.DefinePlugin({
VERSION: JSON.stringify("5fa3b9"),
@@ -383,7 +364,7 @@ plugin = new webpack.NoErrorsPlugin();
plugin = new webpack.NoEmitOnErrorsPlugin();
plugin = new webpack.WatchIgnorePlugin(paths);
plugin = new webpack.LoaderOptionsPlugin({
debug: true
debug: true
});
//
@@ -412,19 +393,19 @@ compiler.watch({ // watch options:
// pass a number to set the polling interval
}, function(err, stats) {
// ...
});
});
// or
compiler.watch({ // watch options:
ignored: 'foo/**/*'
}, function(err, stats) {
// ...
});
});
// or
compiler.watch({ // watch options:
ignored: /node_modules/
}, function(err, stats) {
// ...
});
});
declare function handleFatalError(err: Error): void;
declare function handleSoftErrors(errs: string[]): void;
@@ -438,26 +419,26 @@ webpack({
return handleFatalError(err);
var jsonStats = stats.toJson();
var jsonStatsWithAllOptions = stats.toJson({
assets: true,
assetsSort: "field",
cached: true,
children: true,
chunks: true,
chunkModules: true,
chunkOrigins: true,
chunksSort: "field",
context: "../src/",
errors: true,
errorDetails: true,
hash: true,
modules: true,
modulesSort: "field",
publicPath: true,
reasons: true,
source: true,
timings: true,
version: true,
warnings: true
assets: true,
assetsSort: "field",
cached: true,
children: true,
chunks: true,
chunkModules: true,
chunkOrigins: true,
chunksSort: "field",
context: "../src/",
errors: true,
errorDetails: true,
hash: true,
modules: true,
modulesSort: "field",
publicPath: true,
reasons: true,
source: true,
timings: true,
version: true,
warnings: true
});
if(jsonStats.errors.length > 0)
return handleSoftErrors(jsonStats.errors);
@@ -491,87 +472,87 @@ rule = {
}
configuration = {
module: {
rules: [
{ oneOf: [
{
test: {
and: [
/a.\.js$/,
/b\.js$/
]
},
loader: "./loader?first"
},
{
test: [
require.resolve("./a"),
require.resolve("./c"),
],
issuer: require.resolve("./b"),
use: [
"./loader?second-1",
{
loader: "./loader",
options: "second-2"
},
{
loader: "./loader",
options: {
get: function() { return "second-3"; }
}
}
]
},
{
test: {
or: [
require.resolve("./a"),
require.resolve("./c"),
]
},
loader: "./loader",
options: "third"
}
]}
]
}
module: {
rules: [
{ oneOf: [
{
test: {
and: [
/a.\.js$/,
/b\.js$/
]
},
loader: "./loader?first"
},
{
test: [
require.resolve("./a"),
require.resolve("./c"),
],
issuer: require.resolve("./b"),
use: [
"./loader?second-1",
{
loader: "./loader",
options: "second-2"
},
{
loader: "./loader",
options: {
get: function() { return "second-3"; }
}
}
]
},
{
test: {
or: [
require.resolve("./a"),
require.resolve("./c"),
]
},
loader: "./loader",
options: "third"
}
]}
]
}
}
const resolve: webpack.Resolve = {
cachePredicate: 'boo' // why does this test _not_ fail!?
}
const performance: webpack.PerformanceOptions = {
hints: 'error',
maxEntrypointSize: 400000,
maxAssetSize: 100000,
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js');
},
const performance: webpack.Options.Performance = {
hints: 'error',
maxEntrypointSize: 400000,
maxAssetSize: 100000,
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js');
},
};
configuration = {
performance,
performance,
};
function loader(this: webpack.loader.LoaderContext, source: string, sourcemap: string): void {
this.cacheable();
this.cacheable();
this.async();
this.async();
this.addDependency('');
this.addDependency('');
this.resolve('context', 'request', ( err: Error, result: string) => {});
this.resolve('context', 'request', ( err: Error, result: string) => {});
this.emitError('wraning');
this.emitError('wraning');
this.callback(null, source);
this.callback(null, source);
}
module loader {
export const raw: boolean = true;
export const pitch = (remainingRequest: string, precedingRequest: string, data: any) => {};
export const raw: boolean = true;
export const pitch = (remainingRequest: string, precedingRequest: string, data: any) => {};
}
const loaderRef: webpack.loader.Loader = loader;
console.log(loaderRef.raw === true);