weboptimizer 4.0.104 → 4.0.105-1

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.
Files changed (2) hide show
  1. package/dist/ejsLoader.js +33 -22
  2. package/package.json +7 -13
package/dist/ejsLoader.js CHANGED
@@ -110,28 +110,39 @@ export const loader = async function (source) {
110
110
  }
111
111
  throw new Error(`Given template file "${template}" couldn't be resolved.`);
112
112
  };
113
- const compressHTML = content => minifyHTML(content, extend(true, {
114
- caseSensitive: true,
115
- collapseInlineTagWhitespace: true,
116
- collapseWhitespace: true,
117
- conservativeCollapse: true,
118
- minifyCSS: true,
119
- minifyJS: true,
120
- processScripts: ['text/ng-template', 'text/x-handlebars-template'],
121
- removeAttributeQuotes: true,
122
- removeComments: true,
123
- removeRedundantAttributes: true,
124
- removeScriptTypeAttributes: true,
125
- removeStyleLinkTypeAttributes: true,
126
- sortAttributes: true,
127
- sortClassName: true,
113
+ const compressHTML = content => {
114
+ const minifierOptions = extend(true, {
115
+ caseSensitive: true,
116
+ collapseInlineTagWhitespace: true,
117
+ collapseWhitespace: true,
118
+ conservativeCollapse: true,
119
+ minifyCSS: true,
120
+ minifyJS: true,
121
+ processScripts: ['text/ng-template', 'text/x-handlebars-template'],
122
+ removeAttributeQuotes: true,
123
+ removeComments: true,
124
+ removeDefaultTypeAttributes: true,
125
+ removeRedundantAttributes: true,
126
+ sortAttributes: true,
127
+ sortClassNames: true,
128
+ // NOTE: Avoids whitespace around placeholder in tags.
129
+ trimCustomFragments: true,
130
+ useShortDoctype: true
131
+ }, givenOptions.compress?.html || {});
128
132
  /*
129
- NOTE: Avoids whitespace around placeholder in
130
- tags.
133
+ NOTE: Given options are shared with "html-webpack-plugin" and
134
+ "html-loader" which are based on "html-minifier-terser" so we
135
+ have to map its option names to "html-minifier".
131
136
  */
132
- trimCustomFragments: true,
133
- useShortDoctype: true
134
- }, givenOptions.compress?.html || {}));
137
+ const renamedOptions = {};
138
+ for (const [oldName, newName] of [['removeScriptTypeAttributes', 'removeDefaultTypeAttributes'], ['removeStyleLinkTypeAttributes', 'removeDefaultTypeAttributes'], ['sortClassName', 'sortClassNames']]) if (Object.prototype.hasOwnProperty.call(minifierOptions, oldName)) {
139
+ renamedOptions[newName] = Boolean(renamedOptions[newName]) || Boolean(minifierOptions[oldName]);
140
+ delete minifierOptions[oldName];
141
+ }
142
+ Object.assign(minifierOptions, renamedOptions);
143
+ for (const name of ['html5', 'processConditionalComments', 'removeCDATASectionsFromCDATA', 'removeCommentsFromCDATA']) delete minifierOptions[name];
144
+ return minifyHTML(content, minifierOptions);
145
+ };
135
146
  let result = template;
136
147
  const isString = Boolean(options.isString);
137
148
  delete options.isString;
@@ -165,7 +176,7 @@ export const loader = async function (source) {
165
176
  encoding
166
177
  });
167
178
  }
168
- if (step === compileSteps && givenOptions.compress?.html) result = compressHTML(result);
179
+ if (step === compileSteps && givenOptions.compress?.html) result = await compressHTML(result);
169
180
  if (step === compileSteps && compileSteps % 2) {
170
181
  /*
171
182
  We have to use the templace class directly to get
@@ -235,7 +246,7 @@ export const loader = async function (source) {
235
246
  }
236
247
  } else {
237
248
  result = await result(scope);
238
- if (givenOptions.compress?.html) result = compressHTML(result);
249
+ if (givenOptions.compress?.html) result = await compressHTML(result);
239
250
  }
240
251
  }
241
252
  if (compileSteps % 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "4.0.104",
3
+ "version": "4.0.105-1",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -87,14 +87,14 @@
87
87
  "babel-loader": "^10.1.1",
88
88
  "babel-plugin-polyfill-corejs3": "^1.0.0",
89
89
  "babel-plugin-transform-rewrite-imports": "^1.5.4",
90
- "clientnode": "4.0.1530",
90
+ "clientnode": "4.0.1531",
91
91
  "core-js": "^3.51.0",
92
92
  "ejs": "^7.0.2",
93
93
  "exports-loader": "^5.0.0",
94
94
  "extract-loader": "^5.1.0",
95
95
  "glob-all": "^3.3.1",
96
96
  "html-loader": "^5.1.0",
97
- "html-minifier": "^4.0.0",
97
+ "html-minifier": "^5.0.1",
98
98
  "html-webpack-plugin": "^5.6.8",
99
99
  "imports-loader": "^5.0.0",
100
100
  "jest-environment-jsdom": "^30.5.2",
@@ -111,7 +111,6 @@
111
111
  "@stylistic/eslint-plugin": "^5.10.0",
112
112
  "@types/ejs": "^3.1.5",
113
113
  "@types/eslint": "^9.6.1",
114
- "@types/html-minifier": "^4.0.6",
115
114
  "@types/html-minifier-terser": "^7.0.2",
116
115
  "@types/imagemin": "^9.0.1",
117
116
  "@types/node": "^26.6.6",
@@ -124,7 +123,7 @@
124
123
  "cssnano": "^9.9.0",
125
124
  "eslint": "^10.14.0",
126
125
  "eslint-config-google": "^0.14.0",
127
- "eslint-plugin-jsdoc": "^65.4.2",
126
+ "eslint-plugin-jsdoc": "^65.4.3",
128
127
  "favicons": "^7.3.1",
129
128
  "favicons-webpack-plugin": "^6.0.1",
130
129
  "globals": "^17.14.0",
@@ -143,20 +142,18 @@
143
142
  "postcss-url": "^10.1.4",
144
143
  "shx": "^0.4.0",
145
144
  "style-loader": "^4.0.0",
146
- "stylelint": "^17.16.0",
147
- "stylelint-config-standard": "^40.0.0",
148
- "stylelint-config-standard-scss": "^17.0.0",
145
+ "stylelint": "^18.0.0",
146
+ "stylelint-config-standard": "^41.0.0",
149
147
  "terser-webpack-plugin": "^5.6.1",
150
148
  "typescript-eslint": "^8.72.1",
151
149
  "typescript-plugin-css-modules": "^5.3.0",
152
- "web-documentation": "^1.0.71",
150
+ "web-documentation": "^1.0.72",
153
151
  "workbox-webpack-plugin": "^7.4.1"
154
152
  },
155
153
  "peerDependencies": {
156
154
  "@babel/eslint-parser": "*",
157
155
  "@eslint/js": "*",
158
156
  "@types/ejs": "*",
159
- "@types/html-minifier": "*",
160
157
  "@types/imagemin": "*",
161
158
  "@types/node": "*",
162
159
  "@types/webpack-env": "*",
@@ -201,9 +198,6 @@
201
198
  "@types/ejs": {
202
199
  "optional": true
203
200
  },
204
- "@types/html-minifier": {
205
- "optional": true
206
- },
207
201
  "@types/imagemin": {
208
202
  "optional": true
209
203
  },