weboptimizer 2.0.1108 → 2.0.1112

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/configurator.js CHANGED
@@ -24,7 +24,7 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.resolvedConfiguration = exports["default"] = void 0;
27
+ exports.loadedConfiguration = exports.load = exports.get = exports["default"] = void 0;
28
28
 
29
29
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
30
30
 
@@ -40,8 +40,6 @@ var _package = require("./package.json");
40
40
 
41
41
  var _type4 = require("./type");
42
42
 
43
- var _specificConfiguratio;
44
-
45
43
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
46
44
 
47
45
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -52,343 +50,394 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
52
50
 
53
51
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
54
52
 
55
- /*
56
- To assume to go two folder up from this file until there is no
57
- "node_modules" parent folder is usually resilient again dealing with
58
- projects where current working directory isn't the projects directory and
59
- this library is located as a nested dependency.
60
- */
61
- _package.configuration["default"].path.context = __dirname;
62
-
63
- while (true) {
64
- _package.configuration["default"].path.context = (0, _path.resolve)(_package.configuration["default"].path.context, '../../');
65
- if ((0, _path.basename)((0, _path.dirname)(_package.configuration["default"].path.context)) !== 'node_modules') break;
66
- }
67
-
68
- if ((0, _path.basename)((0, _path.dirname)(process.cwd())) === 'node_modules' || (0, _path.basename)((0, _path.dirname)(process.cwd())) === '.staging' && (0, _path.basename)((0, _path.dirname)((0, _path.dirname)(process.cwd()))) === 'node_modules') {
69
- /*
70
- NOTE: If we are dealing was a dependency project use current directory
71
- as context.
72
- */
73
- _package.configuration["default"].path.context = process.cwd();
74
- _package.configuration["default"].contextType = 'dependency';
75
- } else
76
- /*
77
- NOTE: If the current working directory references this file via a
78
- linked "node_modules" folder using current working directory as context
79
- is a better assumption than two folders up the hierarchy.
80
- */
81
- try {
82
- if ((0, _fs.lstatSync)((0, _path.join)(process.cwd(), 'node_modules')).isSymbolicLink()) _package.configuration["default"].path.context = process.cwd();
83
- } catch (error) {// continue regardless of error
84
- }
85
-
86
- var specificConfiguration = {};
87
-
88
- try {
89
- /* eslint-disable no-eval */
90
- specificConfiguration = eval('require')((0, _path.join)(_package.configuration["default"].path.context, 'package'));
91
- /* eslint-enable no-eval */
92
- } catch (error) {
93
- _package.configuration["default"].path.context = process.cwd();
94
- }
95
-
96
- var name = typeof specificConfiguration.name === 'string' ? specificConfiguration.name : 'mockup';
97
- specificConfiguration = specificConfiguration.webOptimizer || {};
98
- specificConfiguration.name = name; // endregion
99
- // region determine debug mode
100
- // NOTE: Given node command line arguments results in "npm_config_*"
101
- // environment variables.
102
-
103
- var debug = _package.configuration["default"].debug;
104
- if (typeof specificConfiguration.debug === 'boolean') debug = specificConfiguration.debug;else if (process.env.npm_config_dev === 'true' || typeof process.env.NODE_ENV === 'string' && ['debug', 'dev', 'development'].includes(process.env.NODE_ENV)) debug = true;
105
- if (debug) // NOTE: We have to avoid that some pre-processor removes this assignment.
106
- eval("process.env.NODE_ENV = 'development'"); // endregion
107
- // region loading default configuration
108
-
109
- _package.configuration["default"].path.context += '/'; // Merges final default configuration object depending on given target
110
- // environment.
111
-
112
- var libraryConfiguration = _package.configuration.library;
113
- var configuration;
114
- if (debug) configuration = _clientnode["default"].extend(true, _clientnode["default"].modifyObject(_package.configuration["default"], _package.configuration.debug), _package.configuration.debug);else configuration = _package.configuration["default"];
115
- configuration.debug = debug;
116
- if ((0, _typeof2["default"])(configuration.library) === 'object') _clientnode["default"].extend(true, _clientnode["default"].modifyObject(libraryConfiguration, configuration.library), configuration.library);
117
- if (configuration.library && ((_specificConfiguratio = specificConfiguration) === null || _specificConfiguratio === void 0 ? void 0 : _specificConfiguratio.library) !== false) configuration = _clientnode["default"].extend(true, _clientnode["default"].modifyObject(configuration, libraryConfiguration), libraryConfiguration); // endregion
118
- // region merging and evaluating task specific and dynamic configurations
119
- // / region load additional dynamically given configuration
120
-
121
- var count = 0;
122
- var filePath = null;
123
-
124
- while (true) {
125
- var newFilePath = "".concat(configuration.path.context, ".dynamicConfiguration-").concat(count, ".json");
126
- if (!_clientnode["default"].isFileSync(newFilePath)) break;
127
- filePath = newFilePath;
128
- count += 1;
129
- }
130
-
131
- var runtimeInformation = {
132
- givenCommandLineArguments: process.argv
133
- };
134
-
135
- if (filePath) {
136
- runtimeInformation = JSON.parse((0, _fs.readFileSync)(filePath, {
137
- encoding: configuration.encoding
138
- }));
139
- (0, _fs.unlink)(filePath, function (error) {
140
- if (error) throw error;
141
- });
142
- } // // region task specific configuration
143
- // /// region apply task type specific configuration
144
-
145
-
146
- if (runtimeInformation.givenCommandLineArguments.length > 2) {
147
- var _iterator = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
148
- _step;
149
-
150
- try {
151
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
152
- var type = _step.value;
153
- if (runtimeInformation.givenCommandLineArguments[2] === type || debug && type === 'debug' || type === 'test' && runtimeInformation.givenCommandLineArguments[2].startsWith('test:') && runtimeInformation.givenCommandLineArguments[2] !== 'test:browser') for (var _i = 0, _arr = [configuration, specificConfiguration]; _i < _arr.length; _i++) {
154
- var configurationTarget = _arr[_i];
155
- if (_clientnode["default"].isPlainObject(configurationTarget[type])) _clientnode["default"].extend(true, _clientnode["default"].modifyObject(configurationTarget, configurationTarget[type]), configurationTarget[type]);
53
+ // endregion
54
+ var loadedConfiguration = null;
55
+ /**
56
+ * Main entry point to determine current configuration.
57
+ * @param context - Location from where to build current application.
58
+ * @param currentWorkingDirectory - Current working directory to use as
59
+ * reference.
60
+ * @param commandLineArguments - Arguments to take into account.
61
+ * @param webOptimizerPath - Current optimizer context path.
62
+ * @param environment - Environment variables to take into account.
63
+ *
64
+ * @returns Nothing.
65
+ */
66
+
67
+ exports.loadedConfiguration = loadedConfiguration;
68
+
69
+ var load = function load(context) {
70
+ var currentWorkingDirectory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : process.cwd();
71
+ var commandLineArguments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : process.argv;
72
+ var webOptimizerPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : __dirname;
73
+ var environment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : eval('process.env');
74
+ return function () {
75
+ var _specificConfiguratio;
76
+
77
+ // region determine application context location
78
+ if (context) _package.configuration["default"].path.context = context;else {
79
+ /*
80
+ To assume to go two folder up from this file until there is no
81
+ "node_modules" parent folder is usually resilient again dealing
82
+ with projects where current working directory isn't the projects
83
+ directory and this library is located as a nested dependency.
84
+ */
85
+ _package.configuration["default"].path.context = webOptimizerPath;
86
+
87
+ while (true) {
88
+ _package.configuration["default"].path.context = (0, _path.resolve)(_package.configuration["default"].path.context, '../../');
89
+ if ((0, _path.basename)((0, _path.dirname)(_package.configuration["default"].path.context)) !== 'node_modules') break;
156
90
  }
157
- }
158
- } catch (err) {
159
- _iterator.e(err);
160
- } finally {
161
- _iterator.f();
162
- }
163
- } // /// endregion
164
- // /// region clear task type specific configurations
165
-
166
91
 
167
- var _iterator2 = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
168
- _step2;
92
+ if ((0, _path.basename)((0, _path.dirname)(currentWorkingDirectory)) === 'node_modules' || (0, _path.basename)((0, _path.dirname)(currentWorkingDirectory)) === '.staging' && (0, _path.basename)((0, _path.dirname)((0, _path.dirname)(currentWorkingDirectory))) === 'node_modules') {
93
+ /*
94
+ NOTE: If we are dealing was a dependency project use current
95
+ directory as context.
96
+ */
97
+ _package.configuration["default"].path.context = currentWorkingDirectory;
98
+ _package.configuration["default"].contextType = 'dependency';
99
+ } else
100
+ /*
101
+ NOTE: If the current working directory references this file via
102
+ a linked "node_modules" folder using current working directory
103
+ as context is a better assumption than two folders up the
104
+ hierarchy.
105
+ */
106
+ try {
107
+ if ((0, _fs.lstatSync)((0, _path.join)(currentWorkingDirectory, 'node_modules')).isSymbolicLink()) _package.configuration["default"].path.context = currentWorkingDirectory;
108
+ } catch (error) {// Continue regardless of error.
109
+ }
110
+ } // endregion
111
+ // region load application specific configuration
169
112
 
170
- try {
171
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
172
- var _type3 = _step2.value;
113
+ var specificConfiguration = {};
173
114
 
174
- for (var _i2 = 0, _arr2 = [configuration, specificConfiguration]; _i2 < _arr2.length; _i2++) {
175
- var _configurationTarget = _arr2[_i2];
176
- if (Object.prototype.hasOwnProperty.call(_configurationTarget, _type3) && (0, _typeof2["default"])(_configurationTarget[_type3]) === 'object') delete _configurationTarget[_type3];
115
+ try {
116
+ specificConfiguration = (0, _clientnode.currentRequire)((0, _path.join)(_package.configuration["default"].path.context, 'package'));
117
+ } catch (error) {
118
+ _package.configuration["default"].path.context = currentWorkingDirectory;
177
119
  }
178
- } // /// endregion
179
- // // endregion
180
- // / endregion
181
120
 
182
- } catch (err) {
183
- _iterator2.e(err);
184
- } finally {
185
- _iterator2.f();
186
- }
187
-
188
- _clientnode["default"].extend(true, _clientnode["default"].modifyObject(_clientnode["default"].modifyObject(configuration, specificConfiguration), runtimeInformation), specificConfiguration, runtimeInformation);
121
+ specificConfiguration = specificConfiguration.webOptimizer || {}; // endregion
122
+ // region determine application name
123
+
124
+ var name = typeof specificConfiguration.name === 'string' ? specificConfiguration.name : 'mockup';
125
+ specificConfiguration.name = name; // endregion
126
+ // region determine debug mode
127
+ // NOTE: Given node command line arguments results in "npm_config_*"
128
+ // environment variables.
129
+
130
+ var debug = _package.configuration["default"].debug;
131
+ if (typeof specificConfiguration.debug === 'boolean') debug = specificConfiguration.debug;else if (environment.npm_config_dev === 'true' || typeof environment.NODE_ENV === 'string' && ['debug', 'dev', 'development'].includes(environment.NODE_ENV)) debug = true;
132
+ if (debug) environment.NODE_ENV = 'development'; // endregion
133
+ // region loading default configuration
134
+
135
+ _package.configuration["default"].path.context += '/'; // Merges final default configuration object depending on given target
136
+ // environment.
137
+
138
+ var libraryConfiguration = _package.configuration.library;
139
+ var configuration;
140
+ if (debug) configuration = _clientnode["default"].extend(true, _clientnode["default"].modifyObject(_package.configuration["default"], _package.configuration.debug), _package.configuration.debug);else configuration = _package.configuration["default"];
141
+ configuration.debug = debug;
142
+ if ((0, _typeof2["default"])(configuration.library) === 'object') _clientnode["default"].extend(true, _clientnode["default"].modifyObject(libraryConfiguration, configuration.library), configuration.library);
143
+ if (configuration.library && ((_specificConfiguratio = specificConfiguration) === null || _specificConfiguratio === void 0 ? void 0 : _specificConfiguratio.library) !== false) configuration = _clientnode["default"].extend(true, _clientnode["default"].modifyObject(configuration, libraryConfiguration), libraryConfiguration); // endregion
144
+ // region merging and evaluating task specific and dynamic configurations
145
+ // / region load additional dynamically given configuration
146
+
147
+ var count = 0;
148
+ var filePath = null;
149
+
150
+ while (true) {
151
+ var newFilePath = "".concat(configuration.path.context, ".dynamicConfiguration-").concat(count, ".json");
152
+ if (!_clientnode["default"].isFileSync(newFilePath)) break;
153
+ filePath = newFilePath;
154
+ count += 1;
155
+ }
189
156
 
190
- var result = null;
191
- if (runtimeInformation.givenCommandLineArguments.length > 3) result = _clientnode["default"].stringParseEncodedObject(runtimeInformation.givenCommandLineArguments[runtimeInformation.givenCommandLineArguments.length - 1], configuration, 'configuration');
157
+ var runtimeInformation = {
158
+ givenCommandLineArguments: commandLineArguments
159
+ };
160
+
161
+ if (filePath) {
162
+ runtimeInformation = JSON.parse((0, _fs.readFileSync)(filePath, {
163
+ encoding: configuration.encoding
164
+ }));
165
+ (0, _fs.unlink)(filePath, function (error) {
166
+ if (error) throw error;
167
+ });
168
+ } // // region task specific configuration
169
+ // /// region apply task type specific configuration
170
+
171
+
172
+ if (runtimeInformation.givenCommandLineArguments.length > 2) {
173
+ var _iterator = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
174
+ _step;
175
+
176
+ try {
177
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
178
+ var type = _step.value;
179
+ if (runtimeInformation.givenCommandLineArguments[2] === type || debug && type === 'debug' || type === 'test' && runtimeInformation.givenCommandLineArguments[2].startsWith('test:') && runtimeInformation.givenCommandLineArguments[2] !== 'test:browser') for (var _i = 0, _arr = [configuration, specificConfiguration]; _i < _arr.length; _i++) {
180
+ var configurationTarget = _arr[_i];
181
+ if (_clientnode["default"].isPlainObject(configurationTarget[type])) _clientnode["default"].extend(true, _clientnode["default"].modifyObject(configurationTarget, configurationTarget[type]), configurationTarget[type]);
182
+ }
183
+ }
184
+ } catch (err) {
185
+ _iterator.e(err);
186
+ } finally {
187
+ _iterator.f();
188
+ }
189
+ } // /// endregion
190
+ // /// region clear task type specific configurations
192
191
 
193
- if (result !== null && (0, _typeof2["default"])(result) === 'object') {
194
- if (Object.prototype.hasOwnProperty.call(result, '__reference__')) {
195
- var referenceNames = [].concat(result.__reference__);
196
- delete result.__reference__;
197
192
 
198
- var _iterator3 = _createForOfIteratorHelper(referenceNames),
199
- _step3;
193
+ var _iterator2 = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
194
+ _step2;
200
195
 
201
196
  try {
202
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
203
- var _name = _step3.value;
197
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
198
+ var _type3 = _step2.value;
199
+
200
+ for (var _i2 = 0, _arr2 = [configuration, specificConfiguration]; _i2 < _arr2.length; _i2++) {
201
+ var _configurationTarget = _arr2[_i2];
202
+ if (Object.prototype.hasOwnProperty.call(_configurationTarget, _type3) && (0, _typeof2["default"])(_configurationTarget[_type3]) === 'object') delete _configurationTarget[_type3];
203
+ }
204
+ } // /// endregion
205
+ // // endregion
206
+ // / endregion
204
207
 
205
- _clientnode["default"].extend(true, result, configuration[_name]);
206
- }
207
208
  } catch (err) {
208
- _iterator3.e(err);
209
+ _iterator2.e(err);
209
210
  } finally {
210
- _iterator3.f();
211
+ _iterator2.f();
211
212
  }
212
- }
213
213
 
