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

Switch from NPM to PNPM for package management #1818

Merged
merged 12 commits into from
May 27, 2024
Merged

Conversation

rmunn
Copy link
Collaborator

@rmunn rmunn commented May 24, 2024

Fixed issues

Fixes #1811.
Fixes #1653.
Fixes #1654.

Description

Switching to PNPM has a couple of advantages. The first is speed: pnpm install is typically faster than npm install, though how much will depend heavily the speed of your Internet connection. The second is disk usage: if you have multiple copies of the Language Forge repository on your disk, perhaps because you want to keep a copy of develop running while you work on a different branch in another folder, PNPM will de-duplicate the packages whose versions are the same between the copies (which will be 100% of them unless you're fiddling with package.json in your branch).

Screenshots

No visible changes.

Checklist

  • I have labeled my PR with: bug, feature, engineering, security fix or testing
  • I have performed a self-review of my own code
  • I have reviewed the title & description of this PR which I will use as the squashed PR commit message
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have enabled auto-merge (optional)

Testing

Testers, use the following instructions against our staging environment. Post your findings as a comment and include any meaningful screenshots, etc.

Describe how to verify your changes and provide any necessary test data.

  • Run make
  • If you get errors about pnpm not being found, run corepack enable then run make again.
  • Go to http://localhost:8080/ and make sure the site still works.

rmunn added 4 commits May 24, 2024 10:46
Advantage of PNPM is speed and storage size on disk: if you have
multiple projects using the same NPM package, NPM will store multiple
copies, but PNPM will store only one copy and share it between projects.

Most recent version of PNPM also requires Node version 18 or later, so
we'll bump any Node 16 references to most recent Node (22.2.0).
Also lets us remove the rebuild of node-sass, which was needed for devs
running a different architecture on their dev machines than the
architecture the Docker containers are built for (e.g. devs running Macs
with ARM chips, when the Docker containers we build are for x64).
Version 2 of date-fns had some assumptions built into the package about
the layout of node_modules that aren't true when pnpm is managing it.
Version 3 of date-fns fixed those assumptions.
@rmunn rmunn added the engineering Tasks which do not directly relate to a user-facing feature or fix label May 24, 2024
@rmunn rmunn self-assigned this May 24, 2024
Copy link

github-actions bot commented May 24, 2024

Unit Test Results

362 tests   362 ✅  12s ⏱️
 37 suites    0 💤
  1 files      0 ❌

Results for commit f9f550d.

♻️ This comment has been updated with latest results.

By specifying `target: development` in docekr-compose.yml, we get the
same effect as specifying `docker build --target=development`: with
buildx, unused build stages (e.g., prod stages) are skipped.
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

thank you, this will be nice and hopefully make things faster and simpler. I did leave some feedback in relation to changes made for #1654

run: npm ci
name: Prep for production build of legacy app
# docker compose build doesn't allow passing a `--target` parameter, so we have to replace the target in docker-compose.yml
run: "sed -i 's/target: development/target: production/g' docker-compose.yml"
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of this could we introduce a merge and a prod build yml file? That way if we need to make other tweaks for prod we can do it easily via adding changes to the file?
then our compose might look like this docker compose -f compose.yml -f compose.prod.yml up -d where the prod just contains the different targets we want, very similar to kustomzie actually.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for the compose merge solution. That could also be a separate PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll make it a separate PR to minimize the chances of merge conflicts (e.g., #1820 also touches workflows and I expect one merge conflict there, which will be easily resolved but if I'm making larger changes to the build process I might get harder-to-handle conflicts).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolving conversation for now, just to unlock the merge button. Then I'll come back and unresolve it so that the suggestion is easy for me to find later.

docker/app/Dockerfile Show resolved Hide resolved
docker/app/Dockerfile Show resolved Hide resolved
docker/app/Dockerfile Show resolved Hide resolved
Copy link
Collaborator

@megahirt megahirt left a comment

Choose a reason for hiding this comment

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

I won't be able to test this right away but if it works then I approve.

run: npm ci
name: Prep for production build of legacy app
# docker compose build doesn't allow passing a `--target` parameter, so we have to replace the target in docker-compose.yml
run: "sed -i 's/target: development/target: production/g' docker-compose.yml"
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for the compose merge solution. That could also be a separate PR?

.github/workflows/pull-request.yml Outdated Show resolved Hide resolved
rmunn added 2 commits May 27, 2024 10:27
One case switched to pnpm dlx instead of pnpm exec because there's no
package.json or node_modules in the test/e2e folder so pnpm exec would
fail, but pnpm dlx will run the tool globally regardless of location.
Can't use `pnpm exec` here either since it's being run in a step where
`pnpm i` has *not* happened, so there's no prettier binary to run.
@rmunn rmunn merged commit 7867825 into develop May 27, 2024
17 checks passed
@rmunn rmunn deleted the chore/switch-to-pnpm branch May 27, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering Tasks which do not directly relate to a user-facing feature or fix
Projects
None yet
4 participants