weboptimizer 2.0.1109 → 2.0.1113
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.d.ts +21 -2
- package/configurator.js +329 -301
- package/ejsLoader.d.ts +2 -1
- package/ejsLoader.js +15 -7
- package/index.d.ts +8 -1
- package/index.js +641 -585
- package/package.json +7 -6
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.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
|
|
|
@@ -51,365 +51,393 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
51
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; }
|
|
52
52
|
|
|
53
53
|
// endregion
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_package.configuration["default"].path.context = process.cwd();
|
|
78
|
-
_package.configuration["default"].contextType = 'dependency';
|
|
79
|
-
} else
|
|
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 {
|
|
80
79
|
/*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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.
|
|
85
84
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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;
|
|
89
90
|
}
|
|
90
|
-
} // endregion
|
|
91
|
-
// region load application specific configuration
|
|
92
|
-
|
|
93
|
-
var specificConfiguration = {};
|
|
94
|
-
|
|
95
|
-
try {
|
|
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();
|
|
101
|
-
}
|
|
102
|
-
|
|
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
|
-
}
|
|
143
|
-
|
|
144
|
-
var runtimeInformation = {
|
|
145
|
-
givenCommandLineArguments: process.argv
|
|
146
|
-
};
|
|
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
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (runtimeInformation.givenCommandLineArguments.length > 2) {
|
|
160
|
-
var _iterator = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
|
|
161
|
-
_step;
|
|
162
91
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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.
|
|
169
109
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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;
|
|
175
119
|
}
|
|
176
|
-
} // /// endregion
|
|
177
|
-
// /// region clear task type specific configurations
|
|
178
120
|
|
|
121
|
+
specificConfiguration = specificConfiguration.webOptimizer || {}; // endregion
|
|
122
|
+
// region determine application name
|
|
179
123
|
|
|
180
|
-
|
|
181
|
-
|
|
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.
|
|
182
129
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
186
134
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (Object.prototype.hasOwnProperty.call(_configurationTarget, _type3) && (0, _typeof2["default"])(_configurationTarget[_type3]) === 'object') delete _configurationTarget[_type3];
|
|
190
|
-
}
|
|
191
|
-
} // /// endregion
|
|
192
|
-
// // endregion
|
|
193
|
-
// / endregion
|
|
135
|
+
_package.configuration["default"].path.context += '/'; // Merges final default configuration object depending on given target
|
|
136
|
+
// environment.
|
|
194
137
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
|
200
146
|
|
|
201
|
-
|
|
147
|
+
var count = 0;
|
|
148
|
+
var filePath = null;
|
|
202
149
|
|
|
203
|
-
|
|
204
|
-
|
|
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
|
+
}
|
|
205
156
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
delete result.__reference__;
|
|
157
|
+
var runtimeInformation = {
|
|
158
|
+
givenCommandLineArguments: commandLineArguments
|
|
159
|
+
};
|
|
210
160
|
|
|
211
|
-
|
|
212
|
-
|
|
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
|
|
213
170
|
|
|
214
|
-
try {
|
|
215
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
216
|
-
var _name = _step3.value;
|
|
217
171
|
|
|
218
|
-
|
|
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
|
+
}
|
|
219
183
|
}
|
|
220
184
|
} catch (err) {
|
|
221
|
-
|
|
185
|
+
_iterator.e(err);
|
|
222
186
|
} finally {
|
|
223
|
-
|
|
187
|
+
_iterator.f();
|
|
224
188
|
}
|
|
189
|
+
} // /// endregion
|
|
190
|
+
// /// region clear task type specific configurations
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
var _iterator2 = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
|
|
194
|
+
_step2;
|
|
195
|
+
|
|
196
|
+
try {
|
|
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
|
|
207
|
+
|
|
208
|
+
} catch (err) {
|
|
209
|
+
_iterator2.e(err);
|
|
210
|
+
} finally {
|
|
211
|
+
_iterator2.f();
|
|
225
212
|
}
|
|
226
213
|
|
|
227
|
-
_clientnode["default"].extend(true, _clientnode["default"].modifyObject(configuration,
|
|
228
|
-
|
|
214
|
+
_clientnode["default"].extend(true, _clientnode["default"].modifyObject(_clientnode["default"].modifyObject(configuration, specificConfiguration), runtimeInformation), specificConfiguration, runtimeInformation);
|
|
215
|
+
|
|
216
|
+
var result = null;
|
|
217
|
+
if (runtimeInformation.givenCommandLineArguments.length > 3) result = _clientnode["default"].stringParseEncodedObject(runtimeInformation.givenCommandLineArguments[runtimeInformation.givenCommandLineArguments.length - 1], configuration, 'configuration');
|
|
218
|
+
|
|
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__;
|
|
229
223
|
|
|
224
|
+
var _iterator3 = _createForOfIteratorHelper(referenceNames),
|
|
225
|
+
_step3;
|
|
230
226
|
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
try {
|
|
228
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
229
|
+
var _name = _step3.value;
|
|
233
230
|
|
|
234
|
-
|
|
231
|
+
_clientnode["default"].extend(true, result, configuration[_name]);
|
|
232
|
+
}
|
|
233
|
+
} catch (err) {
|
|
234
|
+
_iterator3.e(err);
|
|
235
|
+
} finally {
|
|
236
|
+
_iterator3.f();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
_clientnode["default"].extend(true, _clientnode["default"].modifyObject(configuration, result), result);
|
|
241
|
+
} // Removing comments (default key name to delete is "#").
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
configuration = _clientnode["default"].removeKeyPrefixes(configuration); // endregion
|
|
245
|
+
// / region build absolute paths
|
|
235
246
|
|
|
236
|
-
|
|
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);
|
|
247
|
+
configuration.path.base = (0, _path.resolve)(configuration.path.context, configuration.path.base);
|
|
239
248
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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);
|
|
243
252
|
|
|
244
|
-
|
|
245
|
-
|
|
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);
|
|
256
|
+
|
|
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
|
+
}
|
|
246
260
|
}
|
|
247
261
|
}
|
|
248
262
|
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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) {
|
|
294
|
-
return (0, _path.resolve)(resolvedConfiguration.path.context, filePath);
|
|
295
|
-
}).filter(function (filePath) {
|
|
296
|
-
return !resolvedConfiguration.path.context.startsWith(filePath);
|
|
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) {
|
|
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) {
|
|
302
307
|
return (0, _path.resolve)(resolvedConfiguration.path.context, filePath);
|
|
303
308
|
}).filter(function (filePath) {
|
|
304
309
|
return !resolvedConfiguration.path.context.startsWith(filePath);
|
|
305
|
-
}))
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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();
|
|
333
351
|
}
|
|
334
|
-
} catch (err) {
|
|
335
|
-
_iterator4.e(err);
|
|
336
|
-
} finally {
|
|
337
|
-
_iterator4.f();
|
|
338
352
|
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
353
|
+
} // / endregion
|
|
354
|
+
// endregion
|
|
355
|
+
// region adding special aliases
|
|
342
356
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
357
|
+
/*
|
|
358
|
+
NOTE: This alias couldn't be set in the "package.json" file since this
|
|
359
|
+
would result in an endless loop.
|
|
360
|
+
*/
|
|
347
361
|
|
|
348
362
|
|
|
349
|
-
|
|
363
|
+
resolvedConfiguration.loader.aliases.webOptimizerDefaultTemplateFileLoader = '';
|
|
350
364
|
|
|
351
|
-
|
|
352
|
-
|
|
365
|
+
var _iterator5 = _createForOfIteratorHelper(Array.isArray(resolvedConfiguration.files.defaultHTML.template.use) ? resolvedConfiguration.files.defaultHTML.template.use : [resolvedConfiguration.files.defaultHTML.template.use]),
|
|
366
|
+
_step5;
|
|
353
367
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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();
|
|
360
379
|
}
|
|
361
|
-
} catch (err) {
|
|
362
|
-
_iterator5.e(err);
|
|
363
|
-
} finally {
|
|
364
|
-
_iterator5.f();
|
|
365
|
-
}
|
|
366
380
|
|
|
367
|
-
|
|
368
|
-
|
|
381
|
+
resolvedConfiguration.module.aliases.webOptimizerDefaultTemplateFilePath = resolvedConfiguration.files.defaultHTML.template.filePath; // endregion
|
|
382
|
+
// region apply html webpack plugin workarounds
|
|
369
383
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
384
|
+
/*
|
|
385
|
+
NOTE: Provides a workaround to handle a bug with chained loader
|
|
386
|
+
configurations.
|
|
387
|
+
*/
|
|
374
388
|
|
|
375
|
-
|
|
376
|
-
|
|
389
|
+
var _iterator6 = _createForOfIteratorHelper(resolvedConfiguration.files.html),
|
|
390
|
+
_step6;
|
|
377
391
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
392
|
+
try {
|
|
393
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
394
|
+
var htmlConfiguration = _step6.value;
|
|
381
395
|
|
|
382
|
-
|
|
396
|
+
_clientnode["default"].extend(true, htmlConfiguration, resolvedConfiguration.files.defaultHTML);
|
|
383
397
|
|
|
384
|
-
|
|
398
|
+
htmlConfiguration.template.request = htmlConfiguration.template.filePath;
|
|
385
399
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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 */
|
|
389
403
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
404
|
+
requestString.replace = function (value) {
|
|
405
|
+
return function () {
|
|
406
|
+
return value;
|
|
407
|
+
};
|
|
408
|
+
}(htmlConfiguration.template.filePath);
|
|
409
|
+
/* eslint-enable @typescript-eslint/unbound-method */
|
|
396
410
|
|
|
397
411
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
412
|
+
htmlConfiguration.template.request = requestString;
|
|
413
|
+
}
|
|
414
|
+
} // endregion
|
|
401
415
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
416
|
+
} catch (err) {
|
|
417
|
+
_iterator6.e(err);
|
|
418
|
+
} finally {
|
|
419
|
+
_iterator6.f();
|
|
420
|
+
}
|
|
407
421
|
|
|
408
|
-
|
|
422
|
+
return resolvedConfiguration;
|
|
423
|
+
}();
|
|
409
424
|
};
|
|
425
|
+
/**
|
|
426
|
+
* Get cached or determined configuration object.
|
|
427
|
+
* @returns Nothing.
|
|
428
|
+
*/
|
|
429
|
+
|
|
410
430
|
|
|
411
431
|
exports.load = load;
|
|
412
|
-
|
|
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
|
|
413
441
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
414
442
|
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
415
443
|
// endregion
|