214
- _clientnode["default"].extend(true, _clientnode["default"].modifyObject(configuration, result), result);
215
- } // Removing comments (default key name to delete is "#").
214
+ _clientnode["default"].extend(true, _clientnode["default"].modifyObject(_clientnode["default"].modifyObject(configuration, specificConfiguration), runtimeInformation), specificConfiguration, runtimeInformation);
216
215
 
216
+ var result = null;
217
+ if (runtimeInformation.givenCommandLineArguments.length > 3) result = _clientnode["default"].stringParseEncodedObject(runtimeInformation.givenCommandLineArguments[runtimeInformation.givenCommandLineArguments.length - 1], configuration, 'configuration');
217
218
 
218
- configuration = _clientnode["default"].removeKeyPrefixes(configuration); // endregion
219
- // / region build absolute paths
219
+ if (result !== null && (0, _typeof2["default"])(result) === 'object') {
220
+ if (Object.prototype.hasOwnProperty.call(result, '__reference__')) {
221
+ var referenceNames = [].concat(result.__reference__);
222
+ delete result.__reference__;
220
223
 
221
- configuration.path.base = (0, _path.resolve)(configuration.path.context, configuration.path.base);
224
+ var _iterator3 = _createForOfIteratorHelper(referenceNames),
225
+ _step3;
222
226
 
223
- for (var key in configuration.path) {
224
- if (Object.prototype.hasOwnProperty.call(configuration.path, key) && !['base', 'configuration'].includes(key)) if (typeof configuration.path[key] === 'string') configuration.path[key] = (0, _path.resolve)(configuration.path.base, configuration.path[key]) + '/';else if (_clientnode["default"].isPlainObject(configuration.path[key])) {
225
- if (Object.prototype.hasOwnProperty.call(configuration.path[key], 'base')) configuration.path[key].base = (0, _path.resolve)(configuration.path.base, configuration.path[key].base);
227
+ try {
228
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
229
+ var _name = _step3.value;
226
230
 
227
- for (var subKey in configuration.path[key]) {
228
- if (Object.prototype.hasOwnProperty.call(configuration.path[key], subKey) && !['base', 'public'].includes(subKey) && typeof configuration.path[key][subKey] === 'string') configuration.path[key][subKey] = (0, _path.resolve)(configuration.path[key].base, configuration.path[key][subKey]) + '/';else if (subKey !== 'options' && _clientnode["default"].isPlainObject(configuration.path[key][subKey])) {
229
- configuration.path[key][subKey].base = (0, _path.resolve)(configuration.path[key].base, configuration.path[key][subKey].base);
230
-
231
- for (var subSubKey in configuration.path[key][subKey]) {
232
- if (Object.prototype.hasOwnProperty.call(configuration.path[key][subKey], subSubKey) && subSubKey !== 'base' && typeof configuration.path[key][subKey][subSubKey] === 'string') configuration.path[key][subKey][subSubKey] = (0, _path.resolve)(configuration.path[key][subKey].base, configuration.path[key][subKey][subSubKey]) + '/';
231
+ _clientnode["default"].extend(true, result, configuration[_name]);
232
+ }
233
+ } catch (err) {
234
+ _iterator3.e(err);
235
+ } finally {
236
+ _iterator3.f();
233
237
  }
234
238
  }
235
- }
236
- }
237
- } // / endregion
238
239
 
240
+ _clientnode["default"].extend(true, _clientnode["default"].modifyObject(configuration, result), result);
241
+ } // Removing comments (default key name to delete is "#").
239
242
 
240
- var now = new Date();
241
- /*
242
- NOTE: The configuration is not yet fully resolved but will be transformed
243
- in place in the following lines of code.
244
- */
245
243
 
246
- var resolvedConfiguration = _clientnode["default"].evaluateDynamicData(configuration, {
247
- currentPath: process.cwd(),
248
- fileSystem: _fs["default"],
249
- Helper: _helper["default"],
250
- optionalRequire: _clientnode.optionalRequire,
251
- path: _path["default"],
252
- require: _clientnode.currentRequire,
253
- Tools: _clientnode["default"],
254
- webOptimizerPath: __dirname,
255
- now: now,
256
- nowUTCTimestamp: _clientnode["default"].numberGetUTCTimestamp(now)
257
- }); // region consolidate file specific build configuration
258
- // Apply default file level build configurations to all file type specific
259
- // ones.
260
-
261
-
262
- exports.resolvedConfiguration = resolvedConfiguration;
263
- var defaultConfiguration = resolvedConfiguration.buildContext.types["default"];
264
- delete resolvedConfiguration.buildContext.types["default"];
265
-
266
- for (var _type in resolvedConfiguration.buildContext.types) {
267
- if (Object.prototype.hasOwnProperty.call(resolvedConfiguration.buildContext.types, _type)) resolvedConfiguration.buildContext.types[_type] = _clientnode["default"].extend(true, _clientnode["default"].copy(defaultConfiguration), _clientnode["default"].extend(true, {
268
- extension: _type
269
- }, resolvedConfiguration.buildContext.types[_type], {
270
- type: _type
271
- }));
272
- } // endregion
273
- // region resolve module location and determine which asset types are needed
274
-
275
-
276
- resolvedConfiguration.module.locations = _helper["default"].determineModuleLocations(resolvedConfiguration.injection.entry.normalized, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
277
- file: resolvedConfiguration.extensions.file.internal
278
- }, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base);
279
- resolvedConfiguration.injection = _helper["default"].resolveAutoInjection(resolvedConfiguration.injection, _helper["default"].resolveBuildConfigurationFilePaths(resolvedConfiguration.buildContext.types, resolvedConfiguration.path.source.asset.base, _helper["default"].normalizePaths(resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
280
- return (0, _path.resolve)(resolvedConfiguration.path.context, filePath);
281
- }).filter(function (filePath) {
282
- return !resolvedConfiguration.path.context.startsWith(filePath);
283
- })), resolvedConfiguration["package"].main.fileNames), resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, resolvedConfiguration.extensions, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base, resolvedConfiguration.path.ignore);
284
- var givenInjection = resolvedConfiguration.injection.entry;
285
- resolvedConfiguration.injection.entry = {
286
- given: givenInjection,
287
- normalized: _helper["default"].resolveModulesInFolders(_helper["default"].normalizeGivenInjection(givenInjection), resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base, resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
288
- return (0, _path.resolve)(resolvedConfiguration.path.context, filePath);
289
- }).filter(function (filePath) {
290
- return !resolvedConfiguration.path.context.startsWith(filePath);
291
- }))
292
- };
293
- resolvedConfiguration.needed = {
294
- javaScript: configuration.debug && ['serve', 'test:browser'].includes(resolvedConfiguration.givenCommandLineArguments[2])
295
- };
244
+ configuration = _clientnode["default"].removeKeyPrefixes(configuration); // endregion
245
+ // / region build absolute paths
296
246
 
