Friday, 5 February, 2021 UTC


Summary

In this episode of React Wednesdays, we interviewed Chuck Pierce to learn all about Volta, a new open source tool for simplifying the management of JavaScript environments. 
JavaScript developers live in a world of rapidly changing tool versions. It can be quite a chore to maintain the correct set of libraries and plugins for a solo developer. It's much harder to do so across a team. It's even harder for geographically distributed teams. Many hours are lost troubleshooting differences in library versions between environments. 
Volta, the "Hassle-free JavaScript Tool Manager,", is an open source project to simplify the management of JavaScript environments. The team released Volta 1.0 in December 2020. Since we like hassle-free, and we like code, we needed a closer look at the tool.
I learned about Volta when we featured the 1.0 release in our Enterprise React Newsletter. We then asked Chuck Pierce, the lead maintainer of Volta, to come on our React Wednesdays show and demonstrate how Volta simplifies JavaScript toolchain configuration and administration. During the broadcast, we discussed how Volta works, learned its origin story, and even found out why the team chose Rust as the platform language. I encourage you to watch the broadcast. Below are some highlights from the show that are worth mentioning.
What Is Volta?
Volta is a hassle-free way to manage your JavaScript command-line tools. The creators designed the library to stay out of your way. We joked during the broadcast that a new tagline for Volta could be "Works so good you'll forget it's installed." You specify tool configuration for your project using declarative syntax, and Volta handles the tactical details to properly stand-up the environment to your liking. To speed up execution, Volta will serve items from a local cache if possible. 
Who Needs Volta?
You do, if you are the sort of person who wants to avoid diagnostic and troubleshooting work caused by version mismatches. It seems we all have many projects on our file system. You can tell the last time a project was run by the version of the libraries, sort of like the rings of a tree. Environments can get messy when versions compete or are even just slightly different. Volta lets you configure the exact environment needed and then automatically orchestrates the setup and configuration.
A Practical Example of Volta Helping You Out
Imagine you have a project that uses TypeScript. You have TypeScript v3.9 installed globally, but your project dependency is TypeScript 3.8. If TypeScript 3.8 is not installed in the project, likely your environment will be "helpful" by finding and using the globally installed TypeScript binary. This version mismatch could potentially cause problems with your project. Instead of calling the globally registered TypeScript binary, Volta will throw an error, preventing your application from using the wrong binary version.
How to Configure Environments with Volta
The configuration is available at the global or project level. You specify the recipe needed for your project using the familiar package.json file. You'll need to insert a Volta key into the package.json file for node, and any package managers you use. Volta also provides CLI commands for convenience to set the version and write the appropriate configurations.
The rest of your project toolchain configuration is found in the regular 'dependencies' key in your package.json. Any package installable through a supported package manager is administrable by Volta.
Supported Package Managers:
  • npm
  • yarn
  • npx
Coming Soon Package Managers:
  • pnpm
  • pnpx
How Does Volta Work?
Volta creates shims for commands. A call process looks like this:
  1. A command is executed for a toolchain binary.
  2. Usually, the system will call the toolchain binary and execute the command, but Volta intercepts the command
  3. Volta validates the correct version of the binary is installed and available in the project directory.
  4. If the binary is not in place, Volta looks to see if it has a copy of the binary/version. If it does, Volta makes that binary available to the project. If not, it downloads and installs the binary/version and makes the binary available to the project directory.
  5. Volta executes the original command to the binary.
Because of this shim nature, the Volta team wanted to ensure there wouldn't be undue performance issues arising from Volta serving as an intermediary. To squeeze maximum performance, the Volta team chose the Rust programming environment. Rust is a systems-level language with functional language capability. Rust is also cross-platform, allowing Volta to work on Windows, Mac, and Linux. Chuck said the impact of Volta is about 20ms, which is exceptionally lightweight, as I'm sure you'll agree.
Who Sponsors the Development of Volta?
Chuck is a LinkedIn employee primarily working on the Volta project. LinkedIn uses Volta internally and chose to make Volta available as an open-source project. It is reassuring to know a dedicated resource is in charge of the project.
How Is Volta Licensed?
Volta is licensed under the BSD 2-clause license. The BSD 2-clause license is highly permissive and free of weird requirements, so you'll be able to use Volta in your projects, even if your organization requires a legal review of the license.
Where to Go for More Info
  • Broadcast Recording of Volta on React Wednedsay
  • Volta Website
  • Volta on Twitter
  • Volta on GitHub
  • Chuck Pierce on Twitter
  • Chuck Pierce on Github
Final Thoughts
The beauty of our rapidly evolving JavaScript ecosystem also creates pain. Building applications on a foundation of constantly updating libraries injects complexity into the software development process. It’s too easy to use the wrong version and cause problems of both an urgent, and unplanned nature.
As software developers, our job is to regularly and predictably ship meaningful features for our clients, customers, and business partners. Urgent, unplanned work damages project schedules because the software developer must stop working on new functionality and start troubleshoot something that “used to work,” or “works on my machine.” Volta defends your environment against such issues, giving you the control and automation you need to ensure environments are configured exactly the way you want, every time. Isn’t it time you upgraded how you manage your JavaScript environments?