diff --git a/.eslintrc.js b/.eslintrc.js index 37b4be6f4..79cee6b11 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,7 +23,7 @@ module.exports = { yoda: "error", eqeqeq: "error", "global-require": "off", - "brace-style": "error", + "brace-style": "off", "eol-last": "error", "no-extra-bind": "warn", "no-process-exit": "warn", diff --git a/README.md b/README.md index 8ee539501..344ca1fa9 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ [![deps][deps]][deps-url] [![tests][tests]][tests-url] [![builds][builds]][builds-url] +[![builds2][builds2]][builds2-url] [![coverage][cover]][cover-url] [![licenses][licenses]][licenses-url] @@ -752,6 +753,9 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"> [builds-url]: https://ci.appveyor.com/project/sokra/webpack/branch/master [builds]: https://ci.appveyor.com/api/projects/status/github/webpack/webpack?svg=true +[builds2]: https://dev.azure.com/webpack/webpack/_apis/build/status/webpack.webpack +[builds2-url]: https://dev.azure.com/webpack/webpack/_build/latest?definitionId=3 + [licenses-url]: https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fwebpack%2Fwebpack?ref=badge_shield [licenses]: https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fwebpack%2Fwebpack.svg?type=shield diff --git a/appveyor.yml b/appveyor.yml index db4d6e685..94ecae79a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,21 +13,8 @@ cache: - "..\\.yarn-cache" - ".jest-cache" -# what combinations to test -environment: - matrix: - - nodejs_version: 10 - job_part: unit - jest: --maxWorkers=2 --cacheDirectory .jest-cache - - nodejs_version: 10 - job_part: integration - jest: --maxWorkers=2 --cacheDirectory .jest-cache - - nodejs_version: 8 - job_part: integration - jest: --maxWorkers=2 --cacheDirectory .jest-cache - install: - - ps: Install-Product node $env:nodejs_version x64 + - ps: Install-Product node 10 x64 - yarn --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache - yarn link --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache || yarn link --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache - yarn link webpack --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache @@ -40,8 +27,8 @@ matrix: test_script: - node --version - yarn --version - - cmd: set JEST=%jest% - - cmd: yarn appveyor:%job_part% + - cmd: set JEST=--maxWorkers=2 --cacheDirectory .jest-cache + - cmd: yarn appveyor:integration - cmd: yarn istanbul report --report lcovonly - cmd: yarn unlink webpack - cmd: yarn global add codecov && codecov -F %job_part% --disable=gcov diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 11c5bf8a5..6ae32bda4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,17 +11,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn test:basic --ci yarn test:unit --ci @@ -38,17 +41,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn lint displayName: "Run linting" @@ -74,17 +80,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn cover:init yarn cover:integration "test/(?!TestCases)" --ci --maxWorkers=2 @@ -116,17 +125,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn cover:init yarn cover:integration "test/(?!TestCases)" --ci @@ -158,14 +170,17 @@ jobs: npm install --global yarn displayName: "Install Yarn" - script: | + set -e node -v yarn -v displayName: "Print versions" - script: | + set -e yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - - script: + - script: | + set -e yarn cover:init && yarn cover:integration "test/(?!TestCases)" --ci --maxWorkers=2 && move coverage\\coverage-final.json coverage\\coverage-final-1.json && yarn cover:integration "test/TestCasesD" --ci --maxWorkers=2 && move coverage\\coverage-final.json coverage\\coverage-final-2.json && yarn cover:integration "test/TestCases(?!D)" --ci --maxWorkers=2 && move coverage\\coverage-final.json coverage\\coverage-final-3.json displayName: "Run tests with coverage" diff --git a/declarations.d.ts b/declarations.d.ts index fceb5dac9..250601bc9 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -220,6 +220,15 @@ declare module "@webassemblyjs/ast" { export function isFuncImportDescr(n: Node): boolean; } +// This "hack" is needed because typescript doesn't support recursive type definitions +// It's referenced from "ruleSet-conditions" in schemas/WebpackOptions.json +interface RuleSetConditionsRecursive + extends Array {} +interface RuleSetConditionsAbsoluteRecursive + extends Array< + import("./declarations/WebpackOptions").RuleSetConditionAbsolute + > {} + /** * Global variable declarations * @todo Once this issue is resolved, remove these globals and add JSDoc onsite instead diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts new file mode 100644 index 000000000..4a3aee71f --- /dev/null +++ b/declarations/WebpackOptions.d.ts @@ -0,0 +1,1386 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "Entry". + */ +export type Entry = EntryDynamic | EntryStatic; +/** + * A Function returning an entry object, an entry string, an entry array or a promise to these things. + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryDynamic". + */ +export type EntryDynamic = (() => EntryStatic | Promise); +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryStatic". + */ +export type EntryStatic = EntryObject | EntryItem; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "NonEmptyArrayOfUniqueStringValues". + */ +export type NonEmptyArrayOfUniqueStringValues = string[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryItem". + */ +export type EntryItem = string | NonEmptyArrayOfUniqueStringValues; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "Externals". + */ +export type Externals = + | (( + context: string, + request: string, + callback: (err?: Error, result?: string) => void + ) => void) + | ExternalItem + | ( + | (( + context: string, + request: string, + callback: (err?: Error, result?: string) => void + ) => void) + | ExternalItem)[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ExternalItem". + */ +export type ExternalItem = + | string + | { + /** + * The dependency used for the external + */ + [k: string]: + | string + | { + [k: string]: any; + } + | ArrayOfStringValues + | boolean; + } + | RegExp; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ArrayOfStringValues". + */ +export type ArrayOfStringValues = string[]; +/** + * One or multiple rule conditions + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionOrConditions". + */ +export type RuleSetConditionOrConditions = RuleSetCondition | RuleSetConditions; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetCondition". + */ +export type RuleSetCondition = + | RegExp + | string + | ((value: string) => boolean) + | RuleSetConditions + | { + /** + * Logical AND + */ + and?: RuleSetConditions; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: RuleSetConditionOrConditions; + /** + * Exclude all modules matching not any of these conditions + */ + include?: RuleSetConditionOrConditions; + /** + * Logical NOT + */ + not?: RuleSetConditions; + /** + * Logical OR + */ + or?: RuleSetConditions; + /** + * Exclude all modules matching any of these conditions + */ + test?: RuleSetConditionOrConditions; + }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditions". + */ +export type RuleSetConditions = RuleSetConditionsRecursive; +/** + * One or multiple rule conditions + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionOrConditionsAbsolute". + */ +export type RuleSetConditionOrConditionsAbsolute = + | RuleSetConditionAbsolute + | RuleSetConditionsAbsolute; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionAbsolute". + */ +export type RuleSetConditionAbsolute = + | RegExp + | string + | ((value: string) => boolean) + | RuleSetConditionsAbsolute + | { + /** + * Logical AND + */ + and?: RuleSetConditionsAbsolute; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: RuleSetConditionOrConditionsAbsolute; + /** + * Exclude all modules matching not any of these conditions + */ + include?: RuleSetConditionOrConditionsAbsolute; + /** + * Logical NOT + */ + not?: RuleSetConditionsAbsolute; + /** + * Logical OR + */ + or?: RuleSetConditionsAbsolute; + /** + * Exclude all modules matching any of these conditions + */ + test?: RuleSetConditionOrConditionsAbsolute; + }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionsAbsolute". + */ +export type RuleSetConditionsAbsolute = RuleSetConditionsAbsoluteRecursive; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetLoader". + */ +export type RuleSetLoader = string; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetUse". + */ +export type RuleSetUse = RuleSetUseItem | Function | RuleSetUseItem[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetUseItem". + */ +export type RuleSetUseItem = + | RuleSetLoader + | Function + | { + /** + * Unique loader identifier + */ + ident?: string; + /** + * Loader name + */ + loader?: RuleSetLoader; + /** + * Loader options + */ + options?: RuleSetQuery; + /** + * Loader query + */ + query?: RuleSetQuery; + }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetQuery". + */ +export type RuleSetQuery = + | { + [k: string]: any; + } + | string; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ArrayOfStringOrStringArrayValues". + */ +export type ArrayOfStringOrStringArrayValues = (string | string[])[]; +/** + * Function acting as plugin + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "WebpackPluginFunction". + */ +export type WebpackPluginFunction = ( + compiler: import("../lib/Compiler") +) => void; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetRules". + */ +export type RuleSetRules = RuleSetRule[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "FilterTypes". + */ +export type FilterTypes = FilterItemTypes | FilterItemTypes[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "FilterItemTypes". + */ +export type FilterItemTypes = RegExp | string | Function; + +export interface WebpackOptions { + /** + * Set the value of `require.amd` and `define.amd`. + */ + amd?: { + [k: string]: any; + }; + /** + * Report the first error as a hard error instead of tolerating it. + */ + bail?: boolean; + /** + * Cache generated modules and chunks to improve performance for multiple incremental builds. + */ + cache?: + | boolean + | { + [k: string]: any; + }; + /** + * The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory. + */ + context?: string; + /** + * References to other configurations to depend on. + */ + dependencies?: string[]; + /** + * Options for the webpack-dev-server + */ + devServer?: { + [k: string]: any; + }; + /** + * A developer tool to enhance debugging. + */ + devtool?: string | false; + /** + * The entry point(s) of the compilation. + */ + entry?: Entry; + /** + * Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`. + */ + externals?: Externals; + /** + * Custom values available in the loader context. + */ + loader?: { + [k: string]: any; + }; + /** + * Enable production optimizations or development hints. + */ + mode?: "development" | "production" | "none"; + /** + * Options affecting the normal modules (`NormalModuleFactory`). + */ + module?: ModuleOptions; + /** + * Name of the configuration. Used when loading multiple configurations. + */ + name?: string; + /** + * Include polyfills or mocks for various node stuff. + */ + node?: false | NodeOptions; + /** + * Enables/Disables integrated optimizations + */ + optimization?: OptimizationOptions; + /** + * Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk. + */ + output?: OutputOptions; + /** + * The number of parallel processed modules in the compilation. + */ + parallelism?: number; + /** + * Configuration for web performance recommendations. + */ + performance?: false | PerformanceOptions; + /** + * Add additional plugins to the compiler. + */ + plugins?: (WebpackPluginInstance | WebpackPluginFunction)[]; + /** + * Capture timing information for each module. + */ + profile?: boolean; + /** + * Store compiler state to a json file. + */ + recordsInputPath?: string; + /** + * Load compiler state from a json file. + */ + recordsOutputPath?: string; + /** + * Store/Load compiler state from/to a json file. This will result in persistent ids of modules and chunks. An absolute path is expected. `recordsPath` is used for `recordsInputPath` and `recordsOutputPath` if they left undefined. + */ + recordsPath?: string; + /** + * Options for the resolver + */ + resolve?: ResolveOptions; + /** + * Options for the resolver when resolving loaders + */ + resolveLoader?: ResolveOptions; + /** + * Options for webpack-serve + */ + serve?: { + [k: string]: any; + }; + /** + * Used by the webpack CLI program to pass stats options. + */ + stats?: + | StatsOptions + | boolean + | ("none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose"); + /** + * Environment to build for + */ + target?: + | ( + | "web" + | "webworker" + | "node" + | "async-node" + | "node-webkit" + | "electron-main" + | "electron-renderer") + | ((compiler: import("../lib/Compiler")) => void); + /** + * Enter watch mode, which rebuilds on file change. + */ + watch?: boolean; + /** + * Options for the watcher + */ + watchOptions?: { + /** + * Delay the rebuilt after the first change. Value is a time in ms. + */ + aggregateTimeout?: number; + /** + * Ignore some files from watching + */ + ignored?: { + [k: string]: any; + }; + /** + * Enable polling mode for watching + */ + poll?: boolean | number; + /** + * Stop watching when stdin stream has ended + */ + stdin?: boolean; + }; +} +/** + * Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array. + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryObject". + */ +export interface EntryObject { + /** + * An entry point with name + */ + [k: string]: string | NonEmptyArrayOfUniqueStringValues; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ModuleOptions". + */ +export interface ModuleOptions { + /** + * An array of rules applied by default for modules. + */ + defaultRules?: RuleSetRules; + /** + * Enable warnings for full dynamic dependencies + */ + exprContextCritical?: boolean; + /** + * Enable recursive directory lookup for full dynamic dependencies + */ + exprContextRecursive?: boolean; + /** + * Sets the default regular expression for full dynamic dependencies + */ + exprContextRegExp?: boolean | RegExp; + /** + * Set the default request for full dynamic dependencies + */ + exprContextRequest?: string; + /** + * Don't parse files matching. It's matched against the full resolved request. + */ + noParse?: RegExp[] | RegExp | Function | string[] | string; + /** + * An array of rules applied for modules. + */ + rules?: RuleSetRules; + /** + * Emit errors instead of warnings when imported names don't exist in imported module + */ + strictExportPresence?: boolean; + /** + * Handle the this context correctly according to the spec for namespace objects + */ + strictThisContextOnImports?: boolean; + /** + * Enable warnings when using the require function in a not statically analyse-able way + */ + unknownContextCritical?: boolean; + /** + * Enable recursive directory lookup when using the require function in a not statically analyse-able way + */ + unknownContextRecursive?: boolean; + /** + * Sets the regular expression when using the require function in a not statically analyse-able way + */ + unknownContextRegExp?: boolean | RegExp; + /** + * Sets the request when using the require function in a not statically analyse-able way + */ + unknownContextRequest?: string; + /** + * Cache the resolving of module requests + */ + unsafeCache?: boolean | Function; + /** + * Enable warnings for partial dynamic dependencies + */ + wrappedContextCritical?: boolean; + /** + * Enable recursive directory lookup for partial dynamic dependencies + */ + wrappedContextRecursive?: boolean; + /** + * Set the inner regular expression for partial dynamic dependencies + */ + wrappedContextRegExp?: RegExp; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetRule". + */ +export interface RuleSetRule { + /** + * Match the child compiler name + */ + compiler?: RuleSetConditionOrConditions; + /** + * Enforce this rule as pre or post step + */ + enforce?: "pre" | "post"; + /** + * Shortcut for resource.exclude + */ + exclude?: RuleSetConditionOrConditionsAbsolute; + /** + * Shortcut for resource.include + */ + include?: RuleSetConditionOrConditionsAbsolute; + /** + * Match the issuer of the module (The module pointing to this module) + */ + issuer?: RuleSetConditionOrConditionsAbsolute; + /** + * Shortcut for use.loader + */ + loader?: RuleSetLoader | RuleSetUse; + /** + * Shortcut for use.loader + */ + loaders?: RuleSetUse; + /** + * Only execute the first matching rule in this array + */ + oneOf?: RuleSetRules; + /** + * Shortcut for use.options + */ + options?: RuleSetQuery; + /** + * Options for parsing + */ + parser?: { + [k: string]: any; + }; + /** + * Shortcut for use.query + */ + query?: RuleSetQuery; + /** + * Options for the resolver + */ + resolve?: ResolveOptions; + /** + * Match the resource path of the module + */ + resource?: RuleSetConditionOrConditionsAbsolute; + /** + * Match the resource query of the module + */ + resourceQuery?: RuleSetConditionOrConditions; + /** + * Match and execute these rules when this rule is matched + */ + rules?: RuleSetRules; + /** + * Flags a module as with or without side effects + */ + sideEffects?: boolean; + /** + * Shortcut for resource.test + */ + test?: RuleSetConditionOrConditionsAbsolute; + /** + * Module type to use for the module + */ + type?: + | "javascript/auto" + | "javascript/dynamic" + | "javascript/esm" + | "json" + | "webassembly/experimental"; + /** + * Modifiers applied to the module when rule is matched + */ + use?: RuleSetUse; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ResolveOptions". + */ +export interface ResolveOptions { + /** + * Redirect module requests + */ + alias?: + | { + /** + * New request + */ + [k: string]: string; + } + | { + /** + * New request + */ + alias?: string; + /** + * Request to be redirected + */ + name?: string; + /** + * Redirect only exact matching request + */ + onlyModule?: boolean; + }[]; + /** + * Fields in the description file (package.json) which are used to redirect requests inside the module + */ + aliasFields?: ArrayOfStringOrStringArrayValues; + /** + * Predicate function to decide which requests should be cached + */ + cachePredicate?: Function; + /** + * Include the context information in the cache identifier when caching + */ + cacheWithContext?: boolean; + /** + * Enable concord resolving extras + */ + concord?: boolean; + /** + * Filenames used to find a description file + */ + descriptionFiles?: ArrayOfStringValues; + /** + * Enforce using one of the extensions from the extensions option + */ + enforceExtension?: boolean; + /** + * Enforce using one of the module extensions from the moduleExtensions option + */ + enforceModuleExtension?: boolean; + /** + * Extensions added to the request when trying to find the file + */ + extensions?: ArrayOfStringValues; + /** + * Filesystem for the resolver + */ + fileSystem?: { + [k: string]: any; + }; + /** + * Field names from the description file (package.json) which are used to find the default entry point + */ + mainFields?: ArrayOfStringOrStringArrayValues; + /** + * Filenames used to find the default entry point if there is no description file or main field + */ + mainFiles?: ArrayOfStringValues; + /** + * Extensions added to the module request when trying to find the module + */ + moduleExtensions?: ArrayOfStringValues; + /** + * Folder names or directory paths where to find modules + */ + modules?: ArrayOfStringValues; + /** + * Plugins for the resolver + */ + plugins?: (WebpackPluginInstance | WebpackPluginFunction)[]; + /** + * Custom resolver + */ + resolver?: { + [k: string]: any; + }; + /** + * Enable resolving symlinks to the original location + */ + symlinks?: boolean; + /** + * Enable caching of successfully resolved requests + */ + unsafeCache?: + | boolean + | { + [k: string]: any; + }; + /** + * Use synchronous filesystem calls for the resolver + */ + useSyncFileSystemCalls?: boolean; +} +/** + * Plugin instance + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "WebpackPluginInstance". + */ +export interface WebpackPluginInstance { + /** + * The run point of the plugin, required method. + */ + apply: (compiler: import("../lib/Compiler")) => void; + [k: string]: any; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "NodeOptions". + */ +export interface NodeOptions { + /** + * Include a polyfill for the 'Buffer' variable + */ + Buffer?: false | true | "mock"; + /** + * Include a polyfill for the '__dirname' variable + */ + __dirname?: false | true | "mock"; + /** + * Include a polyfill for the '__filename' variable + */ + __filename?: false | true | "mock"; + /** + * Include a polyfill for the 'console' variable + */ + console?: false | true | "mock"; + /** + * Include a polyfill for the 'global' variable + */ + global?: boolean; + /** + * Include a polyfill for the 'process' variable + */ + process?: false | true | "mock"; + /** + * Include a polyfill for the node.js module + */ + [k: string]: false | true | "mock" | "empty"; +} +/** + * Enables/Disables integrated optimizations + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "OptimizationOptions". + */ +export interface OptimizationOptions { + /** + * Check for incompatible wasm types when importing/exporting from/to ESM + */ + checkWasmTypes?: boolean; + /** + * Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + chunkIds?: "natural" | "named" | "size" | "total-size" | false; + /** + * Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer + */ + concatenateModules?: boolean; + /** + * Also flag chunks as loaded which contain a subset of the modules + */ + flagIncludedChunks?: boolean; + /** + * Reduce size of WASM by changing imports to shorter strings. + */ + mangleWasmImports?: boolean; + /** + * Merge chunks which contain the same modules + */ + mergeDuplicateChunks?: boolean; + /** + * Enable minimizing the output. Uses optimization.minimizer. + */ + minimize?: boolean; + /** + * Minimizer(s) to use for minimizing the output + */ + minimizer?: (WebpackPluginInstance | WebpackPluginFunction)[]; + /** + * Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, deterministic: numeric hash ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + moduleIds?: + | "natural" + | "named" + | "hashed" + | "deterministic" + | "size" + | "total-size" + | false; + /** + * Avoid emitting assets when errors occur + */ + noEmitOnErrors?: boolean; + /** + * Set process.env.NODE_ENV to a specific value + */ + nodeEnv?: false | string; + /** + * Generate records with relative paths to be able to move the context folder + */ + portableRecords?: boolean; + /** + * Figure out which exports are provided by modules to generate more efficient code + */ + providedExports?: boolean; + /** + * Removes modules from chunks when these modules are already included in all parents + */ + removeAvailableModules?: boolean; + /** + * Remove chunks which are empty + */ + removeEmptyChunks?: boolean; + /** + * Create an additional chunk which contains only the webpack runtime and chunk hash maps + */ + runtimeChunk?: + | boolean + | ("single" | "multiple") + | { + /** + * The name or name factory for the runtime chunks + */ + name?: string | Function; + }; + /** + * Skip over modules which are flagged to contain no side effects when exports are not used + */ + sideEffects?: boolean; + /** + * Optimize duplication and caching by splitting chunks by shared modules and cache group + */ + splitChunks?: false | OptimizationSplitChunksOptions; + /** + * Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code + */ + usedExports?: boolean; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "OptimizationSplitChunksOptions". + */ +export interface OptimizationSplitChunksOptions { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) + */ + cacheGroups?: { + /** + * Configuration for a cache group + */ + [k: string]: + | false + | Function + | string + | RegExp + | { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Sets the name prefix for created chunks + */ + automaticNamePrefix?: string; + /** + * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: ("initial" | "async" | "all") | Function; + /** + * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group + */ + enforce?: boolean; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + /** + * Give chunks for this cache group a name (chunks with equal name are merged) + */ + name?: boolean | Function | string; + /** + * Priority of this cache group + */ + priority?: number; + /** + * Try to reuse existing chunk (with name) when it has matching modules + */ + reuseExistingChunk?: boolean; + /** + * Assign modules to a cache group by module name + */ + test?: Function | string | RegExp; + /** + * Assign modules to a cache group by module type + */ + type?: Function | string | RegExp; + }; + }; + /** + * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: ("initial" | "async" | "all") | Function; + /** + * Options for modules not selected by any other cache group + */ + fallbackCacheGroup?: { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + }; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Prevents exposing path info when creating names for parts splitted by maxSize + */ + hidePathInfo?: boolean; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Minimal size for the created chunks + */ + minSize?: number; + /** + * Give chunks created a name (chunks with equal name are merged) + */ + name?: boolean | Function | string; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "OutputOptions". + */ +export interface OutputOptions { + /** + * Add a comment in the UMD wrapper. + */ + auxiliaryComment?: + | string + | { + /** + * Set comment for `amd` section in UMD + */ + amd?: string; + /** + * Set comment for `commonjs` (exports) section in UMD + */ + commonjs?: string; + /** + * Set comment for `commonjs2` (module.exports) section in UMD + */ + commonjs2?: string; + /** + * Set comment for `root` (global variable) section in UMD + */ + root?: string; + }; + /** + * The callback function name used by webpack for loading of chunks in WebWorkers. + */ + chunkCallbackName?: string; + /** + * The filename of non-entry chunks as relative path inside the `output.path` directory. + */ + chunkFilename?: string; + /** + * Number of milliseconds before chunk request expires + */ + chunkLoadTimeout?: number; + /** + * This option enables cross-origin loading of chunks. + */ + crossOriginLoading?: false | "anonymous" | "use-credentials"; + /** + * Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers. + */ + devtoolFallbackModuleFilenameTemplate?: string | Function; + /** + * Enable line to line mapped mode for all/specified modules. Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. It’s a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines. + */ + devtoolLineToLine?: + | boolean + | { + [k: string]: any; + }; + /** + * Filename template string of function for the sources array in a generated SourceMap. + */ + devtoolModuleFilenameTemplate?: string | Function; + /** + * Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries. + */ + devtoolNamespace?: string; + /** + * Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files. + */ + filename?: string | Function; + /** + * An expression which is used to address the global object/scope in runtime code + */ + globalObject?: string; + /** + * Digest type used for the hash + */ + hashDigest?: string; + /** + * Number of chars which are used for the hash + */ + hashDigestLength?: number; + /** + * Algorithm used for generation the hash (see node.js crypto package) + */ + hashFunction?: string | (new () => import("../lib/util/createHash").Hash); + /** + * Any string which is added to the hash to salt it + */ + hashSalt?: string; + /** + * The filename of the Hot Update Chunks. They are inside the output.path directory. + */ + hotUpdateChunkFilename?: string; + /** + * The JSONP function used by webpack for async loading of hot update chunks. + */ + hotUpdateFunction?: string; + /** + * The filename of the Hot Update Main File. It is inside the `output.path` directory. + */ + hotUpdateMainFilename?: string; + /** + * The JSONP function used by webpack for async loading of chunks. + */ + jsonpFunction?: string; + /** + * This option enables loading async chunks via a custom script type, such as script type="module" + */ + jsonpScriptType?: false | "text/javascript" | "module"; + /** + * If set, export the bundle as library. `output.library` is the name. + */ + library?: string | string[] | LibraryCustomUmdObject; + /** + * Specify which export should be exposed as library + */ + libraryExport?: string | ArrayOfStringValues; + /** + * Type of library + */ + libraryTarget?: + | "var" + | "assign" + | "this" + | "window" + | "self" + | "global" + | "commonjs" + | "commonjs2" + | "commonjs-module" + | "amd" + | "umd" + | "umd2" + | "jsonp"; + /** + * The output directory as **absolute path** (required). + */ + path?: string; + /** + * Include comments with information about the modules. + */ + pathinfo?: boolean; + /** + * The `publicPath` specifies the public URL address of the output files when referenced in a browser. + */ + publicPath?: string | Function; + /** + * The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory. + */ + sourceMapFilename?: string; + /** + * Prefixes every line of the source in the bundle with this string. + */ + sourcePrefix?: string; + /** + * Handles exceptions in module loading correctly at a performance cost. + */ + strictModuleExceptionHandling?: boolean; + /** + * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module. + */ + umdNamedDefine?: boolean; + /** + * The filename of WebAssembly modules as relative path inside the `output.path` directory. + */ + webassemblyModuleFilename?: string; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "LibraryCustomUmdObject". + */ +export interface LibraryCustomUmdObject { + /** + * Name of the exposed AMD library in the UMD + */ + amd?: string; + /** + * Name of the exposed commonjs export in the UMD + */ + commonjs?: string; + /** + * Name of the property exposed globally by a UMD library + */ + root?: string | ArrayOfStringValues; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "PerformanceOptions". + */ +export interface PerformanceOptions { + /** + * Filter function to select assets that are checked + */ + assetFilter?: Function; + /** + * Sets the format of the hints: warnings, errors or nothing at all + */ + hints?: false | "warning" | "error"; + /** + * Filesize limit (in bytes) when exceeded, that webpack will provide performance hints + */ + maxAssetSize?: number; + /** + * Total size of an entry point (in bytes) + */ + maxEntrypointSize?: number; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "StatsOptions". + */ +export interface StatsOptions { + /** + * fallback value for stats options when an option is not defined (has precedence over local webpack defaults) + */ + all?: boolean; + /** + * add assets information + */ + assets?: boolean; + /** + * sort the assets by that field + */ + assetsSort?: string; + /** + * add built at time information + */ + builtAt?: boolean; + /** + * add information about cached (not built) modules + */ + cached?: boolean; + /** + * Show cached assets (setting this to `false` only shows emitted files) + */ + cachedAssets?: boolean; + /** + * add children information + */ + children?: boolean; + /** + * Display all chunk groups with the corresponding bundles + */ + chunkGroups?: boolean; + /** + * add built modules information to chunk information + */ + chunkModules?: boolean; + /** + * add the origins of chunks and chunk merging info + */ + chunkOrigins?: boolean; + /** + * add chunk information + */ + chunks?: boolean; + /** + * sort the chunks by that field + */ + chunksSort?: string; + /** + * Enables/Disables colorful output + */ + colors?: + | boolean + | { + /** + * Custom color for bold text + */ + bold?: string; + /** + * Custom color for cyan text + */ + cyan?: string; + /** + * Custom color for green text + */ + green?: string; + /** + * Custom color for magenta text + */ + magenta?: string; + /** + * Custom color for red text + */ + red?: string; + /** + * Custom color for yellow text + */ + yellow?: string; + }; + /** + * context directory for request shortening + */ + context?: string; + /** + * add module depth in module graph + */ + depth?: boolean; + /** + * Display the entry points with the corresponding bundles + */ + entrypoints?: boolean; + /** + * add --env information + */ + env?: boolean; + /** + * add details to errors (like resolving log) + */ + errorDetails?: boolean; + /** + * add errors + */ + errors?: boolean; + /** + * Please use excludeModules instead. + */ + exclude?: FilterTypes | boolean; + /** + * Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions + */ + excludeAssets?: FilterTypes; + /** + * Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions + */ + excludeModules?: FilterTypes | boolean; + /** + * add the hash of the compilation + */ + hash?: boolean; + /** + * Set the maximum number of modules to be shown + */ + maxModules?: number; + /** + * add information about assets inside modules + */ + moduleAssets?: boolean; + /** + * add dependencies and origin of warnings/errors + */ + moduleTrace?: boolean; + /** + * add built modules information + */ + modules?: boolean; + /** + * sort the modules by that field + */ + modulesSort?: string; + /** + * add information about modules nested in other modules (like with module concatenation) + */ + nestedModules?: boolean; + /** + * show reasons why optimization bailed out for modules + */ + optimizationBailout?: boolean; + /** + * add information about orphan modules + */ + orphanModules?: boolean; + /** + * Add output path information + */ + outputPath?: boolean; + /** + * add performance hint flags + */ + performance?: boolean; + /** + * show exports provided by modules + */ + providedExports?: boolean; + /** + * 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; + /** + * show exports used by modules + */ + usedExports?: boolean; + /** + * add webpack version information + */ + version?: boolean; + /** + * add warnings + */ + warnings?: boolean; + /** + * Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions + */ + warningsFilter?: FilterTypes; +} diff --git a/declarations/plugins/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts new file mode 100644 index 000000000..4b3810596 --- /dev/null +++ b/declarations/plugins/BannerPlugin.d.ts @@ -0,0 +1,51 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export type BannerPluginArgument = + | BannerPluginOptions + | BannerFunction + | string; +/** + * The banner as function, it will be wrapped in a comment + */ +export type BannerFunction = ( + data: { + hash: string; + chunk: import("../../lib/Chunk"); + filename: string; + basename: string; + query: string; + } +) => string; +export type Rules = Rule[] | Rule; +export type Rule = RegExp | string; + +export interface BannerPluginOptions { + /** + * Specifies the banner + */ + banner: BannerFunction | string; + /** + * If true, the banner will only be added to the entry chunks + */ + entryOnly?: boolean; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: Rules; + /** + * Include all modules matching any of these conditions + */ + include?: Rules; + /** + * If true, banner will not be wrapped in a comment + */ + raw?: boolean; + /** + * Include all modules that pass test assertion + */ + test?: Rules; +} diff --git a/declarations/plugins/DllPlugin.d.ts b/declarations/plugins/DllPlugin.d.ts new file mode 100644 index 000000000..f7264c2da --- /dev/null +++ b/declarations/plugins/DllPlugin.d.ts @@ -0,0 +1,28 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface DllPluginOptions { + /** + * Context of requests in the manifest file (defaults to the webpack context) + */ + context?: string; + /** + * If true, only entry points will be exposed + */ + entryOnly?: boolean; + /** + * Name of the exposed dll function (external name, use value of 'output.library') + */ + name?: string; + /** + * Absolute path to the manifest json file (output) + */ + path: string; + /** + * Type of the dll bundle (external type, use value of 'output.libraryTarget') + */ + type?: string; +} diff --git a/declarations/plugins/DllReferencePlugin.d.ts b/declarations/plugins/DllReferencePlugin.d.ts new file mode 100644 index 000000000..2354a7e63 --- /dev/null +++ b/declarations/plugins/DllReferencePlugin.d.ts @@ -0,0 +1,125 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export type DllReferencePluginOptions = + | { + /** + * (absolute path) context of requests in the manifest (or content property) + */ + context?: string; + /** + * Extensions used to resolve modules in the dll bundle (only used when using 'scope') + */ + extensions?: string[]; + /** + * An object containing content and name or a string to the absolute path of the JSON manifest to be loaded upon compilation + */ + manifest: DllReferencePluginOptionsManifest | string; + /** + * The name where the dll is exposed (external name, defaults to manifest.name) + */ + name?: string; + /** + * Prefix which is used for accessing the content of the dll + */ + scope?: string; + /** + * How the dll is exposed (libraryTarget, defaults to manifest.type) + */ + sourceType?: DllReferencePluginOptionsSourceType; + /** + * The way how the export of the dll bundle is used + */ + type?: "require" | "object"; + } + | { + /** + * The mappings from request to module info + */ + content: DllReferencePluginOptionsContent; + /** + * (absolute path) context of requests in the manifest (or content property) + */ + context?: string; + /** + * Extensions used to resolve modules in the dll bundle (only used when using 'scope') + */ + extensions?: string[]; + /** + * The name where the dll is exposed (external name) + */ + name: string; + /** + * Prefix which is used for accessing the content of the dll + */ + scope?: string; + /** + * How the dll is exposed (libraryTarget) + */ + sourceType?: DllReferencePluginOptionsSourceType; + /** + * The way how the export of the dll bundle is used + */ + type?: "require" | "object"; + }; +/** + * The type how the dll is exposed (external type) + */ +export type DllReferencePluginOptionsSourceType = + | "var" + | "assign" + | "this" + | "window" + | "global" + | "commonjs" + | "commonjs2" + | "commonjs-module" + | "amd" + | "umd" + | "umd2" + | "jsonp"; + +/** + * An object containing content, name and type + */ +export interface DllReferencePluginOptionsManifest { + /** + * The mappings from request to module info + */ + content: DllReferencePluginOptionsContent; + /** + * The name where the dll is exposed (external name) + */ + name?: string; + /** + * The type how the dll is exposed (external type) + */ + type?: DllReferencePluginOptionsSourceType; +} +/** + * The mappings from request to module info + */ +export interface DllReferencePluginOptionsContent { + /** + * Module info + */ + [k: string]: { + /** + * Meta information about the module + */ + buildMeta?: { + [k: string]: any; + }; + /** + * Information about the provided exports of the module + */ + exports?: true | string[]; + /** + * Module ID + */ + id: number | string; + }; +} diff --git a/declarations/plugins/HashedModuleIdsPlugin.d.ts b/declarations/plugins/HashedModuleIdsPlugin.d.ts new file mode 100644 index 000000000..571ab60a4 --- /dev/null +++ b/declarations/plugins/HashedModuleIdsPlugin.d.ts @@ -0,0 +1,24 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface HashedModuleIdsPluginOptions { + /** + * The context directory for creating names. + */ + context?: string; + /** + * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. + */ + hashDigest?: "hex" | "latin1" | "base64"; + /** + * The prefix length of the hash digest to use, defaults to 4. + */ + hashDigestLength?: number; + /** + * The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported. + */ + hashFunction?: string; +} diff --git a/declarations/plugins/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts new file mode 100644 index 000000000..01ac08139 --- /dev/null +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -0,0 +1,27 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export type IgnorePluginOptions = + | { + /** + * A RegExp to test the context (directory) against + */ + contextRegExp?: RegExp; + /** + * A RegExp to test the request against + */ + resourceRegExp?: RegExp; + } + | { + /** + * A filter function for context + */ + checkContext?: ((context: string) => boolean); + /** + * A filter function for resource + */ + checkResource?: ((resource: string) => boolean); + }; diff --git a/declarations/plugins/LoaderOptionsPlugin.d.ts b/declarations/plugins/LoaderOptionsPlugin.d.ts new file mode 100644 index 000000000..cb48ecc28 --- /dev/null +++ b/declarations/plugins/LoaderOptionsPlugin.d.ts @@ -0,0 +1,27 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface LoaderOptionsPluginOptions { + /** + * Whether loaders should be in debug mode or not. debug will be removed as of webpack 3 + */ + debug?: boolean; + /** + * Where loaders can be switched to minimize mode + */ + minimize?: boolean; + /** + * A configuration object that can be used to configure older loaders + */ + options?: { + /** + * The context that can be used to configure older loaders + */ + context?: string; + [k: string]: any; + }; + [k: string]: any; +} diff --git a/declarations/plugins/SourceMapDevToolPlugin.d.ts b/declarations/plugins/SourceMapDevToolPlugin.d.ts new file mode 100644 index 000000000..76421b508 --- /dev/null +++ b/declarations/plugins/SourceMapDevToolPlugin.d.ts @@ -0,0 +1,94 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +/** + * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema + * via the `definition` "rules". + */ +export type Rules = Rule[] | Rule; +/** + * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema + * via the `definition` "rule". + */ +export type Rule = RegExp | string; + +export interface SourceMapDevToolPluginOptions { + /** + * Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending + */ + append?: (false | null) | string; + /** + * Indicates whether column mappings should be used (defaults to true) + */ + columns?: boolean; + /** + * Exclude modules that match the given value from source map generation + */ + exclude?: Rules; + /** + * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict + */ + fallbackModuleFilenameTemplate?: Function | string; + /** + * Path prefix to which the [file] placeholder is relative to + */ + fileContext?: string; + /** + * Defines the output filename of the SourceMap (will be inlined if no value is provided) + */ + filename?: (false | null) | string; + /** + * Include source maps for module paths that match the given value + */ + include?: Rules; + /** + * (deprecated) try to map original files line to line to generated files + */ + lineToLine?: + | boolean + | { + /** + * Exclude modules that match the given value from source map generation + */ + exclude?: Rules; + /** + * Include source maps for module paths that match the given value + */ + include?: Rules; + /** + * Include source maps for modules based on their extension (defaults to .js and .css) + */ + test?: Rules; + }; + /** + * Indicates whether SourceMaps from loaders should be used (defaults to true) + */ + module?: boolean; + /** + * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap + */ + moduleFilenameTemplate?: Function | string; + /** + * Namespace prefix to allow multiple webpack roots in the devtools + */ + namespace?: string; + /** + * Omit the 'sourceContents' array from the SourceMap + */ + noSources?: boolean; + /** + * Provide a custom public path for the SourceMapping comment + */ + publicPath?: string; + /** + * Provide a custom value for the 'sourceRoot' property in the SourceMap + */ + sourceRoot?: string; + /** + * Include source maps for modules based on their extension (defaults to .js and .css) + */ + test?: Rules; +} diff --git a/declarations/plugins/WatchIgnorePlugin.d.ts b/declarations/plugins/WatchIgnorePlugin.d.ts new file mode 100644 index 000000000..05c857503 --- /dev/null +++ b/declarations/plugins/WatchIgnorePlugin.d.ts @@ -0,0 +1,10 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +/** + * A list of RegExps or absolute paths to directories or files that should be ignored + */ +export type WatchIgnorePluginOptions = (string | RegExp)[]; diff --git a/declarations/plugins/debug/ProfilingPlugin.d.ts b/declarations/plugins/debug/ProfilingPlugin.d.ts new file mode 100644 index 000000000..d3cd664ad --- /dev/null +++ b/declarations/plugins/debug/ProfilingPlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface ProfilingPluginOptions { + /** + * Path to the output file e.g. `profiling/events.json`. Defaults to `events.json`. + */ + outputPath?: string; +} diff --git a/declarations/plugins/ids/OccurrenceChunkIdsPlugin.d.ts b/declarations/plugins/ids/OccurrenceChunkIdsPlugin.d.ts new file mode 100644 index 000000000..31cf4e3a5 --- /dev/null +++ b/declarations/plugins/ids/OccurrenceChunkIdsPlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface OccurrenceChunkIdsPluginOptions { + /** + * Prioritise initial size over total size + */ + prioritiseInitial?: boolean; +} diff --git a/declarations/plugins/ids/OccurrenceModuleIdsPlugin.d.ts b/declarations/plugins/ids/OccurrenceModuleIdsPlugin.d.ts new file mode 100644 index 000000000..3d7b60724 --- /dev/null +++ b/declarations/plugins/ids/OccurrenceModuleIdsPlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface OccurrenceModuleIdsPluginOptions { + /** + * Prioritise initial size over total size + */ + prioritiseInitial?: boolean; +} diff --git a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts new file mode 100644 index 000000000..9f5360c49 --- /dev/null +++ b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts @@ -0,0 +1,24 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface AggressiveSplittingPluginOptions { + /** + * Default: 0 + */ + chunkOverhead?: number; + /** + * Default: 1 + */ + entryChunkMultiplicator?: number; + /** + * Byte, maxsize of per file. Default: 51200 + */ + maxSize?: number; + /** + * Byte, split point. Default: 30720 + */ + minSize?: number; +} diff --git a/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts new file mode 100644 index 000000000..f83ee5a31 --- /dev/null +++ b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts @@ -0,0 +1,24 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface LimitChunkCountPluginOptions { + /** + * Constant overhead for a chunk + */ + chunkOverhead?: number; + /** + * Multiplicator for initial chunks + */ + entryChunkMultiplicator?: number; + /** + * Limit the maximum number of chunks using a value greater greater than or equal to 1 + */ + maxChunks?: number; + /** + * Set a minimum chunk size + */ + minChunkSize?: number; +} diff --git a/declarations/plugins/optimize/MinChunkSizePlugin.d.ts b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts new file mode 100644 index 000000000..643f1c682 --- /dev/null +++ b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts @@ -0,0 +1,20 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface MinChunkSizePluginOptions { + /** + * Constant overhead for a chunk + */ + chunkOverhead?: number; + /** + * Multiplicator for initial chunks + */ + entryChunkMultiplicator?: number; + /** + * Minimum number of characters + */ + minChunkSize: number; +} diff --git a/lib/AmdMainTemplatePlugin.js b/lib/AmdMainTemplatePlugin.js index 686229f94..8e736092a 100644 --- a/lib/AmdMainTemplatePlugin.js +++ b/lib/AmdMainTemplatePlugin.js @@ -13,10 +13,10 @@ const Template = require("./Template"); class AmdMainTemplatePlugin { /** - * @param {string} name the library name + * @param {string=} name the library name */ constructor(name) { - /** @type {string} */ + /** @type {string=} */ this.name = name; } diff --git a/lib/BannerPlugin.js b/lib/BannerPlugin.js index 96b5adef8..d4266d6a3 100644 --- a/lib/BannerPlugin.js +++ b/lib/BannerPlugin.js @@ -12,6 +12,8 @@ const Template = require("./Template"); const schema = require("../schemas/plugins/BannerPlugin.json"); +/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */ +/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */ /** @typedef {import("./Compiler")} Compiler */ const wrapComment = str => { @@ -25,7 +27,10 @@ const wrapComment = str => { }; class BannerPlugin { - constructor(options = {}) { + /** + * @param {BannerPluginArgument} options options object + */ + constructor(options) { validateOptions(schema, options, "Banner Plugin"); if (typeof options === "string" || typeof options === "function") { @@ -36,15 +41,16 @@ class BannerPlugin { this.options = options; - if (typeof options.banner === "function") { - const getBanner = this.options.banner; + const bannerOption = options.banner; + if (typeof bannerOption === "function") { + const getBanner = bannerOption; this.banner = this.options.raw ? getBanner : data => wrapComment(getBanner(data)); } else { const banner = this.options.raw - ? this.options.banner - : wrapComment(this.options.banner); + ? bannerOption + : wrapComment(bannerOption); this.banner = () => banner; } } diff --git a/lib/Compilation.js b/lib/Compilation.js index 106b9d465..a63a68de1 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -347,7 +347,8 @@ class Compilation { this.inputFileSystem = compiler.inputFileSystem; this.requestShortener = compiler.requestShortener; - const options = (this.options = compiler.options); + const options = compiler.options; + this.options = options; this.outputOptions = options && options.output; /** @type {boolean} */ this.bail = (options && options.bail) || false; @@ -1903,23 +1904,27 @@ class Compilation { for (let i = 0; i < chunks.length; i++) { const chunk = chunks[i]; const chunkHash = createHash(hashFunction); - if (outputOptions.hashSalt) { - chunkHash.update(outputOptions.hashSalt); + try { + if (outputOptions.hashSalt) { + chunkHash.update(outputOptions.hashSalt); + } + chunk.updateHash(chunkHash, chunkGraph); + const template = chunk.hasRuntime() + ? this.mainTemplate + : this.chunkTemplate; + template.updateHashForChunk(chunkHash, chunk, { + chunkGraph, + moduleGraph: this.moduleGraph, + runtimeTemplate: this.runtimeTemplate + }); + this.hooks.chunkHash.call(chunk, chunkHash); + chunk.hash = chunkHash.digest(hashDigest); + hash.update(chunk.hash); + chunk.renderedHash = chunk.hash.substr(0, hashDigestLength); + this.hooks.contentHash.call(chunk); + } catch (err) { + this.errors.push(new ChunkRenderError(chunk, "", err)); } - chunk.updateHash(chunkHash, chunkGraph); - const template = chunk.hasRuntime() - ? this.mainTemplate - : this.chunkTemplate; - template.updateHashForChunk(chunkHash, chunk, { - chunkGraph, - moduleGraph: this.moduleGraph, - runtimeTemplate: this.runtimeTemplate - }); - this.hooks.chunkHash.call(chunk, chunkHash); - chunk.hash = chunkHash.digest(hashDigest); - hash.update(chunk.hash); - chunk.renderedHash = chunk.hash.substr(0, hashDigestLength); - this.hooks.contentHash.call(chunk); } this.fullHash = hash.digest(hashDigest); this.hash = this.fullHash.substr(0, hashDigestLength); @@ -2056,7 +2061,7 @@ class Compilation { } /** - * @param {string} filename used to get asset path with hash + * @param {string | function(PathData): string} filename used to get asset path with hash * @param {PathData} data context data * @returns {string} interpolated path */ diff --git a/lib/Compiler.js b/lib/Compiler.js index 3c23e7a94..d58ccfd24 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -27,6 +27,9 @@ const ConcurrentCompilationError = require("./ConcurrentCompilationError"); const RequestShortener = require("./RequestShortener"); const { makePathsRelative } = require("./util/identifier"); +/** @typedef {import("../declarations/WebpackOptions").Entry} Entry */ +/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ + /** * @typedef {Object} CompilationParams * @property {NormalModuleFactory} normalModuleFactory @@ -34,16 +37,6 @@ const { makePathsRelative } = require("./util/identifier"); * @property {Set} compilationDependencies */ -/** @typedef {string|string[]} EntryValues */ -/** @typedef {Record} EntryOptionValues */ - -/** - * @callback EntryOptionValuesFunction - * @returns {EntryOptionValues | EntryValues} the computed value - */ - -/** @typedef {EntryOptionValuesFunction | EntryOptionValues | EntryValues} EntryOptions */ - class Compiler { constructor(context) { this.hooks = Object.freeze({ @@ -99,7 +92,7 @@ class Compiler { afterPlugins: new SyncHook(["compiler"]), /** @type {SyncHook} */ afterResolvers: new SyncHook(["compiler"]), - /** @type {SyncBailHook} */ + /** @type {SyncBailHook} */ entryOption: new SyncBailHook(["context", "entry"]) }); @@ -125,7 +118,8 @@ class Compiler { /** @type {ResolverFactory} */ this.resolverFactory = new ResolverFactory(); - this.options = {}; + /** @type {WebpackOptions} */ + this.options = /** @type {WebpackOptions} */ ({}); this.context = context; diff --git a/lib/DllPlugin.js b/lib/DllPlugin.js index 84cbc15b0..15f68b976 100644 --- a/lib/DllPlugin.js +++ b/lib/DllPlugin.js @@ -12,7 +12,12 @@ const LibManifestPlugin = require("./LibManifestPlugin"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/DllPlugin.json"); +/** @typedef {import("../declarations/plugins/DllPlugin").DllPluginOptions} DllPluginOptions */ + class DllPlugin { + /** + * @param {DllPluginOptions} options options object + */ constructor(options) { validateOptions(schema, options, "Dll Plugin"); this.options = options; diff --git a/lib/DllReferencePlugin.js b/lib/DllReferencePlugin.js index fb7d5edb9..c0ee66bf6 100644 --- a/lib/DllReferencePlugin.js +++ b/lib/DllReferencePlugin.js @@ -17,7 +17,13 @@ const makePathsRelative = require("./util/identifier").makePathsRelative; const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/DllReferencePlugin.json"); +/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */ +/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsManifest} DllReferencePluginOptionsManifest */ + class DllReferencePlugin { + /** + * @param {DllReferencePluginOptions} options options object + */ constructor(options) { validateOptions(schema, options, "Dll Reference Plugin"); this.options = options; @@ -41,55 +47,71 @@ class DllReferencePlugin { compiler.hooks.beforeCompile.tapAsync( "DllReferencePlugin", (params, callback) => { - const manifest = this.options.manifest; - if (typeof manifest === "string") { - params.compilationDependencies.add(manifest); - compiler.inputFileSystem.readFile(manifest, (err, result) => { - if (err) return callback(err); - // Catch errors parsing the manifest so that blank - // or malformed manifest files don't kill the process. - try { - params["dll reference " + manifest] = parseJson( - result.toString("utf-8") - ); - } catch (e) { - // Store the error in the params so that it can - // be added as a compilation error later on. - const manifestPath = makePathsRelative( - compiler.options.context, - manifest - ); - params[ - "dll reference parse error " + manifest - ] = new DllManifestError(manifestPath, e.message); - } - return callback(); - }); - } else { - return callback(); + if ("manifest" in this.options) { + const manifest = this.options.manifest; + if (typeof manifest === "string") { + params.compilationDependencies.add(manifest); + compiler.inputFileSystem.readFile(manifest, (err, result) => { + if (err) return callback(err); + // Catch errors parsing the manifest so that blank + // or malformed manifest files don't kill the process. + try { + params["dll reference " + manifest] = parseJson( + result.toString("utf-8") + ); + } catch (e) { + // Store the error in the params so that it can + // be added as a compilation error later on. + const manifestPath = makePathsRelative( + compiler.options.context, + manifest + ); + params[ + "dll reference parse error " + manifest + ] = new DllManifestError(manifestPath, e.message); + } + return callback(); + }); + return; + } } + return callback(); } ); compiler.hooks.compile.tap("DllReferencePlugin", params => { - let manifest = this.options.manifest; - if (typeof manifest === "string") { - // If there was an error parsing the manifest - // file, exit now because the error will be added - // as a compilation error in the "compilation" hook. - if (params["dll reference parse error " + manifest]) { - return; + let name = this.options.name; + let sourceType = this.options.sourceType; + let content = + "content" in this.options ? this.options.content : undefined; + if ("manifest" in this.options) { + let manifestParameter = this.options.manifest; + let manifest; + if (typeof manifestParameter === "string") { + // If there was an error parsing the manifest + // file, exit now because the error will be added + // as a compilation error in the "compilation" hook. + if (params["dll reference parse error " + manifestParameter]) { + return; + } + manifest = + /** @type {DllReferencePluginOptionsManifest} */ (params[ + "dll reference " + manifestParameter + ]); + } else { + manifest = manifestParameter; + } + if (manifest) { + if (!name) name = manifest.name; + if (!sourceType) sourceType = manifest.type; + if (!content) content = manifest.content; } - manifest = params["dll reference " + manifest]; } - const name = this.options.name || manifest.name; - const sourceType = - this.options.sourceType || (manifest && manifest.type) || "var"; const externals = {}; const source = "dll-reference " + name; externals[source] = name; const normalModuleFactory = params.normalModuleFactory; - new ExternalModuleFactoryPlugin(sourceType, externals).apply( + new ExternalModuleFactoryPlugin(sourceType || "var", externals).apply( normalModuleFactory ); new DelegatedModuleFactoryPlugin({ @@ -97,7 +119,7 @@ class DllReferencePlugin { type: this.options.type, scope: this.options.scope, context: this.options.context || compiler.options.context, - content: this.options.content || manifest.content, + content, extensions: this.options.extensions }).apply(normalModuleFactory); }); @@ -105,13 +127,15 @@ class DllReferencePlugin { compiler.hooks.compilation.tap( "DllReferencePlugin", (compilation, params) => { - let manifest = this.options.manifest; - if (typeof manifest === "string") { - // If there was an error parsing the manifest file, add the - // error as a compilation error to make the compilation fail. - let e = params["dll reference parse error " + manifest]; - if (e) { - compilation.errors.push(e); + if ("manifest" in this.options) { + let manifest = this.options.manifest; + if (typeof manifest === "string") { + // If there was an error parsing the manifest file, add the + // error as a compilation error to make the compilation fail. + let e = params["dll reference parse error " + manifest]; + if (e) { + compilation.errors.push(e); + } } } } diff --git a/lib/DynamicEntryPlugin.js b/lib/DynamicEntryPlugin.js index ec5045b86..42e0a4271 100644 --- a/lib/DynamicEntryPlugin.js +++ b/lib/DynamicEntryPlugin.js @@ -8,13 +8,14 @@ const EntryPlugin = require("./EntryPlugin"); const EntryDependency = require("./dependencies/EntryDependency"); +/** @typedef {import("../declarations/WebpackOptions").EntryDynamic} EntryDynamic */ +/** @typedef {import("../declarations/WebpackOptions").EntryStatic} EntryStatic */ /** @typedef {import("./Compiler")} Compiler */ -/** @typedef {import("./Compiler").EntryOptionValuesFunction} EntryOptionValuesFunction */ class DynamicEntryPlugin { /** * @param {string} context the context path - * @param {EntryOptionValuesFunction} entry the entry value + * @param {EntryDynamic} entry the entry value */ constructor(context, entry) { this.context = context; @@ -42,7 +43,7 @@ class DynamicEntryPlugin { /** * @param {string|string[]} entry entry value or array of entry values * @param {string} name name of entry - * @returns {Promise} returns the promise resolving the Compilation#addEntry function + * @returns {Promise} returns the promise resolving the Compilation#addEntry function */ const addEntry = (entry, name) => { const deps = DynamicEntryPlugin.createDependencies(entry, name); diff --git a/lib/EntryOptionPlugin.js b/lib/EntryOptionPlugin.js index 00c75911a..d85c31935 100644 --- a/lib/EntryOptionPlugin.js +++ b/lib/EntryOptionPlugin.js @@ -8,6 +8,7 @@ const DynamicEntryPlugin = require("./DynamicEntryPlugin"); const EntryPlugin = require("./EntryPlugin"); +/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */ /** @typedef {import("./Compiler")} Compiler */ module.exports = class EntryOptionPlugin { @@ -18,7 +19,7 @@ module.exports = class EntryOptionPlugin { apply(compiler) { compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => { /** - * @param {string | string[]} entry entry array or single path + * @param {EntryItem} entry entry array or single path * @param {string} name entry key name * @returns {void} */ diff --git a/lib/IgnorePlugin.js b/lib/IgnorePlugin.js index a5383e179..2cdea0e21 100644 --- a/lib/IgnorePlugin.js +++ b/lib/IgnorePlugin.js @@ -8,15 +8,12 @@ const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/IgnorePlugin.json"); +/** @typedef {import("../declarations/plugins/IgnorePlugin").IgnorePluginOptions} IgnorePluginOptions */ /** @typedef {import("./Compiler")} Compiler */ class IgnorePlugin { /** - * @param {object} options IgnorePlugin options - * @param {RegExp} options.resourceRegExp - A RegExp to test the request against - * @param {RegExp} options.contextRegExp - A RegExp to test the context (directory) against - * @param {function(string): boolean=} options.checkResource - A filter function for resource - * @param {function(string): boolean=} options.checkContext - A filter function for context + * @param {IgnorePluginOptions} options IgnorePlugin options */ constructor(options) { // TODO webpack 5 remove this compat-layer @@ -40,13 +37,13 @@ class IgnorePlugin { * and the resource given matches the regexp. */ checkResource(resource) { - if (this.options.checkResource) { + if ("checkResource" in this.options && this.options.checkResource) { return this.options.checkResource(resource); } - if (!this.options.resourceRegExp) { - return false; + if ("resourceRegExp" in this.options && this.options.resourceRegExp) { + return this.options.resourceRegExp.test(resource); } - return this.options.resourceRegExp.test(resource); + return false; } /** @@ -55,14 +52,13 @@ class IgnorePlugin { * or if context matches the given regexp. */ checkContext(context) { - if (this.options.checkContext) { + if ("checkContext" in this.options && this.options.checkContext) { return this.options.checkContext(context); } - - if (!this.options.contextRegExp) { - return true; + if ("contextRegExp" in this.options && this.options.contextRegExp) { + return this.options.contextRegExp.test(context); } - return this.options.contextRegExp.test(context); + return true; } /** diff --git a/lib/LibraryTemplatePlugin.js b/lib/LibraryTemplatePlugin.js index e0909104a..7f2f3c459 100644 --- a/lib/LibraryTemplatePlugin.js +++ b/lib/LibraryTemplatePlugin.js @@ -7,6 +7,7 @@ const SetVarMainTemplatePlugin = require("./SetVarMainTemplatePlugin"); +/** @typedef {import("../declarations/WebpackOptions").LibraryCustomUmdObject} LibraryCustomUmdObject */ /** @typedef {import("./Compiler")} Compiler */ /** @@ -19,12 +20,17 @@ const accessorToObjectAccess = accessor => { /** * @param {string=} base the path prefix - * @param {string|string[]} accessor the accessor + * @param {string|string[]|LibraryCustomUmdObject} accessor the accessor + * @param {"amd" | "commonjs" | "root"} umdProperty property used when a custom umd object is provided * @param {string=} joinWith the element separator * @returns {string} the path */ -const accessorAccess = (base, accessor, joinWith = "; ") => { - const accessors = Array.isArray(accessor) ? accessor : [accessor]; +const accessorAccess = (base, accessor, umdProperty, joinWith = "; ") => { + const normalizedAccessor = + typeof accessor === "object" ? accessor[umdProperty] : accessor; + const accessors = Array.isArray(normalizedAccessor) + ? normalizedAccessor + : [normalizedAccessor]; return accessors .map((_, idx) => { const a = base @@ -41,7 +47,7 @@ const accessorAccess = (base, accessor, joinWith = "; ") => { class LibraryTemplatePlugin { /** - * @param {string} name name of library + * @param {string|string[]|LibraryCustomUmdObject} name name of library * @param {string} target type of library * @param {boolean} umdNamedDefine setting this to true will name the UMD module * @param {string|TODO} auxiliaryComment comment in the UMD wrapper @@ -69,14 +75,22 @@ class LibraryTemplatePlugin { } switch (this.target) { case "var": + if ( + !this.name || + (typeof this.name === "object" && !Array.isArray(this.name)) + ) { + throw new Error( + "library name must be set and not an UMD custom object for non-UMD target" + ); + } new SetVarMainTemplatePlugin( - `var ${accessorAccess(undefined, this.name)}`, + `var ${accessorAccess(undefined, this.name, "root")}`, false ).apply(compilation); break; case "assign": new SetVarMainTemplatePlugin( - accessorAccess(undefined, this.name), + accessorAccess(undefined, this.name, "root"), false ).apply(compilation); break; @@ -85,7 +99,7 @@ class LibraryTemplatePlugin { case "window": if (this.name) { new SetVarMainTemplatePlugin( - accessorAccess(this.target, this.name), + accessorAccess(this.target, this.name, "root"), false ).apply(compilation); } else { @@ -97,7 +111,8 @@ class LibraryTemplatePlugin { new SetVarMainTemplatePlugin( accessorAccess( compilation.runtimeTemplate.outputOptions.globalObject, - this.name + this.name, + "root" ), false ).apply(compilation); @@ -111,7 +126,7 @@ class LibraryTemplatePlugin { case "commonjs": if (this.name) { new SetVarMainTemplatePlugin( - accessorAccess("exports", this.name), + accessorAccess("exports", this.name, "commonjs"), false ).apply(compilation); } else { @@ -126,7 +141,13 @@ class LibraryTemplatePlugin { break; case "amd": { const AmdMainTemplatePlugin = require("./AmdMainTemplatePlugin"); - new AmdMainTemplatePlugin(this.name).apply(compilation); + if (this.name) { + if (typeof this.name !== "string") + throw new Error("library name must be a string for amd target"); + new AmdMainTemplatePlugin(this.name).apply(compilation); + } else { + new AmdMainTemplatePlugin().apply(compilation); + } break; } case "umd": @@ -141,6 +162,8 @@ class LibraryTemplatePlugin { } case "jsonp": { const JsonpExportMainTemplatePlugin = require("./web/JsonpExportMainTemplatePlugin"); + if (typeof this.name !== "string") + throw new Error("library name must be a string for jsonp target"); new JsonpExportMainTemplatePlugin(this.name).apply(compilation); break; } diff --git a/lib/LoaderOptionsPlugin.js b/lib/LoaderOptionsPlugin.js index cbd2569ca..4a35d8844 100644 --- a/lib/LoaderOptionsPlugin.js +++ b/lib/LoaderOptionsPlugin.js @@ -10,7 +10,12 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/LoaderOptionsPlugin.json"); +/** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */ + class LoaderOptionsPlugin { + /** + * @param {LoaderOptionsPluginOptions} options options object + */ constructor(options) { validateOptions(schema, options || {}, "Loader Options Plugin"); diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index d2ca7b4ab..eaefa65f2 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -14,6 +14,7 @@ const createHash = require("./util/createHash"); const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json"); +/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ /** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Compiler")} Compiler */ @@ -51,10 +52,15 @@ const getTaskForFile = (file, chunk, options, compilation) => { }; class SourceMapDevToolPlugin { + /** + * @param {SourceMapDevToolPluginOptions=} options options object + */ constructor(options = {}) { validateOptions(schema, options, "SourceMap DevTool Plugin"); + /** @type {string | false} */ this.sourceMapFilename = options.filename; + /** @type {string | false} */ this.sourceMappingURLComment = options.append === false ? false @@ -232,6 +238,7 @@ class SourceMapDevToolPlugin { sourceMap.sourceRoot = options.sourceRoot || ""; sourceMap.file = file; assetsCache.set(asset, { file, assets }); + /** @type {string | false} */ let currentSourceMappingURLComment = sourceMappingURLComment; if ( currentSourceMappingURLComment !== false && @@ -281,6 +288,11 @@ class SourceMapDevToolPlugin { ] = new RawSource(sourceMapString); chunk.files.push(sourceMapFile); } else { + if (currentSourceMappingURLComment === false) { + throw new Error( + "SourceMapDevToolPlugin: append can't be false when no filename is provided" + ); + } assets[file] = compilation.assets[file] = new ConcatSource( new RawSource(source), currentSourceMappingURLComment diff --git a/lib/UmdMainTemplatePlugin.js b/lib/UmdMainTemplatePlugin.js index 7b4f9430d..ff558de2a 100644 --- a/lib/UmdMainTemplatePlugin.js +++ b/lib/UmdMainTemplatePlugin.js @@ -10,6 +10,7 @@ const ExternalModule = require("./ExternalModule"); const Template = require("./Template"); /** @typedef {import("webpack-sources").Source} Source */ +/** @typedef {import("../declarations/WebpackOptions").LibraryCustomUmdObject} LibraryCustomUmdObject */ /** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Compilation")} Compilation */ @@ -42,7 +43,7 @@ const accessorAccess = (base, accessor, joinWith = ", ") => { .join(joinWith); }; -/** @typedef {string | string[] | Record} UmdMainTemplatePluginName */ +/** @typedef {string | string[] | LibraryCustomUmdObject} UmdMainTemplatePluginName */ /** * @typedef {Object} AuxiliaryCommentObject diff --git a/lib/WatchIgnorePlugin.js b/lib/WatchIgnorePlugin.js index ce8359b9e..85484b7ba 100644 --- a/lib/WatchIgnorePlugin.js +++ b/lib/WatchIgnorePlugin.js @@ -8,6 +8,8 @@ const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/WatchIgnorePlugin.json"); +/** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */ + class IgnoringWatchFileSystem { constructor(wfs, paths) { this.wfs = wfs; @@ -83,6 +85,9 @@ class IgnoringWatchFileSystem { } class WatchIgnorePlugin { + /** + * @param {WatchIgnorePluginOptions} paths list of paths + */ constructor(paths) { validateOptions(schema, paths, "Watch Ignore Plugin"); this.paths = paths; diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index a59201cc0..9d13105e6 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -67,11 +67,19 @@ const SplitChunksPlugin = require("./optimize/SplitChunksPlugin"); const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin"); const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin"); +/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ +/** @typedef {import("./Compiler")} Compiler */ + class WebpackOptionsApply extends OptionsApply { constructor() { super(); } + /** + * @param {WebpackOptions} options options object + * @param {Compiler} compiler compiler object + * @returns {WebpackOptions} options object + */ process(options, compiler) { let ExternalsPlugin; compiler.outputPath = options.output.path; @@ -79,6 +87,8 @@ class WebpackOptionsApply extends OptionsApply { compiler.recordsOutputPath = options.recordsOutputPath || options.recordsPath; compiler.name = options.name; + // TODO webpack 5 refactor this to MultiCompiler.setDependencies() with a WeakMap + // @ts-ignore TODO compiler.dependencies = options.dependencies; if (typeof options.target === "string") { let JsonpTemplatePlugin; @@ -205,7 +215,9 @@ class WebpackOptionsApply extends OptionsApply { default: throw new Error("Unsupported target '" + options.target + "'."); } - } else if (options.target !== false) { + } + // @ts-ignore This is always true, which is good this way + else if (options.target !== false) { options.target(compiler); } else { throw new Error("Unsupported target '" + options.target + "'."); @@ -424,7 +436,11 @@ class WebpackOptionsApply extends OptionsApply { } if (options.optimization.minimize) { for (const minimizer of options.optimization.minimizer) { - minimizer.apply(compiler); + if (typeof minimizer === "function") { + minimizer.apply(compiler); + } else { + minimizer.apply(compiler); + } } } diff --git a/lib/debug/ProfilingPlugin.js b/lib/debug/ProfilingPlugin.js index 12dc59b34..56f370087 100644 --- a/lib/debug/ProfilingPlugin.js +++ b/lib/debug/ProfilingPlugin.js @@ -4,10 +4,13 @@ "use strict"; -const fs = require("fs"); const { Tracer } = require("chrome-trace-event"); +const fs = require("fs"); const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/debug/ProfilingPlugin.json"); + +/** @typedef {import("../../declarations/plugins/debug/ProfilingPlugin").ProfilingPluginOptions} ProfilingPluginOptions */ + let inspector = undefined; try { @@ -151,6 +154,9 @@ const createTrace = outputPath => { const pluginName = "ProfilingPlugin"; class ProfilingPlugin { + /** + * @param {ProfilingPluginOptions=} opts options object + */ constructor(opts) { validateOptions(schema, opts || {}, "Profiling plugin"); opts = opts || {}; diff --git a/lib/dependencies/ImportParserPlugin.js b/lib/dependencies/ImportParserPlugin.js index 4e8c5de09..1ee764477 100644 --- a/lib/dependencies/ImportParserPlugin.js +++ b/lib/dependencies/ImportParserPlugin.js @@ -67,7 +67,7 @@ class ImportParserPlugin { ) ); } else { - // Do not instrument `import()` is `webpackIgnore` is `true` + // Do not instrument `import()` if `webpackIgnore` is `true` if (importOptions.webpackIgnore) { return false; } diff --git a/lib/ids/HashedModuleIdsPlugin.js b/lib/ids/HashedModuleIdsPlugin.js index 211d79584..37607083b 100644 --- a/lib/ids/HashedModuleIdsPlugin.js +++ b/lib/ids/HashedModuleIdsPlugin.js @@ -12,10 +12,16 @@ const { } = require("../util/comparators"); const createHash = require("../util/createHash"); +/** @typedef {import("../../declarations/plugins/HashedModuleIdsPlugin").HashedModuleIdsPluginOptions} HashedModuleIdsPluginOptions */ + class HashedModuleIdsPlugin { - constructor(options) { + /** + * @param {HashedModuleIdsPluginOptions=} options options object + */ + constructor(options = {}) { validateOptions(schema, options || {}, "Hashed Module Ids Plugin"); + /** @type {HashedModuleIdsPluginOptions} */ this.options = Object.assign( { context: null, diff --git a/lib/ids/OccurrenceChunkIdsPlugin.js b/lib/ids/OccurrenceChunkIdsPlugin.js index e6d43cd0e..b06a90ef6 100644 --- a/lib/ids/OccurrenceChunkIdsPlugin.js +++ b/lib/ids/OccurrenceChunkIdsPlugin.js @@ -14,11 +14,15 @@ const { } = require("../util/comparators"); const assignAscendingChunkIds = require("./assignAscendingChunkIds"); +/** @typedef {import("../../declarations/plugins/ids/OccurrenceChunkIdsPlugin").OccurrenceChunkIdsPluginOptions} OccurrenceChunkIdsPluginOptions */ /** @typedef {import("../Chunk")} Chunk */ /** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Module")} Module */ class OccurrenceChunkIdsPlugin { + /** + * @param {OccurrenceChunkIdsPluginOptions=} options options object + */ constructor(options = {}) { validateOptions(schema, options, "Occurrence Order Chunk Ids Plugin"); this.options = options; diff --git a/lib/ids/OccurrenceModuleIdsPlugin.js b/lib/ids/OccurrenceModuleIdsPlugin.js index f5b8164e0..a755babff 100644 --- a/lib/ids/OccurrenceModuleIdsPlugin.js +++ b/lib/ids/OccurrenceModuleIdsPlugin.js @@ -12,10 +12,14 @@ const { } = require("../util/comparators"); const assignAscendingModuleIds = require("./assignAscendingModuleIds"); +/** @typedef {import("../../declarations/plugins/ids/OccurrenceModuleIdsPlugin").OccurrenceModuleIdsPluginOptions} OccurrenceModuleIdsPluginOptions */ /** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ class OccurrenceModuleIdsPlugin { + /** + * @param {OccurrenceModuleIdsPluginOptions=} options options object + */ constructor(options = {}) { validateOptions(schema, options, "Occurrence Order Module Ids Plugin"); this.options = options; diff --git a/lib/optimize/AggressiveSplittingPlugin.js b/lib/optimize/AggressiveSplittingPlugin.js index ce5819f73..019d0997b 100644 --- a/lib/optimize/AggressiveSplittingPlugin.js +++ b/lib/optimize/AggressiveSplittingPlugin.js @@ -16,6 +16,7 @@ const { } = require("../util/comparators"); const identifierUtils = require("../util/identifier"); +/** @typedef {import("../../declarations/plugins/optimize/AggressiveSplittingPlugin").AggressiveSplittingPluginOptions} AggressiveSplittingPluginOptions */ /** @typedef {import("../Chunk")} Chunk */ /** @typedef {import("../ChunkGraph")} ChunkGraph */ /** @typedef {import("../Compiler")} Compiler */ @@ -45,10 +46,13 @@ const isNotAEntryModule = (chunkGraph, chunk) => { const recordedChunks = new WeakSet(); class AggressiveSplittingPlugin { - constructor(options) { - validateOptions(schema, options || {}, "Aggressive Splitting Plugin"); + /** + * @param {AggressiveSplittingPluginOptions=} options options object + */ + constructor(options = {}) { + validateOptions(schema, options, "Aggressive Splitting Plugin"); - this.options = options || {}; + this.options = options; if (typeof this.options.minSize !== "number") { this.options.minSize = 30 * 1024; } diff --git a/lib/optimize/LimitChunkCountPlugin.js b/lib/optimize/LimitChunkCountPlugin.js index 6cbc9e835..961f69605 100644 --- a/lib/optimize/LimitChunkCountPlugin.js +++ b/lib/optimize/LimitChunkCountPlugin.js @@ -12,10 +12,15 @@ const { STAGE_ADVANCED } = require("../OptimizationStages"); /** @typedef {import("../Chunk")} Chunk */ /** @typedef {import("../Compiler")} Compiler */ +/** @typedef {import("../../declarations/plugins/optimize/LimitChunkCountPlugin").LimitChunkCountPluginOptions} LimitChunkCountPluginOptions */ + class LimitChunkCountPlugin { - constructor(options) { - validateOptions(schema, options || {}, "Limit Chunk Count Plugin"); - this.options = options || {}; + /** + * @param {LimitChunkCountPluginOptions=} options options object + */ + constructor(options = {}) { + validateOptions(schema, options, "Limit Chunk Count Plugin"); + this.options = options; } /** diff --git a/lib/optimize/MinChunkSizePlugin.js b/lib/optimize/MinChunkSizePlugin.js index d4c1e788d..a633f5ab3 100644 --- a/lib/optimize/MinChunkSizePlugin.js +++ b/lib/optimize/MinChunkSizePlugin.js @@ -12,7 +12,12 @@ const { STAGE_ADVANCED } = require("../OptimizationStages"); /** @typedef {import("../Chunk")} Chunk */ /** @typedef {import("../Compiler")} Compiler */ +/** @typedef {import("../../declarations/plugins/optimize/MinChunkSizePlugin").MinChunkSizePluginOptions} MinChunkSizePluginOptions */ + class MinChunkSizePlugin { + /** + * @param {MinChunkSizePluginOptions} options options object + */ constructor(options) { validateOptions(schema, options, "Min Chunk Size Plugin"); this.options = options; diff --git a/lib/web/JsonpExportMainTemplatePlugin.js b/lib/web/JsonpExportMainTemplatePlugin.js index 423fbe45a..cff7cd4a3 100644 --- a/lib/web/JsonpExportMainTemplatePlugin.js +++ b/lib/web/JsonpExportMainTemplatePlugin.js @@ -8,6 +8,9 @@ const { ConcatSource } = require("webpack-sources"); class JsonpExportMainTemplatePlugin { + /** + * @param {string} name jsonp function name + */ constructor(name) { this.name = name; } diff --git a/lib/webpack.js b/lib/webpack.js index 55653da62..c03f6e686 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -16,6 +16,13 @@ const WebpackOptionsValidationError = require("./WebpackOptionsValidationError") const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin"); const validateSchema = require("./validateSchema"); +/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ + +/** + * @param {WebpackOptions} options options object + * @param {function(Error=, Stats=): void=} callback callback + * @returns {Compiler | MultiCompiler} the compiler object + */ const webpack = (options, callback) => { const webpackOptionsValidationErrors = validateSchema( webpackOptionsSchema, @@ -35,7 +42,11 @@ const webpack = (options, callback) => { new NodeEnvironmentPlugin().apply(compiler); if (options.plugins && Array.isArray(options.plugins)) { for (const plugin of options.plugins) { - plugin.apply(compiler); + if (typeof plugin === "function") { + plugin.apply(compiler); + } else { + plugin.apply(compiler); + } } } compiler.hooks.environment.call(); diff --git a/package.json b/package.json index 396acdac4..78fb51a86 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.7.6", - "@webassemblyjs/helper-module-context": "1.7.6", - "@webassemblyjs/wasm-edit": "1.7.6", - "@webassemblyjs/wasm-parser": "1.7.6", + "@webassemblyjs/ast": "1.7.8", + "@webassemblyjs/helper-module-context": "1.7.8", + "@webassemblyjs/wasm-edit": "1.7.8", + "@webassemblyjs/wasm-parser": "1.7.8", "acorn": "^5.6.2", "acorn-dynamic-import": "^3.0.0", "ajv": "^6.1.0", @@ -29,7 +29,7 @@ "tapable": "^1.1.0", "terser-webpack-plugin": "^1.1.0", "watchpack": "^1.5.0", - "webpack-sources": "^1.2.0" + "webpack-sources": "^1.3.0" }, "devDependencies": { "@types/node": "^9.6.4", @@ -55,6 +55,7 @@ "jest": "^23.4.1", "jest-silent-reporter": "^0.0.5", "json-loader": "^0.5.7", + "json-schema-to-typescript": "^6.0.1", "less": "^2.5.1", "less-loader": "^4.0.3", "lint-staged": "^7.2.0", @@ -115,8 +116,8 @@ "lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint", "code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "type-lint": "tsc --pretty", - "special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/format-file-header", - "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/format-file-header --write", + "special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/format-file-header && node tooling/compile-to-definitions", + "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/format-file-header --write && node tooling/compile-to-definitions --write", "fix": "yarn code-lint --fix && yarn special-lint-fix", "pretty": "prettier --loglevel warn --write \"*.{ts,js,json}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"/test/*.lint.js\" --no-verbose", diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index c2a6e336f..5aa4afb76 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -909,16 +909,8 @@ }, "hotUpdateChunkFilename": { "description": "The filename of the Hot Update Chunks. They are inside the output.path directory.", - "anyOf": [ - { - "type": "string", - "absolutePath": false - }, - { - "instanceof": "Function", - "tsType": "Function" - } - ] + "type": "string", + "absolutePath": false }, "hotUpdateFunction": { "description": "The JSONP function used by webpack for async loading of hot update chunks.", @@ -926,16 +918,8 @@ }, "hotUpdateMainFilename": { "description": "The filename of the Hot Update Main File. It is inside the `output.path` directory.", - "anyOf": [ - { - "type": "string", - "absolutePath": false - }, - { - "instanceof": "Function", - "tsType": "Function" - } - ] + "type": "string", + "absolutePath": false }, "jsonpFunction": { "description": "The JSONP function used by webpack for async loading of chunks.", diff --git a/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json b/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json index 12facf2f6..20ec10288 100644 --- a/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json +++ b/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json @@ -1,5 +1,5 @@ { - "title": "OccurrenceOrderChunkIdsPluginOptions", + "title": "OccurrenceChunkIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json b/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json index d76ac14df..6f8fad052 100644 --- a/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json +++ b/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json @@ -1,5 +1,5 @@ { - "title": "OccurrenceOrderModuleIdsPluginOptions", + "title": "OccurrenceModuleIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/LimitChunkCountPlugin.json b/schemas/plugins/optimize/LimitChunkCountPlugin.json index b2636eefd..a830f9728 100644 --- a/schemas/plugins/optimize/LimitChunkCountPlugin.json +++ b/schemas/plugins/optimize/LimitChunkCountPlugin.json @@ -3,6 +3,14 @@ "type": "object", "additionalProperties": false, "properties": { + "chunkOverhead": { + "description": "Constant overhead for a chunk", + "type": "number" + }, + "entryChunkMultiplicator": { + "description": "Multiplicator for initial chunks", + "type": "number" + }, "maxChunks": { "description": "Limit the maximum number of chunks using a value greater greater than or equal to 1", "type": "number", diff --git a/schemas/plugins/optimize/MinChunkSizePlugin.json b/schemas/plugins/optimize/MinChunkSizePlugin.json index 03e17d65e..1d363f818 100644 --- a/schemas/plugins/optimize/MinChunkSizePlugin.json +++ b/schemas/plugins/optimize/MinChunkSizePlugin.json @@ -3,6 +3,14 @@ "type": "object", "additionalProperties": false, "properties": { + "chunkOverhead": { + "description": "Constant overhead for a chunk", + "type": "number" + }, + "entryChunkMultiplicator": { + "description": "Multiplicator for initial chunks", + "type": "number" + }, "minChunkSize": { "description": "Minimum number of characters", "type": "number" diff --git a/test/configCases/errors/exception-in-chunk-renderer/errors.js b/test/configCases/errors/exception-in-chunk-renderer/errors.js new file mode 100644 index 000000000..d9088af16 --- /dev/null +++ b/test/configCases/errors/exception-in-chunk-renderer/errors.js @@ -0,0 +1,4 @@ +module.exports = [ + [/Test exception/], + [/Test exception/] +]; diff --git a/test/configCases/errors/exception-in-chunk-renderer/index.js b/test/configCases/errors/exception-in-chunk-renderer/index.js new file mode 100644 index 000000000..d4f42bbdd --- /dev/null +++ b/test/configCases/errors/exception-in-chunk-renderer/index.js @@ -0,0 +1,3 @@ +it("should not crash when renderer throws exception", function(done) { + done(); +}); diff --git a/test/configCases/errors/exception-in-chunk-renderer/webpack.config.js b/test/configCases/errors/exception-in-chunk-renderer/webpack.config.js new file mode 100644 index 000000000..6a98bf6eb --- /dev/null +++ b/test/configCases/errors/exception-in-chunk-renderer/webpack.config.js @@ -0,0 +1,16 @@ +class ThrowsExceptionInRender { + apply(compiler) { + compiler.hooks.compilation.tap("ThrowsException", compilation => { + compilation.mainTemplate.hooks.requireExtensions.tap( + "ThrowsException", + () => { + throw new Error("Test exception"); + } + ); + }); + } +} + +module.exports = { + plugins: [new ThrowsExceptionInRender()] +}; diff --git a/tooling/compile-to-definitions.js b/tooling/compile-to-definitions.js new file mode 100644 index 000000000..a19aca0c5 --- /dev/null +++ b/tooling/compile-to-definitions.js @@ -0,0 +1,79 @@ +const fs = require("fs"); +const path = require("path"); +const mkdirp = require("mkdirp"); +const prettierrc = require("../.prettierrc.js"); // eslint-disable-line +const { compileFromFile } = require("json-schema-to-typescript"); + +const schemasDir = path.resolve(__dirname, "../schemas"); +const style = { + printWidth: prettierrc.printWidth, + useTabs: prettierrc.useTabs, + tabWidth: prettierrc.tabWidth +}; + +// When --write is set, files will be written in place +// Elsewise it only prints outdated files +const doWrite = process.argv.includes("--write"); + +const makeSchemas = () => { + // include the top level folder "./schemas" by default + const dirs = new Set([schemasDir]); + + // search for all nestedDirs inside of this folder + for (let dirWithSchemas of dirs) { + for (let item of fs.readdirSync(dirWithSchemas)) { + const absPath = path.resolve(dirWithSchemas, item); + if (fs.statSync(absPath).isDirectory()) { + dirs.add(absPath); + } else if (item.endsWith(".json")) { + makeDefinitionsForSchema(absPath); + } + } + } +}; + +const makeDefinitionsForSchema = absSchemaPath => { + const basename = path + .relative(schemasDir, absSchemaPath) + .replace(/\.json$/i, ""); + const filename = path.resolve(__dirname, `../declarations/${basename}.d.ts`); + compileFromFile(absSchemaPath, { + bannerComment: + "/**\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `yarn special-lint-fix` to update\n */", + unreachableDefinitions: true, + style + }).then( + ts => { + let normalizedContent = ""; + try { + const content = fs.readFileSync(filename, "utf-8"); + normalizedContent = content.replace(/\r\n?/g, "\n"); + } catch (e) { + // ignore + } + if (normalizedContent.trim() !== ts.trim()) { + if (doWrite) { + mkdirp.sync(path.dirname(filename)); + fs.writeFileSync(filename, ts, "utf-8"); + console.error( + `declarations/${basename.replace(/\\/g, "/")}.d.ts updated` + ); + } else { + console.error( + `declarations/${basename.replace( + /\\/g, + "/" + )}.d.ts need to be updated` + ); + process.exitCode = 1; + } + } + }, + err => { + console.error(err); + process.exitCode = 1; + } + ); +}; + +makeSchemas(); diff --git a/tsconfig.json b/tsconfig.json index e94475dc7..3df37338c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,11 @@ "types": ["node"], "esModuleInterop": true }, - "include": ["declarations.d.ts", "bin/*.js", "lib/**/*.js", "tooling/**/*.js"] + "include": [ + "declarations.d.ts", + "declarations/*.d.ts", + "bin/*.js", + "lib/**/*.js", + "tooling/**/*.js" + ] } diff --git a/yarn.lock b/yarn.lock index 4dd8e6740..f08c488f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,14 +32,44 @@ dependencies: "@types/babel-types" "*" +"@types/cli-color@^0.3.29": + version "0.3.29" + resolved "https://registry.yarnpkg.com/@types/cli-color/-/cli-color-0.3.29.tgz#c83a71fe02c8c7e1ccec048dd6a2458d1f6c96ea" + +"@types/json-schema@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.0.tgz#5a2b780fec9f2cf851e1b5e0a29a4cac6c9686c5" + +"@types/lodash@^4.14.116": + version "4.14.116" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.116.tgz#5ccf215653e3e8c786a58390751033a9adca0eb9" + +"@types/minimist@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" + +"@types/mz@0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@types/mz/-/mz-0.0.32.tgz#e8248b4e41424c052edc1725dd33650c313a3659" + dependencies: + "@types/node" "*" + "@types/node@*": version "10.5.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.1.tgz#d578446f4abff5c0b49ade9b4e5274f6badaadfc" +"@types/node@^10.9.4": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.10.1.tgz#d5c96ca246a418404914d180b7fdd625ad18eca6" + "@types/node@^9.6.4": version "9.6.30" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.30.tgz#1ecf83eaf7ac2d0dada7a9d61a1e4e7a6183ac06" +"@types/prettier@^1.13.2": + version "1.13.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.13.2.tgz#ffe96278e712a8d4e467e367a338b05e22872646" + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" @@ -56,133 +86,129 @@ "@types/source-list-map" "*" source-map "^0.6.1" -"@webassemblyjs/ast@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.6.tgz#3ef8c45b3e5e943a153a05281317474fef63e21e" +"@webassemblyjs/ast@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.8.tgz#f31f480debeef957f01b623f27eabc695fa4fe8f" dependencies: - "@webassemblyjs/helper-module-context" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/wast-parser" "1.7.6" - mamacro "^0.0.3" + "@webassemblyjs/helper-module-context" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/wast-parser" "1.7.8" -"@webassemblyjs/floating-point-hex-parser@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.6.tgz#7cb37d51a05c3fe09b464ae7e711d1ab3837801f" +"@webassemblyjs/floating-point-hex-parser@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.8.tgz#1b3ed0e27e384032254e9322fc646dd3e70ef1b9" -"@webassemblyjs/helper-api-error@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.6.tgz#99b7e30e66f550a2638299a109dda84a622070ef" +"@webassemblyjs/helper-api-error@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.8.tgz#a2b49c11f615e736f815ec927f035dcfa690d572" -"@webassemblyjs/helper-buffer@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.6.tgz#ba0648be12bbe560c25c997e175c2018df39ca3e" +"@webassemblyjs/helper-buffer@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.8.tgz#3fc66bfa09c1c60e824cf3d5887826fac062877d" -"@webassemblyjs/helper-code-frame@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.6.tgz#5a94d21b0057b69a7403fca0c253c3aaca95b1a5" +"@webassemblyjs/helper-code-frame@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.8.tgz#cc5a7e9522b70e7580df056dfd34020cf29645b0" dependencies: - "@webassemblyjs/wast-printer" "1.7.6" + "@webassemblyjs/wast-printer" "1.7.8" -"@webassemblyjs/helper-fsm@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.6.tgz#ae1741c6f6121213c7a0b587fb964fac492d3e49" +"@webassemblyjs/helper-fsm@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.8.tgz#fe4607430af466912797c21acafd3046080182ea" -"@webassemblyjs/helper-module-context@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.6.tgz#116d19a51a6cebc8900ad53ca34ff8269c668c23" +"@webassemblyjs/helper-module-context@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.8.tgz#3c2e7ee93d14ff4768ba66fb1be42fdc9dc7160a" + +"@webassemblyjs/helper-wasm-bytecode@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.8.tgz#89bdb78cd6dd5209ae2ed2925de78d0f0e00b6f0" + +"@webassemblyjs/helper-wasm-section@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.8.tgz#c68ef7d26a6fc12421b2e6e56f9bc810dfb33e87" dependencies: - mamacro "^0.0.3" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-buffer" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/wasm-gen" "1.7.8" -"@webassemblyjs/helper-wasm-bytecode@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.6.tgz#98e515eaee611aa6834eb5f6a7f8f5b29fefb6f1" - -"@webassemblyjs/helper-wasm-section@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.6.tgz#783835867bdd686df7a95377ab64f51a275e8333" - dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-buffer" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/wasm-gen" "1.7.6" - -"@webassemblyjs/ieee754@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.7.6.tgz#c34fc058f2f831fae0632a8bb9803cf2d3462eb1" +"@webassemblyjs/ieee754@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.7.8.tgz#1f37974b13cb486a9237e73ce04cac7a2f1265ed" dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.7.6.tgz#197f75376a29f6ed6ace15898a310d871d92f03b" +"@webassemblyjs/leb128@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.7.8.tgz#1bee83426819192db2ea1a234b84c7ebc6d34c1f" dependencies: "@xtuc/long" "4.2.1" -"@webassemblyjs/utf8@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.7.6.tgz#eb62c66f906af2be70de0302e29055d25188797d" +"@webassemblyjs/utf8@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.7.8.tgz#2b489d5cf43e0aebb93d8e2d792aff9879c61f05" -"@webassemblyjs/wasm-edit@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.6.tgz#fa41929160cd7d676d4c28ecef420eed5b3733c5" +"@webassemblyjs/wasm-edit@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.8.tgz#f8bdbe7088718eca27b1c349bb7c06b8a457950c" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-buffer" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/helper-wasm-section" "1.7.6" - "@webassemblyjs/wasm-gen" "1.7.6" - "@webassemblyjs/wasm-opt" "1.7.6" - "@webassemblyjs/wasm-parser" "1.7.6" - "@webassemblyjs/wast-printer" "1.7.6" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-buffer" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/helper-wasm-section" "1.7.8" + "@webassemblyjs/wasm-gen" "1.7.8" + "@webassemblyjs/wasm-opt" "1.7.8" + "@webassemblyjs/wasm-parser" "1.7.8" + "@webassemblyjs/wast-printer" "1.7.8" -"@webassemblyjs/wasm-gen@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.6.tgz#695ac38861ab3d72bf763c8c75e5f087ffabc322" +"@webassemblyjs/wasm-gen@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.8.tgz#7e8abf1545eae74ac6781d545c034af3cfd0c7d5" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/ieee754" "1.7.6" - "@webassemblyjs/leb128" "1.7.6" - "@webassemblyjs/utf8" "1.7.6" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/ieee754" "1.7.8" + "@webassemblyjs/leb128" "1.7.8" + "@webassemblyjs/utf8" "1.7.8" -"@webassemblyjs/wasm-opt@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.6.tgz#fbafa78e27e1a75ab759a4b658ff3d50b4636c21" +"@webassemblyjs/wasm-opt@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.8.tgz#7ada6e211914728fce02ff0ff9c344edc6d41f26" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-buffer" "1.7.6" - "@webassemblyjs/wasm-gen" "1.7.6" - "@webassemblyjs/wasm-parser" "1.7.6" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-buffer" "1.7.8" + "@webassemblyjs/wasm-gen" "1.7.8" + "@webassemblyjs/wasm-parser" "1.7.8" -"@webassemblyjs/wasm-parser@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.6.tgz#84eafeeff405ad6f4c4b5777d6a28ae54eed51fe" +"@webassemblyjs/wasm-parser@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.8.tgz#dac47c291fb6a3e63529aecd647592cd34afbf94" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-api-error" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/ieee754" "1.7.6" - "@webassemblyjs/leb128" "1.7.6" - "@webassemblyjs/utf8" "1.7.6" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-api-error" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/ieee754" "1.7.8" + "@webassemblyjs/leb128" "1.7.8" + "@webassemblyjs/utf8" "1.7.8" -"@webassemblyjs/wast-parser@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.7.6.tgz#ca4d20b1516e017c91981773bd7e819d6bd9c6a7" +"@webassemblyjs/wast-parser@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.7.8.tgz#f8aab9a450c048c1f9537695c89faeb92fabfba5" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/floating-point-hex-parser" "1.7.6" - "@webassemblyjs/helper-api-error" "1.7.6" - "@webassemblyjs/helper-code-frame" "1.7.6" - "@webassemblyjs/helper-fsm" "1.7.6" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/floating-point-hex-parser" "1.7.8" + "@webassemblyjs/helper-api-error" "1.7.8" + "@webassemblyjs/helper-code-frame" "1.7.8" + "@webassemblyjs/helper-fsm" "1.7.8" "@xtuc/long" "4.2.1" - mamacro "^0.0.3" -"@webassemblyjs/wast-printer@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.7.6.tgz#a6002c526ac5fa230fe2c6d2f1bdbf4aead43a5e" +"@webassemblyjs/wast-printer@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.7.8.tgz#e7e965782c1912f6a965f14a53ff43d8ad0403a5" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/wast-parser" "1.7.6" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/wast-parser" "1.7.8" "@xtuc/long" "4.2.1" "@xtuc/ieee754@^1.2.0": @@ -302,7 +328,7 @@ ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" -ansi-regex@^2.0.0: +ansi-regex@^2.0.0, ansi-regex@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -324,6 +350,10 @@ any-observable@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/any-observable/-/any-observable-0.3.0.tgz#af933475e5806a67d0d7df090dd5e8bef65d119b" +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -865,6 +895,10 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +call-me-maybe@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" + caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" @@ -1021,6 +1055,17 @@ clean-css@^4.1.11: dependencies: source-map "0.5.x" +cli-color@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-1.3.0.tgz#cd2ec212efbd1a0eeb5b017f17d4e2d15e91420f" + dependencies: + ansi-regex "^2.1.1" + d "1" + es5-ext "^0.10.46" + es6-iterator "^2.0.3" + memoizee "^0.4.14" + timers-ext "^0.1.5" + cli-cursor@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" @@ -1451,6 +1496,12 @@ cyclist@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -1708,10 +1759,42 @@ es-to-primitive@^1.1.1: is-date-object "^1.0.1" is-symbol "^1.0.1" +es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.45, es5-ext@^0.10.46, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: + version "0.10.46" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.46.tgz#efd99f67c5a7ec789baa3daa7f79870388f7f572" + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" + next-tick "1" + +es6-iterator@^2.0.1, es6-iterator@^2.0.3, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + es6-promise-polyfill@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/es6-promise-polyfill/-/es6-promise-polyfill-1.2.0.tgz#f38925f23cb3e3e8ce6cda8ff774fcebbb090cde" +es6-symbol@^3.1.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1874,6 +1957,13 @@ esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" +event-emitter@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -2198,6 +2288,10 @@ form-data@~2.3.1: combined-stream "1.0.6" mime-types "^2.1.12" +format-util@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.3.tgz#032dca4a116262a12c43f4c3ec8566416c5b2d95" + fragment-cache@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" @@ -2925,7 +3019,7 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" -is-promise@^2.0.0, is-promise@^2.1.0: +is-promise@^2.0.0, is-promise@^2.1, is-promise@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" @@ -3450,7 +3544,7 @@ js-yaml@3.x, js-yaml@^3.9.0: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^3.11.0, js-yaml@^3.7.0: +js-yaml@^3.11.0, js-yaml@^3.12.0, js-yaml@^3.7.0: version "3.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" dependencies: @@ -3515,6 +3609,35 @@ json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" +json-schema-ref-parser@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/json-schema-ref-parser/-/json-schema-ref-parser-5.1.3.tgz#f86c5868f40898e69169e1bbc854725a4fd0e1ad" + dependencies: + call-me-maybe "^1.0.1" + debug "^3.1.0" + js-yaml "^3.12.0" + ono "^4.0.6" + +json-schema-to-typescript@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/json-schema-to-typescript/-/json-schema-to-typescript-6.0.1.tgz#31baac45a124b586d4021d12a5ea0ec07fddf294" + dependencies: + "@types/cli-color" "^0.3.29" + "@types/json-schema" "^7.0.0" + "@types/lodash" "^4.14.116" + "@types/minimist" "^1.2.0" + "@types/mz" "0.0.32" + "@types/node" "^10.9.4" + "@types/prettier" "^1.13.2" + cli-color "^1.3.0" + json-schema-ref-parser "^5.1.3" + json-stringify-safe "^5.0.1" + lodash "^4.17.11" + minimist "^1.2.0" + mz "^2.7.0" + prettier "^1.14.2" + stdin "0.0.1" + json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -3537,7 +3660,7 @@ json-stable-stringify@^1.0.1: dependencies: jsonify "~0.0.0" -json-stringify-safe@~5.0.1: +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" @@ -3787,6 +3910,10 @@ lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" +lodash@^4.17.11: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + log-driver@1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" @@ -3837,6 +3964,12 @@ lru-cache@^4.0.1, lru-cache@^4.1.3: pseudomap "^1.0.2" yallist "^2.1.2" +lru-queue@0.1: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + dependencies: + es5-ext "~0.10.2" + macaddress@^0.2.8: version "0.2.8" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12" @@ -3853,10 +3986,6 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" -mamacro@^0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/mamacro/-/mamacro-0.0.3.tgz#ad2c9576197c9f1abf308d0787865bd975a3f3e4" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -3888,6 +4017,19 @@ mem@^1.1.0: dependencies: mimic-fn "^1.0.0" +memoizee@^0.4.14: + version "0.4.14" + resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.14.tgz#07a00f204699f9a95c2d9e77218271c7cd610d57" + dependencies: + d "1" + es5-ext "^0.10.45" + es6-weak-map "^2.0.2" + event-emitter "^0.3.5" + is-promise "^2.1" + lru-queue "0.1" + next-tick "1" + timers-ext "^0.1.5" + memory-fs@^0.4.0, memory-fs@~0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -4062,6 +4204,14 @@ mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + nan@^2.9.2: version "2.10.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" @@ -4098,6 +4248,10 @@ neo-async@^2.5.0: version "2.5.1" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.5.1.tgz#acb909e327b1e87ec9ef15f41b8a269512ad41ee" +next-tick@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" @@ -4335,6 +4489,12 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" +ono@^4.0.6: + version "4.0.8" + resolved "https://registry.yarnpkg.com/ono/-/ono-4.0.8.tgz#d1b12e048cd8a9fe5d2fbf69d3ad42bf7b0feb5e" + dependencies: + format-util "^1.0.3" + optimist@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" @@ -4861,6 +5021,10 @@ prettier@^1.14.0: version "1.14.0" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.0.tgz#847c235522035fd988100f1f43cf20a7d24f9372" +prettier@^1.14.2: + version "1.14.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.2.tgz#0ac1c6e1a90baa22a62925f41963c841983282f9" + pretty-format@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-23.2.0.tgz#3b0aaa63c018a53583373c1cb3a5d96cc5e83017" @@ -5829,6 +5993,10 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" +stdin@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/stdin/-/stdin-0.0.1.tgz#d3041981aaec3dfdbc77a1b38d6372e38f5fb71e" + stealthy-require@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" @@ -6054,6 +6222,18 @@ text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.0" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839" + dependencies: + any-promise "^1.0.0" + throat@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" @@ -6075,6 +6255,13 @@ timers-browserify@^2.0.4: dependencies: setimmediate "^1.0.4" +timers-ext@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.5.tgz#77147dd4e76b660c2abb8785db96574cbbd12922" + dependencies: + es5-ext "~0.10.14" + next-tick "1" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -6371,9 +6558,9 @@ webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" -webpack-sources@^1.1.0, webpack-sources@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.2.0.tgz#18181e0d013fce096faf6f8e6d41eeffffdceac2" +webpack-sources@^1.1.0, webpack-sources@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.3.0.tgz#2a28dcb9f1f45fe960d8f1493252b5ee6530fa85" dependencies: source-list-map "^2.0.0" source-map "~0.6.1"