297
- for (var chunkName in resolvedConfiguration.injection.entry.normalized) {
298
- if (Object.prototype.hasOwnProperty.call(resolvedConfiguration.injection.entry.normalized, chunkName)) {
299
- var _iterator4 = _createForOfIteratorHelper(resolvedConfiguration.injection.entry.normalized[chunkName]),
300
- _step4;
247
+ configuration.path.base = (0, _path.resolve)(configuration.path.context, configuration.path.base);
301
248
 
302
- try {
303
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
304
- var moduleID = _step4.value;
249
+ for (var key in configuration.path) {
250
+ if (Object.prototype.hasOwnProperty.call(configuration.path, key) && !['base', 'configuration'].includes(key)) if (typeof configuration.path[key] === 'string') configuration.path[key] = (0, _path.resolve)(configuration.path.base, configuration.path[key]) + '/';else if (_clientnode["default"].isPlainObject(configuration.path[key])) {
251
+ if (Object.prototype.hasOwnProperty.call(configuration.path[key], 'base')) configuration.path[key].base = (0, _path.resolve)(configuration.path.base, configuration.path[key].base);
305
252
 
306
- var _filePath = _helper["default"].determineModuleFilePath(moduleID, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
307
- file: resolvedConfiguration.extensions.file.internal
308
- }, resolvedConfiguration.path.context,
309
- /*
310
- NOTE: We doesn't use
311
- "resolvedConfiguration.path.source.asset.base" because we
312
- have already resolve all module ids.
313
- */
314
- './', resolvedConfiguration.path.ignore, resolvedConfiguration.module.directoryNames, resolvedConfiguration["package"].main.fileNames, resolvedConfiguration["package"].main.propertyNames, resolvedConfiguration["package"].aliasPropertyNames, resolvedConfiguration.encoding);
253
+ for (var subKey in configuration.path[key]) {
254
+ if (Object.prototype.hasOwnProperty.call(configuration.path[key], subKey) && !['base', 'public'].includes(subKey) && typeof configuration.path[key][subKey] === 'string') configuration.path[key][subKey] = (0, _path.resolve)(configuration.path[key].base, configuration.path[key][subKey]) + '/';else if (subKey !== 'options' && _clientnode["default"].isPlainObject(configuration.path[key][subKey])) {
255
+ configuration.path[key][subKey].base = (0, _path.resolve)(configuration.path[key].base, configuration.path[key][subKey].base);
315
256
 
316
- var _type2 = null;
317
- if (_filePath) _type2 = _helper["default"].determineAssetType(_filePath, resolvedConfiguration.buildContext.types, resolvedConfiguration.path);else throw new Error("Given request \"".concat(moduleID, "\" couldn't be resolved."));
318
- if (_type2) resolvedConfiguration.needed[_type2] = true;
257
+ for (var subSubKey in configuration.path[key][subKey]) {
258
+ if (Object.prototype.hasOwnProperty.call(configuration.path[key][subKey], subSubKey) && subSubKey !== 'base' && typeof configuration.path[key][subKey][subSubKey] === 'string') configuration.path[key][subKey][subSubKey] = (0, _path.resolve)(configuration.path[key][subKey].base, configuration.path[key][subKey][subSubKey]) + '/';
259
+ }
260
+ }
261
+ }
262
+ }
263
+ } // / endregion
264
+ // region evaluate dynamic configuration structures
265
+
266
+
267
+ var now = new Date();
268
+ /*
269
+ NOTE: The configuration is not yet fully resolved but will be
270
+ transformed in place in the following lines of code.
271
+ */
272
+
273
+ var resolvedConfiguration = _clientnode["default"].evaluateDynamicData(configuration, {
274
+ currentPath: currentWorkingDirectory,
275
+ fileSystem: _fs["default"],
276
+ Helper: _helper["default"],
277
+ optionalRequire: _clientnode.optionalRequire,
278
+ path: _path["default"],
279
+ require: _clientnode.currentRequire,
280
+ Tools: _clientnode["default"],
281
+ webOptimizerPath: webOptimizerPath,
282
+ now: now,
283
+ nowUTCTimestamp: _clientnode["default"].numberGetUTCTimestamp(now)
284
+ }); // endregion
285
+ // region consolidate file specific build configuration
286
+ // Apply default file level build configurations to all file type specific
287
+ // ones.
288
+
289
+
290
+ var defaultConfiguration = resolvedConfiguration.buildContext.types["default"];
291
+ delete resolvedConfiguration.buildContext.types["default"];
292
+
293
+ for (var _type in resolvedConfiguration.buildContext.types) {
294
+ if (Object.prototype.hasOwnProperty.call(resolvedConfiguration.buildContext.types, _type)) resolvedConfiguration.buildContext.types[_type] = _clientnode["default"].extend(true, _clientnode["default"].copy(defaultConfiguration), _clientnode["default"].extend(true, {
295
+ extension: _type
296
+ }, resolvedConfiguration.buildContext.types[_type], {
297
+ type: _type
298
+ }));
299
+ } // endregion
300
+ // region resolve module location and which asset types are needed
301
+
302
+
303
+ resolvedConfiguration.module.locations = _helper["default"].determineModuleLocations(resolvedConfiguration.injection.entry.normalized, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
304
+ file: resolvedConfiguration.extensions.file.internal
305
+ }, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base);
306
+ resolvedConfiguration.injection = _helper["default"].resolveAutoInjection(resolvedConfiguration.injection, _helper["default"].resolveBuildConfigurationFilePaths(resolvedConfiguration.buildContext.types, resolvedConfiguration.path.source.asset.base, _helper["default"].normalizePaths(resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
307
+ return (0, _path.resolve)(resolvedConfiguration.path.context, filePath);
308
+ }).filter(function (filePath) {
309
+ return !resolvedConfiguration.path.context.startsWith(filePath);
310
+ })), resolvedConfiguration["package"].main.fileNames), resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, resolvedConfiguration.extensions, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base, resolvedConfiguration.path.ignore);
311
+ var givenInjection = resolvedConfiguration.injection.entry;
312
+ resolvedConfiguration.injection.entry = {
313
+ given: givenInjection,
314
+ normalized: _helper["default"].resolveModulesInFolders(_helper["default"].normalizeGivenInjection(givenInjection), resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base, resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
315
+ return (0, _path.resolve)(resolvedConfiguration.path.context, filePath);
316
+ }).filter(function (filePath) {
317
+ return !resolvedConfiguration.path.context.startsWith(filePath);
318
+ }))
319
+ };
320
+ resolvedConfiguration.needed = {
321
+ javaScript: configuration.debug && ['serve', 'test:browser'].includes(resolvedConfiguration.givenCommandLineArguments[2])
322
+ }; // / region determine which asset types are needed
323
+
324
+ for (var chunkName in resolvedConfiguration.injection.entry.normalized) {
325
+ if (Object.prototype.hasOwnProperty.call(resolvedConfiguration.injection.entry.normalized, chunkName)) {
326
+ var _iterator4 = _createForOfIteratorHelper(resolvedConfiguration.injection.entry.normalized[chunkName]),
327
+ _step4;
328
+
329
+ try {
330
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
331
+ var moduleID = _step4.value;
332
+
333
+ var _filePath = _helper["default"].determineModuleFilePath(moduleID, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
334
+ file: resolvedConfiguration.extensions.file.internal
335
+ }, resolvedConfiguration.path.context,
336
+ /*
337
+ NOTE: We doesn't use
338
+ "resolvedConfiguration.path.source.asset.base" because
339
+ we already have resolved all module ids.
340
+ */
341
+ './', resolvedConfiguration.path.ignore, resolvedConfiguration.module.directoryNames, resolvedConfiguration["package"].main.fileNames, resolvedConfiguration["package"].main.propertyNames, resolvedConfiguration["package"].aliasPropertyNames, resolvedConfiguration.encoding);
342
+
343
+ var _type2 = null;
344
+ if (_filePath) _type2 = _helper["default"].determineAssetType(_filePath, resolvedConfiguration.buildContext.types, resolvedConfiguration.path);else throw new Error("Given request \"".concat(moduleID, "\" couldn't be resolved."));
345
+ if (_type2) resolvedConfiguration.needed[_type2] = true;
346
+ }
347
+ } catch (err) {
348
+ _iterator4.e(err);
349
+ } finally {
350
+ _iterator4.f();
351
+ }
352
+ }
353
+ } // / endregion
354
+ // endregion
355
+ // region adding special aliases
356
+
357
+ /*
358
+ NOTE: This alias couldn't be set in the "package.json" file since this
359
+ would result in an endless loop.
360
+ */
361
+
362
+
363
+ resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader = '';
364
+
365
+ var _iterator5 = _createForOfIteratorHelper(Array.isArray(resolvedConfiguration.files.defaultHTML.template.use) ? resolvedConfiguration.files.defaultHTML.template.use : [resolvedConfiguration.files.defaultHTML.template.use]),
366
+ _step5;
367
+
368
+ try {
369
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
370
+ var loader = _step5.value;
371
+ if (resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader) resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader += '!';
372
+ resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader += loader.loader;
373
+ if (loader.options) resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader += '?' + _clientnode["default"].convertCircularObjectToJSON(loader.options);
319
374
  }
