Skip to content

Commit 617d6a4

Browse files
authored
Merge pull request #53 from f-lab-edu/refactoring
carousel 패키지 JIT 패키지로 설정 변경
2 parents b66df72 + 018a16e commit 617d6a4

File tree

13 files changed

+84
-63
lines changed

13 files changed

+84
-63
lines changed

apps/watcha_clone_coding/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"dependencies": {
2929
"@lukemorales/query-key-factory": "^1.3.4",
3030
"@tanstack/react-query": "^5.85.5",
31+
"@watcha/carousel": "workspace:*",
3132
"axios": "^1.11.0",
3233
"core-js": "^3.45.0",
3334
"dayjs": "^1.11.18",
@@ -76,9 +77,8 @@
7677
"webpack-cli": "^6.0.1",
7778
"webpack-dev-server": "^4.15.2",
7879
"webpack-merge": "^6.0.1",
79-
"carousel": "workspace:*",
8080
"@watcha/tsconfig": "workspace:*",
8181
"@watcha/eslint-config": "workspace:*",
8282
"@watcha/prettier-config": "workspace:*"
8383
}
84-
}
84+
}

apps/watcha_clone_coding/src/components/AppErrorBoundary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ErrorBoundaryInner extends React.Component<
4444
}
4545
}
4646

