You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPER.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,19 +72,27 @@ We use @testing-library/react for writing tests locally. This library helps mock
72
72
73
73
### Linking
74
74
75
-
We also have a link script, such that you can test components that are in development in environments beyond Storybook. To do so, run`yarn run link -- [path-to-application]`.
75
+
We provide a `link` script to help you test in-development components within environments outside of Storybook. To do this, run:
76
76
77
-
Note: There are some known issues using `yarn link` from yarn workspaces. Using Verdaccio, while more involved, is the more reliable and recommended approach for testing in an external project.
77
+
```
78
+
yarn run link --to=[path-to-application]
79
+
```
78
80
79
-
### Using a local registry (Verdaccio)
81
+
If you encounter issues while linking, try the following troubleshooting flags:
80
82
81
-
Publishing test versions to a local registry can be helpful when you need to make changes and test in an external app (or other library). To do this, you can install and use [Verdaccio](https://verdaccio.org/)
83
+
- When linking multiple packages with `--scope` or multiple `--packages` options, link processes run in parallel by default. If you experience failures, add the `--no-parallel` flag to run the linking tasks sequentially, which can help avoid race conditions.
82
84
83
-
#### 1. Install `verdaccio`
85
+
- If you are using a Node version manager such as `asdf` or `nvm`, add the `--launch-env="$(env)"` flag. This ensures the link script spawns commands using your current shell’s environment, preventing environment pollutions that may happen through the tooling of the version manager.
84
86
85
-
```bash
86
-
yarn install --global verdaccio
87
-
```
87
+
- In your external project, make sure your module resolver picks up `'react'` from your own `node_modules` (not from LeafyGreen’s). If using webpack, you can enforce this by adding an alias in your webpack configuration:
Copy file name to clipboardExpand all lines: tools/cli/src/index.ts
+15-2Lines changed: 15 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -83,10 +83,23 @@ cli
83
83
'When running from a consuming application, defines the source of linked packages',
84
84
)
85
85
.option('-v --verbose','Prints additional information to the console',false)
86
-
.option('--scope <name>','The NPM organization')
86
+
.option(
87
+
'--no-parallel',
88
+
'Run the link command sequentially for each package. Useful for debugging or when the parallel approach fails',
89
+
true,
90
+
)
91
+
.option(
92
+
'--launch-env <launchEnv>',
93
+
'A string of environment variable lines as `KEY=VALUE`, separated by a newline. '+
94
+
'Only the specified environment variables will be used during npm link commands in the source and destination directories. '+
95
+
'This is useful to workaround environment variable pollution by tools such as version managers (e.g., asdf) or script runners (e.g., pnpm) that interfere with `npm link`. '+
96
+
'We recommend using --launch-env="$(env)" to use your original shell environment.',
97
+
undefined,
98
+
)
99
+
.option('--scope <name>','The NPM organization, e.g. @lg-charts')
87
100
.option(
88
101
'--packages <names...>',
89
-
'Specific package names (requires `scope` option, or full package name)',
102
+
'Specific package names (requires `scope` option, or full package name) e.g. `@lg-charts/core` or `core` if @lg-charts is the scope',
0 commit comments