320
375
  } catch (err) {
321
- _iterator4.e(err);
376
+ _iterator5.e(err);
322
377
  } finally {
323
- _iterator4.f();
378
+ _iterator5.f();
324
379
  }
325
- }
326
- } // endregion
327
- // region adding special aliases
328
- // NOTE: This alias couldn't be set in the "package.json" file since this would
329
- // result in an endless loop.
330
-
331
-
332
- resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader = '';
333
-
334
- var _iterator5 = _createForOfIteratorHelper(Array.isArray(resolvedConfiguration.files.defaultHTML.template.use) ? resolvedConfiguration.files.defaultHTML.template.use : [resolvedConfiguration.files.defaultHTML.template.use]),
335
- _step5;
336
-
337
- try {
338
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
339
- var loader = _step5.value;
340
- if (resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader) resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader += '!';
341
- resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader += loader.loader;
342
- if (loader.options) resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader += '?' + _clientnode["default"].convertCircularObjectToJSON(loader.options);
343
- }
344
- } catch (err) {
345
- _iterator5.e(err);
346
- } finally {
347
- _iterator5.f();
348
- }
349
-
350
- resolvedConfiguration.module.aliases.webOptimizerDefaultTemplateFilePath = resolvedConfiguration.files.defaultHTML.template.filePath; // endregion
351
- // region apply html webpack plugin workarounds
352
-
353
- /*
354
- NOTE: Provides a workaround to handle a bug with chained loader
355
- configurations.
356
- */
357
380
 
