weboptimizer 2.0.1440 → 2.0.1442

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { Browser, InitializedBrowser } from './type';
2
+ export declare const browser: Browser;
3
+ /**
4
+ * Provides a generic browser api in node or web contexts.
5
+ * @param replaceWindow - Indicates whether a potential existing window object
6
+ * should be replaced or not.
7
+ *
8
+ * @returns Determined environment.
9
+ */
10
+ export declare const getInitializedBrowser: (replaceWindow?: boolean) => Promise<InitializedBrowser>;
11
+ export default getInitializedBrowser;
@@ -0,0 +1,26 @@
1
+ /// <reference types="webpack-env" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ /// <reference types="node" />
6
+ /// <reference types="node" />
7
+ import { ResolvedConfiguration } from './type';
8
+ export declare let loadedConfiguration: null | ResolvedConfiguration;
9
+ /**
10
+ * Main entry point to determine current configuration.
11
+ * @param context - Location from where to build current application.
12
+ * @param currentWorkingDirectory - Current working directory to use as
13
+ * reference.
14
+ * @param commandLineArguments - Arguments to take into account.
15
+ * @param webOptimizerPath - Current optimizer context path.
16
+ * @param environment - Environment variables to take into account.
17
+ *
18
+ * @returns Nothing.
19
+ */
20
+ export declare const load: (context?: string, currentWorkingDirectory?: string, commandLineArguments?: Array<string>, webOptimizerPath?: string, environment?: NodeJS.ProcessEnv) => ResolvedConfiguration;
21
+ /**
22
+ * Get cached or determined configuration object.
23
+ * @returns Nothing.
24
+ */
25
+ export declare const get: () => ResolvedConfiguration;
26
+ export default get;
package/ejsLoader.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { Encoding, Mapping } from 'clientnode/type';
2
+ import { Options, TemplateFunction as EJSTemplateFunction } from 'ejs';
3
+ import { LoaderContext } from 'webpack';
4
+ import { Extensions, Replacements } from './type';
5
+ export type PreCompiledTemplateFunction = ((...parameters: Array<unknown>) => string);
6
+ export type TemplateFunction = EJSTemplateFunction | PreCompiledTemplateFunction;
7
+ export type CompilerOptions = Options & {
8
+ encoding: Encoding;
9
+ isString?: boolean;
10
+ };
11
+ export type CompileFunction = (template: string, options?: Partial<CompilerOptions>, compileSteps?: number) => TemplateFunction;
12
+ export type LoaderConfiguration = Mapping<unknown> & {
13
+ compiler: Partial<CompilerOptions>;
14
+ compileSteps: number;
15
+ compress: {
16
+ html: Mapping<unknown>;
17
+ javaScript: Mapping<unknown>;
18
+ };
19
+ context: string;
20
+ debug: boolean;
21
+ extensions: Extensions;
22
+ locals?: Mapping<unknown>;
23
+ module: {
24
+ aliases: Mapping<string>;
25
+ replacements: Replacements;
26
+ };
27
+ };
28
+ /**
29
+ * Main transformation function.
30
+ * @param source - Input string to transform.
31
+ *
32
+ * @returns Transformed string.
33
+ */
34
+ export declare const loader: (this: LoaderContext<LoaderConfiguration>, source: string) => string;
35
+ export default loader;
package/helper.d.ts ADDED
@@ -0,0 +1,284 @@
1
+ import { Encoding, Mapping } from 'clientnode/type';
2
+ import { BuildConfiguration, Extensions, GivenInjection, GivenInjectionConfiguration, NormalizedGivenInjection, PathConfiguration, PackageDescriptor, Replacements, ResolvedBuildConfiguration, SpecificExtensions } from './type';
3
+ export declare const KNOWN_FILE_EXTENSIONS: Array<string>;
4
+ /**
5
+ * Provides a class of static methods with generic use cases.
6
+ */
7
+ export declare class Helper {
8
+ /**
9
+ * Determines whether given file path is within given list of file
10
+ * locations.
11
+ * @param filePath - Path to file to check.
12
+ * @param locationsToCheck - Locations to take into account.
13
+ *
14
+ * @returns Value "true" if given file path is within one of given
15
+ * locations or "false" otherwise.
16
+ */
17
+ static isFilePathInLocation(this: void, filePath: string, locationsToCheck: Array<string>): boolean;
18
+ /**
19
+ * Strips loader informations form given module request including loader
20
+ * prefix and query parameter.
21
+ * @param moduleID - Module request to strip.
22
+ *
23
+ * @returns Given module id stripped.
24
+ */
25
+ static stripLoader(this: void, moduleID: string): string;
26
+ /**
27
+ * Converts given list of path to a normalized list with unique values.
28
+ * @param paths - File paths.
29
+ *
30
+ * @returns The given file path list with normalized unique values.
31
+ */
32
+ static normalizePaths(this: void, paths: Array<string>): Array<string>;
33
+ /**
34
+ * Applies file path/name placeholder replacements with given bundle
35
+ * associated informations.
36
+ * @param template - File path to process placeholder in.
37
+ * @param scope - Scope to use for processing.
38
+ *
39
+ * @returns Processed file path.
40
+ */
41
+ static renderFilePathTemplate(this: void, template: string, scope?: Mapping<number | string>): string;
42
+ /**
43
+ * Converts given request to a resolved request with given context
44
+ * embedded.
45
+ * @param request - Request to determine.
46
+ * @param context - Context of given request to resolve relative to.
47
+ * @param referencePath - Path to resolve local modules relative to.
48
+ * @param aliases - Mapping of aliases to take into account.
49
+ * @param moduleReplacements - Mapping of replacements to take into
50
+ * account.
51
+ * @param relativeModuleLocations - List of relative directory paths to
52
+ * search for modules in.
53
+ *
54
+ * @returns A new resolved request.
55
+ */
56
+ static applyContext(this: void, request: string, context?: string, referencePath?: string, aliases?: Mapping, moduleReplacements?: Replacements, relativeModuleLocations?: Array<string>): false | string;
57
+ /**
58
+ * Check if given request points to an external dependency not maintained
59
+ * by current package context.
60
+ * @param request - Request to determine.
61
+ * @param context - Context of current project.
62
+ * @param requestContext - Context of given request to resolve relative to.
63
+ * @param normalizedGivenInjection - Mapping of chunk names to modules
64
+ * which should be injected.
65
+ * @param relativeExternalModuleLocations - Array of paths where external
66
+ * modules take place.
67
+ * @param aliases - Mapping of aliases to take into account.
68
+ * @param moduleReplacements - Mapping of replacements to take into
69
+ * account.
70
+ * @param extensions - List of file and module extensions to take into
71
+ * account.
72
+ * @param referencePath - Path to resolve local modules relative to.
73
+ * @param pathsToIgnore - Paths which marks location to ignore.
74
+ * @param relativeModuleLocations - List of relative file path to search
75
+ * for modules in.
76
+ * @param packageEntryFileNames - List of package entry file names to
77
+ * search for. The magic name "__package__" will search for an appreciate
78
+ * entry in a "package.json" file.
79
+ * @param packageMainPropertyNames - List of package file main property
80
+ * names to search for package representing entry module definitions.
81
+ * @param packageAliasPropertyNames - List of package file alias property
82
+ * names to search for package specific module aliases.
83
+ * @param includePattern - Array of regular expressions to explicitly mark
84
+ * as external dependency.
85
+ * @param excludePattern - Array of regular expressions to explicitly mark
86
+ * as internal dependency.
87
+ * @param inPlaceNormalLibrary - Indicates whether normal libraries should
88
+ * be external or not.
89
+ * @param inPlaceDynamicLibrary - Indicates whether requests with
90
+ * integrated loader configurations should be marked as external or not.
91
+ * @param encoding - Encoding for file names to use during file traversing.
92
+ *
93
+ * @returns A new resolved request indicating whether given request is an
94
+ * external one.
95
+ */
96
+ static determineExternalRequest(this: void, request: string, context?: string, requestContext?: string, normalizedGivenInjection?: NormalizedGivenInjection, relativeExternalModuleLocations?: Array<string>, aliases?: Mapping, moduleReplacements?: Replacements, extensions?: Extensions, referencePath?: string, pathsToIgnore?: Array<string>, relativeModuleLocations?: Array<string>, packageEntryFileNames?: Array<string>, packageMainPropertyNames?: Array<string>, packageAliasPropertyNames?: Array<string>, includePattern?: Array<string | RegExp>, excludePattern?: Array<string | RegExp>, inPlaceNormalLibrary?: boolean, inPlaceDynamicLibrary?: boolean, encoding?: Encoding): null | string;
97
+ /**
98
+ * Determines asset type of given file.
99
+ * @param filePath - Path to file to analyse.
100
+ * @param buildConfiguration - Meta informations for available asset
101
+ * types.
102
+ * @param paths - List of paths to search if given path doesn't reference
103
+ * a file directly.
104
+ *
105
+ * @returns Determined file type or "null" of given file couldn't be
106
+ * determined.
107
+ */
108
+ static determineAssetType(this: void, filePath: string, buildConfiguration: BuildConfiguration, paths: PathConfiguration): null | string;
109
+ /**
110
+ * Adds a property with a stored array of all matching file paths, which
111
+ * matches each build configuration in given entry path and converts given
112
+ * build configuration into a sorted array were javaScript files takes
113
+ * precedence.
114
+ * @param configuration - Given build configurations.
115
+ * @param entryPath - Path to analyse nested structure.
116
+ * @param pathsToIgnore - Paths which marks location to ignore.
117
+ * @param mainFileBasenames - File basenames to sort into the front.
118
+ *
119
+ * @returns Converted build configuration.
120
+ */
121
+ static resolveBuildConfigurationFilePaths(this: void, configuration: BuildConfiguration, entryPath?: string, pathsToIgnore?: Array<string>, mainFileBasenames?: Array<string>): ResolvedBuildConfiguration;
122
+ /**
123
+ * Determines all file and directory paths related to given internal
124
+ * modules as array.
125
+ * @param givenInjection - List of module ids or module file paths.
126
+ * @param aliases - Mapping of aliases to take into account.
127
+ * @param moduleReplacements - Mapping of module replacements to take into
128
+ * account.
129
+ * @param extensions - List of file and module extensions to take into
130
+ * account.
131
+ * @param context - File path to resolve relative to.
132
+ * @param referencePath - Path to search for local modules.
133
+ * @param pathsToIgnore - Paths which marks location to ignore.
134
+ * @param relativeModuleLocations - List of relative file path to search
135
+ * for modules in.
136
+ * @param packageEntryFileNames - List of package entry file names to
137
+ * search for. The magic name "__package__" will search for an appreciate
138
+ * entry in a "package.json" file.
139
+ * @param packageMainPropertyNames - List of package file main property
140
+ * names to search for package representing entry module definitions.
141
+ * @param packageAliasPropertyNames - List of package file alias property
142
+ * names to search for package specific module aliases.
143
+ * @param encoding - File name encoding to use during file traversing.
144
+ *
145
+ * @returns Object with a file path and directory path key mapping to
146
+ * corresponding list of paths.
147
+ */
148
+ static determineModuleLocations(this: void, givenInjection: GivenInjection, aliases?: Mapping, moduleReplacements?: Replacements, extensions?: SpecificExtensions, context?: string, referencePath?: string, pathsToIgnore?: Array<string>, relativeModuleLocations?: Array<string>, packageEntryFileNames?: Array<string>, packageMainPropertyNames?: Array<string>, packageAliasPropertyNames?: Array<string>, encoding?: Encoding): {
149
+ directoryPaths: Array<string>;
150
+ filePaths: Array<string>;
151
+ };
152
+ /**
153
+ * Determines a list of concrete file paths for given module id pointing to
154
+ * a folder which isn't a package.
155
+ * @param normalizedGivenInjection - Injection data structure of modules
156
+ * with folder references to resolve.
157
+ * @param aliases - Mapping of aliases to take into account.
158
+ * @param moduleReplacements - Mapping of replacements to take into
159
+ * account.
160
+ * @param context - File path to determine relative to.
161
+ * @param referencePath - Path to resolve local modules relative to.
162
+ * @param pathsToIgnore - Paths which marks location to ignore.
163
+ *
164
+ * @returns Given injections with resolved folder pointing modules.
165
+ */
166
+ static resolveModulesInFolders(this: void, normalizedGivenInjection: NormalizedGivenInjection, aliases?: Mapping, moduleReplacements?: Replacements, context?: string, referencePath?: string, pathsToIgnore?: Array<string>): NormalizedGivenInjection;
167
+ /**
168
+ * Every injection definition type can be represented as plain object
169
+ * (mapping from chunk name to array of module ids). This method converts
170
+ * each representation into the normalized plain object notation.
171
+ * @param givenInjection - Given entry injection to normalize.
172
+ *
173
+ * @returns Normalized representation of given entry injection.
174
+ */
175
+ static normalizeGivenInjection(this: void, givenInjection: GivenInjection): NormalizedGivenInjection;
176
+ /**
177
+ * Determines all concrete file paths for given injection which are marked
178
+ * with the "__auto__" indicator.
179
+ * @param givenInjection - Given entry and external injection to take
180
+ * into account.
181
+ * @param buildConfigurations - Resolved build configuration.
182
+ * @param aliases - Mapping of aliases to take into account.
183
+ * @param moduleReplacements - Mapping of replacements to take into
184
+ * account.
185
+ * @param extensions - List of file and module extensions to take into
186
+ * account.
187
+ * @param context - File path to use as starting point.
188
+ * @param referencePath - Reference path from where local files should be
189
+ * resolved.
190
+ * @param pathsToIgnore - Paths which marks location to ignore.
191
+ *
192
+ * @returns Given injection with resolved marked indicators.
193
+ */
194
+ static resolveAutoInjection<T extends GivenInjectionConfiguration>(this: void, givenInjection: T, buildConfigurations: ResolvedBuildConfiguration, aliases?: Mapping, moduleReplacements?: Replacements, extensions?: Extensions, context?: string, referencePath?: string, pathsToIgnore?: Array<string>): T;
195
+ /**
196
+ * Determines all module file paths.
197
+ * @param buildConfigurations - Resolved build configuration.
198
+ * @param moduleFilePathsToExclude - A list of modules file paths to
199
+ * exclude (specified by path or id) or a mapping from chunk names to
200
+ * module ids.
201
+ * @param context - File path to use as starting point.
202
+ *
203
+ * @returns All determined module file paths.
204
+ */
205
+ static getAutoInjection(this: void, buildConfigurations: ResolvedBuildConfiguration, moduleFilePathsToExclude: Array<string>, context: string): Mapping;
206
+ /**
207
+ * Determines a resolved module file path in given package path.
208
+ * @param packagePath - Path to package to resolve in.
209
+ * @param packageMainPropertyNames - List of package file main property
210
+ * names to search for package representing entry module definitions.
211
+ * @param packageAliasPropertyNames - List of package file alias property
212
+ * names to search for package specific module aliases.
213
+ * @param encoding - Encoding to use for file names during file traversing.
214
+ *
215
+ * @returns Path if found and / or additional package aliases to consider.
216
+ */
217
+ static determineModuleFilePathInPackage(this: void, packagePath: string, packageMainPropertyNames?: Array<string>, packageAliasPropertyNames?: Array<string>, encoding?: Encoding): {
218
+ fileName: null | string;
219
+ packageAliases: Mapping | null;
220
+ };
221
+ /**
222
+ * Determines a concrete file path for given module id.
223
+ * @param moduleID - Module id to determine.
224
+ * @param aliases - Mapping of aliases to take into account.
225
+ * @param moduleReplacements - Mapping of replacements to take into
226
+ * account.
227
+ * @param extensions - List of file and module extensions to take into
228
+ * account.
229
+ * @param context - File path to determine relative to.
230
+ * @param referencePath - Path to resolve local modules relative to.
231
+ * @param pathsToIgnore - Paths which marks location to ignore.
232
+ * @param relativeModuleLocations - List of relative file path to search
233
+ * for modules in.
234
+ * @param packageEntryFileNames - List of package entry file names to
235
+ * search for. The magic name "__package__" will search for an appreciate
236
+ * entry in a "package.json" file.
237
+ * @param packageMainPropertyNames - List of package file main property
238
+ * names to search for package representing entry module definitions.
239
+ * @param packageAliasPropertyNames - List of package file alias property
240
+ * names to search for package specific module aliases.
241
+ * @param encoding - Encoding to use for file names during file traversing.
242
+ *
243
+ * @returns File path or given module id if determinations has failed or
244
+ * wasn't necessary.
245
+ */
246
+ static determineModuleFilePath(this: void, moduleID: false | string, aliases?: Mapping, moduleReplacements?: Replacements, extensions?: SpecificExtensions, context?: string, referencePath?: string, pathsToIgnore?: Array<string>, relativeModuleLocations?: Array<string>, packageEntryFileNames?: Array<string>, packageMainPropertyNames?: Array<string>, packageAliasPropertyNames?: Array<string>, encoding?: Encoding): null | string;
247
+ /**
248
+ * Determines a concrete file path for given module id.
249
+ * @param moduleID - Module id to determine.
250
+ * @param aliases - Mapping of aliases to take into account.
251
+ *
252
+ * @returns The alias applied given module id.
253
+ */
254
+ static applyAliases(this: void, moduleID: string, aliases: Mapping): string;
255
+ /**
256
+ * Determines a concrete file path for given module id.
257
+ * @param moduleID - Module id to determine.
258
+ * @param replacements - Mapping of regular expressions to their
259
+ * corresponding replacements.
260
+ *
261
+ * @returns The replacement applied given module id.
262
+ */
263
+ static applyModuleReplacements(this: void, moduleID: false | string, replacements: Replacements): false | string;
264
+ /**
265
+ * Determines the nearest package configuration file from given file path.
266
+ * @param start - Reference location to search from.
267
+ * @param fileName - Package configuration file name.
268
+ *
269
+ * @returns Determined file path.
270
+ */
271
+ static findPackageDescriptorFilePath(this: void, start: Array<string> | string, fileName?: string): null | string;
272
+ /**
273
+ * Determines the nearest package configuration from given module file
274
+ * path.
275
+ * @param modulePath - Module path to take as reference location (leaf in
276
+ * tree).
277
+ * @param fileName - Package configuration file name.
278
+ *
279
+ * @returns A object containing found parsed configuration an their
280
+ * corresponding file path.
281
+ */
282
+ static getClosestPackageDescriptor(this: void, modulePath: string, fileName?: string): null | PackageDescriptor;
283
+ }
284
+ export default Helper;
package/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env babel-node
2
+ /// <reference types="webpack-env" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ /// <reference types="node" />
6
+ /// <reference types="node" />
7
+ /// <reference types="node" />
8
+ /**
9
+ * Main entry point.
10
+ * @param context - Location from where to build current application.
11
+ * @param currentWorkingDirectory - Current working directory to use as
12
+ * reference.
13
+ * @param commandLineArguments - Arguments to take into account.
14
+ * @param webOptimizerPath - Current optimizer context path.
15
+ * @param environment - Environment variables to take into account.
16
+ *
17
+ * @returns Nothing.
18
+ */
19
+ declare const main: (context?: string, currentWorkingDirectory?: string, commandLineArguments?: Array<string>, webOptimizerPath?: string, environment?: NodeJS.ProcessEnv) => Promise<() => void>;
20
+ export default main;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Implements the default browser environment to run script context in.
3
+ */
4
+ export declare class BrowserEnvironment {
5
+ /**
6
+ * @returns Nothing.
7
+ */
8
+ setup(): Promise<void>;
9
+ /**
10
+ * @returns Nothing.
11
+ */
12
+ teardown(): void;
13
+ /**
14
+ * @returns Null.
15
+ */
16
+ runScript(): null;
17
+ }
18
+ export default BrowserEnvironment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "2.0.1440",
3
+ "version": "2.0.1442",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -69,7 +69,7 @@
69
69
  "build:types": "tsc --declaration --emitDeclarationOnly",
