@@ -39,22 +39,53 @@ This repository is optimized for [Yarn](https://yarnpkg.com/) v4 or greater and
3939may not work with NPM or other package managers. Run ` corepack enable ` to enable
4040the ` yarn ` command that is bundled with this repository.
4141
42- ### Environment variables
42+ #### Environment variables
4343
4444In order to make map-based examples work, you will have to set the
4545` VITE_MAPBOX_API_TOKEN ` environment variable to a valid Mapbox token. You can do
4646this by creating a ` .env ` file in the root of the repository.
4747
48- ### Developing components with storybook
48+ ### Developing components
49+
50+ #### Using Storybook as a component workbench
4951
5052We use [ Storybook] ( https://storybook.js.org/ ) for developing components in an
5153isolated environment. To start the storybook, run ` yarn run dev ` in the root
52- directory. The storybook will start at port ` 6006 `
54+ directory. The storybook will start at port ` 6006 ` . You can then create new
55+ 'stories' referencing components to create standalone views. This is the main
56+ approach for component development preferred by the Macrostrat team.
57+
58+ #### Developing components in a consuming application
59+
60+ Sometimes, it can be useful to prototype components as you are developing a
61+ consuming application. To do this, you can use ` yarn link ` (or an equivalent
62+ command in your package manager) to link the packages in this monorepo to your
63+ application.
64+
65+ For instance, if you were working on the
66+ [ Macrostrat web] ( https://github.com/UW-Macrostrat/web ) repository, you could run
67+ the following commands:
68+
69+ ``` sh
70+ # In the `web` directory with a `web-components` directory at the same level
71+ yarn link -A -r ../web-components
72+ # Creates relative links to the packages in the `web-components` directory
73+ ```
5374
54- ### Other commands
75+ This will link the packages in the ` web-components ` directory to the ` web `
76+ application using the [ "portal" protocol] ( https://yarnpkg.com/protocol/portal ) .
77+
78+ The ` package.json ` ` resolutions ` entries created by this linking process should
79+ be removed before publishing the application, as they will prevent the
80+ application from being compiled correctly in CI or a new environment.
81+
82+ ### Other useful commands
5583
5684- Check types: ` yarn run check `
5785- Build all packages locally: ` yarn run build `
86+ - Check how a package is consumed: ` yarn why <package-name> `
87+ - General information about packages and dependencies:
88+ ` yarn info -A -R <package-name> `
5889
5990### Publishing packages
6091
@@ -77,15 +108,19 @@ organization) to publish packages.
77108#### Upgrading storybook
78109
79110```
111+
80112yarn dlx storybook@latest upgrade
113+
81114```
82115
83116#### Upgrading dependencies
84117
85118It can be useful to upgrade a specific dependency to its latest version:
86119
87120```
121+
88122yarn up -i <package-name>
123+
89124```
90125
91126#### Maintaining references
0 commit comments