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

PCWEB-8414 번들러 Webpack, Rollup 제거와 vite마이그레이션 #90

Merged
merged 17 commits into from
Sep 8, 2022

Conversation

ikki-kki
Copy link
Contributor

@ikki-kki ikki-kki commented Sep 1, 2022

작업 내용 (Content) 📝

  • 기존에 Webpack과 Rollup을 통해 번들링 했던 remember-ui를 vite로 마이그레이션 했습니다.
  • 새로운 툴을 사용해 storybook을 빌드 하기 때문에 docs에 file changed가 많습니다. 스킵하고 리뷰 해주시면 됩니다
  • 자세한 설명은 코드에 남기도록 하겠습니다.

스크린샷 (Screenshot) 📷

  • 필요하다면 스크린샷을 첨부해주세요.
  • Attach a Screenshot if necessary.

링크 (Links) 🔗

기타 사항 (Etc) 🔖

  • PR에 대한 추가 설명이나 작업하면서 고민이 되었던 부분 등
  • Additional information about this PR or any troubles working on this PR.
  • Merge 전 필요한 작업이 있다면 적어주세요 (Checklist before merge)
  • eg) Create XX table, Deploy app etc

테스트 Checklist (Test Checklist) ✅

  • 꼭 테스트 해봐야하는 시나리오를 적어주세요
  • eg) Test case

희망 리뷰 완료 일 (Expected due date) ⏰

202X.X.X. Wed

@ikki-kki ikki-kki marked this pull request as ready for review September 1, 2022 05:16
config.plugins.push(
/** @see https://github.com/aleclarson/vite-tsconfig-paths */
tsconfigPaths({
projects: [path.resolve(path.dirname(__dirname), 'tsconfig.json')],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

타입스크립트 경로 매핑을 위해 vite-tsconfig-paths를 사용하여 tsconfig.json에 설정되어있는 세팅을 가져다 사용하고 있습니다.
storybook은 자동으로 root경로에 있는 컴파일러 설정을 가져올 수 없고 위와같이 설정을 덮어 씌워줘야 정상적으로 작동합니다

@@ -40,6 +40,8 @@ export const parameters = {

/**
* global decorators
* @see https://vitejs.dev/guide/features.html#jsx
* vite 설정으로 인해 JSX syntax를 사용하려면 .jsx 확장자를 사용해야한다.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제목이 곧 내용

"tsc": "tsc",
"storybook": "start-storybook -p 6006",
"storybook-nocache": "start-storybook --no-manager-cache -p 6006",
Copy link
Contributor Author

@ikki-kki ikki-kki Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_modules 삭제 후에 node_modules/.cache/storybook안의 캐쉬가 꼬이거나 사라져 yarn storybook이 정상 동작 하지 않을 경우가 있는데
이 경우 최초 1회 storybook-nocahe로 실행시켜 주면 storybook의 캐싱 매커니즘을 비활성화하여 동작 할 수 있게합니다.
다만 스토리북 로딩 시간에 심각한 영향을 줄 수 있으므로 일반적으로는 사용하지 않는 게 좋습니다

Comment on lines +35 to +36
"react": "^17.0.0",
"react-dom": "^17.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vitejs/vite#6215
빌드 할 때 아래와 같은 에러가 있었는데 react 17버전으로 올려주니 해결됨,.,
Uncaught ReferenceError: module is not defined at jsx-runtime.js:6

"@storybook/addon-essentials": "^6.5.10",
"@storybook/addon-interactions": "^6.5.10",
"@storybook/addon-links": "^6.5.10",
"@storybook/addons": "^6.5.10",
"@storybook/builder-webpack4": "^6.5.10",
"@storybook/manager-webpack4": "^6.5.10",
"@storybook/builder-vite": "^0.2.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack -> vite로 넘어갈 경우 관련 패키지를 모두 삭제해야함.
반대의 경우도 마찬가지

"@storybook/react": "^6.5.10",
"@storybook/testing-library": "^0.0.13",
Copy link
Contributor Author

@ikki-kki ikki-kki Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는 testing-library (jest기반)
이를 사용하고자 하면 .storybook/preview-head.html 내부에 아래의 코드를 추가해야한다.

<script>
  window.global = window;
</script>

jest는 node 런타임에서 동작하기 때므로 global 객체를 사용하는데 브라우저는 global을 참조하고 있지 않기 때문에 추가하지 않으면 레퍼런스 오류가 난다. Uncaught ReferenceError: global is not defined

관련 자료

package.json Outdated
Comment on lines 52 to 64
"babel-loader": "^8.2.5",
"babel-preset-react-app": "^9.1.2",
"eslint-config-prettier": "^6.10.0",
"prettier": "2.0.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"rollup": "^2.7.2",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-peer-deps-external": "^2.2.2",
"rollup-plugin-postcss": "^3.1.1",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.31.2",
"sass": "^1.53.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel, rollup, sass등 사용하지 않는 라이브러리 삭제

Copy link
Contributor

@Yuddomack Yuddomack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~

@ikki-kki ikki-kki closed this Sep 8, 2022
@ikki-kki ikki-kki reopened this Sep 8, 2022
@ikki-kki ikki-kki merged commit 4b009bf into master Sep 8, 2022
@ikki-kki ikki-kki deleted the feature/PCWEB-8414.change_wabpack_to_vite branch September 8, 2022 03:15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants