html-minifier-next 4.2.0 → 4.2.2
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/cli.js +10 -10
- package/dist/htmlminifier.cjs +2 -2
- package/dist/htmlminifier.esm.bundle.js +2 -2
- package/package.json +1 -1
- package/src/htmlminifier.js +2 -2
package/cli.js
CHANGED
|
@@ -180,8 +180,8 @@ program.option('-d --dry', 'Dry run: process and report statistics without writi
|
|
|
180
180
|
function readFile(file) {
|
|
181
181
|
try {
|
|
182
182
|
return fs.readFileSync(file, { encoding: 'utf8' });
|
|
183
|
-
} catch (
|
|
184
|
-
fatal('Cannot read ' + file + '\n' +
|
|
183
|
+
} catch (err) {
|
|
184
|
+
fatal('Cannot read ' + file + '\n' + err.message);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -196,7 +196,7 @@ async function loadConfigFromPath(configPath) {
|
|
|
196
196
|
// Try JSON first
|
|
197
197
|
try {
|
|
198
198
|
return JSON.parse(data);
|
|
199
|
-
} catch (
|
|
199
|
+
} catch (jsonErr) {
|
|
200
200
|
const abs = path.resolve(configPath);
|
|
201
201
|
|
|
202
202
|
// Try CJS require
|
|
@@ -204,13 +204,13 @@ async function loadConfigFromPath(configPath) {
|
|
|
204
204
|
const result = require(abs);
|
|
205
205
|
// Handle ESM interop: if `require()` loads an ESM file, it may return `{__esModule: true, default: …}`
|
|
206
206
|
return (result && result.__esModule && result.default) ? result.default : result;
|
|
207
|
-
} catch (
|
|
207
|
+
} catch (cjsErr) {
|
|
208
208
|
// Try ESM import
|
|
209
209
|
try {
|
|
210
210
|
const mod = await import(pathToFileURL(abs).href);
|
|
211
211
|
return mod.default || mod;
|
|
212
|
-
} catch (
|
|
213
|
-
fatal('Cannot read the specified config file.\nAs JSON: ' +
|
|
212
|
+
} catch (esmErr) {
|
|
213
|
+
fatal('Cannot read the specified config file.\nAs JSON: ' + jsonErr.message + '\nAs CJS: ' + cjsErr.message + '\nAs ESM: ' + esmErr.message);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -307,8 +307,8 @@ program.option('--file-ext <extensions>', 'Specify file extension(s) to process
|
|
|
307
307
|
let minified;
|
|
308
308
|
try {
|
|
309
309
|
minified = await minify(data, createOptions());
|
|
310
|
-
} catch (
|
|
311
|
-
fatal('Minification error on ' + inputFile + '\n' +
|
|
310
|
+
} catch (err) {
|
|
311
|
+
fatal('Minification error on ' + inputFile + '\n' + err.message);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
const stats = calculateStats(data, minified);
|
|
@@ -466,8 +466,8 @@ program.option('--file-ext <extensions>', 'Specify file extension(s) to process
|
|
|
466
466
|
|
|
467
467
|
try {
|
|
468
468
|
minified = await minify(content, minifierOptions);
|
|
469
|
-
} catch (
|
|
470
|
-
fatal('Minification error:\n' +
|
|
469
|
+
} catch (err) {
|
|
470
|
+
fatal('Minification error:\n' + err.message);
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
const stats = calculateStats(content, minified);
|
package/dist/htmlminifier.cjs
CHANGED
|
@@ -1328,8 +1328,8 @@ const processOptions = (inputOptions) => {
|
|
|
1328
1328
|
try {
|
|
1329
1329
|
const result = await terser.minify(code, terserOptions);
|
|
1330
1330
|
return result.code.replace(/;$/, '');
|
|
1331
|
-
} catch (
|
|
1332
|
-
options.log(
|
|
1331
|
+
} catch (err) {
|
|
1332
|
+
options.log(err);
|
|
1333
1333
|
return text;
|
|
1334
1334
|
}
|
|
1335
1335
|
};
|
|
@@ -40381,8 +40381,8 @@ const processOptions = (inputOptions) => {
|
|
|
40381
40381
|
try {
|
|
40382
40382
|
const result = await minify$1(code, terserOptions);
|
|
40383
40383
|
return result.code.replace(/;$/, '');
|
|
40384
|
-
} catch (
|
|
40385
|
-
options.log(
|
|
40384
|
+
} catch (err) {
|
|
40385
|
+
options.log(err);
|
|
40386
40386
|
return text;
|
|
40387
40387
|
}
|
|
40388
40388
|
};
|
package/package.json
CHANGED
package/src/htmlminifier.js
CHANGED
|
@@ -798,8 +798,8 @@ const processOptions = (inputOptions) => {
|
|
|
798
798
|
try {
|
|
799
799
|
const result = await terser(code, terserOptions);
|
|
800
800
|
return result.code.replace(/;$/, '');
|
|
801
|
-
} catch (
|
|
802
|
-
options.log(
|
|
801
|
+
} catch (err) {
|
|
802
|
+
options.log(err);
|
|
803
803
|
return text;
|
|
804
804
|
}
|
|
805
805
|
};
|