Local Development Assemblage
March 6, 2023 ยท View on GitHub
This guide is meant for developers who needs to work on this project and an external project that relies on their changes in this project. For example: the developer creates a new core extension of legend-studio and plan to use this new extension in their external project my-new-dsl. This guide will cover setup needed to make this workflow smooth.
Workstation Setup
Take the example above, let's assume this is the directory structure on your machine:
projects
|__ legend-studio <-- `Legend Studio` project codebase
|__ my-new-dsl <-- `My New DSL` project codebase
You would need to modify my-new-dsl to have all of its relevant dependencies pointing at the packages from legend-studio instead of downloading them from NPM. To achieve this, there are 2 approaches:
- Linking packages: This approach is fast, and particularly useful for development, its caveat is that it might require minor temporary code changes in the consumer project
my-new-dsl. It allows development inlegend-studioto go on at the same time: i.e. if you make changes inlegend-studio, these changes will be automatically propagated tomy-new-dsl. As such, this is the recommended approach. - Using snapshot artifacts: This approach is fairly straight-forward and requires no code-change in consumer project
my-new-dsl, its caveat is that it does not dynamically propagate changes made inlegend-studio: i.e. if you make changes inlegend-studio, you would need to rerun the steps.
Approach 1: Linking packages (recommended)
# Assume that you have already built `legend-studio`
# Run this script from `legend-studio` root
yarn dev:assemblage ../my-new-dsl
If you use webpack to bundle the app, make sure to add:
{
"resolve": {
...
// See https://webpack.js.org/configuration/resolve/#resolvesymlinks
"symlinks": false
}
}
to your webpack config to ensure transitive dependencies are resolved properly.
There is a known problem with
YarnandnodeLinkerwhere transitive dependencies might not get resolved properly when usingportalprotocol. When used withwebpack, if not explicitly stated,webpackwill attempt to resolvesymlinks, which could cause certain dependencies clashes, for example,reactbeing found in 2 places (fromlegend-studio/node_modulesandmy-new-dsl/node_modules); sometimes, this is not an issue, sometimes it could be.
Approach 2: Using snapshot artifacts
# Assume that you have already built `legend-studio`
# Run this script from `legend-studio` root
yarn publish:local-snapshot
yarn dev:assemblage ../my-new-dsl --snapshot
# In `my-new-dsl`
yarn cache clean # clean Yarn cache to avoid reusing older published snapshots
rm -rf ./node_modules # remove ./node_modules directory
rm \"yarn.lock\" && touch \"yarn.lock\" # clear the content of yarn.lock
Cleaning
Yarncache, blowing away thenode_modules, and clearing the content ofyarn.lockare the necessary step to ensuremy-new-dsldoes not pick up an outdated published snapshots fromlegend-studio, this is a limitation with Yarnfile:protocol.
How to Develop
# In `legend-studio`
yarn dev:ts
# then proceed with your development workflow
# In `my-new-dsl`
yarn install
yarn setup
yarn dev
yarn dev:ts
# then proceed with your development workflow