carbon-preprocess-svelte 0.11.1 → 0.11.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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const compare_diff_1 = require("./compare-diff");
4
+ const print_diff_1 = require("./print-diff");
5
5
  const create_optimized_css_1 = require("./create-optimized-css");
6
6
  // Webpack plugin to optimize CSS for Carbon Svelte components.
7
7
  class OptimizeCssPlugin {
@@ -38,7 +38,7 @@ class OptimizeCssPlugin {
38
38
  const optimized_css = (0, create_optimized_css_1.createOptimizedCss)(original_css, ids, this.options);
39
39
  compilation.updateAsset(id, new RawSource(optimized_css));
40
40
  if (this.options.verbose) {
41
- (0, compare_diff_1.compareDiff)({ original_css, optimized_css, id });
41
+ (0, print_diff_1.printDiff)({ original_css, optimized_css, id });
42
42
  }
43
43
  }
44
44
  }
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.optimizeCss = void 0;
13
13
  const utils_1 = require("../utils");
14
- const compare_diff_1 = require("./compare-diff");
14
+ const print_diff_1 = require("./print-diff");
15
15
  const create_optimized_css_1 = require("./create-optimized-css");
16
16
  // Vite plugin (Rollup-compatible) to optimize CSS for Carbon Svelte components.
17
17
  const optimizeCss = (options) => {
@@ -38,7 +38,7 @@ const optimizeCss = (options) => {
38
38
  const optimized_css = (0, create_optimized_css_1.createOptimizedCss)(original_css, ids, options);
39
39
  file.source = optimized_css;
40
40
  if (verbose) {
41
- (0, compare_diff_1.compareDiff)({ original_css, optimized_css, id });
41
+ (0, print_diff_1.printDiff)({ original_css, optimized_css, id });
42
42
  }
43
43
  }
44
44
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- export declare function compareDiff(props: {
2
+ export declare function printDiff(props: {
3
3
  original_css: Uint8Array | Buffer | string;
4
4
  optimized_css: string;
5
5
  id: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareDiff = void 0;
3
+ exports.printDiff = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const formatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
6
6
  function toHumanReadableSize(size_in_kb) {
@@ -19,10 +19,13 @@ function stringSizeInKB(str) {
19
19
  function padIfNeeded(a, b) {
20
20
  return a.length > b.length ? a : a.padStart(b.length, " ");
21
21
  }
22
- function compareDiff(props) {
22
+ function printDiff(props) {
23
23
  const { original_css, optimized_css, id } = props;
24
24
  const original_size = stringSizeInKB(original_css.toString());
25
25
  const optimized_size = stringSizeInKB(optimized_css);
26
+ if (original_size === optimized_size) {
27
+ return;
28
+ }
26
29
  const original = toHumanReadableSize(original_size);
27
30
  const optimized = toHumanReadableSize(optimized_size);
28
31
  const original_display = padIfNeeded(original, optimized);
@@ -33,4 +36,4 @@ function compareDiff(props) {
33
36
  console.log("Before:", original_display);
34
37
  console.log("After: ", optimized_display, `(-${diff})\n`);
35
38
  }
36
- exports.compareDiff = compareDiff;
39
+ exports.printDiff = printDiff;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-preprocess-svelte",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Svelte preprocessors for the Carbon Design System",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/bun": "latest",
21
+ "@types/jest": "^29.5.12",
21
22
  "carbon-components-svelte": "0.85.0",
22
23
  "prettier": "latest",
23
24
  "svelte": "latest",