Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 빌드 후 typescript 절대 경로 상대 경로로 변환하지 못하는 에러 해결 #43

Merged
merged 10 commits into from
Jun 9, 2024
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ styled-system-studio

*storybook.log

eslintcache
.eslintcache
17 changes: 4 additions & 13 deletions apps/wow-docs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<main
className={css({
color: "textBlack",
textStyle: "h1",
bg: "backgroundAlternative",
})}
>
<p>docs</p>
</main>
<Switch />
<Checkbox />
<Chip label="Chip" />
<Switch />
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/scripts/generateReactComponentFromSvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -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<SVGSVGElement, IconProps>(
(${propsString}, ref) => {
Expand Down Expand Up @@ -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) =>
Expand Down
8 changes: 4 additions & 4 deletions packages/wow-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 11 additions & 1 deletion packages/wow-icons/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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/**/*"],
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SVGSVGElement, IconProps>(
(
Expand Down
2 changes: 1 addition & 1 deletion packages/wow-icons/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"@/*": ["src/*"]
}
},
"include": ["src", "svg.d.ts"],
"include": ["src", "svg.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "dist"]
}
3 changes: 1 addition & 2 deletions packages/wow-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
ghdtjgus76 marked this conversation as resolved.
Show resolved Hide resolved
"lint": "eslint . --max-warnings 0",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion packages/wow-ui/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
ghdtjgus76 marked this conversation as resolved.
Show resolved Hide resolved
},
{
format: "cjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/wow-ui/src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 사용자가 선택하거나 선택 해제할 수 있는 체크박스 컴포넌트입니다.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/wow-ui/src/components/Chip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
PolymorphicComponentProps,
PolymorphicRef,
ToggleButtonProps,
} from "../../types";
} from "@/types";

/**
* @template T 렌더링할 요소 또는 컴포넌트 타입
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion packages/wow-ui/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./button";
export * from "./Button";
export * from "./Polymorphic";
50 changes: 42 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading