-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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: cli upgrade helper fail when no package.dependencies
#5204
Conversation
In Flipper, https://github.com/facebook/flipper/blob/master/website/package.json, all our dependencies live in `devDependecies` of our `package.json`. As a result `dependencies` is not set, causing a crash when running `yarn start`: ``` /Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50 const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies) ^ TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at Object.<anonymous> (/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50:50) at Module._compile (internal/modules/cjs/loader.js:955:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) at internal/main/run_main_module.js:17:11 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` Setting `"dependencies": {}`, works as work around, but this patch fixes the crash, and makes sure the deps are upgraded as well if they live in `devDependencies` instead of `dependencies`.
✔️ [V2] 🔨 Explore the source changes: d35f470 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60f944ca2ade84000754bdfa 😎 Browse the preview: https://deploy-preview-5204--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5204--docusaurus-2.netlify.app/ |
Summary: `yarn start` in `website` crashed with ``` /Users/mweststrate/fbsource/xplat/sonar/website/node_modules/docusaurus/core/bin/docusaurus.js:50 const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies) ^ TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at Object.<anonymous> (/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/docusaurus/core/bin/docusaurus.js:50:50) ``` This diff adds an empty `dependencies` section as work around. Proper patch has been made in: facebook/docusaurus#5204 Reviewed By: nikoant Differential Revision: D29844597 fbshipit-source-id: 29cfad53d9ca785dd9d93c4800647add219a48ba
LGTM thanks 👍 Was wondering why you put docusaurus packages as devDependencies? It's unusual |
dependencies
section.package.dependencies
Just checked, doesn't seem to be a specific rationale behind it, but just there as devDependency since original generation early 2018 with docusaurus 1.0.9. Semantically speaking I'd say it is quite correct to have them as devDependencies, since these are all(?) build-only deps. But that gets into the nit picking territory 😅. ....Unless dependabot would finally stop running false security errors havoc on devDependencies, then it would suddenly add a lot of value to use those instead of normal dependencies 😆 |
I see thanks :) I guess it's a matter of perspective. IMHO for an SSG we can consider the CI (Netlify/Vercel/GH actions) is the production env, and can leverage |
Motivation
In Flipper, https://github.com/facebook/flipper/blob/master/website/package.json, all our dependencies live in
devDependecies
of ourpackage.json
. As a resultdependencies
is not set, causing a crash when runningyarn start
:Setting
"dependencies": {}
, works as work around, but this patch fixes the crash, and makes sure the deps are upgraded as well if they live indevDependencies
instead ofdependencies
.Have you read the Contributing Guidelines on pull requests?
skimmed
Test Plan
yarn install && yarn start
in the flipper website/ dir, per link above.Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)