domflax 0.1.4 → 0.2.0
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 +47 -29
- package/dist/{chunk-EVENAJYI.js → chunk-EYQXQQQH.js} +3 -3
- package/dist/{chunk-3Z5ZWLXX.js → chunk-FPT4EJ6Q.js} +805 -1612
- package/dist/chunk-FPT4EJ6Q.js.map +1 -0
- package/dist/{chunk-5FWENSD2.js → chunk-JBM3MJRM.js} +149 -10
- package/dist/chunk-JBM3MJRM.js.map +1 -0
- package/dist/{chunk-H5KTGI3A.js → chunk-TTJEXWAC.js} +172 -5
- package/dist/chunk-TTJEXWAC.js.map +1 -0
- package/dist/cli.cjs +1032 -1640
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +30 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1116 -1627
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +226 -485
- package/dist/index.d.ts +226 -485
- package/dist/index.js +16 -36
- package/dist/{pattern-CP9_HpVK.d.cts → pattern-DotR_dHs.d.cts} +1 -1
- package/dist/pattern-kit.cjs +60 -1
- package/dist/pattern-kit.cjs.map +1 -1
- package/dist/pattern-kit.d.cts +2 -2
- package/dist/pattern-kit.d.ts +2 -2
- package/dist/pattern-kit.js +1 -1
- package/dist/{pattern-CYgsv-jO.d.ts → pattern-urm5uuwj.d.ts} +1 -1
- package/dist/{resolve-ops-Ci7LgYHC.d.ts → resolve-ops-D8aQina5.d.cts} +11 -0
- package/dist/{resolve-ops-Ci7LgYHC.d.cts → resolve-ops-D8aQina5.d.ts} +11 -0
- package/dist/verify.d.cts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/webpack-loader.cjs +1014 -1578
- package/dist/webpack-loader.cjs.map +1 -1
- package/dist/webpack-loader.d.cts +8 -2
- package/dist/webpack-loader.d.ts +8 -2
- package/dist/webpack-loader.js +7 -4
- package/dist/webpack-loader.js.map +1 -1
- package/dist/worker.cjs +983 -1601
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-3Z5ZWLXX.js.map +0 -1
- package/dist/chunk-5FWENSD2.js.map +0 -1
- package/dist/chunk-H5KTGI3A.js.map +0 -1
- /package/dist/{chunk-EVENAJYI.js.map → chunk-EYQXQQQH.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
destinationFor,
|
|
5
5
|
isGitClean,
|
|
6
6
|
planWrites
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-EYQXQQQH.js";
|
|
8
|
+
import "./chunk-FPT4EJ6Q.js";
|
|
9
|
+
import "./chunk-TTJEXWAC.js";
|
|
10
10
|
import {
|
|
11
11
|
__commonJS,
|
|
12
12
|
__dirname,
|
|
@@ -185,6 +185,7 @@ function parseInvocation(argv) {
|
|
|
185
185
|
css: { type: "string", multiple: true },
|
|
186
186
|
"dry-run": { type: "boolean", default: false },
|
|
187
187
|
report: { type: "boolean", default: false },
|
|
188
|
+
details: { type: "boolean", default: false },
|
|
188
189
|
"dangerously-overwrite-source": { type: "boolean", default: false },
|
|
189
190
|
"no-git-check": { type: "boolean", default: false },
|
|
190
191
|
"no-interactive": { type: "boolean", default: false },
|
|
@@ -206,6 +207,7 @@ function parseInvocation(argv) {
|
|
|
206
207
|
css: values.css ?? [],
|
|
207
208
|
dryRun: values["dry-run"] === true,
|
|
208
209
|
report: values.report === true,
|
|
210
|
+
details: values.details === true,
|
|
209
211
|
dangerouslyOverwriteSource: values["dangerously-overwrite-source"] === true,
|
|
210
212
|
noGitCheck: values["no-git-check"] === true,
|
|
211
213
|
interactive: values["no-interactive"] !== true && values.yes !== true,
|
|
@@ -222,7 +224,7 @@ function shouldPrompt(options, isTty) {
|
|
|
222
224
|
var USAGE = [
|
|
223
225
|
"Usage: domflax [paths...] [options]",
|
|
224
226
|
"",
|
|
225
|
-
"Optimizes .jsx/.tsx files (flatten redundant wrappers + compress class sets).",
|
|
227
|
+
"Optimizes .jsx/.tsx/.html files (flatten redundant wrappers + compress class sets).",
|
|
226
228
|
"Source is READ-ONLY by default \u2014 output goes to --out or ./domflax-out.",
|
|
227
229
|
"",
|
|
228
230
|
"Arguments:",
|
|
@@ -234,6 +236,7 @@ var USAGE = [
|
|
|
234
236
|
" --css <file...> stylesheets feeding the custom-CSS provider",
|
|
235
237
|
" --dry-run print per-file diffs; write nothing",
|
|
236
238
|
" --report print a summary of what changed",
|
|
239
|
+
" --details print per-file optimization stats (nodes/classes/bytes)",
|
|
237
240
|
" --dangerously-overwrite-source overwrite source in place (needs a clean git tree)",
|
|
238
241
|
" --no-git-check skip the clean-git-tree gate",
|
|
239
242
|
" --safety <0|1|2|3> optimization aggressiveness (default: 2)",
|
|
@@ -307,6 +310,7 @@ function runPool(files, init, plan, onWrote) {
|
|
|
307
310
|
const workerPath = resolveWorkerPath();
|
|
308
311
|
const totals = emptyTotals();
|
|
309
312
|
const wrote = [];
|
|
313
|
+
const changedFiles = [];
|
|
310
314
|
const errors = [];
|
|
311
315
|
let failures = 0;
|
|
312
316
|
const budgetBytes = plan.budgetMB * 1024 * 1024;
|
|
@@ -329,7 +333,7 @@ function runPool(files, init, plan, onWrote) {
|
|
|
329
333
|
}
|
|
330
334
|
}
|
|
331
335
|
handles.clear();
|
|
332
|
-
resolve3({ totals, failures, wrote, errors });
|
|
336
|
+
resolve3({ totals, failures, wrote, changedFiles, errors });
|
|
333
337
|
};
|
|
334
338
|
const recordFailure = (file, error) => {
|
|
335
339
|
failures += 1;
|
|
@@ -369,6 +373,7 @@ function runPool(files, init, plan, onWrote) {
|
|
|
369
373
|
addStats(totals, msg.stats, msg.changed);
|
|
370
374
|
if (msg.wrote) {
|
|
371
375
|
wrote.push(msg.wrote);
|
|
376
|
+
changedFiles.push({ dest: msg.wrote, stats: msg.stats });
|
|
372
377
|
onWrote?.(msg.wrote);
|
|
373
378
|
}
|
|
374
379
|
} else {
|
|
@@ -1304,6 +1309,9 @@ async function runWizard(base) {
|
|
|
1304
1309
|
}
|
|
1305
1310
|
|
|
1306
1311
|
// ../cli/src/index.ts
|
|
1312
|
+
function fileDetail(stats) {
|
|
1313
|
+
return `${stats.nodesRemoved} nodes, ${stats.classesSaved} classes, ${stats.bytesSaved} bytes`;
|
|
1314
|
+
}
|
|
1307
1315
|
function printReport(totals) {
|
|
1308
1316
|
console.log("");
|
|
1309
1317
|
console.log("domflax report");
|
|
@@ -1329,8 +1337,13 @@ function runInline(files, options, inputRoot, plan, totals) {
|
|
|
1329
1337
|
addStats(totals, result.stats, result.changed);
|
|
1330
1338
|
if (options.dryRun) {
|
|
1331
1339
|
const rel = path4.relative(inputRoot, file) || path4.basename(file);
|
|
1332
|
-
if (result.changed)
|
|
1333
|
-
|
|
1340
|
+
if (result.changed) {
|
|
1341
|
+
console.log(
|
|
1342
|
+
options.details ? `domflax: ${rel} \u2014 ${fileDetail(result.stats)}` : unifiedDiff(code, result.code, rel)
|
|
1343
|
+
);
|
|
1344
|
+
} else if (!options.report && !options.details) {
|
|
1345
|
+
console.log(` (unchanged) ${rel}`);
|
|
1346
|
+
}
|
|
1334
1347
|
continue;
|
|
1335
1348
|
}
|
|
1336
1349
|
if (!result.changed) continue;
|
|
@@ -1343,7 +1356,8 @@ function runInline(files, options, inputRoot, plan, totals) {
|
|
|
1343
1356
|
try {
|
|
1344
1357
|
mkdirSync(path4.dirname(target.value), { recursive: true });
|
|
1345
1358
|
writeFileSync(target.value, result.code, "utf8");
|
|
1346
|
-
|
|
1359
|
+
const rel = path4.relative(process.cwd(), target.value) || target.value;
|
|
1360
|
+
console.log(options.details ? `domflax: wrote ${rel} \u2014 ${fileDetail(result.stats)}` : `domflax: wrote ${rel}`);
|
|
1347
1361
|
} catch (err) {
|
|
1348
1362
|
console.error(`domflax: cannot write ${target.value}: ${String(err?.message ?? err)}`);
|
|
1349
1363
|
failures += 1;
|
|
@@ -1382,8 +1396,14 @@ async function execute(options) {
|
|
|
1382
1396
|
for (const { path: p2, error } of outcome.errors) {
|
|
1383
1397
|
console.error(`domflax: failed ${path4.relative(process.cwd(), p2) || p2}: ${error}`);
|
|
1384
1398
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1399
|
+
if (options.details) {
|
|
1400
|
+
for (const { dest, stats } of [...outcome.changedFiles].sort((a, b3) => a.dest.localeCompare(b3.dest))) {
|
|
1401
|
+
console.log(`domflax: wrote ${path4.relative(process.cwd(), dest) || dest} \u2014 ${fileDetail(stats)}`);
|
|
1402
|
+
}
|
|
1403
|
+
} else {
|
|
1404
|
+
for (const dest of [...outcome.wrote].sort()) {
|
|
1405
|
+
console.log(`domflax: wrote ${path4.relative(process.cwd(), dest) || dest}`);
|
|
1406
|
+
}
|
|
1387
1407
|
}
|
|
1388
1408
|
} else {
|
|
1389
1409
|
failures += runInline(files, options, inputRoot, plan, totals);
|