docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

fix(create-docusaurus): add missing dependencies to templates

Open merceyz opened this issue 2 years ago • 4 comments

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/types since they try to import from it in docusaurus.config.js.

  • The TS template must depend on @docusaurus/theme-classic and @types/node since @tsconfig/docusaurus specifies that they need to be loaded.

  • The TS template must depend on @types/react since it imports from react and also needs to provide it to @docusaurus/theme-classic for its types.

  • The @types/react resolutions entry is needed because other @types packages 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

merceyz avatar May 31 '22 17:05 merceyz

[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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar May 31 '22 17:05 netlify[bot]

⚡️ 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

github-actions[bot] avatar May 31 '22 17:05 github-actions[bot]

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.

merceyz avatar Jun 02 '22 08:06 merceyz

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.

Josh-Cena avatar Jun 02 '22 14:06 Josh-Cena