weboptimizer 2.0.1110 → 2.0.1114

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