Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Auto-disable docs presets if docs/controls unused #17697

Merged
merged 21 commits into from Mar 14, 2022

Conversation

shilman
Copy link
Member

@shilman shilman commented Mar 12, 2022

Issue: #16210

What I did

  • Added verbose setting to node-logger
  • Add utility to test whether addon-docs/controls is used by the user
  • Auto-disable docs presets for each of the frameworks that provide it
  • Documented the changes in MIGRATION.md

What to review

  1. The MIGRATION notes
  2. Overall structure: does this form of disabling make sense? Note that there is no way to force these presets to execute if you're not using docs or controls addon
  3. Every preset function has the following "exit early" pattern. I would've preferred to conditionally remove the entire docs preset rather than each preset function, but unfortunately, the preset/addon hierarchy must be statically defined (for good reason):
export const config: StorybookConfig['config'] = (entry = [], options) => {
  if (!hasDocsOrControls(options)) return entry;
  return [...entry, findDistEsm(__dirname, 'client/docs/config')];
};

How to test

With and without addon-essentials in .storybook/main.ts:

cd examples/react-ts
yarn storybook --loglevel=verbose

@nx-cloud
Copy link

nx-cloud bot commented Mar 12, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit 2c351b3. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@shilman shilman requested a review from tmeasday March 13, 2022 18:06
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor nit suggestion

lib/docs-tools/src/hasDocsOrControls.ts Outdated Show resolved Hide resolved
Base automatically changed from 16210-fix-docs-dependencies to next March 14, 2022 02:56
@shilman shilman changed the title Addon-docs: Auto-disable docs presets if docs/controls is unused Addon-docs: Auto-disable docs presets if docs/controls unused Mar 14, 2022
@shilman shilman merged commit edde091 into next Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants