If you’re looking to get started with Rush, check out the references at the end.
The first choice is definitely the official documentation. Read the Developer tutorials and Maintainer tutorials carefully. Maintainer tutorials will familiarise you with most scenarios using Rush. Install Git hooks, which are used in the following steps: install Git hooks, which are used in the following steps:
However, there are not many articles about Rush on the Internet, especially a complete step-by-step guide. The following two articles are good ones I have seen, as supplements to the official documents.
It’s possible that most people who use Rush already have experience with Monorepo, so it’s easier to get started. I have no experience in using Monorepo before, so I feel it is a little difficult to get started. Sometimes I can only turn over one Issue after another, which is a little tired, so I hope to have a relatively complete guide, but fortunately, most of the problems can be solved 😆.
The following is my development github.com/XYShaoKang/… Some problems encountered, and solutions, mainly some configuration, if there are students encounter the same problem, I hope to help you.
My ability is limited. There may be better solutions in some places. I hope you will kindly advise me.
strictPeerDependencies
Rush officially recommends turning on strictPeerDependencies. However, when using Taobao mirror, peerDependenciesMeta is configured in the dependent package @pmmmwh/react-refresh-webpack-plugin /react-refresh /react-refresh
@ PMMMWH/[email protected] requires a peer of the @ types/[email protected] | | 5. X but none was installedCopy the code
The reason is that the field peerDependenciesMeta is missing in the data returned by CNPM.
In China, can not escape the use of Taobao mirror, so if you encounter this problem, you can only close the strictPeerDependencies option, such as CNPM repair it!
- Github.com/cnpm/cnpmjs…
The VSCode intelligent message fails
When using [email protected].*,VSCode intelligence prompts and automatic import will fail, which can be used normally after testing 4.2 and 4.4.
The current version of TS has been released, and the latest version of VSCode has been built in 4.4, so just updating to the latest version of VSCode can solve the current problem. The following solution is still available when you need to switch to the built-in version of VSCode.
Solutions:
- This can be done by installing it inside the package
4.2
or4.4
For later versions, configure VSCode to use the workspace version of TS. - Or you can install the JavaScript and TypeScript Nightly plug-in, which supports the Nightly TS build (typescript@next) as the built-in TS version of VSCode. That can be done. However, this will be more uncontrollable, maybe which update will have problems, but also to test, trouble. The first method is recommended.
Set the TS version used by VSCode
Prerequisites: Open a TS file, move the cursor to the TS file, and perform the following operations
- According to the
Ctrl(Mac press Cmd) + Shift + P
Enter in the command panelTypesCript: Select TypeScript Version
Press Enter to select the version you want to use - Or you can click the TS version number in the lower right corner
If it has not been modified, it is generally current, select the version in the pop-up selection window.4.3.5
Version, click4.3.5
The type of implicit dependency
The types of dependencies that are implicitly installed in the project (i.e. dependencies contained in third-party packages that the current project depends on) can be used, such as @types/testing-library__jest-dom, so @tes would normally be installed Ting-library /jest-dom,@types/testing-library__jest-dom are also installed in node_modules so that TS can find the corresponding type when using toBeInTheDocument.
With Rush, however, all dependencies are extracted into common/temp/node_modules, and node_modules under the project only retain the links of direct dependencies, so implicit dependency types cannot be found by THE TS engine and the corresponding type packages need to be explicitly installed in the project.
ESLint
.eslintrc.js works in subdirectories, but.eslintignore does not. You can use the ignorePatterns configuration in.eslintrc.js instead
- Github.com/eslint/esli…
- Eslint.org/docs/user-g…
lint-staged
Let Lint-staged ignore our defined ESLint ignore rule.
Lint-staged execution does not involve ignoring configuration of files, but some files, such as packaged files, do not need to be checked or fixed. The official solution is provided, which can be customized to solve:
- how-can-i-ignore-files-from-eslintignore
- Github.com/okonet/lint…
Failure in CI due to Jest output
The reason is that Jest uses stderr for output, which causes Rush to exit in a non-zero state, causing CI to fail.
The solution is to create a custom Jest Reporter that replaces the default output with stdout and only uses stderr when an error occurs
- microsoft/just/… /JestReporter.ts
- Github.com/microsoft/r…
Finally shameless again for a praise 😂
In addition, I developed github.com/XYShaoKang/… The command line tool is used to specify a directory, start a service, and view videos in the directory in the browser. The main application scenario is to directly watch videos on the PC on the mobile phone. You know, chasing a guy or something.
Of course, it has just been developed, and it is still very simple. It is for personal use, so it will be developed all the time. If there is a need for friends can point a Star, such as it slowly grow up.
If you find this article helpful, you can also help by clicking Star 😭
Read more
- Rush.js
- Rushjs + PNPM on MonorePO
- Rushjs + PNPM advanced monorepo rush
- These holes in Monorepo, we stepped them for you!