diff --git a/.gitignore b/.gitignore index a58fc6da..064af033 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,4 @@ styled-system-studio *storybook.log -eslintcache \ No newline at end of file +.eslintcache \ No newline at end of file diff --git a/apps/wow-docs/app/page.tsx b/apps/wow-docs/app/page.tsx index 1b8b6e94..5c430099 100644 --- a/apps/wow-docs/app/page.tsx +++ b/apps/wow-docs/app/page.tsx @@ -1,22 +1,13 @@ -import { css } from "@styled-system/css/css"; +import Checkbox from "wowds-ui/Checkbox"; +import Chip from "wowds-ui/Chip"; import Switch from "wowds-ui/Switch"; -import Checkbox from "../../../packages/wow-ui/src/components/Checkbox"; - const Home = () => { return ( <> -
-

docs

-
- + + ); }; diff --git a/package.json b/package.json index 0d29aa39..30346fdb 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "@rollup/plugin-url": "^8.0.2", "@testing-library/jest-dom": "^6.4.5", "@testing-library/react": "^15.0.7", @@ -72,6 +73,7 @@ "theme": "workspace:^", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", + "tsc-alias": "^1.8.10", "tsx": "^4.11.0", "turbo": "latest", "typescript": "^5.3.3", diff --git a/packages/scripts/generateReactComponentFromSvg.ts b/packages/scripts/generateReactComponentFromSvg.ts index 89f1e393..a08f184c 100644 --- a/packages/scripts/generateReactComponentFromSvg.ts +++ b/packages/scripts/generateReactComponentFromSvg.ts @@ -2,7 +2,7 @@ import { existsSync, promises as fs } from "fs"; import path from "path"; const SVG_DIR = "../wow-icons/src/svg"; -const COMPONENT_DIR = "../wow-icons/src/react"; +const COMPONENT_DIR = "../wow-icons/src/component"; type SvgComponentMap = { [key: string]: string }; @@ -84,7 +84,7 @@ const createComponentContent = ( import { forwardRef } from 'react'; import { color } from "wowds-tokens"; - import type { IconProps } from "../types/Icon.ts"; + import type { IconProps } from "@/types/Icon.ts"; const ${componentName} = forwardRef( (${propsString}, ref) => { @@ -130,7 +130,7 @@ const generateComponentFiles = async (svgComponentMap: SvgComponentMap) => { }; const generateExportFile = async (components: string[]) => { - const EXPORT_FILE_PATH = "../wow-icons/src/react/index.ts"; + const EXPORT_FILE_PATH = "../wow-icons/src/component/index.ts"; const exportFileContent = components .map( (component) => diff --git a/packages/wow-icons/package.json b/packages/wow-icons/package.json index ec4a9de7..6215a646 100644 --- a/packages/wow-icons/package.json +++ b/packages/wow-icons/package.json @@ -19,17 +19,17 @@ "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./dist/react/index.d.ts", + "types": "./dist/component/index.d.ts", "require": "./dist/index.cjs", "import": "./dist/index.js", "default": "./dist/index.js" } }, "scripts": { - "build": "pnpm generate:icons && rm -rf dist && rollup -c --bundleConfigAsCjs && tsc --emitDeclarationOnly", + "build": "pnpm generate:icons && rm -rf dist && rollup -c --bundleConfigAsCjs && tsc-alias", "generate:icons": "tsx ../scripts/generateReactComponentFromSvg.ts && pnpm format && pnpm lint", - "lint": "eslint --fix ./src/react/**/*.tsx", - "format": "prettier --write ./src/react/**/*" + "lint": "eslint --fix ./src/component/**/*.tsx", + "format": "prettier --write ./src/component/**/*" }, "keywords": [], "author": "gdsc-hongik", diff --git a/packages/wow-icons/rollup.config.js b/packages/wow-icons/rollup.config.js index a5fd4e57..0d5bdfb0 100644 --- a/packages/wow-icons/rollup.config.js +++ b/packages/wow-icons/rollup.config.js @@ -1,15 +1,25 @@ import baseConfig from "../shared-config/rollup.config.js"; import babel from "@rollup/plugin-babel"; +import alias from "@rollup/plugin-alias"; import url from "@rollup/plugin-url"; import typescript from "@rollup/plugin-typescript"; +import path from "path"; +import { fileURLToPath } from "url"; const extensions = [".ts", ".tsx", ".js", ".jsx"]; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +process.env.BABEL_ENV = "production"; + export default { ...baseConfig, - input: "./src/react/index.ts", + input: "./src/component/index.ts", plugins: [ ...baseConfig.plugins, + alias({ + entries: [{ find: "@", replacement: path.join(__dirname, "./src") }], + }), babel({ extensions, include: ["src/**/*"], diff --git a/packages/wow-icons/src/react/Check.tsx b/packages/wow-icons/src/component/Check.tsx similarity index 93% rename from packages/wow-icons/src/react/Check.tsx rename to packages/wow-icons/src/component/Check.tsx index 3b852892..d379a73f 100644 --- a/packages/wow-icons/src/react/Check.tsx +++ b/packages/wow-icons/src/component/Check.tsx @@ -1,7 +1,7 @@ import { forwardRef } from "react"; import { color } from "wowds-tokens"; -import type { IconProps } from "../types/Icon.ts"; +import type { IconProps } from "@/types/Icon.ts"; const Check = forwardRef( ( diff --git a/packages/wow-icons/src/react/index.ts b/packages/wow-icons/src/component/index.ts similarity index 100% rename from packages/wow-icons/src/react/index.ts rename to packages/wow-icons/src/component/index.ts diff --git a/packages/wow-icons/tsconfig.json b/packages/wow-icons/tsconfig.json index 623cf111..0c2ab819 100644 --- a/packages/wow-icons/tsconfig.json +++ b/packages/wow-icons/tsconfig.json @@ -23,6 +23,6 @@ "@/*": ["src/*"] } }, - "include": ["src", "svg.d.ts"], + "include": ["src", "svg.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules", "dist"] } diff --git a/packages/wow-ui/package.json b/packages/wow-ui/package.json index dac69807..a025674e 100644 --- a/packages/wow-ui/package.json +++ b/packages/wow-ui/package.json @@ -49,7 +49,7 @@ "keywords": [], "license": "ISC", "scripts": { - "build": "pnpm generate:build-config && rm -rf dist && rollup -c --bundleConfigAsCjs && panda cssgen --outfile dist/styles.css", + "build": "pnpm generate:build-config && rm -rf dist && rollup -c --bundleConfigAsCjs && tsc-alias && panda cssgen --outfile dist/styles.css", "lint": "eslint . --max-warnings 0", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", @@ -59,7 +59,6 @@ }, "devDependencies": { "@chromatic-com/storybook": "^1.3.3", - "@rollup/plugin-typescript": "^11.1.6", "@storybook/addon-a11y": "^7.5.3", "@storybook/addon-essentials": "^7.5.3", "@storybook/addon-interactions": "^7.5.3", diff --git a/packages/wow-ui/rollup.config.js b/packages/wow-ui/rollup.config.js index 57f15698..4db4d471 100644 --- a/packages/wow-ui/rollup.config.js +++ b/packages/wow-ui/rollup.config.js @@ -22,14 +22,16 @@ export default { Box: "./src/components/Box", Button: "./src/components/Button", Checkbox: "./src/components/Checkbox", + Chip: "./src/components/Chip", Switch: "./src/components/Switch", }, output: [ { format: "esm", dir: "dist", - entryFileNames: "[name].js", preserveModules: true, + preserveModulesRoot: "src", + entryFileNames: "[name].js", }, { format: "cjs", diff --git a/packages/wow-ui/src/components/Checkbox/index.tsx b/packages/wow-ui/src/components/Checkbox/index.tsx index e7d6d671..1f723d4f 100644 --- a/packages/wow-ui/src/components/Checkbox/index.tsx +++ b/packages/wow-ui/src/components/Checkbox/index.tsx @@ -10,8 +10,8 @@ import type { import { forwardRef, useId } from "react"; import { Check as CheckIcon } from "wowds-icons"; -//FIXME: alias 경로로 설정하면 import 경로 인식하지 못하는 문제가 있어서 상대경로로 우선 해결 -import { useCheckedState } from "../../hooks"; +import { useCheckedState } from "@/hooks"; + /** * @description 사용자가 선택하거나 선택 해제할 수 있는 체크박스 컴포넌트입니다. * diff --git a/packages/wow-ui/src/components/Chip/index.tsx b/packages/wow-ui/src/components/Chip/index.tsx index 830bb353..bd9d4145 100644 --- a/packages/wow-ui/src/components/Chip/index.tsx +++ b/packages/wow-ui/src/components/Chip/index.tsx @@ -9,7 +9,7 @@ import type { PolymorphicComponentProps, PolymorphicRef, ToggleButtonProps, -} from "../../types"; +} from "@/types"; /** * @template T 렌더링할 요소 또는 컴포넌트 타입 diff --git a/packages/wow-ui/src/hooks/.gitkeep b/packages/wow-ui/src/hooks/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/wow-ui/src/types/index.ts b/packages/wow-ui/src/types/index.ts index 6e1bad85..b280a6fb 100644 --- a/packages/wow-ui/src/types/index.ts +++ b/packages/wow-ui/src/types/index.ts @@ -1,2 +1,2 @@ -export * from "./button"; +export * from "./Button"; export * from "./Polymorphic"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eed497f3..b577ca46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,6 +48,9 @@ importers: '@rollup/plugin-terser': specifier: ^0.4.4 version: 0.4.4(rollup@4.17.2) + '@rollup/plugin-typescript': + specifier: ^11.1.6 + version: 11.1.6(rollup@4.17.2)(typescript@5.3.3) '@rollup/plugin-url': specifier: ^8.0.2 version: 8.0.2(rollup@4.17.2) @@ -168,6 +171,9 @@ importers: ts-node: specifier: ^10.9.2 version: 10.9.2(@types/node@20.11.24)(typescript@5.3.3) + tsc-alias: + specifier: ^1.8.10 + version: 1.8.10 tsx: specifier: ^4.11.0 version: 4.11.0 @@ -251,9 +257,6 @@ importers: '@chromatic-com/storybook': specifier: ^1.3.3 version: 1.3.3(react@18.2.0) - '@rollup/plugin-typescript': - specifier: ^11.1.6 - version: 11.1.6(rollup@4.17.2)(typescript@5.3.3) '@storybook/addon-a11y': specifier: ^7.5.3 version: 7.6.19 @@ -320,9 +323,6 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 - wowds-tokens: - specifier: workspace:^ - version: link:../wow-tokens packages: @@ -7757,6 +7757,11 @@ packages: engines: {node: '>= 12'} dev: true + /commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + dev: true + /common-path-prefix@3.0.0: resolution: {integrity: sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==} dev: true @@ -10117,7 +10122,7 @@ packages: dependencies: foreground-child: 3.1.1 jackspeak: 2.3.6 - minimatch: 9.0.3 + minimatch: 9.0.4 minipass: 7.0.4 path-scurry: 1.10.1 dev: true @@ -10200,7 +10205,7 @@ packages: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.3.1 + fast-glob: 3.3.2 ignore: 5.3.1 merge2: 1.4.1 slash: 3.0.0 @@ -12650,6 +12655,11 @@ packages: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} dev: true + /mylas@2.1.13: + resolution: {integrity: sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==} + engines: {node: '>=12.0.0'} + dev: true + /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -13501,6 +13511,13 @@ packages: fsevents: 2.3.2 dev: true + /plimit-lit@1.6.1: + resolution: {integrity: sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==} + engines: {node: '>=12'} + dependencies: + queue-lit: 1.5.2 + dev: true + /pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} @@ -13927,6 +13944,11 @@ packages: resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} dev: true + /queue-lit@1.5.2: + resolution: {integrity: sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==} + engines: {node: '>=12'} + dev: true + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -15799,6 +15821,18 @@ packages: typescript: 5.3.3 dev: true + /tsc-alias@1.8.10: + resolution: {integrity: sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==} + hasBin: true + dependencies: + chokidar: 3.6.0 + commander: 9.5.0 + globby: 11.1.0 + mylas: 2.1.13 + normalize-path: 3.0.0 + plimit-lit: 1.6.1 + dev: true + /tsconfck@3.0.2(typescript@5.3.3): resolution: {integrity: sha512-6lWtFjwuhS3XI4HsX4Zg0izOI3FU/AI9EGVlPEUMDIhvLPMD4wkiof0WCoDgW7qY+Dy198g4d9miAqUHWHFH6Q==} engines: {node: ^18 || >=20}