Skip to content

Commit

Permalink
docs: add importance of subpath import order
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejilderda committed Jul 11, 2024
1 parent 87b1e9f commit fa327f2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ To configure subpath imports, you define the `imports` property in your project'

{/* prettier-ignore-end */}

There are two aspects to this configuration worth noting:
There are three aspects to this configuration worth noting:

First, **each subpath must begin with `#`**, to differentiate it from a regular module path. The `#*` entry is a catch-all that maps all subpaths to the root directory.

Second, note the **`storybook`, `test`, and `default` keys** in each module's entry. The `storybook` value is used to import the mock file when loaded in Storybook, while the `default` value is used to import the original module when loaded in your project. The `test` condition is also used within Storybook, which allows you to use the same configuration in Storybook and your other tests.
Second, the order of the keys is important. The `default` key should come last.

Third, note the **`storybook`, `test`, and `default` keys** in each module's entry. The `storybook` value is used to import the mock file when loaded in Storybook, while the `default` value is used to import the original module when loaded in your project. The `test` condition is also used within Storybook, which allows you to use the same configuration in Storybook and your other tests.

With the package configuration in place, you can then update your component file to use the subpath import:

Expand Down

0 comments on commit fa327f2

Please sign in to comment.