carbon-preprocess-svelte 0.11.3 → 0.11.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 CHANGED
@@ -49,7 +49,7 @@ The preprocessor optimizes imports from the following packages:
49
49
 
50
50
  > [!NOTE]
51
51
  > When this preprocessor was first created, there was no workaround to optimize slow cold start times with Vite in development.
52
- > As of today, [@sveltejs/vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte) enables [`prebundleSvelteLibraries`](https://github.com/sveltejs/vite-plugin-svelte/blob/ba4ac32cf5c3e9c048d1ac430c1091ca08eaa130/docs/config.md#prebundlesveltelibraries), which pre-bundles Svelte libraries to improve cold start times for Vite-based set-ups.
52
+ > As of today, [@sveltejs/vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte) enables [`prebundleSvelteLibraries`](https://github.com/sveltejs/vite-plugin-svelte/blob/ba4ac32cf5c3e9c048d1ac430c1091ca08eaa130/docs/config.md#prebundlesveltelibraries) by default, which greatly improves development times.
53
53
  > However, this preprocessor is still useful for non-Vite bundlers, like Rollup and Webpack.
54
54
 
55
55
  #### SvelteKit
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createOptimizedCss = void 0;
6
+ exports.createOptimizedCss = createOptimizedCss;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const postcss_1 = __importDefault(require("postcss"));
9
9
  const postcss_discard_empty_1 = __importDefault(require("postcss-discard-empty"));
@@ -69,6 +69,10 @@ function createOptimizedCss(options) {
69
69
  break;
70
70
  }
71
71
  });
72
+ // Do not proceed if font is not IBM Plex.
73
+ if (!attributes["font-family"].startsWith("IBM Plex")) {
74
+ return;
75
+ }
72
76
  const is_mono = attributes["font-style"] === "normal" &&
73
77
  attributes["font-family"] === "IBM Plex Mono" &&
74
78
  attributes["font-weight"] === "400";
@@ -84,4 +88,3 @@ function createOptimizedCss(options) {
84
88
  (0, postcss_discard_empty_1.default)(),
85
89
  ]).process(source).css;
86
90
  }
87
- exports.createOptimizedCss = createOptimizedCss;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare function printDiff(props: {
3
2
  original_css: Uint8Array | Buffer | string;
4
3
  optimized_css: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printDiff = void 0;
3
+ exports.printDiff = printDiff;
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) {
@@ -36,4 +36,3 @@ function printDiff(props) {
36
36
  console.log("Before:", original_display);
37
37
  console.log("After: ", optimized_display, `(-${diff})\n`);
38
38
  }
39
- exports.printDiff = printDiff;
@@ -1,3 +1,2 @@
1
- /// <reference types="svelte" />
2
1
  import type { SveltePreprocessor } from "svelte/types/compiler/preprocess";
3
2
  export declare const optimizeImports: SveltePreprocessor<"script">;
package/dist/utils.js CHANGED
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCarbonSvelteImport = exports.isCssFile = exports.isSvelteFile = void 0;
3
+ exports.isSvelteFile = isSvelteFile;
4
+ exports.isCssFile = isCssFile;
5
+ exports.isCarbonSvelteImport = isCarbonSvelteImport;
4
6
  const constants_1 = require("./constants");
5
7
  function isSvelteFile(id) {
6
8
  return constants_1.RE_EXT_SVELTE.test(id);
7
9
  }
8
- exports.isSvelteFile = isSvelteFile;
9
10
  function isCssFile(id) {
10
11
  return constants_1.RE_EXT_CSS.test(id);
11
12
  }
12
- exports.isCssFile = isCssFile;
13
13
  function isCarbonSvelteImport(id) {
14
14
  return isSvelteFile(id) && id.includes("carbon-components-svelte" /* CarbonSvelte.Components */);
15
15
  }
16
- exports.isCarbonSvelteImport = isCarbonSvelteImport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-preprocess-svelte",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
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)",
@@ -9,12 +9,13 @@
9
9
  "scripts": {
10
10
  "index:components": "bun scripts/index-components.ts",
11
11
  "build": "bun --bun tsc -p tsconfig.build.json",
12
+ "test:e2e": "bun tests/test-e2e.ts",
12
13
  "format": "bun --bun prettier --write . --cache"
13
14
  },
14
15
  "dependencies": {
15
16
  "estree-walker": "^2.0.2",
16
- "magic-string": "^0.30.8",
17
- "postcss": "^8.4.36",
17
+ "magic-string": "^0.30.10",
18
+ "postcss": "^8.4.40",
18
19
  "postcss-discard-empty": "^6.0.3"
19
20
  },
20
21
  "devDependencies": {