weboptimizer 3.0.7 → 3.0.9
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 +27 -17
- package/package.json +11 -11
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,39 @@ 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
|
+
/*
|
|
178
|
+
We have to use the templace class directly to get
|
|
179
|
+
the generated source code.
|
|
180
|
+
*/
|
|
181
|
+
var templateInstance = new _ejs["default"].Template(template, options);
|
|
182
|
+
templateInstance.compile();
|
|
183
|
+
var compiledSourceCode = templateInstance.source;
|
|
184
|
+
result = "\n module.exports = function(\n ".concat(options.localsName, "\n ) {\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(\n err, str, flnm, lineno, esc\n ) {\n var lines = str.split('\\n');\n var start = Math.max(lineno - 3, 0);\n var end = Math.min(\n lines.length, lineno + 3\n );\n var filename = esc(flnm);\n // Error context\n var context = lines\n .slice(start, end)\n .map(function (line, i) {\n var curr = i + start + 1;\n return (\n curr == lineno ?\n ' >> ' :\n ' '\n ) +\n curr +\n '| ' +\n line;\n })\n .join('\\n');\n // Alter exception message\n err.path = filename;\n err.message =\n (filename || 'ejs') +\n ':' +\n lineno +\n '\\n' +\n context +\n '\\n\\n' +\n err.message;\n throw err;\n };\n ").concat(compiledSourceCode, "\n };\n ").trim();
|
|
185
|
+
} else result = _ejs["default"].compile(result, options);
|
|
176
186
|
}
|
|
177
187
|
} else {
|
|
188
|
+
var _givenOptions$compres3;
|
|
178
189
|
result = result(scope);
|
|
179
|
-
result = compressHTML(result);
|
|
190
|
+
if ((_givenOptions$compres3 = givenOptions.compress) !== null && _givenOptions$compres3 !== void 0 && _givenOptions$compres3.html) result = compressHTML(result);
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
if (compileSteps % 2) {
|
|
183
|
-
var _givenOptions$
|
|
184
|
-
var
|
|
185
|
-
var processed = (0, _core.transformSync)(code, {
|
|
194
|
+
var _givenOptions$compres4, _givenOptions$compres5, _givenOptions$compres6, _givenOptions$compres7;
|
|
195
|
+
var processed = (0, _core.transformSync)(result, {
|
|
186
196
|
ast: false,
|
|
187
197
|
babelrc: false,
|
|
188
|
-
comments: !((_givenOptions$
|
|
189
|
-
compact: Boolean((_givenOptions$
|
|
198
|
+
comments: !((_givenOptions$compres4 = givenOptions.compress) !== null && _givenOptions$compres4 !== void 0 && _givenOptions$compres4.javaScript),
|
|
199
|
+
compact: Boolean((_givenOptions$compres5 = givenOptions.compress) === null || _givenOptions$compres5 === void 0 ? void 0 : _givenOptions$compres5.javaScript),
|
|
190
200
|
filename: options.filename || 'unknown',
|
|
191
|
-
minified: Boolean((_givenOptions$
|
|
192
|
-
presets: (_givenOptions$
|
|
201
|
+
minified: Boolean((_givenOptions$compres6 = givenOptions.compress) === null || _givenOptions$compres6 === void 0 ? void 0 : _givenOptions$compres6.javaScript),
|
|
202
|
+
presets: (_givenOptions$compres7 = givenOptions.compress) !== null && _givenOptions$compres7 !== void 0 && _givenOptions$compres7.javaScript ? [[_babelPresetMinify["default"], givenOptions.compress.javaScript]] : [],
|
|
193
203
|
sourceMaps: false,
|
|
194
204
|
sourceType: 'script'
|
|
195
205
|
});
|
|
196
|
-
if (typeof (processed === null || processed === void 0 ? void 0 : processed.code) === 'string')
|
|
197
|
-
return "".concat(options.strict ? "'use strict';\n" : '').concat(
|
|
206
|
+
if (typeof (processed === null || processed === void 0 ? void 0 : processed.code) === 'string') result = processed.code;
|
|
207
|
+
return "".concat(options.strict ? "'use strict';\n" : '').concat(result);
|
|
198
208
|
}
|
|
199
209
|
if (typeof result === 'string') {
|
|
200
210
|
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.9",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
93
93
|
"@babel/plugin-syntax-top-level-await": "^7.14.5",
|
|
94
94
|
"@babel/plugin-transform-runtime": "^7.29.0",
|
|
95
|
-
"@babel/preset-env": "^7.29.
|
|
95
|
+
"@babel/preset-env": "^7.29.2",
|
|
96
96
|
"@babel/preset-typescript": "^7.28.5",
|
|
97
|
-
"@babel/runtime": "^7.
|
|
97
|
+
"@babel/runtime": "^7.29.2",
|
|
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.1359",
|
|
102
102
|
"ejs": "^5.0.1",
|
|
103
103
|
"exports-loader": "^5.0.0",
|
|
104
104
|
"extract-loader": "^5.1.0",
|
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
"jest-environment-jsdom": "^30.3.0",
|
|
111
111
|
"rimraf": "^6.1.3",
|
|
112
112
|
"script-loader": "^0.7.2",
|
|
113
|
-
"typescript": "^
|
|
113
|
+
"typescript": "^6.0.2",
|
|
114
114
|
"webpack": "^5.105.4",
|
|
115
|
-
"webpack-cli": "^
|
|
115
|
+
"webpack-cli": "^7.0.2",
|
|
116
116
|
"webpack-sources": "^3.3.4"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
@@ -125,16 +125,16 @@
|
|
|
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",
|
|
132
132
|
"@types/webpack-sources": "^3.2.3",
|
|
133
|
-
"@typescript-eslint/parser": "^8.57.
|
|
133
|
+
"@typescript-eslint/parser": "^8.57.2",
|
|
134
134
|
"css-loader": "^7.1.4",
|
|
135
135
|
"cssnano": "^7.1.3",
|
|
136
136
|
"documentation-website": "^1.0.401",
|
|
137
|
-
"eslint": "^10.0
|
|
137
|
+
"eslint": "^10.1.0",
|
|
138
138
|
"eslint-config-google": "^0.14.0",
|
|
139
139
|
"eslint-plugin-jsdoc": "^62.8.0",
|
|
140
140
|
"favicons": "^7.2.0",
|
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
"postcss-url": "^10.1.3",
|
|
156
156
|
"shx": "^0.4.0",
|
|
157
157
|
"style-loader": "^4.0.0",
|
|
158
|
-
"stylelint": "^17.
|
|
158
|
+
"stylelint": "^17.5.0",
|
|
159
159
|
"stylelint-config-standard": "^40.0.0",
|
|
160
160
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
161
|
-
"typescript-eslint": "^8.57.
|
|
161
|
+
"typescript-eslint": "^8.57.2",
|
|
162
162
|
"typescript-plugin-css-modules": "^5.2.0",
|
|
163
163
|
"workbox-webpack-plugin": "^7.4.0"
|
|
164
164
|
},
|