weboptimizer 2.0.1108 → 2.0.1109

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