weboptimizer 3.0.7 → 3.0.8
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/ejsLoader.js +26 -17
- package/package.json +4 -4
package/ejsLoader.js
CHANGED
|
@@ -116,7 +116,7 @@ var loader = exports.loader = function loader(source) {
|
|
|
116
116
|
};
|
|
117
117
|
var compressHTML = function compressHTML(content) {
|
|
118
118
|
var _givenOptions$compres;
|
|
119
|
-
return (
|
|
119
|
+
return (0, _htmlMinifier.minify)(content, (0, _clientnode.extend)(true, {
|
|
120
120
|
caseSensitive: true,
|
|
121
121
|
collapseInlineTagWhitespace: true,
|
|
122
122
|
collapseWhitespace: true,
|
|
@@ -137,11 +137,14 @@ var loader = exports.loader = function loader(source) {
|
|
|
137
137
|
*/
|
|
138
138
|
trimCustomFragments: true,
|
|
139
139
|
useShortDoctype: true
|
|
140
|
-
}, givenOptions.compress.html)
|
|
140
|
+
}, ((_givenOptions$compres = givenOptions.compress) === null || _givenOptions$compres === void 0 ? void 0 : _givenOptions$compres.html) || {}));
|
|
141
141
|
};
|
|
142
142
|
var result = template;
|
|
143
143
|
var isString = Boolean(options.isString);
|
|
144
144
|
delete options.isString;
|
|
145
|
+
|
|
146
|
+
// NOTE: Needed to have standalone useable js code afterwards.
|
|
147
|
+
if (compileSteps % 2) options.client = true;
|
|
145
148
|
var stepLocals;
|
|
146
149
|
var scope = {};
|
|
147
150
|
for (var step = 1; step <= compileSteps; step += 1) {
|
|
@@ -161,6 +164,7 @@ var loader = exports.loader = function loader(source) {
|
|
|
161
164
|
if (typeof result === 'string') {
|
|
162
165
|
var filePath = isString ? options.filename : result;
|
|
163
166
|
if (filePath && (0, _path.extname)(filePath) === '.js' && _clientnode.currentRequire) result = (0, _clientnode.currentRequire)(filePath);else {
|
|
167
|
+
var _givenOptions$compres2;
|
|
164
168
|
if (!isString) {
|
|
165
169
|
var encoding = configuration.encoding;
|
|
166
170
|
if (typeof options.encoding === 'string') encoding = options.encoding;
|
|
@@ -168,33 +172,38 @@ var loader = exports.loader = function loader(source) {
|
|
|
168
172
|
encoding: encoding
|
|
169
173
|
});
|
|
170
174
|
}
|
|
171
|
-
if (step === compileSteps) result = compressHTML(result);
|
|
172
|
-
if (
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
if (step === compileSteps && (_givenOptions$compres2 = givenOptions.compress) !== null && _givenOptions$compres2 !== void 0 && _givenOptions$compres2.html) result = compressHTML(result);
|
|
176
|
+
if (step === compileSteps && compileSteps % 2) {
|
|
177
|
+
// Wir nutzen die Template-Klasse direkt, um an den generierten Quellcode zu kommen
|
|
178
|
+
var templateInstance = new _ejs["default"].Template(template, options);
|
|
179
|
+
|
|
180
|
+
// Generiert den JS-Code der Funktion als String
|
|
181
|
+
templateInstance.compile();
|
|
182
|
+
var compiledSourceCode = templateInstance.source;
|
|
183
|
+
result = "\n module.exports = function(".concat(options.localsName, ") {\n var escapeFn = function(value) {\n return String(value)\n .replace(\n /[&<>\"']/g,\n function(char) {\n return {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": \"'\"\n }[char]\n }\n )\n };\n var include = function() {\n throw new Error('Include not implemented.')\n };\n var rethrow = function rethrow(err, str, flnm, lineno, esc) {\n var lines = str.split('\\n');\n var start = Math.max(lineno - 3, 0);\n var end = Math.min(lines.length, lineno + 3);\n var filename = esc(flnm);\n // Error context\n var context = lines.slice(start, end).map(function (line, i) {\n var curr = i + start + 1;\n return (curr == lineno ? ' >> ' : ' ')\n + curr\n + '| '\n + line;\n }).join('\\n');\n // Alter exception message\n err.path = filename;\n err.message = (filename || 'ejs') + ':'\n + lineno + '\\n'\n + context + '\\n\\n'\n + err.message;\n throw err;\n };\n ").concat(compiledSourceCode, "\n };\n ").trim();
|
|
184
|
+
} else result = _ejs["default"].compile(result, options);
|
|
176
185
|
}
|
|
177
186
|
} else {
|
|
187
|
+
var _givenOptions$compres3;
|
|
178
188
|
result = result(scope);
|
|
179
|
-
result = compressHTML(result);
|
|
189
|
+
if ((_givenOptions$compres3 = givenOptions.compress) !== null && _givenOptions$compres3 !== void 0 && _givenOptions$compres3.html) result = compressHTML(result);
|
|
180
190
|
}
|
|
181
191
|
}
|
|
182
192
|
if (compileSteps % 2) {
|
|
183
|
-
var _givenOptions$
|
|
184
|
-
var
|
|
185
|
-
var processed = (0, _core.transformSync)(code, {
|
|
193
|
+
var _givenOptions$compres4, _givenOptions$compres5, _givenOptions$compres6, _givenOptions$compres7;
|
|
194
|
+
var processed = (0, _core.transformSync)(result, {
|
|
186
195
|
ast: false,
|
|
187
196
|
babelrc: false,
|
|
188
|
-
comments: !((_givenOptions$
|
|
189
|
-
compact: Boolean((_givenOptions$
|
|
197
|
+
comments: !((_givenOptions$compres4 = givenOptions.compress) !== null && _givenOptions$compres4 !== void 0 && _givenOptions$compres4.javaScript),
|
|
198
|
+
compact: Boolean((_givenOptions$compres5 = givenOptions.compress) === null || _givenOptions$compres5 === void 0 ? void 0 : _givenOptions$compres5.javaScript),
|
|
190
199
|
filename: options.filename || 'unknown',
|
|
191
|
-
minified: Boolean((_givenOptions$
|
|
192
|
-
presets: (_givenOptions$
|
|
200
|
+
minified: Boolean((_givenOptions$compres6 = givenOptions.compress) === null || _givenOptions$compres6 === void 0 ? void 0 : _givenOptions$compres6.javaScript),
|
|
201
|
+
presets: (_givenOptions$compres7 = givenOptions.compress) !== null && _givenOptions$compres7 !== void 0 && _givenOptions$compres7.javaScript ? [[_babelPresetMinify["default"], givenOptions.compress.javaScript]] : [],
|
|
193
202
|
sourceMaps: false,
|
|
194
203
|
sourceType: 'script'
|
|
195
204
|
});
|
|
196
|
-
if (typeof (processed === null || processed === void 0 ? void 0 : processed.code) === 'string')
|
|
197
|
-
return "".concat(options.strict ? "'use strict';\n" : '').concat(
|
|
205
|
+
if (typeof (processed === null || processed === void 0 ? void 0 : processed.code) === 'string') result = processed.code;
|
|
206
|
+
return "".concat(options.strict ? "'use strict';\n" : '').concat(result);
|
|
198
207
|
}
|
|
199
208
|
if (typeof result === 'string') {
|
|
200
209
|
result = result.replace(new RegExp("<script +processing-workaround *" + "(?: = *(?: \" *\"|' *') *)?>([\\s\\S]*?)</ *script *>", 'ig'), '$1').replace(new RegExp("<script +processing(-+)-workaround *" + "(?: = *(?: \" *\"|' *') *)?>([\\s\\S]*?)</ *script *>", 'ig'), '<script processing$1workaround>$2</script>');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"babel-loader": "^10.1.1",
|
|
99
99
|
"babel-plugin-transform-modern-regexp": "^0.0.6",
|
|
100
100
|
"babel-preset-minify": "^0.5.2",
|
|
101
|
-
"clientnode": "4.0.
|
|
101
|
+
"clientnode": "4.0.1357",
|
|
102
102
|
"ejs": "^5.0.1",
|
|
103
103
|
"exports-loader": "^5.0.0",
|
|
104
104
|
"extract-loader": "^5.1.0",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"script-loader": "^0.7.2",
|
|
113
113
|
"typescript": "^5.9.3",
|
|
114
114
|
"webpack": "^5.105.4",
|
|
115
|
-
"webpack-cli": "^
|
|
115
|
+
"webpack-cli": "^7.0.0",
|
|
116
116
|
"webpack-sources": "^3.3.4"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"@types/html-minifier": "^4.0.6",
|
|
126
126
|
"@types/html-minifier-terser": "^7.0.2",
|
|
127
127
|
"@types/imagemin": "^9.0.1",
|
|
128
|
-
"@types/node": "^25.
|
|
128
|
+
"@types/node": "^25.5.0",
|
|
129
129
|
"@types/postcss-import": "^14.0.3",
|
|
130
130
|
"@types/postcss-url": "^10.0.4",
|
|
131
131
|
"@types/webpack-env": "^1.18.8",
|