Skip to content

Commit

Permalink
chore: add jsdoc explaining the need for getAbsoluteDependencyPath
Browse files Browse the repository at this point in the history
  • Loading branch information
tkajtoch committed May 13, 2024
1 parent 334f250 commit 208e430
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/eui/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
import path from 'path';
import type { StorybookConfig } from '@storybook/react-webpack5';

/**
* Get an absolute path to package's `node_modules` directory. It's compatible
* with yarn hoisting logic.
*
* It works by resolving a path to its `package.json` file since it's the only
* file that must exist in the package's root directory. Resolving the package
* itself would return a path to the entry point that could be anywhere within
* that package's directory.
*
* @see {@link https://github.com/storybookjs/storybook/issues/21710#issuecomment-1604260157}
*/
const getAbsoluteDependencyPath = (packageName: string) =>
path.dirname(require.resolve(path.join(packageName, 'package.json')));

Expand Down

0 comments on commit 208e430

Please sign in to comment.