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.d.ts +2 -2
- package/configurator.js +304 -283
- package/ejsLoader.js +6 -5
- package/index.d.ts +3 -1
- package/index.js +135 -117
- package/package.json +22 -2
- package/stylelintConfigurator.js +2 -1
- package/type.d.ts +5 -1
- package/webpackConfigurator.js +143 -143
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.
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
specificConfiguration =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
}
|
|
159
|
-
|
|
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
|
-
|
|
180
|
+
var _iterator2 = _createForOfIteratorHelper(_type4.SubConfigurationTypes),
|
|
181
|
+
_step2;
|
|
169
182
|
|
|
170
|
-
try {
|
|
171
|
-
|
|
172
|
-
|
|
183
|
+
try {
|
|
184
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
185
|
+
var _type3 = _step2.value;
|
|
173
186
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
184
|
-
} finally {
|
|
185
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
199
|
-
|
|
211
|
+
var _iterator3 = _createForOfIteratorHelper(referenceNames),
|
|
212
|
+
_step3;
|
|
200
213
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
214
|
+
try {
|
|
215
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
216
|
+
var _name = _step3.value;
|
|
204
217
|
|
|
205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
225
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
232
|
-
|
|
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
|
-
|
|
250
|
+
} // / endregion
|
|
251
|
+
// region evaluate dynamic configuration structures
|
|
238
252
|
|
|
239
253
|
|
|
240
|
-
var now = new Date();
|
|
241
|
-
/*
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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
|
-
|
|
359
|
-
|
|
367
|
+
resolvedConfiguration.module.aliases.webOptimizerDefaultTemplateFilePath = resolvedConfiguration.files.defaultHTML.template.filePath; // endregion
|
|
368
|
+
// region apply html webpack plugin workarounds
|
|
360
369
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
370
|
+
/*
|
|
371
|
+
NOTE: Provides a workaround to handle a bug with chained loader
|
|
372
|
+
configurations.
|
|
373
|
+
*/
|
|
364
374
|
|
|
365
|
-
|
|
375
|
+
var _iterator6 = _createForOfIteratorHelper(resolvedConfiguration.files.html),
|
|
376
|
+
_step6;
|
|
366
377
|
|
|
367
|
-
|
|
378
|
+
try {
|
|
379
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
380
|
+
var htmlConfiguration = _step6.value;
|
|
368
381
|
|
|
369
|
-
|
|
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
|
-
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
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
|
-
|
|
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
|