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

Refactor ClientApp part dependencies and infrastructures. #1

Merged
merged 3 commits into from
Dec 4, 2018

Conversation

mvpdw06
Copy link
Contributor

@mvpdw06 mvpdw06 commented Dec 4, 2018

Hi 我來發 PR 了!

這邊用了三個 commit 做 Refactor 整個 ClientApp 架構,以大方向來說切成以下幾個方向

  • 拆掉 react-script
  • 升級 Babel 7
  • 重新架構 Eslint 包含 React 與 Prettier 設定,並且有 config 與 src 的不同 (因為 config 通常使用 node 來寫,偏好使用 ES5 的 requiremodule.exports 語法,而 src 部份都是 React 所以全走 importexport default 語法)
  • 重新架構 Jest,並加上 jest-html-reporter,而未來如果想要測試 React Component 就加上 Enzyme 並加上幾個設定即可。

以上修改我都有跑過 $ npm start, $ npm build, $ npm test:coverage, $ npm test:watch, $ npm lint:check, $ npm lint:fix and $ npm format 的測試沒問題。

另外

如果你在跑 test 發現有 'open too many files .... ' 之類的錯誤,請使用 brew 安裝 watchman
相關 reference: facebook/create-react-app#4540

最後

這裡面貌似還有相依 event-stream 3.3.6 的 package,所以我直接使用 npm install 會死掉,這個部分再請你修改了!

如果有任何問題請再告訴我,謝謝!

- Run `eject` commend.
- Make sure ClientApp still can run successfully.
- Comment the pre loader (eslint-loader) part of config/webpack.config.dev.js to make sure can run successfully.

Need to fix items below:
- Babel version need to upgrate to version 7, current project is only depend on `babel-preset-react-app`.
- Extract `.babelrc` file from `package.json`.
- Remove eslintConfig part of `package.json`.
- Refactor and extract jest settings from `package.json`.
- Make sure some packages which output from `eject` is need or not.
- Fix command runing with warnings.
- Fix the error of eslint rules.
- Change babel setting from only `babel-preset-react-app` to babel 7 dependencies.
- All babel dependencies which named start with '@babel/...' just from `preset-recat`, `preset-env`, `preset-stage-0` of babel 6.
- Remove babel setting and eslint setting in `package.json`.
- Add `.babelrc` file for babel setting, including jest env runtime babel setting.
- Put all eslint package in optionalDependencies.
- Remove `whatwg-fetch` and its dependency in `polyfills.js`
- Upgrade React to 16.6.3 for new features of memo and lazy.
- Add `react-hot-loader` for react's advanced hot module replacement.
- Remove `eslint-loader` in current webpack setting temporarily.

> All Change pass `$ npm start` and `$ npm build` test.
- `package.json` move script section higher than dependencies for clearify.
- Upgrade packages' version of eslint and jest.
- Add `jest-html-reporter` package and `./jesthtmlreporter.config.json` setting file for another jest report.
- Add `.gitignore` for new test report.
- Move jest setting to `config/jest/jest.config.js` and `config/jest/jest.config.watch.js`.
- Refactor `.eslintrc.js` for code quality and fit react and prettier.
- Add `eslint-plugin-import` package for rule only import syntax(can not use require) for webpack tree-shacking.
- Refactor all config file by adding /* eslint 'import/no-commonjs': 'off' */ on top for eslint and single quote.
- Add "babel-core": "^7.0.0-bridge.0" package for run jest with babel success.

If you run jest command with some error like 'open too many files .... etc', please to use `$ brew update && brew install watchman`.
After installation, I think you will fix this issue.

> All Change pass `$ npm start`, `$ npm build`, `$ npm test:coverage`, `$ npm test:watch`, `$ npm lint:check`, `$ npm lint:fix` and `$ npm format` test.
@blackie1019 blackie1019 merged commit dafde2d into blackie1019:master Dec 4, 2018
@blackie1019
Copy link
Owner

安裝時看到一個弱點警高

Run npm install react-scripts@2.1.1 to resolve 1 vulnerability

SEMVER WARNING: Recommended action is a potentially breaking change

found 1 high severity vulnerability in 20581 scanned packages
1 vulnerability requires semver-major dependency updates.

這要解嗎?

@mvpdw06
Copy link
Contributor Author

mvpdw06 commented Dec 5, 2018

是說整個 project 應該是沒有「直接」相依在 react-script 上了

然後我自己在使用 yarn 安裝的時候沒出現這個警告,使用 npm 才會提出

我自己這邊的訊息是細節是 webpack-dev-server 發出的
https://imgur.com/a/ohKlQwj

查了一下原因應該是 這個

如果要解,就是要把 webpack-dev-server 升到 3.1.6 以上,但也就是說這樣就要把 webpack 升版到 webpack 4 就可以完全解掉。

如果你願意等的話我今天晚上可以再處理一版 webpack 4 的版本!

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.

2 participants