Skip to content

Commit

Permalink
Merge pull request #28546 from andrejilderda/docs/add-importance-of-s…
Browse files Browse the repository at this point in the history
…ubpath-import-order

Docs: add importance of subpath import order
  • Loading branch information
jonniebigodes authored Jul 11, 2024
2 parents b44ffd8 + 0740b24 commit f8f9f1b
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 f8f9f1b

Please sign in to comment.