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

fix: pnpm @docusaurus/types hoist #9087

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

2239559319
Copy link

Pre-flight checklist

  • 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.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Fix #9080

Test Plan

no test required

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

#9080

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 20, 2023
@netlify
Copy link

netlify bot commented Jun 20, 2023

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit f44b736
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6491b2e19ef33100082ae924
😎 Deploy Preview https://deploy-preview-9087--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.

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 58 🟢 97 🟢 92 🟢 100 🟠 89 Report
/docs/installation 🟠 75 🟢 100 🟢 92 🟢 100 🟠 89 Report

Copy link
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

It's been a while since I've been battling with this, but usually we got away with adding it to the init templates' package.json. Any reason not to do it here?

@2239559319
Copy link
Author

It's been a while since I've been battling with this, but usually we got away with adding it to the init templates' package.json. Any reason not to do it here?

This problem only occurs when the package manager is pnpm. There is no such problem when using yarn or npm, so there is no need to add it to the template. Adding to package.json will not solve the problem, see public-hoist-pattern for details

@2239559319
Copy link
Author

It's been a while since I've been battling with this, but usually we got away with adding it to the init templates' package.json. Any reason not to do it here?

image
The picture above is the project generated using the resolved code, @docusaurus/types exists in the outermost node_modules

@slorber
Copy link
Collaborator

slorber commented Jun 23, 2023

Adding to package.json will not solve the problem, see public-hoist-pattern for details

Someone just reported here it actually fixes the problem, so are you sure? #9094 (comment)

I'm not particularly knowledgeable of pnpm but that looks simpler to add the types as a dependency instead of configuring this setting 🤷‍♂️ will need to investigate

@Josh-Cena
Copy link
Collaborator

public-hoist-pattern is a way to work around badly configured libraries. If the user is explicitly referencing @docusaurus/types in their config, they should of course add @docusaurus/types to their package.json.

@slorber
Copy link
Collaborator

slorber commented Jun 23, 2023

public-hoist-pattern is a way to work around badly configured libraries. If the user is explicitly referencing @docusaurus/types in their config, they should of course add @docusaurus/types to their package.json.

Considering we reference it in the config file as jsdoc for both js/ts sites, I think we should do that.

/** @returns {Promise<import('@docusaurus/types').Config>} */

Would a new TS site initialized with pnpm even pass typecheck without this?

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Jun 23, 2023

Would a new TS site initialized with pnpm even pass typecheck without this?

If you mean without @docusaurus/types in package.json—my guess is no. But most pnpm users just add @docusaurus/types` to package.json instantly anyway, since it's a common issue with init templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types aren't recognized if the project is setup with pnpm
4 participants