ni / nimble

The NI Nimble Design System
https://nimble.ni.dev
MIT License
29 stars 9 forks source link

Storybook link directly to components source code #2131

Closed rajsite closed 1 month ago

rajsite commented 1 month ago

Pull Request

๐Ÿคจ Rationale

This PR is an abomination but hopefully fixes https://github.com/ni/nimble/issues/2118

Turbosnap relies on git source history to detect changes. As a separate package, the storybook build was correctly implemented to rely on the build output of nimble-components and spright-components instead of the non-public source.

However there is not a link that Turbosnap can detect from the source in git to the ephemeral dist output paths that ends up being used during build. So Turbosnap was now unable to follow the dependency path from a story file to specific component source files.

๐Ÿ‘ฉโ€๐Ÿ’ป Implementation

Do as minimally scoped a change as possible to enable storybook to link directly to non-public source code in the nimble-components and spright-components packages. Any other non-mechanical changes have comments in the PR.

๐Ÿงช Testing

I think this build where I reverted a change that was only in the spright rectangle css source confirms that the approach will work. You can see turbosnap detected the original component source file changes for the rectangle story in the log:

Found 5 changed files:
  change/@ni-spright-components-a39f0ecb-4139-47f6-86f7-c22779ee1f08.json
  package.json
  packages/spright-components/src/rectangle/styles.ts
  packages/storybook/.eslintrc.cjs
  packages/storybook/README.md
...
Found affected story files:
  packages/storybook/src/spright/rectangle/rectangle-matrix.stories.ts [./src/spright/rectangle/rectangle-matrix.stories.ts]
  packages/storybook/src/spright/rectangle/rectangle.stories.ts [./src/spright/rectangle/rectangle.stories.ts]
  packages/storybook/src/spright/rectangle/rectangle.mdx [./src/spright/rectangle/rectangle.mdx]
...
โœ” TurboSnap enabled
Capturing 8 snapshots and skipping 582 snapshots.

โœ… Checklist