html-minifier-next 8.4.2 → 8.4.4
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/README.md +3 -1
- package/cli.js +31 -9
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/lib/constants.d.ts +2 -1
- package/dist/types/lib/constants.d.ts.map +1 -1
- package/dist/types/lib/options.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts +14 -1
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/htmlminifier.js +17 -7
- package/src/lib/constants.js +5 -0
- package/src/lib/file-pool.js +3 -2
- package/src/lib/file-write.js +87 -0
- package/src/lib/options.js +32 -5
- package/src/lib/utils.js +46 -1
package/README.md
CHANGED
|
@@ -83,6 +83,8 @@ export default {
|
|
|
83
83
|
};
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
A module can also hold values JSON cannot express, like regular expressions (e.g., `ignoreCustomFragments: [/\{\{[\s\S]*?\}\}/]`) and functions (for `minifyCSS`, `minifyJS`, and `minifyURLs`, or in custom SVGO plugins for `minifySVG`). As functions cannot be passed to worker threads, a run using them minifies in-process.
|
|
87
|
+
|
|
86
88
|
### Node.js
|
|
87
89
|
|
|
88
90
|
```js
|
|
@@ -241,7 +243,7 @@ Where the modifiers disagree, the preserving one wins—`conservativeCollapse` a
|
|
|
241
243
|
|
|
242
244
|
### Sorting attributes and style classes
|
|
243
245
|
|
|
244
|
-
Minifier options like `sortAttributes` and `sortClassNames` won’t impact the plain-text size of the output. However,
|
|
246
|
+
Minifier options like `sortAttributes` and `sortClassNames` won’t impact the plain-text size of the output. However, `sortAttributes` (but not `sortClassNames`) improves the compression ratio for Gzip and Brotli used over HTTP.
|
|
245
247
|
|
|
246
248
|
### CSS minification
|
|
247
249
|
|
package/cli.js
CHANGED
|
@@ -53,6 +53,7 @@ const commanderOptionKey = (key) => {
|
|
|
53
53
|
import { getPreset, getPresetNames } from './src/presets.js';
|
|
54
54
|
import { paramCase, parseRegExp } from './src/lib/utils.js';
|
|
55
55
|
import { optionDefinitions } from './src/lib/option-definitions.js';
|
|
56
|
+
import { writeFileAtomic } from './src/lib/file-write.js';
|
|
56
57
|
|
|
57
58
|
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
58
59
|
|
|
@@ -261,6 +262,28 @@ const CONFIG_KEYS_EXTRA = new Set(['$schema', 'preset', 'fileExt', 'ignoreDir'])
|
|
|
261
262
|
// `--config-file` isn’t specified
|
|
262
263
|
const CONFIG_FILES_DEFAULT = ['html-minifier-next.config.json', 'htmlminifier.config.json'];
|
|
263
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Parse a config value—strings as on the command line, anything else as it is, since
|
|
267
|
+
* a JSON round trip would drop what only a module config can hold (functions, regexes)
|
|
268
|
+
* @param {string} key Option definition key
|
|
269
|
+
* @param {string} type Option definition type
|
|
270
|
+
* @param {unknown} value
|
|
271
|
+
*/
|
|
272
|
+
function parseConfigValue(key, type, value) {
|
|
273
|
+
if (typeof value === 'string') return getParser(key, type)(value);
|
|
274
|
+
switch (type) {
|
|
275
|
+
case 'int':
|
|
276
|
+
return getParser(key, type)(String(value));
|
|
277
|
+
// A single value is wrapped as its string form is; `null` and `undefined` leave the option unset
|
|
278
|
+
case 'regexpArray':
|
|
279
|
+
return value == null ? undefined : (Array.isArray(value) ? value : [value]).map(parseRegExp);
|
|
280
|
+
case 'jsonArray':
|
|
281
|
+
return value == null ? undefined : (Array.isArray(value) ? value : [value]);
|
|
282
|
+
default:
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
264
287
|
/**
|
|
265
288
|
* Normalize and validate config object by applying parsers and transforming values.
|
|
266
289
|
* @param {Record<string, any>} config - Raw config object
|
|
@@ -281,8 +304,7 @@ function normalizeConfig(config) {
|
|
|
281
304
|
Object.entries(optionDefinitions).forEach(function ([key, { type }]) {
|
|
282
305
|
if (key in normalized) {
|
|
283
306
|
if (type !== 'boolean' && type !== 'invertedBoolean') {
|
|
284
|
-
|
|
285
|
-
normalized[key] = getParser(key, type)(typeof value === 'string' ? value : JSON.stringify(value));
|
|
307
|
+
normalized[key] = parseConfigValue(key, type, normalized[key]);
|
|
286
308
|
}
|
|
287
309
|
}
|
|
288
310
|
});
|
|
@@ -553,7 +575,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
553
575
|
|
|
554
576
|
/**
|
|
555
577
|
* A pool for this run, or `null` where one wouldn’t pay or wouldn’t work—in which case
|
|
556
|
-
* the caller minifies in
|
|
578
|
+
* the caller minifies in-process exactly as before
|
|
557
579
|
* @param {string[]} files
|
|
558
580
|
*/
|
|
559
581
|
async function createPool(files) {
|
|
@@ -563,7 +585,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
563
585
|
// Whether the run went wide is worth saying, since the default weighs the file
|
|
564
586
|
// count and the bytes there are to share out, neither of which the caller sees
|
|
565
587
|
const inProcess = () => {
|
|
566
|
-
if (isVerbose) console.error('Worker threads: none (minifying in
|
|
588
|
+
if (isVerbose) console.error('Worker threads: none (minifying in-process)');
|
|
567
589
|
return null;
|
|
568
590
|
};
|
|
569
591
|
// `availableParallelism` reports what this process may actually use, which under a
|
|
@@ -593,7 +615,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
593
615
|
}
|
|
594
616
|
|
|
595
617
|
// `log` is a closure over this process’s console and is rebuilt inside the worker;
|
|
596
|
-
// anything else unclonable (
|
|
618
|
+
// anything else unclonable (such as a function from a module config) stays in-process
|
|
597
619
|
const { log, ...options } = createOptions();
|
|
598
620
|
try {
|
|
599
621
|
structuredClone(options);
|
|
@@ -602,7 +624,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
602
624
|
}
|
|
603
625
|
|
|
604
626
|
// A pool this small has nothing to share out and still pays for its workers, so an
|
|
605
|
-
// explicit request for them lands in
|
|
627
|
+
// explicit request for them lands in-process as `--workers=1` does
|
|
606
628
|
const poolSize = Math.min(size, fileCount);
|
|
607
629
|
if (poolSize <= 1) {
|
|
608
630
|
return inProcess();
|
|
@@ -681,7 +703,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
681
703
|
return { originalSize: stats.originalSize, minifiedSize: stats.minifiedSize, saved: stats.saved };
|
|
682
704
|
}
|
|
683
705
|
|
|
684
|
-
await
|
|
706
|
+
await writeFileAtomic(outputFile, minified).catch(err => {
|
|
685
707
|
fatal('Cannot write ' + outputFile + '\n' + err.message);
|
|
686
708
|
});
|
|
687
709
|
|
|
@@ -1000,7 +1022,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
1000
1022
|
if (programOptions.output) {
|
|
1001
1023
|
try {
|
|
1002
1024
|
await fs.promises.mkdir(path.dirname(programOptions.output), { recursive: true });
|
|
1003
|
-
await
|
|
1025
|
+
await writeFileAtomic(programOptions.output, minified);
|
|
1004
1026
|
} catch (err) {
|
|
1005
1027
|
fatal('Cannot write ' + programOptions.output + '\n' + errorMessage(err));
|
|
1006
1028
|
}
|
|
@@ -1188,7 +1210,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
1188
1210
|
if (programOptions.output) {
|
|
1189
1211
|
try {
|
|
1190
1212
|
await fs.promises.mkdir(path.dirname(programOptions.output), { recursive: true });
|
|
1191
|
-
await
|
|
1213
|
+
await writeFileAtomic(programOptions.output, minifiedCombined);
|
|
1192
1214
|
} catch (err) {
|
|
1193
1215
|
fatal('Cannot write ' + programOptions.output + '\n' + errorMessage(err));
|
|
1194
1216
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAEA,O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A2FD;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAJR,MAAM,YACN,eAAe,KACb,OAAO,CAAC,MAAM,CAsE1B,CAAC;AAIF,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACf,CAAC"}
|
|
@@ -106,5 +106,6 @@ declare const genericRawTextElements: Set<string>;
|
|
|
106
106
|
declare const endlessRawTextElements: Set<string>;
|
|
107
107
|
declare const escapableRawTextElements: Set<string>;
|
|
108
108
|
declare const rawTextElements: Set<string>;
|
|
109
|
-
|
|
109
|
+
declare const MISSING_DEPENDENCY = "HMN_MISSING_DEPENDENCY";
|
|
110
|
+
export { RE_WS_START, RE_WS_END, RE_WS_ONLY, RE_WS_NBSP_END, RE_ALL_WS_NBSP, RE_NBSP_LEADING_GROUP, RE_NBSP_LEAD_GROUP, RE_NBSP_TRAILING_GROUP, RE_NBSP_TRAILING_STRIP, RE_EVENT_ATTR_DEFAULT, RE_CAN_REMOVE_ATTR_QUOTES, RE_TRAILING_SEMICOLON, RE_AMP_ENTITY, RE_LEGACY_ENTITIES, RE_ESCAPE_LT, RE_ESCAPE_LT_RAW_TEXT, RE_HTML_ENCODING, RE_ATTR_WS_CHECK, RE_ATTR_WS_COLLAPSE, RE_ATTR_WS_TRIM, RE_STYLE_ELEMENT, RE_EMPTY_ATTRIBUTE, inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin, inlineElementsToKeepWhitespace, formControlElements, generalDefaults, tagDefaults, executableScriptsMimetypes, keepScriptsMimetypes, jsonScriptTypes, isSimpleBoolean, isBooleanValue, collapsibleValues, srcsetElements, MISSING_DEPENDENCY, optionalStartTags, optionalEndTags, headerElements, descriptionElements, pBlockElements, pInlineElements, rubyEndTagOmission, rubyRtcEndTagOmission, optionElements, tableContentElements, tableSectionElements, cellElements, topLevelElements, compactElements, looseElements, trailingElements, htmlElements, specialContentElements, genericRawTextElements, endlessRawTextElements, escapableRawTextElements, rawTextElements };
|
|
110
111
|
//# sourceMappingURL=constants.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4
|
/**
|
|
5
|
+
* Stringify with sorted keys, for cache keys—values that can behave differently must not
|
|
6
|
+
* stringify alike, so unquoted markers stand in for what JSON cannot express
|
|
5
7
|
* @param {unknown} obj
|
|
6
8
|
* @returns {string}
|
|
7
9
|
*/
|
|
@@ -98,5 +100,16 @@ declare function describeQuantifierRisk(pattern: RegExp | string): string | null
|
|
|
98
100
|
* @returns {number} Index of the closing `>`, or -1 if not found
|
|
99
101
|
*/
|
|
100
102
|
declare function findTagEnd(html: string, pos: number, limit?: number): number;
|
|
101
|
-
|
|
103
|
+
/**
|
|
104
|
+
* A package that resolves but fails to load—e.g., a native binding built for
|
|
105
|
+
* another platform—is not one another `npm install` fixes, so name what happened
|
|
106
|
+
* rather than the install command
|
|
107
|
+
*
|
|
108
|
+
* @param {string} label - Minifier name as it should read in the message
|
|
109
|
+
* @param {string} specifier - Package that failed to load
|
|
110
|
+
* @param {unknown} cause - Error the import rejected with
|
|
111
|
+
* @returns {string} Message describing the failure
|
|
112
|
+
*/
|
|
113
|
+
declare function describeDependencyFailure(label: string, specifier: string, cause: unknown): string;
|
|
114
|
+
export { stableStringify, findTagEnd, LRU, MAX_CACHE_ENTRY_SIZE, hashContent, uniqueId, identity, isThenable, lowercase, paramCase, replaceAsync, parseRegExp, embedSource, lostFlag, describeQuantifierRisk, describeDependencyFailure };
|
|
102
115
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAAA;;GAEG;AAkBH;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,GAAG,EAHjB,OAGiB,GAFf,MAAM,CAgBlB;AAID,cAAM,GAAG;IAEA,KAAK;IACL,IAAI;IACJ,IAAI;IACT,mCAAmC;IAC9B,GAAG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I,CAqDlC;AAED;;;;;;;;;GASG;AACH,iBAAS,WAAW,CAAC,OAAO,EAHjB,MAGiB,GAFf,MAAM,CAOlB;AAGE,YAA6D,MAAM,GAAzD;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAA;CAAC,CAE7D;AAqKD;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,OAAO,EAL5B,MAAM,GAAG,MAKmB,GAH1B,MAAM,GAAG,IAAI,CAqBzB;AAED;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,IAAI,EALb,MAKa,EAAE,GAAG,EAJlB,MAIkB,EAAE,KAAK,AAHjC,CACA,EADQ,MAGuC,GAFrC,MAAM,CAelB;AAED;;;;;;;;;GASG;AACH,iBAAS,yBAAyB,CAAC,KAAK,EAL7B,MAK6B,EAAE,SAAS,EAJxC,MAIwC,EAAE,KAAK,EAH/C,OAG+C,GAF7C,MAAM,CAYlB;AAID,OAAO,EACL,eAAe,EACf,UAAU,EACV,GAAG,EACH,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,sBAAsB,EACtB,yBAAyB,EAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"@commitlint/cli": "^21.2.2",
|
|
18
18
|
"@eslint/js": "^10.0.1",
|
|
19
19
|
"@swc/core": "^1.16.2",
|
|
20
|
-
"@types/node": "^26.5.
|
|
20
|
+
"@types/node": "^26.5.1",
|
|
21
21
|
"eslint": "^10.10.0",
|
|
22
22
|
"globals": "^17.12.0",
|
|
23
23
|
"typescript": "^7.0.2",
|
|
24
|
-
"vite": "^8.
|
|
24
|
+
"vite": "^8.3.0"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=22.13"
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"types": "dist/types/htmlminifier.d.ts",
|
|
98
|
-
"version": "8.4.
|
|
98
|
+
"version": "8.4.4"
|
|
99
99
|
}
|
package/src/htmlminifier.js
CHANGED
|
@@ -2,7 +2,7 @@ import { HTMLParser, endTag } from './htmlparser.js';
|
|
|
2
2
|
import TokenChain from './tokenchain.js';
|
|
3
3
|
import { presets, getPreset, getPresetNames } from './presets.js';
|
|
4
4
|
|
|
5
|
-
import { LRU, findTagEnd, identity, isThenable, lowercase, uniqueId } from './lib/utils.js';
|
|
5
|
+
import { LRU, describeDependencyFailure, findTagEnd, identity, isThenable, lowercase, uniqueId } from './lib/utils.js';
|
|
6
6
|
import { collectUsedSymbols } from './lib/unused-css.js';
|
|
7
7
|
|
|
8
8
|
import {
|
|
@@ -26,7 +26,8 @@ import {
|
|
|
26
26
|
compactElements,
|
|
27
27
|
looseElements,
|
|
28
28
|
trailingElements,
|
|
29
|
-
pInlineElements
|
|
29
|
+
pInlineElements,
|
|
30
|
+
MISSING_DEPENDENCY
|
|
30
31
|
} from './lib/constants.js';
|
|
31
32
|
|
|
32
33
|
import {
|
|
@@ -516,17 +517,26 @@ async function getTerser() {
|
|
|
516
517
|
return terserPromise;
|
|
517
518
|
}
|
|
518
519
|
|
|
520
|
+
/**
|
|
521
|
+
* @param {string} label - Minifier name as it should read in the message
|
|
522
|
+
* @param {string} specifier - Package that failed to load
|
|
523
|
+
* @param {unknown} cause - Error the import rejected with
|
|
524
|
+
* @returns {Error} Error marked as an unavailable dependency
|
|
525
|
+
*/
|
|
526
|
+
function unavailableDependency(label, specifier, cause) {
|
|
527
|
+
const err = new Error(describeDependencyFailure(label, specifier, cause), { cause });
|
|
528
|
+
/** @type {any} */ (err).code = MISSING_DEPENDENCY;
|
|
529
|
+
return err;
|
|
530
|
+
}
|
|
531
|
+
|
|
519
532
|
/** @type {Promise<any> | undefined} */
|
|
520
533
|
let swcPromise;
|
|
521
534
|
async function getSwc() {
|
|
522
535
|
if (!swcPromise) {
|
|
523
536
|
swcPromise = import('@swc/core')
|
|
524
537
|
.then(m => m.default || m)
|
|
525
|
-
.catch(
|
|
526
|
-
throw
|
|
527
|
-
'The swc minifier requires @swc/core to be installed.\n' +
|
|
528
|
-
'Install it with: npm install @swc/core'
|
|
529
|
-
);
|
|
538
|
+
.catch(err => {
|
|
539
|
+
throw unavailableDependency('swc', '@swc/core', err);
|
|
530
540
|
});
|
|
531
541
|
}
|
|
532
542
|
return swcPromise;
|
package/src/lib/constants.js
CHANGED
|
@@ -207,6 +207,10 @@ const escapableRawTextElements = new Set(['textarea', 'title']);
|
|
|
207
207
|
// of `textarea` and `title`, where they are resolved as they are anywhere else
|
|
208
208
|
const rawTextElements = new Set([...specialContentElements, ...genericRawTextElements]);
|
|
209
209
|
|
|
210
|
+
// Marks the error for a minifier that was asked for but isn’t available—a
|
|
211
|
+
// configuration error, and so not one that `continueOnMinifyError` waves through
|
|
212
|
+
const MISSING_DEPENDENCY = 'HMN_MISSING_DEPENDENCY';
|
|
213
|
+
|
|
210
214
|
// Exports
|
|
211
215
|
|
|
212
216
|
export {
|
|
@@ -256,6 +260,7 @@ export {
|
|
|
256
260
|
|
|
257
261
|
// Misc
|
|
258
262
|
srcsetElements,
|
|
263
|
+
MISSING_DEPENDENCY,
|
|
259
264
|
|
|
260
265
|
// Tag omission rules
|
|
261
266
|
optionalStartTags,
|
package/src/lib/file-pool.js
CHANGED
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
* worker runs its own isolate and warms up its own JIT, so the useful worker count tops
|
|
16
16
|
* out well short of the core count.
|
|
17
17
|
*
|
|
18
|
-
* Node-only: cli.js loads this module lazily and minifies in
|
|
18
|
+
* Node-only: cli.js loads this module lazily and minifies in-process wherever worker
|
|
19
19
|
* threads are unavailable or the options can’t cross a structured clone.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'node:fs';
|
|
23
23
|
import { isMainThread, parentPort, workerData, Worker } from 'node:worker_threads';
|
|
24
|
+
import { writeFileAtomic } from './file-write.js';
|
|
24
25
|
|
|
25
26
|
// This module is its own worker entry point: The pool spawns it by URL and the branch
|
|
26
27
|
// below runs in the spawned copy. Keeping both halves in one file keeps the message
|
|
@@ -61,7 +62,7 @@ if (!isMainThread && parentPort) {
|
|
|
61
62
|
const minified = await minify(data, taskOptions);
|
|
62
63
|
if (!task.dryRun) {
|
|
63
64
|
stage = 'write';
|
|
64
|
-
await
|
|
65
|
+
await writeFileAtomic(task.outputFile, minified);
|
|
65
66
|
}
|
|
66
67
|
port.postMessage({
|
|
67
68
|
id: task.id,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output writing for the CLI, shared by in-process runs and the worker pool
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import crypto from 'node:crypto';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
// A random name is taken by chance only, so a few attempts are plenty
|
|
10
|
+
const ATTEMPTS_MAX = 10;
|
|
11
|
+
// As many links as a system commonly follows before reporting a loop
|
|
12
|
+
const LINKS_MAX = 40;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The file a write replaces: the output itself or, for a symlink, the file it
|
|
16
|
+
* points to—followed by hand where that file does not exist yet, which
|
|
17
|
+
* `realpath` cannot resolve
|
|
18
|
+
* @param {string} outputFile
|
|
19
|
+
* @returns {Promise<string>}
|
|
20
|
+
*/
|
|
21
|
+
async function resolveTarget(outputFile) {
|
|
22
|
+
let file = outputFile;
|
|
23
|
+
for (let i = 0; i < LINKS_MAX; i++) {
|
|
24
|
+
try {
|
|
25
|
+
return await fs.promises.realpath(file);
|
|
26
|
+
} catch {
|
|
27
|
+
const link = await fs.promises.readlink(file).catch(() => undefined);
|
|
28
|
+
if (link === undefined) return file;
|
|
29
|
+
// A relative link is read from the real location of its folder
|
|
30
|
+
const dir = await fs.promises.realpath(path.dirname(file)).catch(() => path.dirname(file));
|
|
31
|
+
file = path.resolve(dir, link);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// A loop, which writing through would not resolve, either—refused so the rename cannot replace the link
|
|
35
|
+
throw Object.assign(new Error(`ELOOP: Too many symbolic links encountered, '${outputFile}'`), { code: 'ELOOP', path: outputFile });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a temporary file next to the target under a random name, exclusively,
|
|
40
|
+
* so that it can neither be predicted nor write through a file or link already there
|
|
41
|
+
* @param {string} targetFile
|
|
42
|
+
* @param {number | undefined} mode
|
|
43
|
+
*/
|
|
44
|
+
async function openTempFile(targetFile, mode) {
|
|
45
|
+
for (let attempt = 1; ; attempt++) {
|
|
46
|
+
const tempFile = path.join(path.dirname(targetFile), `.${path.basename(targetFile)}.${crypto.randomBytes(8).toString('hex')}.tmp`);
|
|
47
|
+
try {
|
|
48
|
+
return { tempFile, handle: await fs.promises.open(tempFile, 'wx', mode) };
|
|
49
|
+
} catch (err) {
|
|
50
|
+
if (/** @type {any} */ (err).code !== 'EEXIST' || attempt >= ATTEMPTS_MAX) throw err;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Write a file by way of a temporary file in the same folder, so that an exit
|
|
57
|
+
* that leaves no chance to clean up—a native crash in a minifier, an OOM
|
|
58
|
+
* kill—cannot leave a half-written file where the output belongs
|
|
59
|
+
* @param {string} outputFile
|
|
60
|
+
* @param {string} data
|
|
61
|
+
*/
|
|
62
|
+
export async function writeFileAtomic(outputFile, data) {
|
|
63
|
+
// A rename would replace a symlink itself, so work on the file it points to
|
|
64
|
+
const targetFile = await resolveTarget(outputFile);
|
|
65
|
+
// The rename replaces the output rather than writing through it, so a mode set on the output has to be carried over
|
|
66
|
+
const stats = await fs.promises.stat(targetFile).catch(() => undefined);
|
|
67
|
+
const mode = stats ? stats.mode & 0o7777 : undefined;
|
|
68
|
+
|
|
69
|
+
// Outside the `try`, so that only a file this write created is ever removed
|
|
70
|
+
const { tempFile, handle } = await openTempFile(targetFile, mode);
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
try {
|
|
74
|
+
await handle.writeFile(data, 'utf8');
|
|
75
|
+
} finally {
|
|
76
|
+
await handle.close();
|
|
77
|
+
}
|
|
78
|
+
// `mode` on creation is subject to the umask, so the exact bits have to be set separately
|
|
79
|
+
if (mode !== undefined) {
|
|
80
|
+
await fs.promises.chmod(tempFile, mode);
|
|
81
|
+
}
|
|
82
|
+
await fs.promises.rename(tempFile, targetFile);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
await fs.promises.rm(tempFile, { force: true });
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/lib/options.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { createUrlMinifier } from './urls.js';
|
|
6
6
|
import { LRU, MAX_CACHE_ENTRY_SIZE, stableStringify, hashContent, identity, lowercase, paramCase, replaceAsync, parseRegExp, describeQuantifierRisk, lostFlag } from './utils.js';
|
|
7
|
-
import { RE_TRAILING_SEMICOLON } from './constants.js';
|
|
7
|
+
import { RE_TRAILING_SEMICOLON, MISSING_DEPENDENCY } from './constants.js';
|
|
8
8
|
import { canCollapseWhitespace, canTrimWhitespace } from './whitespace.js';
|
|
9
9
|
import { wrapCSS, unwrapCSS } from './content.js';
|
|
10
10
|
import { findUnusedSymbols, normalizeUnusedCSSOptions } from './unused-css.js';
|
|
@@ -152,6 +152,33 @@ function isRequested(value) {
|
|
|
152
152
|
return Array.isArray(value) ? value.length > 0 : Boolean(value);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
/** @param {unknown} err - Error raised while minifying */
|
|
156
|
+
function isMissingDependency(err) {
|
|
157
|
+
return Boolean(err) && /** @type {any} */ (err).code === MISSING_DEPENDENCY;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// An unset (falsy) engine takes the fallback and names match lowercase; anything else
|
|
161
|
+
// passes through untouched so that validation reports it instead of a type error
|
|
162
|
+
/**
|
|
163
|
+
* @param {unknown} engine - Configured engine name
|
|
164
|
+
* @param {string} fallback - Engine to use when none is configured
|
|
165
|
+
*/
|
|
166
|
+
function normalizeEngine(engine, fallback) {
|
|
167
|
+
if (!engine) return fallback;
|
|
168
|
+
return typeof engine === 'string' ? engine.toLowerCase() : engine;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** @param {unknown} engine - Engine name as it should read in an error message */
|
|
172
|
+
function describeEngine(engine) {
|
|
173
|
+
if (typeof engine === 'string') return engine;
|
|
174
|
+
try {
|
|
175
|
+
return JSON.stringify(engine) ?? String(engine);
|
|
176
|
+
} catch {
|
|
177
|
+
// BigInt and cyclic values do not serialize
|
|
178
|
+
return String(engine);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
155
182
|
// Main options processor
|
|
156
183
|
|
|
157
184
|
/**
|
|
@@ -433,12 +460,12 @@ const processOptions = (inputOptions, { getLightningCSS, getTerser, getSwc, getS
|
|
|
433
460
|
|
|
434
461
|
// Parse configuration
|
|
435
462
|
const config = typeof option === 'object' ? option : {};
|
|
436
|
-
const engine = (config.engine
|
|
463
|
+
const engine = normalizeEngine(config.engine, 'terser');
|
|
437
464
|
|
|
438
465
|
// Validate engine
|
|
439
466
|
const supportedEngines = ['terser', 'swc'];
|
|
440
|
-
if (!supportedEngines.includes(engine)) {
|
|
441
|
-
throw new Error(`Unsupported JS minifier engine:
|
|
467
|
+
if (!supportedEngines.includes(/** @type {string} */ (engine))) {
|
|
468
|
+
throw new Error(`Unsupported JS minifier engine: \`${describeEngine(engine)}\`. Supported engines: ${supportedEngines.join(', ')}`);
|
|
442
469
|
}
|
|
443
470
|
|
|
444
471
|
// Extract engine-specific options (excluding `engine` field itself)
|
|
@@ -530,7 +557,7 @@ const processOptions = (inputOptions, { getLightningCSS, getTerser, getSwc, getS
|
|
|
530
557
|
return resolved;
|
|
531
558
|
} catch (err) {
|
|
532
559
|
if (jsKey !== undefined) jsCache.delete(jsKey);
|
|
533
|
-
if (!options.continueOnMinifyError) {
|
|
560
|
+
if (!options.continueOnMinifyError || isMissingDependency(err)) {
|
|
534
561
|
throw err;
|
|
535
562
|
}
|
|
536
563
|
options.log && options.log(err);
|
package/src/lib/utils.js
CHANGED
|
@@ -2,13 +2,35 @@
|
|
|
2
2
|
* General utility functions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
// Functions and other non-plain objects have no structure to compare (closures with the
|
|
6
|
+
// same source can behave differently), so they are told apart by identity
|
|
7
|
+
/** @type {WeakMap<object, number>} */
|
|
8
|
+
const objectIds = new WeakMap();
|
|
9
|
+
let objectIdLast = 0;
|
|
10
|
+
|
|
11
|
+
/** @param {object} obj */
|
|
12
|
+
function objectId(obj) {
|
|
13
|
+
let id = objectIds.get(obj);
|
|
14
|
+
if (id === undefined) {
|
|
15
|
+
id = ++objectIdLast;
|
|
16
|
+
objectIds.set(obj, id);
|
|
17
|
+
}
|
|
18
|
+
return id;
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
/**
|
|
22
|
+
* Stringify with sorted keys, for cache keys—values that can behave differently must not
|
|
23
|
+
* stringify alike, so unquoted markers stand in for what JSON cannot express
|
|
6
24
|
* @param {unknown} obj
|
|
7
25
|
* @returns {string}
|
|
8
26
|
*/
|
|
9
27
|
function stableStringify(obj) {
|
|
28
|
+
if (typeof obj === 'function') return 'function#' + objectId(obj);
|
|
10
29
|
if (obj == null || typeof obj !== 'object') return JSON.stringify(obj);
|
|
30
|
+
if (obj instanceof RegExp) return String(obj);
|
|
11
31
|
if (Array.isArray(obj)) return '[' + obj.map(stableStringify).join(',') + ']';
|
|
32
|
+
const proto = Object.getPrototypeOf(obj);
|
|
33
|
+
if (proto !== Object.prototype && proto !== null) return 'object#' + objectId(obj);
|
|
12
34
|
const keys = Object.keys(obj).sort();
|
|
13
35
|
let out = '{';
|
|
14
36
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -840,6 +862,28 @@ function findTagEnd(html, pos, limit = html.length) {
|
|
|
840
862
|
return -1;
|
|
841
863
|
}
|
|
842
864
|
|
|
865
|
+
/**
|
|
866
|
+
* A package that resolves but fails to load—e.g., a native binding built for
|
|
867
|
+
* another platform—is not one another `npm install` fixes, so name what happened
|
|
868
|
+
* rather than the install command
|
|
869
|
+
*
|
|
870
|
+
* @param {string} label - Minifier name as it should read in the message
|
|
871
|
+
* @param {string} specifier - Package that failed to load
|
|
872
|
+
* @param {unknown} cause - Error the import rejected with
|
|
873
|
+
* @returns {string} Message describing the failure
|
|
874
|
+
*/
|
|
875
|
+
function describeDependencyFailure(label, specifier, cause) {
|
|
876
|
+
const err = /** @type {any} */ (cause);
|
|
877
|
+
const notInstalled =
|
|
878
|
+
err?.code === 'ERR_MODULE_NOT_FOUND' && String(err?.message).includes(`'${specifier}'`);
|
|
879
|
+
if (notInstalled) {
|
|
880
|
+
return `The ${label} minifier requires ${specifier} to be installed.\n` +
|
|
881
|
+
`Install it with: npm install ${specifier}`;
|
|
882
|
+
}
|
|
883
|
+
return `The ${label} minifier could not load ${specifier}: ` +
|
|
884
|
+
(cause instanceof Error ? cause.message : String(cause));
|
|
885
|
+
}
|
|
886
|
+
|
|
843
887
|
// Exports
|
|
844
888
|
|
|
845
889
|
export {
|
|
@@ -857,5 +901,6 @@ export {
|
|
|
857
901
|
parseRegExp,
|
|
858
902
|
embedSource,
|
|
859
903
|
lostFlag,
|
|
860
|
-
describeQuantifierRisk
|
|
904
|
+
describeQuantifierRisk,
|
|
905
|
+
describeDependencyFailure
|
|
861
906
|
};
|