@liner-fe/internal-icon 1.0.43 → 1.0.45

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/.ultra.cache.json CHANGED
@@ -1 +1 @@
1
- {"files":{"lib":"1777425688807.4224","node_modules":"1777425674169.456","CHANGELOG.md":"505d7344ee19579877285ad7321c6ec7ab14d575","README.md":"e0a89d4fcf5bddf1f816bfb20a928ddb301b8d2c","figma.json":"59f77fec62cc40cbfa38d3cc1851e37cad331146","package.json":"f3aede9b430373e6e06a6ba6875d67dbc1b72a6b","src/generate-svg-files.ts":"207c9eeabf5593f57cd8e01c569b086ce98356fc","src/generate-tsx-components.ts":"52991558d51f4d6261d637f36f0ff457c78a9670","src/index.ts":"9e03c9c45c92fc534262982bce233b91892c05f1","tsconfig.json":"298030567ca332304807fcdbb95d1218c9c0814f","tsup.config.ts":"4dc8bfd36076fff8fa1d84a48a072d40e6581810"},"deps":{}}
1
+ {"files":{"lib":"1777428555904.532","node_modules":"1777428541121.5059","CHANGELOG.md":"4b3a1e3902fa384773aeb7fe040f5d6315838d0d","README.md":"e0a89d4fcf5bddf1f816bfb20a928ddb301b8d2c","figma.json":"59f77fec62cc40cbfa38d3cc1851e37cad331146","package.json":"17a2459a39492e8ee716b484eada4ca0b4f80d6e","src/generate-svg-files.ts":"6e4949b774de5b509eaab4a1a8efa600ee9a17fc","src/generate-tsx-components.ts":"29612d03b5e8b69e7919b03627853d2e0f287ea4","src/index.ts":"9e03c9c45c92fc534262982bce233b91892c05f1","tsconfig.json":"298030567ca332304807fcdbb95d1218c9c0814f","tsup.config.ts":"8460f94f8ebd1d42fb4cc968298195ae5dd67cde"},"deps":{}}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @internal/icon
2
2
 
3
+ ## 1.0.45
4
+
5
+ ### Patch Changes
6
+
7
+ - dc55569: generate-tsx-components 에도 SVGO 적용. 아이콘 TSX 번들 크기 감소: @liner-fe/icon -26.4% (902 → 664 KB unpacked), @liner-fe/icon-rn -30.0% (448 → 314 KB unpacked).
8
+
9
+ ## 1.0.44
10
+
11
+ ### Patch Changes
12
+
13
+ - 00f3c64: SVGO를 도입해 아이콘 SVG 생성 파이프라인 최적화. icon-rn의 SVG 결과물 총합이 약 33.7% 감소.
14
+
3
15
  ## 1.0.43
4
16
 
5
17
  ### Patch Changes
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@ var __dirname = /* @__PURE__ */ getDirname();
11
11
  // src/generate-svg-files.ts
12
12
  import fs from "fs";
13
13
  import path2 from "path";
