weboptimizer 2.0.1439 → 2.0.1441

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;
package/index.js CHANGED
@@ -69,9 +69,10 @@ var main = function main(context) {
69
69
  return _regenerator["default"].wrap(function _callee2$(_context3) {
70
70
  while (1) switch (_context3.prev = _context3.next) {
71
71
  case 0:
72
+ if (environment.PATH && !environment.PATH.includes(':node_modules/.bin')) environment.PATH += ':node_modules/.bin';else environment.PATH = 'node_modules/.bin';
72
73
  configuration = (0, _configurator.load)(context, currentWorkingDirectory, commandLineArguments, webOptimizerPath, environment);
73
74
  clear = _clientnode["default"].noop();
74
- _context3.prev = 2;
75
+ _context3.prev = 3;
75
76
  // region controller
76
77
  processOptions = {
77
78
  cwd: configuration.path.context,
@@ -86,7 +87,7 @@ var main = function main(context) {
86
87
  possibleArguments = ['build', 'build:types', 'clear', 'document', 'lint', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report', 'check:types'];
87
88
  closeEventHandlers = [];
88
89
  if (!(configuration.givenCommandLineArguments.length > 2)) {
89
- _context3.next = 117;
90
+ _context3.next = 118;
90
91
  break;
91
92
  }
92
93
  // region temporary save dynamically given configurations
@@ -97,28 +98,28 @@ var main = function main(context) {
97
98
  if (configuration.givenCommandLineArguments.length > 3 && _clientnode["default"].stringParseEncodedObject(configuration.givenCommandLineArguments[configuration.givenCommandLineArguments.length - 1], configuration, 'configuration')) configuration.givenCommandLineArguments.pop();
98
99
  count = 0;
99
100
  filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
100
- case 14:
101
+ case 15:
101
102
  if (!true) {
102
- _context3.next = 23;
103
+ _context3.next = 24;
103
104
  break;
104
105
  }
105
106
  filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
106
- _context3.next = 18;
107
+ _context3.next = 19;
107
108
  return _clientnode["default"].isFile(filePath);
108
- case 18:
109
+ case 19:
109
110
  if (_context3.sent) {
110
- _context3.next = 20;
111
+ _context3.next = 21;
111
112
  break;
112
113
  }
113
- return _context3.abrupt("break", 23);
114
- case 20:
114
+ return _context3.abrupt("break", 24);
115
+ case 21:
115
116
  count += 1;
116
- _context3.next = 14;
117
+ _context3.next = 15;
117
118
  break;
118
- case 23:
119
- _context3.next = 25;
119
+ case 24:
120
+ _context3.next = 26;
120
121
  return (0, _promises.writeFile)(filePath, JSON.stringify(dynamicConfiguration));
121
- case 25:
122
+ case 26:
122
123
  additionalArguments = commandLineArguments.splice(3); /// region register exit handler to tidy up
123
124
  clear = function clear(error) {
124
125
  // NOTE: Close handler have to be synchronous.
@@ -137,14 +138,14 @@ var main = function main(context) {
137
138
  during pre-install phase.
138
139
  */
139
140
  if (!(!['build', 'build:types', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2]) && possibleArguments.includes(configuration.givenCommandLineArguments[2]))) {
140
- _context3.next = 66;
141
+ _context3.next = 67;
141
142
  break;
142
143
  }
143
144
  if (!((0, _path.resolve)(configuration.path.target.base) === (0, _path.resolve)(configuration.path.context))) {
144
- _context3.next = 56;
145
+ _context3.next = 57;
145
146
  break;
146
147
  }
147
- _context3.next = 32;
148
+ _context3.next = 33;
148
149
  return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, /*#__PURE__*/function () {
149
150
  var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
150
151
  var type, _file$stats;
@@ -198,60 +199,60 @@ var main = function main(context) {
198
199
  return _ref2.apply(this, arguments);
199
200
  };
200
201
  }());
201
- case 32:
202
+ case 33:
202
203
  _context3.t0 = _createForOfIteratorHelper;
203
- _context3.next = 35;
204
+ _context3.next = 36;
204
205
  return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, function () {
205
206
  return false;
206
207
  }, configuration.encoding);
207
- case 35:
208
+ case 36:
208
209
  _context3.t1 = _context3.sent;
209
210
  _iterator = (0, _context3.t0)(_context3.t1);
210
- _context3.prev = 37;
211
+ _context3.prev = 38;
211
212
  _iterator.s();
212
- case 39:
213
+ case 40:
213
214
  if ((_step = _iterator.n()).done) {
214
- _context3.next = 46;
215
+ _context3.next = 47;
215
216
  break;
216
217
  }
217
218
  file = _step.value;
218
219
  if (!file.name.startsWith('npm-debug')) {
219
- _context3.next = 44;
220
+ _context3.next = 45;
220
221
  break;
221
222
  }
222
- _context3.next = 44;
223
+ _context3.next = 45;
223
224
  return (0, _promises.unlink)(file.path);
224
- case 44:
225
- _context3.next = 39;
225
+ case 45:
226
+ _context3.next = 40;
226
227
  break;
227
- case 46:
228
- _context3.next = 51;
228
+ case 47:
229
+ _context3.next = 52;
229
230
  break;
230
- case 48:
231
- _context3.prev = 48;
232
- _context3.t2 = _context3["catch"](37);
231
+ case 49:
232
+ _context3.prev = 49;
233
+ _context3.t2 = _context3["catch"](38);
233
234
  _iterator.e(_context3.t2);
234
- case 51:
235
- _context3.prev = 51;
235
+ case 52:
236
+ _context3.prev = 52;
236
237
  _iterator.f();
237
- return _context3.finish(51);
238
- case 54:
239
- _context3.next = 58;
238
+ return _context3.finish(52);
239
+ case 55:
240
+ _context3.next = 59;
240
241
  break;
241
- case 56:
242
- _context3.next = 58;
242
+ case 57:
243
+ _context3.next = 59;
243
244
  return (0, _rimraf.rimraf)(configuration.path.target.base);
244
- case 58:
245
- _context3.next = 60;
245
+ case 59:
246
+ _context3.next = 61;
246
247
  return _clientnode["default"].isDirectory(configuration.path.apiDocumentation);
247
- case 60:
248
+ case 61:
248
249
  if (!_context3.sent) {
249
- _context3.next = 63;
250
+ _context3.next = 64;
250
251
  break;
251
252
  }
252
- _context3.next = 63;
253
+ _context3.next = 64;
253
254
  return (0, _rimraf.rimraf)(configuration.path.apiDocumentation);
254
- case 63:
255
+ case 64:
255
256
  _iterator2 = _createForOfIteratorHelper(configuration.path.tidyUpOnClear);
256
257
  try {
257
258
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -266,7 +267,7 @@ var main = function main(context) {
266
267
  _iterator2.f();
267
268
  }
268
269
  (0, _rimraf.sync)((0, _globAll.sync)(configuration.path.tidyUpOnClearGlobs));
269
- case 66:
270
+ case 67:
270
271
  // endregion
271
272
  // region handle build
272
273
  buildConfigurations = _helper["default"].resolveBuildConfigurationFilePaths(configuration.buildContext.types, configuration.path.source.asset.base, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
@@ -275,7 +276,7 @@ var main = function main(context) {
275
276
  return !configuration.path.context.startsWith(filePath);
276
277
  }), configuration["package"].main.fileNames);
277
278
  if (!['build', 'document', 'test', 'test:coverage', 'test:coverage:report'].includes(commandLineArguments[2])) {
278
- _context3.next = 74;
279
+ _context3.next = 75;
279
280
  break;
280
281
  }
281
282
  tidiedUp = false;
@@ -389,11 +390,11 @@ var main = function main(context) {
389
390
  }));
390
391
  // endregion
391
392
  // region handle pre-install
392
- _context3.next = 109;
393
+ _context3.next = 110;
393
394
  break;
394
- case 74:
395
+ case 75:
395
396
  if (!(configuration.library && configuration.givenCommandLineArguments[2] === 'preinstall')) {
396
- _context3.next = 109;
397
+ _context3.next = 110;
397
398
  break;
398
399
  }
399
400
  // Perform all file specific preprocessing stuff.
@@ -402,17 +403,17 @@ var main = function main(context) {
402
403
  file: configuration.extensions.file.internal
403
404
  }, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore).filePaths;
404
405
  _iterator7 = _createForOfIteratorHelper(buildConfigurations);
405
- _context3.prev = 78;
406
+ _context3.prev = 79;
406
407
  _iterator7.s();
407
- case 80:
408
+ case 81:
408
409
  if ((_step7 = _iterator7.n()).done) {
409
- _context3.next = 101;
410
+ _context3.next = 102;
410
411
  break;
411
412
  }
412
413
  buildConfiguration = _step7.value;
413
414
  expression = buildConfiguration[configuration.givenCommandLineArguments[2]].trim();
414
415
  _iterator8 = _createForOfIteratorHelper(buildConfiguration.filePaths);
415
- _context3.prev = 84;
416
+ _context3.prev = 85;
416
417
  _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
417
418
  var filePath, evaluated;
418
419
  return _regenerator["default"].wrap(function _loop$(_context2) {
@@ -455,41 +456,41 @@ var main = function main(context) {
455
456
  }, _loop);
456
457
  });
457
458
  _iterator8.s();
458
- case 87:
459
+ case 88:
459
460
  if ((_step8 = _iterator8.n()).done) {
460
- _context3.next = 91;
461
+ _context3.next = 92;
461
462
  break;
462
463
  }
463
- return _context3.delegateYield(_loop(), "t3", 89);
464
- case 89:
465
- _context3.next = 87;
464
+ return _context3.delegateYield(_loop(), "t3", 90);
465
+ case 90:
466
+ _context3.next = 88;
466
467
  break;
467
- case 91:
468
- _context3.next = 96;
468
+ case 92:
469
+ _context3.next = 97;
469
470
  break;
470
- case 93:
471
- _context3.prev = 93;
472
- _context3.t4 = _context3["catch"](84);
471
+ case 94:
472
+ _context3.prev = 94;
473
+ _context3.t4 = _context3["catch"](85);
473
474
  _iterator8.e(_context3.t4);
474
- case 96:
475
- _context3.prev = 96;
475
+ case 97:
476
+ _context3.prev = 97;
476
477
  _iterator8.f();
477
- return _context3.finish(96);
478
- case 99:
479
- _context3.next = 80;
478
+ return _context3.finish(97);
479
+ case 100:
480
+ _context3.next = 81;
480
481
  break;
481
- case 101:
482
- _context3.next = 106;
482
+ case 102:
483
+ _context3.next = 107;
483
484
  break;
484
- case 103:
485
- _context3.prev = 103;
486
- _context3.t5 = _context3["catch"](78);
485
+ case 104:
486
+ _context3.prev = 104;
487
+ _context3.t5 = _context3["catch"](79);
487
488
  _iterator7.e(_context3.t5);
488
- case 106:
489
- _context3.prev = 106;
489
+ case 107:
490
+ _context3.prev = 107;
490
491
  _iterator7.f();
491
- return _context3.finish(106);
492
- case 109:
492
+ return _context3.finish(107);
493
+ case 110:
493
494
  // endregion
494
495
  // region handle remaining tasks
495
496
  handleTask = function handleTask(type) {
@@ -536,18 +537,18 @@ var main = function main(context) {
536
537
  }
537
538
  }; /// region a-/synchronous
538
539
  if (!['document', 'test', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2])) {
539
- _context3.next = 116;
540
+ _context3.next = 117;
540
541
  break;
541
542
  }
542
- _context3.next = 113;
543
+ _context3.next = 114;
543
544
  return Promise.all(processPromises);
544
- case 113:
545
+ case 114:
545
546
  handleTask(configuration.givenCommandLineArguments[2]);
546
- _context3.next = 117;
547
+ _context3.next = 118;
547
548
  break;
548
- case 116:
549
- if (['build:types', 'check:types', 'lint', 'serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) handleTask(configuration.givenCommandLineArguments[2]);
550
549
  case 117:
550
+ if (['build:types', 'check:types', 'lint', 'serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) handleTask(configuration.givenCommandLineArguments[2]);
551
+ case 118:
551
552
  finished = false;
552
553
  closeHandler = function closeHandler() {
553
554
  if (!finished) for (var _i2 = 0, _closeEventHandlers = closeEventHandlers; _i2 < _closeEventHandlers.length; _i2++) {
@@ -570,37 +571,37 @@ var main = function main(context) {
570
571
  if (require.main === module && (configuration.givenCommandLineArguments.length < 3 || !possibleArguments.includes(configuration.givenCommandLineArguments[2]))) console.info("Give one of \"".concat(possibleArguments.join('", "'), "\" as command ") + 'line argument. You can provide a json string as second ' + 'parameter to dynamically overwrite some configurations.\n');
571
572
  // endregion
572
573
  // region forward nested return codes
573
- _context3.prev = 122;
574
- _context3.next = 125;
574
+ _context3.prev = 123;
575
+ _context3.next = 126;
575
576
  return Promise.all(processPromises);
576
- case 125:
577
- _context3.next = 131;
577
+ case 126:
578
+ _context3.next = 132;
578
579
  break;
579
- case 127:
580
- _context3.prev = 127;
581
- _context3.t6 = _context3["catch"](122);
580
+ case 128:
581
+ _context3.prev = 128;
582
+ _context3.t6 = _context3["catch"](123);
582
583
  console.error(_context3.t6);
583
584
  process.exit(_context3.t6.returnCode);
584
- case 131:
585
- _context3.next = 140;
585
+ case 132:
586
+ _context3.next = 141;
586
587
  break;
587
- case 133:
588
- _context3.prev = 133;
589
- _context3.t7 = _context3["catch"](2);
588
+ case 134:
589
+ _context3.prev = 134;
590
+ _context3.t7 = _context3["catch"](3);
590
591
  if (!configuration.debug) {
591
- _context3.next = 139;
592
+ _context3.next = 140;
592
593
  break;
593
594
  }
594
595
  throw _context3.t7;
595
- case 139:
596
- console.error(_context3.t7);
597
596
  case 140:
598
- return _context3.abrupt("return", clear);
597
+ console.error(_context3.t7);
599
598
  case 141:
599
+ return _context3.abrupt("return", clear);
600
+ case 142:
600
601
  case "end":
601
602
  return _context3.stop();
602
603
  }
603
- }, _callee2, null, [[2, 133], [37, 48, 51, 54], [78, 103, 106, 109], [84, 93, 96, 99], [122, 127]]);
604
+ }, _callee2, null, [[3, 134], [38, 49, 52, 55], [79, 104, 107, 110], [85, 94, 97, 100], [123, 128]]);
604
605
  }))();
605
606
  } catch (e) {
606
607
  return Promise.reject(e);
@@ -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.1439",
3
+ "version": "2.0.1441",
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'",
@@ -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;