Co-authored-by: Ivan Akulov <mail@iamakulov.com> Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Ivan Akulov <iamakulov@outlook.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: somangshu <somangshu.goswami1508@gmail.com>
993 B
993 B
Shared Dependencies
We wanted to share common logic with different applications within our repo, so we picked yarn workspaces as our approach to tackle this problem. Following are the way in which you can take advantage of the module sharing architecture.
Create a shared module
- Create a directory inside
shared - Inside the directory, create a
package.jsonfile, and set itsnamefield to@shared/<name of the module>. For example, if the module isabc, the name field should be@shared/abc. - Add the module code
- Add a
postinstallscript to build the module as needed, e.g.:
// shared/abc/package.json
{
"name": "@shared/abc",
"scripts": {
"postinstall": "rollup -c"
}
}
Install a shared module
Navigate to the directory where you want to use the module and run yarn add <module-name>.
For example, if the package.json name field is @shared/abc, run
yarn add @shared/abc