fix(create-docusaurus): add missing dependencies to templates
Pre-flight checklist
- [x] I have read the Contributing Guidelines on pull requests.
- [ ] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
- [x] If this is a new API or substantial change: the PR has an accompanying issue (closes #6157) and the maintainers have approved on my working plan.
Motivation
Resolve the type checking errors in the templates by adding undeclared dependencies.
Motivations for the changes made:
-
JS and TS templates must depend on
@docusaurus/typessince they try to import from it indocusaurus.config.js. -
The TS template must depend on
@docusaurus/theme-classicand@types/nodesince@tsconfig/docusaurusspecifies that they need to be loaded. -
The TS template must depend on
@types/reactsince it imports fromreactand also needs to provide it to@docusaurus/theme-classicfor its types. -
The
@types/reactresolutionsentry is needed because other@typespackages depend on@types/react@*which causes duplicated/incompatible types.
Test Plan
e2e test should pass.
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
https://github.com/facebook/docusaurus/pull/7521 https://github.com/facebook/docusaurus/issues/6157#issuecomment-1140293297
[V2]
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | d10a3d92a7b49a5bb39ebd4932d6901ec55f329a |
| Latest deploy log | https://app.netlify.com/sites/docusaurus-2/deploys/62ac64200d214500095e16f5 |
| Deploy Preview | https://deploy-preview-7539--docusaurus-2.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
⚡️ Lighthouse report for the deploy preview of this PR
| URL | Performance | Accessibility | Best Practices | SEO | PWA | Report |
|---|---|---|---|---|---|---|
| / | 🟠 71 | 🟢 100 | 🟢 100 | 🟢 100 | 🟢 90 | Report |
| /docs/installation | 🟠 80 | 🟢 99 | 🟢 100 | 🟢 100 | 🟢 90 | Report |
I wonder if it's necessary to actually add @docusaurus/theme-classic to the dependencies? To an average user it may be confusing why this is needed, because this dependency is kind of hidden in the shareable tsconfig
It can be "hidden" by having @docusaurus/preset-classic expose it and a .d.ts file in the template that references it instead of the types config in tsconfig.json (see how Next.js does this) but as it stands right now it's required.
(And we have a lot of "below average" users that don't use PnP and don't understand how it works!)
While that's fair this is an issue with node_modules as well.
I see... I'll think about in the coming days about what we shall do. I think we should re-export all types from preset-classic.