Utilize Yarn's portal to seamlessly link to external local libraries you're developing, allowing your project's source code and configuration to remain consistent with the distributed version, eliminating the need for constant toggling manually between the two.
yarn plugin import https://codeberg.org/devthefuture/yarn-plugin-dev-portal/raw/branch/master/bundles/@yarnpkg/plugin-dev-portal.js
For the smoothest experience with the yarn-dev-portal
plugin, commit the .prod
suffixed files like yarn.lock.prod
and package.json.prod
. While working locally, the default mode of operation is development. This ensures a seamless transition between development activities and production-ready states.
- Enhanced Portal Protocol: The plugin makes use of Yarn's portal protocol for dependencies that are being worked on in parallel.
Understanding the Portal Protocol: The portal protocol is a Yarn feature, allowing for a dependency declaration that points directly to a directory on your disk. This is incredibly helpful when developing multiple interrelated projects concurrently. - Easy Environment Toggling: Switch effortlessly between development and production environments.
- Centralized & Local Portal Repositories: The plugin looks in
~/.yarn-dev-portal
(global) and./.yarn-dev-portal
(local) directories for symlinked repos, integrating them as portals. This supports synchronized development on the primary projects and linked libraries. - Automatic Symlinking: In the absence of
yarn.lock
orpackage.json
files, the plugin creates symlinks that point to their respective.prod
versions.
- Initial Setup: Commit the
.prod
suffixed files:yarn.lock.prod
andpackage.json.prod
.
.gitignore snippet:yarn.lock package.json yarn.lock.dev package.json.dev
- Development Workflow: By default, the plugin operates in development mode. Whenever a
yarn
command is invoked and either theyarn.lock
orpackage.json
file is missing, the plugin will symlink them to their corresponding.prod
versions. Local packages should be linked using Yarn's portal protocol withinpackage.json.dev
. - Toggling Environments: Use
yarn dev-portal dev
to activate the development mode. Switch to production withyarn dev-portal prod
. By default,yarn dev-portal
without arguments sets the mode to development. - Post-Installation: Adding new packages prompts the plugin's post-install command to refresh the associated
yarn.lock
files. - Docker Integration: For integration with Docker, consider the following snippet:
COPY package.json.prod /app/package.json COPY yarn.lock.prod /app/yarn.lock
- Portal Repository Management: Both
~/.yarn-dev-portal
(global) and./.yarn-dev-portal
(local) are scanned by the plugin for symlinked repositories. Every identified symlink is assimilated as a portal. For scoped packages (ones prefixed with@
), the plugin searches the nested subdirectories, ensuring the concurrent development of the main project and the intertwined libraries.
- Thorough Testing: Prior to moving to production, make sure to test your application's performance without the development portal links.
- Ensure the
yarn-dev-portal
plugin is placed at the top of the plugins list in the.yarnrc.yml
file to guarantee that thepackage.json
andyarn.lock
symlinks are present for any other plugins that might require them during repository initialization after cloning. - to configure vscode/vscodium you can put this in
.vscode/settings.json
:{ "files.associations": { "package.json.*": "json" } }
We welcome contributions! If you encounter a bug or have a feature suggestion, please open an issue. To contribute code, simply fork the repository and submit a pull request.
This repository is mirrored on both GitHub and Codeberg. Contributions can be made on either platform, as the repositories are synchronized bidirectionally.
- Codeberg: https://codeberg.org/devthefuture/yarn-plugin-dev-portal
- GitHub: https://github.com/devthefuture-org/yarn-plugin-dev-portal
For more information: