Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Different approaches to testing your own packages locally: Relative Deps

Posted on Jun 13 In this article, we will explore a practical solution for testing your own packages locally without the need to publish them to production and risking any potential issues. By leveraging the power of relative-deps, we can easily link our libraries with our projects during development, ensuring that everything works seamlessly without impacting the production environment. Let's dive in and discover how this useful tool can simplify our testing process and make our coding experience even more enjoyable.This is part of a series of articles:The official description says: Installs dependencies from a local checkout and keeps them in sync, without the limitations of npm link.Imagine you are working on your awesome project and you need to check if your fancy Library works with the new changes you just made but without publishing and pushing your changes to prod. You don’t want to test in production, right?I've got you covered; relative-deps to the rescue!With relative-deps you can link your library with a relative path to your project while developing and testing it locally, making sure you don’t break stuff in prod. This package is super simple to use and easy to set up. Let’s get started!Like the previous articles, we have the following folder structure:In the root of your project (my-awesome-project), you need to install relative-deps:Running this script will install relative-deps, add the prepare script and initialize an empty relativeDependencies section.You will use the prepare script after changing something in your fancy library. This will update the project with the latest changes from your library.Now, you need to add your library as a relative dependency in your project. You can do this by running the following command:After running this command, you will see that the relativeDependencies section has been updated with the path to your library.It's ready! 🎉 Now you can start using your library in your project as if it was published with the latest changes you just did without publishing it to prod.After making changes to your library, you need to update your project with the latest changes. To do that you need to run the build script in your library and then run the prepare script in your project.This will update your project with the latest changes from your library. Have you seen how fast it is? ⚡️If you want to remove your library from your project, just delete the entries created in the relativeDependencies section and in the devDependencies section. Delete the prepare script as well and you are good to go.In conclusion, relative-deps provides a straightforward and efficient solution for local package testing. By allowing us to link our libraries with our projects using relative paths, it eliminates the need for publishing and deploying changes to production. With its speedy update process, it proves to be one of the best alternatives available. Embracing relative-deps can greatly enhance our development workflow, ensuring seamless integration and preventing potential issues in the production environment. Give it a try and experience the convenience and speed it brings to your package testing endeavors. 🧑‍💻 Happy coding!Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Duc Dao - May 30 Nitin Sharma - Jun 7 Jasmin Virdi - May 26 Syed Sadiq ali - Jun 2 Once suspended, one-beyond will not be able to comment or publish posts until their suspension is removed. Once unsuspended, one-beyond will be able to comment and publish posts again. Once unpublished, all posts by one-beyond will become hidden and only accessible to themselves. If one-beyond is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to Jorge Baumann. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag one-beyond: one-beyond consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging one-beyond will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Different approaches to testing your own packages locally: Relative Deps

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×