70
70
  "check": "yarn check:types; yarn lint",
71
71
  "check:types": "tsc --noEmit",
72
- "clear": "rimraf apiDocumentation 'plugins/*.d.ts' 'plugins/*.js' browser.d.ts configurator.d.ts ejsLoader.d.ts helper.d.ts index.d.ts jestEnvironmentBrowser.d.ts stylelintConfigurator.d.ts type.d.ts webpackConfigurator.d.ts '*.js' '*.compiled.*' '*.compiled' 'test/*.js' 'test/*.compiled.*' 'test/*.d.ts' '*.html' '*.log' node_modules/weboptimizer .coverage .nyc_output || true",
72
+ "clear": "rimraf apiDocumentation 'plugins/*.d.ts' 'plugins/*.js' browser.d.ts configurator.d.ts ejsLoader.d.ts helper.d.ts index.d.ts jestSetup.d.ts jestEnvironmentBrowser.d.ts stylelintConfigurator.d.ts type.d.ts webpackConfigurator.d.ts '*.js' '*.compiled.*' '*.compiled' 'test/*.js' 'test/*.compiled.*' 'test/*.d.ts' '*.html' '*.log' node_modules/weboptimizer .coverage .nyc_output || true",
73
73
  "document": "yarn build:plain && jsdoc --package ./package.json --readme ./readme.md --destination apiDocumentation *.js",
74
74
  "lint": "yarn lint:base",
75
75
  "lint:base": "eslint --ignore-pattern '**/exclude/*' --ignore-pattern '*.compiled.*' --ignore-pattern '*.d.ts' --ignore-pattern '*.js' --parser-options=project:tsconfig.json '*.ts' 'test/*.ts'",
@@ -97,7 +97,7 @@
97
97
  "babel-loader": "*",
98
98
  "babel-plugin-transform-modern-regexp": "*",
99
99
  "babel-preset-minify": "*",
100
- "clientnode": "3.0.1121",
100
+ "clientnode": "^3.0.1121",
101
101
  "ejs": "*",
102
102
  "exports-loader": "*",
103
103
  "extract-loader": "*",
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
package/type.d.ts ADDED
@@ -0,0 +1,483 @@
1
+ /// <reference types="webpack-env" />
2
+ /// <reference types="node" />
3
+ import { AnyFunction, Encoding, Mapping, PlainObject, SecondParameter } from 'clientnode/type';
4
+ import FaviconWebpackPlugin from 'favicons-webpack-plugin';
5
+ import { FaviconWebpackPlugionOptions as FaviconWebpackPluginOptions } from 'favicons-webpack-plugin/src/options';
6
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
7
+ import ImageMinimizerWebpackPlugin, { PluginOptions as ImageMinimizerOptions } from 'image-minimizer-webpack-plugin';
8
+ import { JSDOM } from 'jsdom';
9
+ import MiniCSSExtractPlugin from 'mini-css-extract-plugin';
10
+ import TerserWebpackPlugin from 'terser-webpack-plugin';
11
+ import { DefinePlugin as WebpackDefinePlugin, Configuration as BaseWebpackConfiguration, IgnorePlugin as WebpackIgnorePlugin, library as webpackLibrary, ModuleOptions as WebpackModuleOptions, RuleSetRule as WebpackRuleSetRule, RuleSetUseItem as WebpackRuleSetUseItem, WebpackOptionsNormalized } from 'webpack';
12
+ import { WebpackPartial as WorkboxBaseCommonOptions, BasePartial as WorkboxCommonOptions, WebpackGenerateSWOptions as WorkboxGenerateSWOptions, WebpackInjectManifestOptions as WorkboxInjectManifestOptions } from 'workbox-build';
13
+ import OfflinePlugin from 'workbox-webpack-plugin';
14
+ export interface Browser {
15
+ debug: boolean;
16
+ domContentLoaded: boolean;
17
+ DOM: typeof JSDOM | null;
18
+ initialized: boolean;
19
+ instance: JSDOM | null;
20
+ window: null | Window;
21
+ windowLoaded: boolean;
22
+ }
23
+ export interface InitializedBrowser extends Browser {
24
+ DOM: typeof JSDOM;
25
+ instance: JSDOM;
26
+ window: Window;
27
+ }
28
+ export interface PackageConfiguration {
29
+ name: string;
30
+ version: string;
31
+ }
32
+ export interface PackageDescriptor {
33
+ configuration: PackageConfiguration;
34
+ filePath: string;
35
+ }
36
+ export type Replacements = Mapping<SecondParameter<string['replace']>>;
37
+ export type Resolvable = {
38
+ [_K in '__evaluate__' | '__execute__']?: Resolvable;
39
+ } & Mapping<unknown>;
40
+ export interface RedundantRequest {
41
+ path: string;
42
+ version: string;
43
+ }
44
+ export type ExternalAliases = Mapping<Mapping | string | ((_request: string, _key: string) => string)>;
45
+ export type GivenInjection = AnyFunction | string | Array<string> | Mapping<string | Array<string>>;
46
+ export type NormalizedGivenInjection = Mapping<Array<string>>;
47
+ export interface GivenInjectionConfiguration {
48
+ autoExclude: Array<string>;
49
+ entry: GivenInjection;
50
+ external: GivenInjection;
51
+ }
52
+ export type IgnorePattern = WebpackIgnorePlugin['options'] | {
53
+ contextRegExp?: string;
54
+ resourceRegExp?: string;
55
+ };
56
+ export interface InjectionConfiguration {
57
+ autoExclude: Array<string>;
58
+ chunks: NonNullable<BaseWebpackConfiguration['optimization']>['splitChunks'];
59
+ entry: {
60
+ given: GivenInjection;
61
+ normalized: NormalizedGivenInjection;
62
+ };
63
+ external: {
64
+ aliases: ExternalAliases;
65
+ implicit: {
66
+ pattern: {
67
+ exclude: Array<RegExp | string>;
68
+ include: Array<RegExp | string>;
69
+ };
70
+ };
71
+ modules: BaseWebpackConfiguration['externals'];
72
+ };
73
+ externalAliases: Mapping;
74
+ ignorePattern: Array<IgnorePattern> | IgnorePattern;
75
+ implicitExternalExcludePattern: Array<RegExp | string>;
76
+ implicitExternalIncludePattern: Array<RegExp | string>;
77
+ }
78
+ export interface HTMLTransformationOptions {
79
+ hashAlgorithm: string;
80
+ htmlPlugin: typeof HtmlWebpackPlugin;
81
+ files: Array<HTMLConfiguration>;
82
+ }
83
+ export interface InPlaceAssetsIntoHTMLOptions {
84
+ cascadingStyleSheet: InPlaceAssetConfiguration;
85
+ javaScript: InPlaceAssetConfiguration;
86
+ htmlPlugin: typeof HtmlWebpackPlugin;
87
+ }
88
+ export interface AssetPathConfiguration {
89
+ base: string;
90
+ cascadingStyleSheet: string;
91
+ data: string;
92
+ font: string;
93
+ image: string;
94
+ javaScript: string;
95
+ template: string;
96
+ }
97
+ export interface BasePathConfiguration {
98
+ base: string;
99
+ context: string;
100
+ source: {
101
+ asset: AssetPathConfiguration;
102
+ base: string;
103
+ };
104
+ target: {
105
+ asset: AssetPathConfiguration;
106
+ base: string;
107
+ manifest: string;
108
+ public: string;
109
+ };
110
+ }
111
+ export interface PathConfiguration extends BasePathConfiguration {
112
+ apiDocumentation: string;
113
+ base: string;
114
+ configuration: {
115
+ javaScript: string;
116
+ json: string;
117
+ typeScript: string;
118
+ };
119
+ context: string;
120
+ ignore: Array<string>;
121
+ tidyUp: Array<string>;
122
+ tidyUpGlobs: Array<string>;
123
+ tidyUpOnClear: Array<string>;
124
+ tidyUpOnClearGlobs: Array<string>;
125
+ }
126
+ export type DefaultPathConfiguration = BasePathConfiguration & Resolvable;
127
+ export interface BuildConfigurationItem {
128
+ extension: string;
129
+ ignoredExtension: string;
130
+ filePathPattern: string;
131
+ outputExtension: string;
132
+ }
133
+ export type BuildConfiguration = Mapping<BuildConfigurationItem>;
134
+ export declare const SubConfigurationTypes: readonly ["debug", "document", "test", "test:browser"];
135
+ export declare const TaskTypes: readonly ["build", "serve", "debug", "document", "test", "test:browser"];
136
+ export type BooleanExpression = boolean | null | string;
137
+ export interface AdditionalLoaderConfiguration {
138
+ exclude?: BooleanExpression;
139
+ include?: BooleanExpression;
140
+ test: string;
141
+ use: Array<WebpackLoader> | WebpackLoader | string;
142
+ }
143
+ export interface AdditionalLoaderConfigurations {
144
+ post: Array<AdditionalLoaderConfiguration>;
145
+ pre: Array<AdditionalLoaderConfiguration>;
146
+ }
147
+ export interface AdditionalLoader {
148
+ post: Array<string>;
149
+ pre: Array<string>;
150
+ }
151
+ export interface WebpackLoader {
152
+ loader: string;
153
+ options?: Mapping<unknown>;
154
+ }
155
+ export type ResourceLoaderConfiguration = WebpackLoader & {
156
+ exclude: BooleanExpression;
157
+ include: BooleanExpression;
158
+ loader: Array<string>;
159
+ regularExpression: string;
160
+ };
161
+ export interface LoaderConfiguration extends ResourceLoaderConfiguration {
162
+ additional: AdditionalLoaderConfigurations;
163
+ }
164
+ export interface WebpackLoaderConfiguration {
165
+ exclude: WebpackLoaderIndicator;
166
+ include: WebpackLoaderIndicator;
167
+ test: RegExp;
168
+ use: Array<WebpackLoader> | WebpackLoader;
169
+ }
170
+ export type WebpackLoaderIndicator = WebpackRuleSetRule['include'];
171
+ export interface Command {
172
+ arguments: Array<string>;
173
+ command: string;
174
+ indicator?: string;
175
+ }
176
+ export interface CommandLineArguments {
177
+ build: Command;
178
+ document: Array<Command> | Command;
179
+ lint: Array<Command> | Command;
180
+ serve: Array<Command> | Command;
181
+ test: Array<Command> | Command;
182
+ 'test:browser': Array<Command> | Command;
183
+ 'check:types': Array<Command> | Command;
184
+ }
185
+ export type NodeEnvironment = BaseWebpackConfiguration['node'] & {
186
+ '#': string;
187
+ };
188
+ export interface PluginConfiguration {
189
+ name: {
190
+ initializer: string;
191
+ module: string;
192
+ };
193
+ parameters: Array<unknown>;
194
+ }
195
+ export interface DefaultConfiguration {
196
+ contextType: string;
197
+ debug: boolean;
198
+ document: PlainObject;
199
+ encoding: Encoding;
200
+ givenCommandLineArguments: Array<string>;
201
+ library: boolean;
202
+ nodeEnvironment: NodeEnvironment;
203
+ path: DefaultPathConfiguration;
204
+ plugins: Array<PluginConfiguration>;
205
+ test: PlainObject;
206
+ 'test:browser': PlainObject;
207
+ }
208
+ export type ExportFormat = 'amd' | 'amd-require' | 'assign' | 'global' | 'jsonp' | 'var' | 'this' | 'commonjs' | 'commonjs2' | 'umd';
209
+ export interface HTMLConfiguration {
210
+ filename: string;
211
+ template: {
212
+ filePath: string;
213
+ options?: PlainObject;
214
+ postCompileOptions: PlainObject;
215
+ request: string;
216
+ use: Array<WebpackLoader> | WebpackLoader;
217
+ };
218
+ }
219
+ export interface MetaConfiguration {
220
+ default: DefaultConfiguration;
221
+ debug: Resolvable;
222
+ library: Resolvable;
223
+ }
224
+ export interface ResolvedBuildConfigurationItem extends BuildConfigurationItem {
225
+ filePaths: Array<string>;
226
+ type: string;
227
+ }
228
+ export interface Extensions {
229
+ file: {
230
+ external: Array<string>;
231
+ internal: Array<string>;
232
+ };
233
+ }
234
+ export interface SpecificExtensions {
235
+ file: Array<string>;
236
+ }
237
+ export interface InPlaceAssetConfiguration {
238
+ body?: Array<RegExp | string> | RegExp | string;
239
+ head?: Array<RegExp | string> | RegExp | string;
240
+ }
241
+ export interface InPlaceConfiguration {
242
+ cascadingStyleSheet: InPlaceAssetConfiguration;
243
+ externalLibrary: {
244
+ normal: boolean;
245
+ dynamic: boolean;
246
+ };
247
+ javaScript: InPlaceAssetConfiguration;
248
+ otherMaximumFileSizeLimitInByte: number;
249
+ }
250
+ export interface ResolvedConfiguration {
251
+ assetPattern: Mapping<{
252
+ excludeFilePathRegularExpression: string;
253
+ includeFilePathRegularExpression: string;
254
+ pattern: string;
255
+ }>;
256
+ buildContext: {
257
+ definitions: WebpackDefinePlugin['definitions'];
258
+ types: BuildConfiguration;
259
+ };
260
+ cache?: {
261
+ main?: WebpackOptionsNormalized['cache'];
262
+ unsafe?: WebpackModuleOptions['unsafeCache'];
263
+ };
264
+ commandLine: CommandLineArguments;
265
+ contextType: string;
266
+ debug: boolean;
267
+ development: {
268
+ includeClient?: boolean | null;
269
+ server: (WebpackOptionsNormalized['devServer'] & {
270
+ hot: boolean;
271
+ host: string;
272
+ https: boolean;
273
+ liveReload: boolean;
274
+ port: number;
275
+ });
276
+ tool: WebpackOptionsNormalized['devtool'];
277
+ };
278
+ document: PlainObject;
279
+ encoding: Encoding;
280
+ exportFormat: {
281
+ external: ExportFormat;
282
+ globalObject: string;
283
+ self: ExportFormat;
284
+ };
285
+ extensions: Extensions;
286
+ favicon: FaviconWebpackPluginOptions;
287
+ files: {
288
+ additionalPaths: Array<string>;
289
+ compose: {
290
+ cascadingStyleSheet: string | ((_asset: unknown) => string);
291
+ image: string;
292
+ javaScript: string;
293
+ };
294
+ defaultHTML: HTMLConfiguration;
295
+ html: Array<HTMLConfiguration>;
296
+ };
297
+ givenCommandLineArguments: Array<string>;
298
+ hashAlgorithm: string;
299
+ injection: InjectionConfiguration;
300
+ inPlace: InPlaceConfiguration;
301
+ library: boolean;
302
+ libraryName: string;
303
+ loader: {
304
+ aliases: Mapping;
305
+ directoryNames: Array<string>;
306
+ extensions: {
307
+ file: Array<string>;
308
+ };
309
+ resolveSymlinks: boolean;
310
+ };
311
+ module: {
312
+ additional: AdditionalLoaderConfigurations;
313
+ aliases: Mapping;
314
+ cascadingStyleSheet: ResourceLoaderConfiguration;
315
+ directoryNames: Array<string>;
316
+ enforceDeduplication: boolean;
317
+ html: LoaderConfiguration;
318
+ locations: {
319
+ directoryPaths: Array<string>;
320
+ filePaths: Array<string>;
321
+ };
322
+ optimizer: BaseWebpackConfiguration['optimization'] & {
323
+ babelMinify?: {
324
+ bundle?: {
325
+ plugin?: PlainObject;
326
+ transform?: PlainObject;
327
+ };
328
+ module?: PlainObject;
329
+ };
330
+ cssnano: PlainObject;
331
+ data: ResourceLoaderConfiguration;
332
+ font: {
333
+ eot: ResourceLoaderConfiguration;
334
+ svg: ResourceLoaderConfiguration;
335
+ ttf: ResourceLoaderConfiguration;
336
+ woff: ResourceLoaderConfiguration;
337
+ };
338
+ htmlMinifier?: PlainObject;
339
+ image: {
340
+ content: ImageMinimizerOptions<unknown, unknown>;
341
+ exclude: string;
342
+ loader: Array<string>;
343
+ };
344
+ };
345
+ preprocessor: {
346
+ cascadingStyleSheet: WebpackLoader & {
347
+ additional: AdditionalLoader & {
348
+ plugins: AdditionalLoader;
349
+ };
350
+ postcssPresetEnv: PlainObject;
351
+ };
352
+ ejs: LoaderConfiguration;
353
+ html: LoaderConfiguration;
354
+ javaScript: LoaderConfiguration;
355
+ json: {
356
+ exclude: string;
357
+ loader: string;
358
+ };
359
+ };
360
+ provide: Mapping | null;
361
+ replacements: {
362
+ context: Array<[string, string]>;
363
+ normal: Replacements;
364
+ };
365
+ resolveSymlinks: boolean;
366
+ skipParseRegularExpressions: WebpackModuleOptions['noParse'];
367
+ style: WebpackLoader;
368
+ };
369
+ name: string;
370
+ needed: Mapping<boolean>;
371
+ nodeENV: false | null | string;
372
+ nodeEnvironment: NodeEnvironment;
373
+ offline: {
374
+ common: WorkboxBaseCommonOptions & WorkboxCommonOptions;
375
+ injectionManifest: WorkboxInjectManifestOptions;
376
+ serviceWorker: WorkboxGenerateSWOptions;
377
+ use: 'injectionManifest' | 'serviceWorker';
378
+ };
379
+ package: {
380
+ aliasPropertyNames: Array<string>;
381
+ main: {
382
+ fileNames: Array<string>;
383
+ propertyNames: Array<string>;
384
+ };
385
+ };
386
+ path: PathConfiguration;
387
+ performanceHints: BaseWebpackConfiguration['performance'];
388
+ plugins: Array<PluginConfiguration>;
389
+ showConfiguration: boolean;
390
+ stylelint: PlainObject;
391
+ targetTechnology: {
392
+ boilerplate: string;
393
+ payload: string;
394
+ };
395
+ test: PlainObject;
396
+ 'test:browser': PlainObject;
397
+ webpack: WebpackConfiguration;
398
+ }
399
+ export type ResolvedBuildConfiguration = Array<ResolvedBuildConfigurationItem>;
400
+ export type RuntimeInformation = PlainObject & {
401
+ givenCommandLineArguments: Array<string>;
402
+ };
403
+ export interface WebpackConfiguration extends BaseWebpackConfiguration {
404
+ devServer: Mapping<unknown>;
405
+ replaceWebOptimizer: WebpackConfiguration;
406
+ }
407
+ export type RuleSet = Array<WebpackRuleSetUseItem>;
408
+ export type RuleSetRule = WebpackRuleSetRule & {
409
+ use: RuleSet;
410
+ };
411
+ export interface GenericLoader {
412
+ ejs: RuleSetRule;
413
+ script: RuleSetRule;
414
+ html: {
415
+ ejs: RuleSetRule;
416
+ html: RuleSetRule;
417
+ main: {
418
+ test: RegExp;
419
+ use: Array<WebpackLoader> | WebpackLoader;
420
+ };
421
+ };
422
+ style: RuleSetRule;
423
+ font: {
424
+ eot: RuleSetRule;
425
+ svg: RuleSetRule;
426
+ ttf: RuleSetRule;
427
+ woff: RuleSetRule;
428
+ };
429
+ image: RuleSetRule;
430
+ data: RuleSetRule;
431
+ }
432
+ export type Loader = GenericLoader & Mapping<WebpackRuleSetRule>;
433
+ export interface EvaluationScope {
434
+ configuration: ResolvedConfiguration;
435
+ isFilePathInDependencies: (_filePath: string) => boolean;
436
+ loader: Loader;
437
+ require: typeof require;
438
+ }
439
+ export interface WebpackBaseAssets {
440
+ outputName: string;
441
+ plugin: HtmlWebpackPlugin;
442
+ }
443
+ export interface WebpackAssets extends WebpackBaseAssets {
444
+ bodyTags: HtmlWebpackPlugin.HtmlTagObject[];
445
+ headTags: HtmlWebpackPlugin.HtmlTagObject[];
446
+ outputName: string;
447
+ publicPath: string;
448
+ plugin: HtmlWebpackPlugin;
449
+ }
450
+ export type WebpackPlugin = webpackLibrary.AbstractLibraryPlugin<unknown> & Mapping<unknown>;
451
+ export type WebpackPlugins = Mapping<WebpackPlugin> & {
452
+ Favicon?: typeof FaviconWebpackPlugin;
453
+ GenerateServiceWorker?: typeof OfflinePlugin.GenerateSW;
454
+ HTML?: typeof HtmlWebpackPlugin;
455
+ ImageMinimizer?: typeof ImageMinimizerWebpackPlugin;
456
+ InjectManifest?: typeof OfflinePlugin.InjectManifest;
457
+ Offline?: {
458
+ GenerateSW: typeof OfflinePlugin.GenerateSW;
459
+ InjectManifest: typeof OfflinePlugin.InjectManifest;
460
+ };
461
+ MiniCSSExtract?: typeof MiniCSSExtractPlugin;
462
+ Terser?: typeof TerserWebpackPlugin;
463
+ };
464
+ export type WebpackResolveData = Parameters<WebpackIgnorePlugin['checkIgnore']>[0];
465
+ export type WebpackExtendedResolveData = WebpackResolveData & {
466
+ createData: {
467
+ rawRequest: string;
468
+ request: string;
469
+ resource: string;
470
+ userRequest: string;
471
+ };
472
+ };
473
+ export interface HTMLWebpackPluginAssetTagGroupsData {
474
+ bodyTags: HtmlWebpackPlugin.HtmlTagObject[];
475
+ headTags: HtmlWebpackPlugin.HtmlTagObject[];
476
+ outputName: string;
477
+ plugin: HtmlWebpackPlugin;
478
+ }
479
+ export interface HTMLWebpackPluginBeforeEmitData {
480
+ html: string;
481
+ outputName: string;
482
+ plugin: HtmlWebpackPlugin;
483
+ }
@@ -0,0 +1,4 @@
1
+ import { WebpackConfiguration } from './type';
2
+ export declare const optionalRequire: <T = unknown>(id: string) => T | null;
3
+ export declare let webpackConfiguration: WebpackConfiguration;
4
+ export default webpackConfiguration;