14
+ import { optimize } from "svgo";
14
15
  var generateSvgFiles = /* @__PURE__ */ __name(() => {
15
16
  const figmaData = JSON.parse(fs.readFileSync(path2.resolve(__dirname, "../figma.json"), "utf8"));
16
17
  function convertToCurrentColor(svgString) {
@@ -18,7 +19,7 @@ var generateSvgFiles = /* @__PURE__ */ __name(() => {
18
19
  }
19
20
  __name(convertToCurrentColor, "convertToCurrentColor");
20
21
  function optimizeSvg(svgString) {
21
- return svgString.replace(/\s+/g, " ").replace(/>\s+</g, "><").trim();
22
+ return optimize(svgString, { multipass: true }).data;
22
23
  }
23
24
  __name(optimizeSvg, "optimizeSvg");
24
25
  const svgDir = "./";
@@ -51,7 +52,24 @@ var generateSvgFiles = /* @__PURE__ */ __name(() => {
51
52
  // src/generate-tsx-components.ts
52
53
  import fs2 from "fs";
53
54
  import path3 from "path";
55
+ import { optimize as optimize2 } from "svgo";
54
56
  var generateTsxComponents = /* @__PURE__ */ __name(() => {
57
+ function optimizeSvg(svgString) {
58
+ return optimize2(svgString, {
59
+ multipass: true,
60
+ plugins: [
61
+ {
62
+ name: "preset-default",
63
+ params: {
64
+ overrides: {
65
+ convertColors: false
66
+ }
67
+ }
68
+ }
69
+ ]
70
+ }).data;
71
+ }
72
+ __name(optimizeSvg, "optimizeSvg");
55
73
  const FIGMA_DATA_PATH = path3.resolve(__dirname, "../figma.json");
56
74
  const OUTPUT_DIR = "./assets";
57
75
  const INDEX_FILE_PATH = "./index.tsx";
@@ -103,7 +121,9 @@ var generateTsxComponents = /* @__PURE__ */ __name(() => {
103
121
  };
104
122
  Object.entries(variants).forEach(([variant, svgString]) => {
105
123
  if (svgString && svgString.trim() !== "") {
106
- variantSvgs[variant] = normalizeSvgAttributes(convertToCurrentColor(svgString));
124
+ variantSvgs[variant] = normalizeSvgAttributes(
125
+ convertToCurrentColor(optimizeSvg(svgString))
126
+ );
107
127
  }
108
128
  });
109
129
  return variantSvgs;
@@ -152,7 +172,7 @@ export const Icon${componentName} = forwardRef<SVGSVGElement, IconProps>(
152
172
  const tsxCode = generateColorTsxComponent(
153
173
  componentName,
154
174
  // @ts-ignore
155
- normalizeSvgAttributes(variants.default)
175
+ normalizeSvgAttributes(optimizeSvg(variants.default))
156
176
  );
157
177
  const filePath = path3.join(iconDir, "index.tsx");
158
178
  fs2.writeFileSync(filePath, tsxCode);
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@liner-fe/internal-icon",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
+ "dependencies": {
9
+ "svgo": "4.0.1"
10
+ },
8
11
  "devDependencies": {
9
12
  "@types/node": "^25.1.0",
10
13
  "tsup": "^8.5.0",
@@ -1,5 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { optimize } from 'svgo';
3
4
 
4
5
  export const generateSvgFiles = () => {
5
6
  const figmaData = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../figma.json'), 'utf8'));
@@ -9,7 +10,7 @@ export const generateSvgFiles = () => {
9
10
  }
10
11
 
11
12
  function optimizeSvg(svgString: string): string {
12
- return svgString.replace(/\s+/g, ' ').replace(/>\s+</g, '><').trim();
13
+ return optimize(svgString, { multipass: true }).data;
13
14
  }
14
15
 
15
16
  const svgDir = './';
@@ -1,7 +1,24 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { optimize } from 'svgo';
3
4
 
4
5
  export const generateTsxComponents = () => {
6
+ function optimizeSvg(svgString: string): string {
7
+ return optimize(svgString, {
8
+ multipass: true,
9
+ plugins: [
10
+ {
11
+ name: 'preset-default',
12
+ params: {
13
+ overrides: {
14
+ convertColors: false,
15
+ },
16
+ },
17
+ },
18
+ ],
19
+ }).data;
20
+ }
21
+
5
22
  // 상수 정의
6
23
  const FIGMA_DATA_PATH = path.resolve(__dirname, '../figma.json');
7
24
  const OUTPUT_DIR = './assets';
@@ -86,7 +103,9 @@ export const generateTsxComponents = () => {
86
103
  Object.entries(variants).forEach(([variant, svgString]) => {
87
104
  if (svgString && svgString.trim() !== '') {
88
105
  // @ts-ignore
89
- variantSvgs[variant] = normalizeSvgAttributes(convertToCurrentColor(svgString));
106
+ variantSvgs[variant] = normalizeSvgAttributes(
107
+ convertToCurrentColor(optimizeSvg(svgString)),
108
+ );
90
109
  }
91
110
  });
92
111
 
@@ -147,7 +166,7 @@ export const Icon${componentName} = forwardRef<SVGSVGElement, IconProps>(
147
166
  const tsxCode = generateColorTsxComponent(
148
167
  componentName,
149
168
  // @ts-ignore
150
- normalizeSvgAttributes(variants.default),
169
+ normalizeSvgAttributes(optimizeSvg(variants.default)),
151
170
  );
152
171
 
153
172
  const filePath = path.join(iconDir, 'index.tsx');
package/tsup.config.ts CHANGED
@@ -5,6 +5,7 @@ export default defineConfig({
5
5
  outDir: 'lib',
6
6
  format: 'esm',
7
7
  bundle: true,
8
+ external: ['svgo'],
8
9
  minify: false,
9
10
  keepNames: true,
10
11
  clean: true,