A monorepo for Presentation packages.
-
Install dependencies.
pnpm install
-
Build test-app.
pnpm build:test-app
-
Start test-app.
3.1 Web version of test-app.
pnpm start:web
3.2. Electron version of test-app.
pnpm start:electron
Test-app is setup to be debugged using Visual Studio Code. Debug session can be started using provided configurations:
Test App (web)
for debugging web version of test-app.Test App (electron)
for debugging electron version of test-app.
For local development it is recommended to setup CoSpace
. It provides a convenient way to link local versions of packages from other repositories like: itwinjs-core
, appui
.
-
Initialize
CoSpace
.npx cospace@latest init my-cospace
-
Clone repos you want to link together under the
repos
sub directory. List of recommended repos to clone:-
See Get and build imodel02 code page for instructions to build native addon.
-
Update the
pnpm-workspace.yaml
file with all the packages you want to add to yourCoSpace
. By default all packages under therepos
sub directory will be added. Recommended configuration:packages: # presentation - "repos/presentation/**" # or just enough to build the presentation-test-app # - "repos/presentation/apps/test-app/**" # - "repos/presentation/apps/build-tools" # - "repos/presentation/packages/**" # itwinjs-core - "repos/itwinjs-core/presentation/*" - "repos/itwinjs-core/core/**" - "repos/itwinjs-core/tools/**" - "repos/itwinjs-core/ui/*" # appui - "repos/appui/ui/**"
-
Copy all the pnpm catalogs configuration from
repos/presentation/pnpm-workspcace.yaml
to the rootpnpm-workspace.yaml
in the cospace. -
Update the
cospace.code-workspace
file with all the repos you want to add to your vscode multi-root workspace. -
Add the following to the
pnpm.overrides
section of theCoSpace
'spackage.json
:"overrides": { // other overrides "@types/node": "^20.12.12", }
Note: You might have to add new packages or update versions of ones that are listed above in the
pnpm.overrides
section. To know which versions you need look at thedependencies
sections ofitwinjs-core > common > config > rush > pnpm-lock.aml
file. -
Run
pnpm exec cospace override
to automatically update thepnpm.overrides
section of theCoSpace
'spackage.json
, to link all the dependencies together with the copy found in the workspace. -
Run
pnpm install
to install all dependencies in your workspace and link all the packages you've added to yourCoSpace
. -
Run
pnpm build
to build all the packages you've added to yourCoSpace
using your monorepo task runner. -
There might be build issues due to different versions of dependencies resolved.
In order to debug packages from different repos using Visual Studio Code
you will need launch configuration at your CoSpace
root. Example configuration for debugging presentation test-app and locally built presentation packages from itwinjs-core (you may need to adjust paths and pathMapping
for [presentation-test-app] Launch Browser
configuration according your CoSpace
setup):
{
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "[presentation-test-app] Start Web Backend",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}/repos/presentation/apps/test-app/backend",
"program": "${workspaceFolder}/repos/presentation/apps/test-app/backend/lib/main.js",
"outFiles": [
"${workspaceFolder}/repos/presentation/apps/test-app/{backend, common}/**/*.js",
"${workspaceFolder}/repos/itwinjs-core/presentation/{backend, common}/**/*.js",
"${workspaceFolder}/repos/itwinjs-core/core/{backend, common}/**/*.js",
"!**/node_modules/**"
]
},
{
"type": "node",
"request": "launch",
"name": "[presentation-test-app] Start Web Server",
"cwd": "${workspaceFolder}/repos/presentation/apps/test-app/frontend",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "start"]
},
{
"type": "chrome",
"request": "launch",
"name": "[presentation-test-app] Launch Browser",
"url": "http://localhost:3000/",
"webRoot": "${workspaceFolder}/repos/presentation/apps/test-app/frontend",
"pathMapping": {
"/@fs": ""
}
}
],
"compounds": [
{
"name": "[presentation-test-app] Debug Test App",
"configurations": ["[presentation-test-app] Start Web Backend", "[presentation-test-app] Start Web Server", "[presentation-test-app] Launch Browser"]
}
]
}
}
Additional configuration for presentation-test-app in repos/presentation/apps/test-app/frontend/vite.config.mts
might be needed when linking with local version of itwinjs-core
packages:
{
server: {
// other settings
fs: {
allow: ["../../../../../"], // relative path to cospace root
}
},
resolve: {
alias: [
// other aliases
{
find: "@itwin/core-electron/lib/cjs/ElectronFrontend",
replacement: "@itwin/core-electron/src/ElectronFrontend.ts",
}
]
},
optimizeDeps: {
force: true,
include: [
"@itwin/core-electron/lib/cjs/ElectronFrontend",
]
exclude: ["@itwin/core-frontend", "@itwin/core-common"]
}
}