-
Notifications
You must be signed in to change notification settings - Fork 91
Sylwia/adds monorepo support section #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
bfb68cb
a2ad4f8
e30fc7f
ed13d4b
9a9b6a2
b3f1a74
9aba289
480cd22
ea80e3b
a484f75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,6 @@ Follow these steps: | |
|
||
To integrate the bot, please follow the instructions on [Integrating CodeflowApp bot](./integrating-codeflowapp-bot.md). | ||
|
||
|
||
## Troubleshooting | ||
|
||
### Out of memory error | ||
|
@@ -92,6 +91,10 @@ It may happen that having a few Codeflow IDE or StackBlitz projects open at the | |
|
||
<!-- @include: ../parts/error-out-of-memory.md --> | ||
|
||
### Can't switch to a remote branch | ||
|
||
Currently, when you load your repository, Codeflow only pulls in the branch you are trying to open or the default one. For now, to switch to a remote branch you can either fetch the branches (by running `git fetch` in the terminal) or immediately open the desired branch through its URL by following this pattern: `http://pr.new/github/${owner}/${repo}/tree/${branchName}` | ||
|
||
### Preview doesn't work | ||
|
||
If the Preview doesn't work, oftentimes browser configuration or browser incompatibility is the culprit. Please see [this page for troubleshooting](/platform/webcontainers/browser-support). | ||
|
@@ -109,3 +112,9 @@ Check in the terminal if the dev server is still running. If you want to restart | |
### Reopening the Preview panel | ||
|
||
If you close the Preview by accident, you can reopen it by selecting the icon of a plug entitled "Ports in use" from the left-side navigation bar. Note that you can open the Preview in a separate tab or as a split screen. | ||
|
||
## Running monorepos in Codeflow IDE | ||
|
||
Codeflow IDE supports workspaces. Follow a walkthrough below to get your monorepo running in Codeflow. <!-- @include: ../parts/monorepo-support.md --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not fond of having a large content fragment that we include in several places, to be honest. I like having a single URL where content leaves. Might be better for SEO (avoids the risk of a search engine classing a page as duplicate content and removing it from its index), and for search (you don't get two competing results for the same information). |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
You can also see demos for each of the package managers in this [monorepo demo collection](https://stackblitz.com/@d3lm/collections/workspaces). | ||
|
||
### npm | ||
|
||
Your project repository may look like this: | ||
|
||
``` | ||
workspace-project | ||
├─ packages | ||
│ ├─ backend | ||
│ │ ├─ package.json | ||
│ │ └─ index.js | ||
│ ├─ frontend | ||
│ │ ├─ package.json | ||
│ │ └─ index.js | ||
│ └─ common | ||
│ ├─ package.json | ||
│ └─ index.js | ||
└─ package.json | ||
``` | ||
|
||
To define a workspace, add the `workspaces` field to the `package.json`: | ||
|
||
``` | ||
sylwiavargas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"workspaces": [ | ||
"packages/*" | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this page, some of our examples of fragments from My vote would be for no trailing comma, because:
It's hard to predict where users will need to add commas exactly to have valid JSON, so I'd rather let users be responsible for that. But I’m fine with always including the trailing comma if we think that's better (as long as we're consistent). |
||
``` | ||
|
||
This refers to every sub-directory inside `packages` which contains a `package.json`. | ||
|
||
Check [npm documentation](https://docs.npmjs.com/cli/v7/using-npm/workspaces) for more information or [this npm-based monorepo demo](https://stackblitz.com/edit/node-4cygsf?file=README.md) for reference. | ||
sylwiavargas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### pnpm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
To configure a workspace with pnpm, add the `pnpm-workspace.yaml` file to the root of the project: | ||
|
||
```yaml | ||
packages: | ||
- 'packages/*' | ||
``` | ||
|
||
Next, add a package from the workspace as a dependency to another package. In the example below we define `frontend` as dependent on `common`: | ||
|
||
```json | ||
"dependencies": { | ||
"common": "workspace:^1.0.0" | ||
} | ||
``` | ||
|
||
The `workspace:` protocol ensures the correct package from the workspace is used. However, this is not required because, by default, pnpm will link packages from the workspace if the available packages match the declared ranges. | ||
|
||
Check [pnpm documentation](https://pnpm.io/workspaces) for more information or [this pnpm-based monorepo demo](https://stackblitz.com/edit/node-gw1rvh?file=README.md) for reference. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally the two example projects we link from this page could have:
|
||
|
||
|
||
### Yarn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we specify that we support Yarn v1 only? I'm not sure if Yarn Berry (v2+) workspaces are exactly the same or different. |
||
|
||
To define a workspace with yarn, add the `workspaces` field to our `package.json`: | ||
|
||
``` | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
``` | ||
|
||
This refers to every sub-directory inside `packages` which contains a `package.json`. | ||
|
||
:::info | ||
Note that a yarn workspace looks somewhat identical to an npm workspace. For the most parts that's true, but yarn also has [`nohoist`](https://classic.yarnpkg.com/blog/2018/02/15/nohoist). | ||
sylwiavargas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
::: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Monorepo support in WebContainers | ||
--- | ||
|
||
# {{ $frontmatter.title }} | ||
|
||
|
||
WebContainers support workspaces. Follow a walkthrough below to get your monorepo running in WebContainers. <!-- @include: ../../parts/monorepo-support.md --> |
Uh oh!
There was an error while loading. Please reload this page.