47-
const AppErrorBoundary = ({ children }: AppErrorBoundaryProps): JSX.Element => {
47+
const AppErrorBoundary = ({ children }: AppErrorBoundaryProps): React.ReactElement => {
4848
const { reset } = useQueryErrorResetBoundary();
4949
return <ErrorBoundaryInner onReset={reset}>{children}</ErrorBoundaryInner>;
5050
};

apps/watcha_clone_coding/src/components/Button.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { ButtonHTMLAttributes, ReactNode } from 'react';
1+
import React, { ButtonHTMLAttributes, ReactNode } from 'react';
22

3-
type ButtonProps = {
4-
children: ReactNode;
3+
type ButtonProps = React.PropsWithChildren<{
54
icon?: ReactNode;
6-
} & ButtonHTMLAttributes<HTMLButtonElement>;
5+
}> &
6+
ButtonHTMLAttributes<HTMLButtonElement>;
77

8-
const Button = ({ icon, children, ...props }: ButtonProps): JSX.Element => {
8+
const Button = ({ icon, children, ...props }: ButtonProps): React.ReactElement => {
99
return (
1010
<button type="button" {...props}>
1111
{icon && <span className="button-icon">{icon}</span>}

apps/watcha_clone_coding/src/components/Header.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Watcha from '@/assets/watcha.svg';
66
import Button from '@/components/Button';
77
import useSearchMovie from '@/hooks/useSearchMovie';
88

9-
109
const Header = () => {
1110
const location = useLocation();
1211
const pathName = location.pathname;

apps/watcha_clone_coding/src/pages/ListPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Carousel } from 'carousel';
1+
import { Carousel } from '@watcha/carousel';
22
import React from 'react';
33

44
import AppErrorBoundary from '@/components/AppErrorBoundary';

apps/watcha_clone_coding/src/pages/SearchHomePage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Carousel } from 'carousel';
1+
import { Carousel } from '@watcha/carousel';
22
import React from 'react';
33
import { Link } from 'react-router-dom';
44

@@ -8,8 +8,8 @@ import { SearchHomePageSkeleton } from '@/components/Skeleton';
88
import ThemeTab from '@/components/ThemeTab';
99
import useSearchMovies from '@/hooks/useSearchMovies';
1010
import { useSearchListQuery } from '@/queries/search/useSearchListQuery';
11-
import { Genre } from '@/types/Movie';
1211
import { buildImageUrl } from '@/utils/transform';
12+
1313
import '@/styles/Search.css';
1414

1515
const TAB_BUTTONS = [
@@ -78,8 +78,8 @@ const SearchHomePageContent = () => {
7878
<Carousel.LeftButton />
7979
<Carousel.Track articleWidth={319}>
8080
<Carousel.Article articleWidth={319} layout="overlay">
81-
{(slide) => {
82-
return <GenresCard slide={slide as Genre} layout="overlay" type="genres" />;
81+
{(slide: any) => {
82+
return <GenresCard slide={slide} layout="overlay" type="genres" />;
8383
}}
8484
</Carousel.Article>
8585
</Carousel.Track>

apps/watcha_clone_coding/webpack.common.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ module.exports = {
4646
},
4747
],
4848
},
49+
optimization: {
50+
splitChunks: {
51+
chunks: 'all',
52+
cacheGroups: {
53+
carousel: {
54+
test: /[\\/]packages[\\/]carousel[\\/]/,
55+
name: 'carousel',
56+
chunks: 'all',
57+
},
58+
},
59+
},
60+
},
4961
plugins: [
5062
new HtmlWebpackPlugin({
5163
template: './public/index.html', // 템플릿 파일 경로

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"build:production": "pnpm --F \"watcha_clone_coding\" build:production",
88
"start": "pnpm --F \"watcha_clone_coding\" start",
99
"dev": "pnpm --F \"watcha_clone_coding\" dev",
10-
"type-check": "pnpm --F \"watcha_clone_coding\" type-check",
11-
"lint": "pnpm --F \"watcha_clone_coding\" lint",
12-
"lint:fix": "pnpm --F \"watcha_clone_coding\" lint --fix",
13-
"format": "pnpm --F \"watcha_clone_coding\" format",
10+
"type-check": "pnpm -r type-check",
11+
"lint": "pnpm -r lint",
12+
"lint:fix": "pnpm -r lint:fix",
13+
"format": "pnpm -r format",
1414
"format:check": "prettier --check .",
1515
"prepare": "husky"
1616
},

packages/carousel/package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{
2-
"name": "carousel",
2+
"name": "@watcha/carousel",
33
"version": "1.0.0",
4-
"type": "module",
54
"description": "",
6-
"main": "index.js",
5+
"main": "./dist/index.js",
6+
"module": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"require": "./dist/index.js",
11+
"import": "./dist/index.js",
12+
"types": "./dist/index.d.ts"
13+
}
14+
},
15+
"sideEffects": false,
716
"scripts": {
17+
"build": "tsc",
818
"test": "echo \"Error: no test specified\" && exit 1",
19+
"type-check": "tsc --noEmit",
920
"lint": "eslint . --ext .ts,.tsx",
10-
"lint:fix": "eslint . --ext .ts,.tsx --fix"
21+
"lint:fix": "eslint . --ext .ts,.tsx --fix",
22+
"format": "prettier --write ."
1123
},
1224
"keywords": [],
1325
"author": "",
@@ -30,4 +42,4 @@
3042
"react": "^19.1.1",
3143
"react-dom": "^19.1.1"
3244
}
33-
}
45+
}

packages/carousel/src/hooks/useCarousel.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import React, { useState, useRef, useEffect, useCallback } from "react";
1+
import React, { useState, useRef, useEffect, useCallback } from 'react';
22

3-
import { CarouselProps as CarouselSlide } from "../types/Carousel";
4-
import { Genre } from "../types/Movie";
3+
import { CarouselProps as CarouselSlide } from '../types/Carousel';
4+
import { Genre } from '../types/Movie';
55

66
type Slide = CarouselSlide | Genre;
77

8-
const useCarousel = ({ articleWidth, slides }: { articleWidth: number; slides: Slide[] }): {
9-
containerRef: React.RefObject<HTMLDivElement>;
10-
trackRef: React.RefObject<HTMLDivElement>;
8+
const useCarousel = ({
9+
articleWidth,
10+
slides,
11+
}: {
12+
articleWidth: number;
13+
slides: Slide[];
14+
}): {
15+
containerRef: React.RefObject<HTMLDivElement | null>;
16+
trackRef: React.RefObject<HTMLDivElement | null>;
1117
transitionEnabled: boolean;
1218
displayIndex: number;
1319
clonedSlides: Slide[];
@@ -47,8 +53,8 @@ const useCarousel = ({ articleWidth, slides }: { articleWidth: number; slides: S
4753
calculateVisibleCount();
4854
};
4955

50-
window.addEventListener("resize", handleResize);
51-
return (): void => window.removeEventListener("resize", handleResize);
56+
window.addEventListener('resize', handleResize);
57+
return (): void => window.removeEventListener('resize', handleResize);
5258
}, [calculateVisibleCount]);
5359

5460
const clonedSlides = [...slides.slice(-visibleCount), ...slides, ...slides.slice(0, visibleCount)];

0 commit comments

Comments
 (0)