-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(all): switch from yarn to pnpm
I tried to get all the apps and libraries under a single yarn workspace and found I could not do it. This message describes the difficulties I had. `react-scripts` does some preflight checks to ensure that there isn't another resolvable copy of some of the packages it needs that might conflict with the versions it wants. When it finds one, [it bails with an error message](facebook/create-react-app#4296). Trying to put multiple `react-scripts`-using projects into the same yarn workspace means that yarn will hoist shared dependencies, such as `babel-eslint`, to the root. Thus, these packages become visible to the preflight check and it aborts. To work around this, you can use the [`nohoist`](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) option to tell yarn which packages not to hoist. This sort of worked, but there were subtle issues remaining. I got BMD and ballot-encoder into the workspace together, but when I added election-manager [it broke BMD](#139). I still don't know exactly why, but I believe something changed the versions of some packages that BMD was using in a way that caused the tests to fail. Sometimes multiple packages reference the same types, i.e. for a mutual dependency. However, sometimes they'd end up using different (and subtly incompatible) versions of the same `@types/` package. When this happened, the best recourse was to use another yarn workspaces feature: `resolutions`. This allows you to configure what version packages should resolve to. This fixed most of the type incompatibility issues, but I suspect it caused another issue. I noticed some crashes due to an API incompatibility. Specifically, one of the `@babel/` packages required another one in the `^7.12.0` range, but yarn hooked it up with `7.8.6`. Why? I don't know. Perhaps it was the `resolutions` stuff. I was only able to work around this by finding the entry in the `yarn.lock` file, deleting it, and re-running `yarn`. I tried both npm v7 and pnpm. npm v7 has support for workspaces similar to yarn, but does not yet have support for configuring hoisting behavior. Lacking hoisting control meant it hoisted everything it could, which made `react-scripts` angry. Thus I couldn't use npm v7. Previous versions of pnpm did not hoist anything, and still was able to share dependencies by symlinking. Though it does hoist by default now, that behavior can be turned off. So I added `hoist = false` to `.npmrc` and then started trying to run everything to determine what would break without hoisting. It turns out that a good number of packages have implicit dependencies that hoisting allowed them to access, but that could not be accessed in a non-hoisted `node_modules` layout. pnpm has a hook called `readPackage` that allows altering the package data for any npm package using any custom logic you want. This allows us to act as if these packages with implicit dependencies actually had those dependencies listed explicitly. In my testing, this has yielded a good balance of correctness and functionality. So pnpm seems to work and I think is flexible enough to meet our needs going forward.
- Loading branch information
1 parent
e3f6765
commit 8fe2a7e
Showing
56 changed files
with
21,777 additions
and
63,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Prevent packages from accessing anything they don't explicitly depend on. This | ||
# is mostly here so that the `react-scripts` preflight check succeeds and does | ||
# not find babel-eslint or babel-jest or any of the other packages it is afraid | ||
# it might get the wrong version of. | ||
hoist = false | ||
|
||
# We _do_ try to hoist `@types` packages so that TS will not end up with type | ||
# errors from comparing types from different versions of the same package. | ||
public-hoist-pattern=['@types/*'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# vxsuite | ||
|
||
The VotingWorks in-person voting system. | ||
|
||
## About | ||
|
||
Includes software for a [ballot-marking device (BMD)](./apps/bmd), a | ||
[ballot activation system (BAS)](./apps/bas), a | ||
[ballot scanning device (BSD)](./apps/bsd), and an | ||
[election manager](./apps/election-manager). See https://voting.works for more | ||
information about VotingWorks. | ||
|
||
## Development | ||
|
||
Building VxSuite for development requires git, [NodeJS](https://nodejs.org/) | ||
v12.19.0 and [pnpm](https://pnpm.js.org). | ||
|
||
### Ubuntu Quickstart | ||
|
||
This expects Ubuntu 18.0.4, though it may work on other versions. This installs | ||
the right version of NodeJS manually. You can use a tool like | ||
[nvm](https://github.com/nvm-sh/nvm) or [volta](https://volta.sh) to do this in | ||
a nicer way. | ||
|
||
```sh | ||
# change this to wherever you want: | ||
NODE_ROOT="${HOME}/usr/local/nodejs" | ||
|
||
# download and install: | ||
mkdir -p "$NODE_ROOT" | ||
curl -sLo- https://nodejs.org/dist/v12.19.0/node-v12.19.0-linux-x64.tar.gz | \ | ||
tar xz --strip-components 1 -C "${NODE_ROOT}" | ||
|
||
# configure your shell; this assumes bash: | ||
echo "export PATH=\$PATH:${NODE_ROOT}/bin" | ||
export PATH="${PATH}:${NODE_ROOT}" | ||
node -v # should print "v12.19.0" | ||
|
||
# install pnpm: | ||
npm i -g pnpm | ||
|
||
# clone the repository: | ||
sudo apt install git -y # in case you don't have git | ||
mkdir -p ~/src && cd ~/src | ||
git clone https://github.com/votingworks/vxsuite.git | ||
|
||
# install dependencies: | ||
cd vxsuite | ||
pnpm install | ||
|
||
# try out BMD: | ||
cd apps/bmd | ||
pnpm start | ||
# if it worked, go to http://localhost:3000/ | ||
``` | ||
|
||
See the individual README documents for more information on how to run the individual services. | ||
|
||
## License | ||
|
||
GPLv3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.