@animus-ui/vite-plugin 0.1.50 → 0.1.51

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.
@@ -1 +1 @@
1
- {"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAa/D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAY/D;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,WAAW,EAC7B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CA4If"}
1
+ {"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAa/D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAY/D;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,WAAW,EAC7B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CAgJf"}
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-removal.d.ts","sourceRoot":"","sources":["../src/bundle-removal.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,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E,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,KAAK,IAAI,CAAC;CAC9C,GACA,aAAa,GAAG,IAAI,CAiJtB"}
package/dist/index.cjs CHANGED
@@ -171,7 +171,8 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
171
171
  }).length;
172
172
  const componentSize = ctx.resolvedComponentCss.length;
173
173
  ctx.log(`Delivery: split mode — static ${staticSize} bytes, components ${componentSize} bytes (adopted stylesheet)`);
174
- } else ctx.log("Delivery: single file mode (production)");
174
+ } else if (ctx.splitsStylesheet) ctx.log("Delivery: split mode (production), linking each slice from the page");
175
+ else ctx.log("Delivery: single file mode (production)");
175
176
  }
176
177
  const { declaration } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
177
178
  layers: ctx.options.layers,
@@ -516,19 +517,26 @@ function bundleRemoval(ctx, bundle, sliceIds, context) {
516
517
  const classes = new Set(removed.values());
517
518
  let characters = 0;
518
519
  const renamed = /* @__PURE__ */ new Map();
520
+ const went = /* @__PURE__ */ new Set();
521
+ const kept = /* @__PURE__ */ new Map();
522
+ const unread = /* @__PURE__ */ new Set();
519
523
  return {
520
524
  replace(file) {
521
525
  const css = Buffer.from(file.source).toString("utf8");
522
- let pruned;
526
+ let removal;
523
527
  try {
524
- pruned = (0, _animus_ui_extract_pipeline.removeComponentRules)(css, classes, {
528
+ removal = (0, _animus_ui_extract_pipeline.removeComponentRules)(css, classes, {
525
529
  targets: ctx.lcssTargets,
526
530
  keepDirSelector: ctx.options.keepDirSelector
527
531
  });
528
532
  } catch (error) {
529
533
  ctx.warn(`[animus-extract] removeUnbundledComponents kept ${file.fileName} whole: Lightning CSS could not read it (${error instanceof Error ? error.message : String(error)})`);
534
+ for (const name of classes) if (css.includes(name)) unread.add(name);
530
535
  return null;
531
536
  }
537
+ for (const name of removal.went) went.add(name);
538
+ for (const [name, reason] of removal.kept) (0, _animus_ui_extract_pipeline.noteKept)(kept, name, reason);
539
+ const { css: pruned } = removal;
532
540
  if (pruned === null) return null;
533
541
  characters += css.length - pruned.length;
534
542
  const extension = node_path.posix.extname(file.fileName);
@@ -552,11 +560,35 @@ function bundleRemoval(ctx, bundle, sliceIds, context) {
552
560
  for (const [before, after] of renamed) text = text.replaceAll(JSON.stringify(before).slice(1, -1), JSON.stringify(after).slice(1, -1));
553
561
  file.source = text;
554
562
  }
555
- if (ctx.tracing) for (const [id, className] of removed) ctx.trace(`removed ${id} (${className}): no output file includes it`);
556
- ctx.info(`removed the CSS of ${removed.size} of ${Object.keys(components).length} components no output file includes (${characters} characters of the stylesheet)`);
563
+ let count = 0;
564
+ let ruleless = 0;
565
+ const whole = /* @__PURE__ */ new Map();
566
+ for (const [id, className] of removed) {
567
+ const reason = kept.get(className) ?? (unread.has(className) ? "unreadable" : void 0);
568
+ if (went.has(className)) {
569
+ count += 1;
570
+ ctx.trace(`removed ${id} (${className}): no output file includes it`);
571
+ } else if (reason === void 0) {
572
+ ruleless += 1;
573
+ ctx.trace(`${id} (${className}): no output file includes it, and no rule names it`);
574
+ } else {
575
+ whole.set(reason, (whole.get(reason) ?? 0) + 1);
576
+ ctx.trace(`kept ${id} (${className}) whole, though no output file includes it: ${KEPT_WHOLE[reason]}`);
577
+ }
578
+ }
579
+ const keptWhole = [...whole].map(([reason, n]) => `${KEPT_WHOLE[reason]}: ${n}`).join(", ");
580
+ const wholeCount = [...whole.values()].reduce((sum, n) => sum + n, 0);
581
+ ctx.info(`removed the CSS of ${count} of ${Object.keys(components).length} components no output file includes (${characters} characters of the stylesheet)${wholeCount > 0 ? `; kept ${wholeCount} more whole (${keptWhole})` : ""}${ruleless > 0 ? `; with no rules to remove: ${ruleless}` : ""}`);
557
582
  }
558
583
  };
559
584
  }
585
+ /** Each reason, as the trace and the build's report print it. */
586
+ const KEPT_WHOLE = {
587
+ "shared-list": "shares a selector list with a kept component",
588
+ nested: "a rule naming it holds nested rules removal cannot prove unused",
589
+ conditional: "named only where a selector can match without it, or in a pseudo-class argument removal does not read, such as :not(), :has(), :host(), or an :is() or :where() with an alternative that does not need it",
590
+ unreadable: "in a stylesheet Lightning CSS could not read"
591
+ };
560
592
  /** How many times `needle` occurs in `text`. */
561
593
  function occurrences(text, needle) {
562
594
  let count = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/vite-plugin",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "description": "Animus static CSS extraction Vite plugin",
5
5
  "keywords": [
6
6
  "animus",
@@ -43,16 +43,16 @@
43
43
  "compile": "bun check"
44
44
  },
45
45
  "dependencies": {
46
- "@animus-ui/extract": "0.1.50",
46
+ "@animus-ui/extract": "0.1.51",
47
47
  "browserslist": "^4.28.8",
48
48
  "lightningcss": "^1.33.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@animus-ui/assertions": "0.1.50",
52
- "@animus-ui/layergate": "0.1.50"
51
+ "@animus-ui/assertions": "0.1.51",
52
+ "@animus-ui/layergate": "0.1.51"
53
53
  },
54
54
  "peerDependencies": {
55
- "@animus-ui/layergate": "0.1.50",
55
+ "@animus-ui/layergate": "0.1.51",
56
56
  "vite": ">=8 <9"
57
57
  },
58
58
  "peerDependenciesMeta": {