Initialize yarn for the project
yarn init
Create a index.js file which is the entry point for the package. Inside the index.js file add a console.log to see if the package can be used in other projects.
Initially to test the package we can create a test.js file use the index.js from local and then test the exported objects. But this is not a perfect approach since we want to test the package as a package in other projects. Since it will be not published in npm registery we cannot use to test it directly.
To use the package in other projects locally we can just use the following command in this project.
yarn link
To use this in the project that we want to use this package we can use the following command in that particular project directory
yarn link yarn-package-experiment
Once linking is not required we can unlink the package.
yarn unlink
Unlinking the package in the different project where it is used
yarn unlink yarn-package-experiment
We can also test the package in the same way it will be used once published by using the follwing command.
yarn pack
Adding it to the project
yarn add ~/Personal/Sandboxes/Yarn/yarn-package-experiment/yarn-package-experiment.v1.0.0.tgz