Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Use pnpm (and fix Storybook issues as a result) #525

Merged
merged 4 commits into from
Dec 15, 2021

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Dec 14, 2021

Fixes

Fixes #483 by @krysal

Description

Replaces npm with pnpm. pnpm has some significant advantages compared to npm, including super fast installs thanks to its local dependency cache. Dependencies are sym-linked into node_modules which makes using pnpm for many projects ultimately result in smaller disk usage. It also makes dependency re-installation super fast as it just has to create the sym-links. Similarly, deleting node_modules is much faster as you're just removing sym-links.

To support Vue we need to use the shamefully-hoist option as noted in this issue: pnpm/pnpm#831 (note that the shamefully-flatten option has been renamed to shamefully-hoist)

Tagging @rbadillap specifically for review on this one as it touches the newly minted Dockerfile 🙂

Marking this as high priority as not being able to properly use Storybook is not good for redesign development which we're currently moving quickly on.

Testing Instructions

Checkout this branch and remove node_modules (for example rm -rf node_modules). Follow the instructions in the readme to install pnpm (volta install pnpm) then run pnpm install. Next run pnpm storybook and pnpm dev to ensure that they work 🎉 Also run pnpm build followed by pnpm start.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added 🟧 priority: high Stalls work on the project or its dependents 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Dec 14, 2021
@zackkrida
Copy link
Member

Oops, I actually pushed a commit with some config suggestions to your PR. Please review, as they're minor anyway!

Everything is working flawlessly for me, tested with:

✅ Installation and local run

rm -rf node_modules
volta install pnpm
pnpm i
npm run dev

Docker run

docker compose up

Storybook

pnpm run storybook

Tests

pnpm run test:e2e
pnpm run test

@sarayourfriend
Copy link
Contributor Author

@zackkrida just curious, why do we need to explicitly use run in docker?

@zackkrida
Copy link
Member

@sarayourfriend We don't, I just think it's clearer for anyone checking, for example, documentation:
https://pnpm.io/cli/run

I generally lean towards being verbose

@sarayourfriend
Copy link
Contributor Author

Gotcha. I was following the style the recommend in their npm equivalency table where they exclude run

@sarayourfriend sarayourfriend marked this pull request as ready for review December 14, 2021 21:17
@sarayourfriend sarayourfriend requested a review from a team as a code owner December 14, 2021 21:17
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

I'm fine with eliminating run usage @sarayourfriend, since the pnpm docs actively encourage not writing out run it might actually be clearer without it. So glad this was such a win, and thanks for finding everywhere npm needed to be replaced 👍

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

I haven't tested the docker build but locally it is amazingly fast and Storybook mdx files all work for me. Thank you for improving devex, @sarayourfriend !

One small thing that isn't related but would reduce the number of warnings when running Storybook is to replace "license/VLicence" with "License/VLicense" (first letter is upper-case L). I added a tiny PR : #527

@obulat
Copy link
Contributor

obulat commented Dec 15, 2021

Just a note: Webstorm integration with pnpm is not working great. I used the GUI (green 'run' triangles) to run the scripts from package.json, and now it's not working. Will have to use the command line more :)

@sarayourfriend sarayourfriend merged commit 79c74e9 into main Dec 15, 2021
@sarayourfriend sarayourfriend deleted the fix/storybook-mdx branch December 15, 2021 14:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟧 priority: high Stalls work on the project or its dependents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storybook issues
3 participants