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
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,19 +72,29 @@ We use @testing-library/react for writing tests locally. This library helps mock
72
72
73
73
### Linking
74
74
75
-
We provide a `link` script to help you test in-development components within environments outside of Storybook. To do this, run:
75
+
We provide a `link` script to help you test in-development components within environments outside of Storybook such as in your application. To do this, run:
76
76
77
77
```
78
78
pnpm run link --to=[path-to-application]
79
79
```
80
80
81
-
If you encounter issues while linking, try the following troubleshooting flags:
81
+
The script does the following in order:
82
+
83
+
- It scans the destination application for any installed `leafygreen-ui` components in its `node_modules` folder.
84
+
**NOTE:** If the package is new and unpublished/not installed, you will need to create a directory for the new component within the destination application inside `node_modules` before running this command.
85
+
- If any `leafygreen-ui` components are found then:
86
+
- The script runs `pnpm link` in the corresponding leafygreen-ui package directory to publish a link to the package in the pnpm global registry.
87
+
- The script then runs `pnpm link <package-name>` in the destination application directory to install the package from the published link in the pnpm global registry.
88
+
89
+
After the script completes, you can make changes directly to the component in your local `leafygreen-ui` repository. Once you do this, make sure to rebuild the component and the changes will be visible on your running application.
90
+
91
+
If you encounter issues while linking, try the following any of the following flags:
82
92
83
93
- 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.
84
94
85
95
- 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.
86
96
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:
97
+
- In your destination application 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:
88
98
89
99
```js
90
100
resolve: {
@@ -94,8 +104,7 @@ If you encounter issues while linking, try the following troubleshooting flags:
94
104
},
95
105
```
96
106
97
-
Note: There are some known issues using `pnpm link` from pnpm workspaces. Using Verdaccio, while
98
-
more involved, is the more reliable and recommended approach for testing in an external project.
107
+
Note: There are some known issues in linking packages with `pnpm link`, if you encounter issues, try using a local registry instead. `Verdaccio` for example is a more reliable and recommended approach for testing in an external project.
To publish additional versions, manually the version number in `packages/<package-name>/package.json`, and re-run step 4. Then, either manually update the external project's `package.json`, or re-run `pnpm install @leafygreen-ui/<package-name>`.
187
+
To publish additional versions, manually update the version number in `packages/<package-name>/package.json`, and re-run step 4. Then, either manually update the external project's `package.json`, or re-run `pnpm install @leafygreen-ui/<package-name>`.
To actively develop `leafygreen-ui` components within an application, the following script will link all `leafygreen-ui` components within your application to the local `leafygreen-ui` repository.
244
-
245
-
This will allow you to make changes to your local repository of `leafygreen-ui` and see those changes immediately reflected within your running application. This allows you to develop both in isolation (within `leafygreen-ui`) and in the context of your application.
246
-
247
-
To do this, clone this repository and navigate to the root directory (where `package.json` is located), then run the following:
248
-
249
-
```
250
-
pnpm run link -- ${PATH_TO_APPLICATION}
251
-
```
252
-
253
-
The script does several things in order:
254
-
255
-
1. This builds every `leafygreen-ui` component so they are ready to be linked
256
-
257
-
2. It scans your application for any installed `leafygreen-ui` components in your `node_modules/@leafygreen-ui` folder.
258
-
**NOTE:** If the package is new and unpublished/not installed, you will need to create a directory for the new component within your application inside `node_modules/@leafygreen-ui` before running this command.
259
-
260
-
3. If any `leafygreen-ui` components are found then the script uses `pnpm link` to link every `node_modules/@leafygreen-ui` module to your local `leafygreen-ui` repository.
261
-
262
-
After the script completes, you can make changes directly to the component in your local `leafygreen-ui` repository. Once you do this, run `pnpm build` in the root of the `leafygreen-ui` repository and the changes will be visible on your running application.
243
+
To actively develop `leafygreen-ui` components within an application, we have a `link` script that will link all `leafygreen-ui` components within your application to the local `leafygreen-ui` repository. See the [DEVELOPER.md](./DEVELOPER.md) file for more information.
0 commit comments