PromucFlow_constructor/app/shared
Ayangade Adeoluwa 3de00c6bf4
feat: Extraction of AST Logic (#15892)
* POC for Shared AST Logic using Yarn Symlinks

* fix: preinstall script for bundling shared packages

* Merge commit

* fix: updated the script to link, unlink the package as shared dep

* fix: updated dependencies

* Add a post-install script and fix yarn.lock file

* Remove commented code

* fix: added verification script, readme, moved scripts to shared

* Extraction of AST Logic into shared/ast folder

* Add jest test script

* Replace hardcoded ast Logic use with Shared AST module

* Replace parse code with getAST

Co-authored-by: Aman Agarwal <aman@appsmith.com>
2022-08-23 16:39:42 +05:30
..
ast feat: Extraction of AST Logic (#15892) 2022-08-23 16:39:42 +05:30
.gitignore feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30
build-shared-dep.js feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30
install-dependencies.js feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30
package.json feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30
Readme.md feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30
shared-dependencies.json feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30
verify-shared-dep.js feat: ast mono repo poc (#15610) 2022-08-11 20:59:26 +05:30

Shared Dependencies

We wanted to share common logic with different applications within our repo, so we picked yarn symlinks as our approach to tackle this problem. Following are the way in which you can take advantage of the module sharing architecture.

Creation of a Shared Module

  • Create a directory inside shared directory with name eg. abc
  • Inside package.json of module, keep the name like @shared/abc
  • Add a rollup config to generate package.json after the module is build

Installation of Shared Modules

  • Add an entry for an application inside shared-dependencies.json eg. for client there should be an entry "client": []
  • Add the name of the shared module in the entry of the application in the above file eg. "client": ["@shared/abc"]
  • If the application does not have any postinstall or preinstall scripts for shared modules then add the two commands described below in the application's (eg. client) package.json : "postinstall": "CURRENT_SCOPE=client node ../shared/install-dependencies.js" "preinstall": "CURRENT_SCOPE=client node ../shared/build-shared-dep.js" CURRENT_SCOPE is the environment variable that's being used in the scripts

Verifying the Installed Shared Modules

  • Run yarn run verify inside shared directory to verify shared dependencies for an application.