358
- var _iterator6 = _createForOfIteratorHelper(resolvedConfiguration.files.html),
359
- _step6;
381
+ resolvedConfiguration.module.aliases.webOptimizerDefaultTemplateFilePath = resolvedConfiguration.files.defaultHTML.template.filePath; // endregion
382
+ // region apply html webpack plugin workarounds
360
383
 
361
- try {
362
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
363
- var htmlConfiguration = _step6.value;
384
+ /*
385
+ NOTE: Provides a workaround to handle a bug with chained loader
386
+ configurations.
387
+ */
364
388
 
365
- _clientnode["default"].extend(true, htmlConfiguration, resolvedConfiguration.files.defaultHTML);
389
+ var _iterator6 = _createForOfIteratorHelper(resolvedConfiguration.files.html),
390
+ _step6;
366
391
 
367
- htmlConfiguration.template.request = htmlConfiguration.template.filePath;
392
+ try {
393
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
394
+ var htmlConfiguration = _step6.value;
395
+
396
+ _clientnode["default"].extend(true, htmlConfiguration, resolvedConfiguration.files.defaultHTML);
397
+
398
+ htmlConfiguration.template.request = htmlConfiguration.template.filePath;
368
399
 
369
- if (htmlConfiguration.template.filePath !== resolvedConfiguration.files.defaultHTML.template.filePath && htmlConfiguration.template.options) {
370
- var requestString = new String(htmlConfiguration.template.request + _clientnode["default"].convertCircularObjectToJSON(htmlConfiguration.template.options));
371
- /* eslint-disable @typescript-eslint/unbound-method */
400
+ if (htmlConfiguration.template.filePath !== resolvedConfiguration.files.defaultHTML.template.filePath && htmlConfiguration.template.options) {
401
+ var requestString = new String(htmlConfiguration.template.request + _clientnode["default"].convertCircularObjectToJSON(htmlConfiguration.template.options));
402
+ /* eslint-disable @typescript-eslint/unbound-method */
372
403
 
373
- requestString.replace = function (value) {
374
- return function () {
375
- return value;
376
- };
377
- }(htmlConfiguration.template.filePath);
378
- /* eslint-enable @typescript-eslint/unbound-method */
404
+ requestString.replace = function (value) {
405
+ return function () {
406
+ return value;
407
+ };
408
+ }(htmlConfiguration.template.filePath);
409
+ /* eslint-enable @typescript-eslint/unbound-method */
379
410
 
380
411
 
381
- htmlConfiguration.template.request = requestString;
412
+ htmlConfiguration.template.request = requestString;
413
+ }
414
+ } // endregion
415
+
416
+ } catch (err) {
417
+ _iterator6.e(err);
418
+ } finally {
419
+ _iterator6.f();
382
420
  }
383
- } // endregion
384
421
 
385
- } catch (err) {
386
- _iterator6.e(err);
387
- } finally {
388
- _iterator6.f();
389
- }
422
+ return resolvedConfiguration;
423
+ }();
424
+ };
425
+ /**
426
+ * Get cached or determined configuration object.
427
+ * @returns Nothing.
428
+ */
429
+
430
+
431
+ exports.load = load;
432
+
433
+ var get = function get() {
434
+ if (loadedConfiguration) return loadedConfiguration;
435
+ exports.loadedConfiguration = loadedConfiguration = load();
436
+ return loadedConfiguration;
437
+ };
390
438
 
391
- var _default = resolvedConfiguration; // region vim modline
439
+ exports.get = get;
440
+ var _default = get; // region vim modline
392
441
  // vim: set tabstop=4 shiftwidth=4 expandtab:
393
442
  // vim: foldmethod=marker foldmarker=region,endregion:
394
443
  // endregion