Skip to content

Conversation

@ndelangen
Copy link
Member

@ndelangen ndelangen commented Oct 6, 2025

What I did

I've added a deprecation warning about us dropping pnp support starting sb11 in both the create-storybook step as well as the dev command.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • New Features

    • Improved Yarn Plug’n’Play (PnP) compatibility across manager, presets, and project scaffolding.
    • Automatic PnP detection during development and project initialization.
  • Deprecations

    • Emits a deprecation notice when PnP is detected, signaling planned removal in a future major release.
  • Chores

    • Removed internal PnP sandbox template.
    • Include webpack in the React Scripts generator.
    • Added an optional PnP flag to internal load options.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 6, 2025

📝 Walkthrough

Walkthrough

Adds Yarn Plug'n'Play (PnP) detection and deprecation notices to init/dev flows, integrates PnP plugins into the builder/CRA webpack resolution, exposes a package-manager API to read installed package versions, extends types with an optional pnp flag, deletes an internal PnP sandbox template, and scatters SB11 TODO comments.

Changes

Cohort / File(s) Summary of edits
PnP detection & deprecation
code/core/src/cli/detect.ts, code/core/src/core-server/build-dev.ts, code/lib/create-storybook/src/initiate.ts, code/core/src/types/modules/core-common.ts
Added detectPnp() and use of it to set options.pnp; emit deprecation notices when PnP is present; added pnp?: boolean to LoadOptions.
Builder / Webpack PnP integration
code/core/src/builder-manager/index.ts, code/core/src/core-server/typings.d.ts, code/presets/create-react-app/src/index.ts
Imported esbuild PnP plugin; declared ambient module for pnp-webpack-plugin; integrated pnp-webpack-plugin into CRA preset resolveLoader and resolve.plugins.
Package manager API
code/core/src/common/js-package-manager/JsPackageManager.ts
Added `getInstalledVersion(packageName: string): Promise<string
Automigration & templates
code/lib/cli-storybook/src/automigrate/fixes/wrap-getAbsolutePath-utils.ts, code/lib/cli-storybook/src/sandbox-templates.ts
Added detection for alternative wrapper name wrapForPnp; removed the internal template entry internal/pnp.
Generators & CLI notes
code/lib/create-storybook/src/generators/REACT_SCRIPTS/index.ts, code/lib/create-storybook/src/generators/baseGenerator.ts, code/lib/create-storybook/src/generators/types.ts, code/lib/create-storybook/src/bin/run.ts, code/lib/cli-storybook/src/bin/run.ts
Added webpack to React Scripts generator extraPackages; inserted TODO comments about removing PnP in SB11; no behavioral changes.
Non-functional TODO comments
code/core/src/common/js-package-manager/PNPMProxy.ts, code/core/src/common/js-package-manager/Yarn2Proxy.ts, code/core/src/common/utils/strip-abs-node-modules-path.ts, code/core/src/telemetry/get-framework-info.ts, code/core/src/telemetry/get-package-manager-info.ts, code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts, code/renderers/react/src/preset.ts, scripts/sandbox/utils/yarn.ts, scripts/utils/yarn.ts
Inserted SB11 / PnP removal TODO comments; no functional changes.
Test sandbox note
test-storybooks/yarn-pnp/.yarnrc.yml
Added top-of-file TODO comment noting test directory removal in SB11.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CLI as CLI / create-storybook
  participant Detect as detectPnp()
  participant Initiate as initiate / installStorybook
  participant Logger as deprecate/logger

  CLI->>Detect: check for .pnp.{js,cjs}
  Detect-->>CLI: returns boolean pnp
  CLI->>Logger: if pnp true -> emit deprecation notice
  CLI-->>Initiate: continue init/install flow
Loading
sequenceDiagram
  autonumber
  participant Dev as buildDev
  participant Detect as detectPnp()
  participant Builder as builder-manager (esbuild)
  participant Preset as CRA preset
  participant PNPPlugin as pnp-webpack-plugin

  Dev->>Detect: detect PnP
  Detect-->>Dev: pnp flag
  Dev->>Builder: set options.pnp and import esbuild-plugin-pnp
  Dev->>Preset: enable PNP integrations
  Preset->>PNPPlugin: add moduleLoader to resolveLoader
  Preset->>Preset: add PNP to resolve.plugins
  Note right of PNPPlugin: resolution hooks applied when PnP present
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Files/areas to pay extra attention to:

  • code/core/src/core-server/build-dev.ts — propagation of options.pnp into build flows and standalone path.
  • code/presets/create-react-app/src/index.ts — correctness and typings when adding pnp-webpack-plugin to resolve and resolveLoader.
  • code/core/src/common/js-package-manager/JsPackageManager.ts — correctness and race conditions around getInstalledVersion caching and filesystem reads.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch norbert/mark-pnp-deprecated

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a80203c and e055907.

📒 Files selected for processing (1)
  • code/lib/cli-storybook/src/sandbox-templates.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • code/lib/cli-storybook/src/sandbox-templates.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Danger JS
  • GitHub Check: Core Unit Tests, windows-latest

Comment @coderabbitai help to get the list of available commands and usage tips.

@ndelangen ndelangen requested review from JReinhold and shilman October 6, 2025 11:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
code/core/src/common/js-package-manager/JsPackageManager.ts (1)

674-707: Fix cache key inconsistency.

The cache key at line 677 only uses packageName, but the comment at line 680 mentions "both working directory and package name for isolation." Additionally, clearInstalledVersionCache at lines 486-496 expects keys to include a working directory prefix (checking key.endsWith(\::${packageName}`)`), which creates a mismatch.

Apply this diff to align the cache key with the documented behavior and clearing logic:

 // TODO: Remove pnp compatibility code in SB11
 /** Returns the installed (within node_modules or pnp zip) version of a specified package */
 public async getInstalledVersion(packageName: string): Promise<string | null> {
-  const cacheKey = packageName;
+  const cacheKey = `${this.cwd}::${packageName}`;

   try {
-    // Create cache key that includes both working directory and package name for isolation
-
     // Check cache first
     const cachedVersion = JsPackageManager.installedVersionCache.get(cacheKey);
🧹 Nitpick comments (2)
code/lib/create-storybook/src/generators/REACT_SCRIPTS/index.ts (1)

49-51: Consider moving the TODO closer to the prop-types dependency for clarity.

The TODO on line 49 appears to refer to the prop-types dependency (lines 50-51) that's explicitly tied to Yarn PnP mode, but its placement between the webpack and prop-types lines creates ambiguity about what "this" refers to.

Apply this diff to improve clarity:

   const extraPackages = [];
   extraPackages.push('webpack');
-  // TODO: Evaluate if this is correct after removing pnp compatibility code in SB11
   // Miscellaneous dependency to add to be sure Storybook + CRA is working fine with Yarn PnP mode
+  // TODO: Evaluate if prop-types is still needed after removing PnP compatibility code in SB11
   extraPackages.push('prop-types');
code/core/src/cli/detect.ts (1)

173-176: Consider adding search boundary for consistency.

The detectPnp() function doesn't specify a last option to limit the search scope, unlike other detection functions in this file (e.g., detectBuilder at lines 115-116). This could lead to inconsistent behavior where PnP detection searches beyond the project root.

Apply this diff to align with the pattern used by other detection functions:

 // TODO: Remove in SB11
 export async function detectPnp() {
-  return !!find.any(['.pnp.js', '.pnp.cjs']);
+  return !!find.any(['.pnp.js', '.pnp.cjs'], { last: getProjectRoot() });
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38b157d and 51c0518.

📒 Files selected for processing (25)
  • code/core/src/builder-manager/index.ts (1 hunks)
  • code/core/src/cli/detect.ts (1 hunks)
  • code/core/src/common/js-package-manager/JsPackageManager.ts (1 hunks)
  • code/core/src/common/js-package-manager/PNPMProxy.ts (1 hunks)
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts (1 hunks)
  • code/core/src/common/utils/strip-abs-node-modules-path.ts (1 hunks)
  • code/core/src/core-server/build-dev.ts (2 hunks)
  • code/core/src/core-server/typings.d.ts (1 hunks)
  • code/core/src/telemetry/get-framework-info.ts (1 hunks)
  • code/core/src/telemetry/get-package-manager-info.ts (1 hunks)
  • code/core/src/types/modules/core-common.ts (1 hunks)
  • code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts (1 hunks)
  • code/lib/cli-storybook/src/automigrate/fixes/wrap-getAbsolutePath-utils.ts (1 hunks)
  • code/lib/cli-storybook/src/bin/run.ts (1 hunks)
  • code/lib/cli-storybook/src/sandbox-templates.ts (0 hunks)
  • code/lib/create-storybook/src/bin/run.ts (1 hunks)
  • code/lib/create-storybook/src/generators/REACT_SCRIPTS/index.ts (1 hunks)
  • code/lib/create-storybook/src/generators/baseGenerator.ts (2 hunks)
  • code/lib/create-storybook/src/generators/types.ts (1 hunks)
  • code/lib/create-storybook/src/initiate.ts (2 hunks)
  • code/presets/create-react-app/src/index.ts (3 hunks)
  • code/renderers/react/src/preset.ts (1 hunks)
  • scripts/sandbox/utils/yarn.ts (1 hunks)
  • scripts/utils/yarn.ts (1 hunks)
  • test-storybooks/yarn-pnp/.yarnrc.yml (1 hunks)
💤 Files with no reviewable changes (1)
  • code/lib/cli-storybook/src/sandbox-templates.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/lib/cli-storybook/src/bin/run.ts
  • code/core/src/telemetry/get-framework-info.ts
  • code/presets/create-react-app/src/index.ts
  • code/lib/create-storybook/src/bin/run.ts
  • code/core/src/common/js-package-manager/PNPMProxy.ts
  • code/core/src/types/modules/core-common.ts
  • code/renderers/react/src/preset.ts
  • scripts/sandbox/utils/yarn.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/cli/detect.ts
  • code/core/src/telemetry/get-package-manager-info.ts
  • code/core/src/common/utils/strip-abs-node-modules-path.ts
  • code/lib/create-storybook/src/generators/types.ts
  • code/core/src/core-server/build-dev.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/lib/cli-storybook/src/automigrate/fixes/wrap-getAbsolutePath-utils.ts
  • code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts
  • scripts/utils/yarn.ts
  • code/lib/create-storybook/src/generators/REACT_SCRIPTS/index.ts
  • code/lib/create-storybook/src/generators/baseGenerator.ts
  • code/core/src/builder-manager/index.ts
  • code/core/src/core-server/typings.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/lib/cli-storybook/src/bin/run.ts
  • code/core/src/telemetry/get-framework-info.ts
  • code/presets/create-react-app/src/index.ts
  • code/lib/create-storybook/src/bin/run.ts
  • code/core/src/common/js-package-manager/PNPMProxy.ts
  • code/core/src/types/modules/core-common.ts
  • code/renderers/react/src/preset.ts
  • scripts/sandbox/utils/yarn.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/cli/detect.ts
  • code/core/src/telemetry/get-package-manager-info.ts
  • code/core/src/common/utils/strip-abs-node-modules-path.ts
  • code/lib/create-storybook/src/generators/types.ts
  • code/core/src/core-server/build-dev.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/lib/cli-storybook/src/automigrate/fixes/wrap-getAbsolutePath-utils.ts
  • code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts
  • scripts/utils/yarn.ts
  • code/lib/create-storybook/src/generators/REACT_SCRIPTS/index.ts
  • code/lib/create-storybook/src/generators/baseGenerator.ts
  • code/core/src/builder-manager/index.ts
  • code/core/src/core-server/typings.d.ts
🧠 Learnings (3)
📚 Learning: 2025-09-17T07:31:04.432Z
Learnt from: ndelangen
PR: storybookjs/storybook#32484
File: code/core/package.json:326-326
Timestamp: 2025-09-17T07:31:04.432Z
Learning: In Storybook's core package, dependencies like `open` are bundled into the final distribution during the build process, so they should remain in devDependencies rather than being moved to dependencies. End users don't need these packages as separate runtime dependencies since they're included in the bundled code.

Applied to files:

  • code/lib/create-storybook/src/generators/REACT_SCRIPTS/index.ts
📚 Learning: 2025-10-02T09:22:13.185Z
Learnt from: JReinhold
PR: storybookjs/storybook#32607
File: code/package.json:243-243
Timestamp: 2025-10-02T09:22:13.185Z
Learning: The Storybook repository uses Yarn v^4 (any 4.x version) as the package manager, configured via .yarnrc.yml and package.json packageManager field. Specific patch versions within v4 can be upgraded as needed.

Applied to files:

  • test-storybooks/yarn-pnp/.yarnrc.yml
📚 Learning: 2025-09-25T09:21:27.284Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-25T09:21:27.284Z
Learning: Applies to test-storybooks/** : Maintain test configurations and assets under test-storybooks/ for Storybook testing

Applied to files:

  • test-storybooks/yarn-pnp/.yarnrc.yml
🧬 Code graph analysis (2)
code/lib/create-storybook/src/initiate.ts (1)
code/core/src/cli/detect.ts (1)
  • detectPnp (174-176)
code/core/src/core-server/build-dev.ts (1)
code/core/src/cli/detect.ts (1)
  • detectPnp (174-176)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (23)
scripts/sandbox/utils/yarn.ts (1)

9-10: Comment addition looks good.

Acknowledging the TODO to revisit PnP handling post-SB11 cleanup; no actionable issues here.

code/core/src/telemetry/get-framework-info.ts (1)

66-68: LGTM! Clear deprecation note for future cleanup.

The TODO comment clearly marks the framework name sanitization logic for reevaluation when PnP compatibility code is removed in SB11. This is appropriately placed and will help future maintainers understand the context.

code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts (1)

156-158: LGTM! Helpful deprecation notes for PnP-related logic.

The TODO comments clearly mark the PnP version check and related file reading logic for reevaluation in SB11. The placement before the !process.versions.pnp condition provides good context for future maintainers.

code/lib/create-storybook/src/bin/run.ts (1)

34-35: LGTM! Proper deprecation marking for the PnP flag.

The TODO comment clearly marks the --use-pnp option for removal in SB11 while keeping it functional for the deprecation period. This is the correct approach for a graceful deprecation path.

code/renderers/react/src/preset.ts (1)

39-40: LGTM! Clear deprecation note for PnP workaround logic.

The TODO comment appropriately marks the resolvedReact function for reevaluation in SB11, as this function exists specifically to handle Yarn PnP resolution issues (explained in the comment below).

test-storybooks/yarn-pnp/.yarnrc.yml (1)

1-2: LGTM! Clear removal plan for PnP test infrastructure.

The TODO comment clearly marks the entire test-storybooks/yarn-pnp directory for removal in SB11, which aligns with the broader deprecation of PnP support. This is appropriate for test infrastructure related to a deprecated feature.

scripts/utils/yarn.ts (1)

52-53: LGTM! Clear deprecation note for PnP detection logic.

The TODO comment appropriately marks the PnP API existence check (.pnp.cjs file) for removal in SB11. This aligns with the broader deprecation strategy and is placed correctly before the related logic.

code/core/src/common/utils/strip-abs-node-modules-path.ts (1)

12-14: LGTM! Important deprecation notes for path normalization logic.

The TODO comments appropriately flag the node_modules path logic for reevaluation in SB11. This is particularly important because PnP doesn't use traditional node_modules structures, so this path-stripping logic may need adjustments when PnP support is removed.

code/core/src/types/modules/core-common.ts (1)

155-155: LGTM! Type addition enables PnP deprecation flow.

The optional pnp?: boolean field addition to LoadOptions enables passing PnP detection state through the options, which supports the deprecation warning flow implemented in other parts of the PR (e.g., build-dev.ts). This is backward compatible since it's optional.

code/core/src/telemetry/get-package-manager-info.ts (1)

14-14: LGTM! Documentation note for future consideration.

The TODO appropriately flags that the nodeLinker detection logic may need reevaluation after PnP compatibility code is removed in SB11.

code/core/src/builder-manager/index.ts (2)

7-8: LGTM! PnP plugin import aligns with deprecation strategy.

The import of pnpPlugin from @yarnpkg/esbuild-plugin-pnp correctly enables Yarn Plug'n'Play resolution in the manager builder, and the TODO comment appropriately flags this for removal in SB11.


107-107: LGTM! Plugin correctly integrated into esbuild configuration.

The pnpPlugin() is appropriately added to the plugins array alongside globalExternals, enabling PnP resolution for manager entries.

code/lib/cli-storybook/src/automigrate/fixes/wrap-getAbsolutePath-utils.ts (2)

5-6: LGTM! Alternative wrapper name supports backward compatibility.

The addition of ALTERNATIVE_GET_ABSOLUTE_PATH_WRAPPER_NAME with the wrapForPnp value allows detection of existing PnP-specific wrapper functions, appropriately marked for removal in SB11.


59-67: LGTM! Detection logic correctly prioritizes alternative wrapper.

The updated getAbsolutePathWrapperName correctly checks for the alternative wrapForPnp wrapper before the preferred getAbsolutePath wrapper, providing backward compatibility during the PnP deprecation period.

code/core/src/common/js-package-manager/PNPMProxy.ts (1)

145-145: LGTM! TODO appropriately marks PnP compatibility code.

The comment correctly flags the getModulePackageJSON method's PnP-specific logic (lines 147-174) for removal in SB11, consistent with the broader deprecation strategy.

code/core/src/common/js-package-manager/Yarn2Proxy.ts (1)

152-152: LGTM! TODO appropriately marks PnP compatibility code.

The comment correctly flags the getModulePackageJSON method's PnP-specific logic (lines 154-199) for removal in SB11, mirroring the identical annotation in PNPMProxy.ts.

code/lib/create-storybook/src/generators/types.ts (1)

10-11: LGTM! TODO appropriately marks the PnP field for removal.

The comment correctly flags the pnp boolean field in GeneratorOptions for removal in SB11, consistent with the broader PnP deprecation strategy.

code/core/src/core-server/build-dev.ts (2)

27-27: LGTM! Import of PnP detection utility.

The import of detectPnp from the CLI detect module is appropriate for checking PnP usage during the dev build.


98-107: No update needed to deprecation version reference.
The deprecation message correctly cites the version when PnP was deprecated (Storybook 10.x) and aligns with the SB11 removal TODO; leave it as is.

Likely an incorrect or invalid review comment.

code/core/src/core-server/typings.d.ts (1)

2-3: LGTM! Ambient module declaration enables TypeScript compilation.

The ambient module declaration for pnp-webpack-plugin is necessary for TypeScript to compile code that imports this third-party library, and the TODO comment appropriately flags it for removal in SB11 alongside other PnP-related code.

code/lib/create-storybook/src/initiate.ts (1)

87-96: LGTM! Deprecation warning appropriately implemented.

The PnP detection and deprecation notice are correctly positioned in the initialization flow and provide clear guidance to users about the upcoming removal.

code/core/src/common/js-package-manager/JsPackageManager.ts (1)

709-712: LGTM!

The isPackageInstalled method correctly delegates to getInstalledVersion and provides a clear boolean interface.

code/presets/create-react-app/src/index.ts (1)

5-6: LGTM! PnP plugin integration is appropriate for CRA preset.

The PnP webpack plugin is correctly integrated in both loader resolution and main module resolution, which is necessary for CRA projects using Yarn PnP. The as any cast at line 133 is acceptable for a deprecated feature marked for removal.

Also applies to: 32-33, 132-133

@nx-cloud
Copy link

nx-cloud bot commented Oct 6, 2025

View your CI Pipeline Execution ↗ for commit e055907

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 46s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-26 10:41:06 UTC

@Sidnioulz Sidnioulz added maintenance User-facing maintenance tasks yarn ci:normal labels Oct 6, 2025
@storybook-app-bot
Copy link

storybook-app-bot bot commented Oct 6, 2025

Package Benchmarks

Commit: e055907, ran on 26 October 2025 at 10:35:23 UTC

No significant changes detected, all good. 👏

@RDIL
Copy link

RDIL commented Oct 7, 2025

There is no rationale or issue link provided. Why is this change being made?

@Sidnioulz
Copy link
Member

There is no rationale or issue link provided. Why is this change being made?

@ndelangen is there a tracking issue somewhere to add an explanation to MIGRATION.md post 10.0? If so, might it be worth linking to the explanation within the deprecation warning, or inlining a rationale in the warnings?

As of Storybook 10.0, PnP is deprecated.
If you are using PnP, you can continue to use Storybook 10.0, but we recommend migrating to a different package manager or linker-mode.
In future versions, PnP compatibility will be removed.
Copy link
Member

Choose a reason for hiding this comment

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

Let's say version 11 here if that's what we're planning

Copy link
Member

Choose a reason for hiding this comment

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

@ndelangen ☝️

Copy link
Member

Choose a reason for hiding this comment

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

@JReinhold
Copy link
Contributor

JReinhold commented Oct 9, 2025

There is no rationale or issue link provided. Why is this change being made?

The effort required to continuously support Yarn PnP is significant, and has always been. However usage metrics show that the number of users actually using Yarn PnP is a very tiny fraction of the total. So we'd rather re-prioritize maintainers' time elsewhere.

@mrginglymus
Copy link
Contributor

A lot of the marked deprecations here are either already effectively no-ops (esbuild supports yarn without plugins, for example), or solely related to the CLI.

The builder otherwise seems largely unaffected - other than the need to pre-resolve plugin paths (which is required in monorepos, not just pnp).

I can appreciate that the effort that goes into maintaining support for custom node loaders for the CLI is substantial, and a sufficiently minority of users using it - but at the same time, I hope that you'll still be open to patch submissions for the builder should any arise.

@ndelangen ndelangen added freeze Freeze the Release PR with this label and removed yarn freeze Freeze the Release PR with this label labels Oct 16, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
code/core/src/cli/detect.ts (1)

175-176: Consider removing async keyword.

The function is declared async but doesn't use await, so it unnecessarily wraps the result in a Promise. If API consistency with other detection functions isn't required, removing async would be slightly more efficient.

-export async function detectPnp() {
+export function detectPnp() {
   return !!find.any(['.pnp.js', '.pnp.cjs'], { last: getProjectRoot() });
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51c0518 and a80203c.

📒 Files selected for processing (1)
  • code/core/src/cli/detect.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier formatting on changed files before committing
Run ESLint on changed files and fix all errors/warnings before committing (use yarn lint:js:cmd <file>)

Files:

  • code/core/src/cli/detect.ts
**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Export functions from modules when they need to be unit-tested

Files:

  • code/core/src/cli/detect.ts
code/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

In application code, use Storybook loggers instead of console.* (client code: storybook/internal/client-logger; server code: storybook/internal/node-logger)

Files:

  • code/core/src/cli/detect.ts
{code/**,scripts/**}/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/cli/detect.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest

Comment on lines +174 to 177
// TODO: Remove in SB11
export async function detectPnp() {
return !!find.any(['.pnp.js', '.pnp.cjs']);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Limit search scope to prevent false positives.

The find.any() call searches without a boundary and may traverse parent directories beyond the project root. If a parent directory contains .pnp.js or .pnp.cjs, this function will return true even when the current project doesn't use PnP, triggering incorrect deprecation warnings.

Apply this diff to limit the search to the project root, consistent with detectBuilder (lines 115–116):

 // TODO: Remove in SB11
 export async function detectPnp() {
-  return !!find.any(['.pnp.js', '.pnp.cjs']);
+  return !!find.any(['.pnp.js', '.pnp.cjs'], { last: getProjectRoot() });
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// TODO: Remove in SB11
export async function detectPnp() {
return !!find.any(['.pnp.js', '.pnp.cjs']);
}
// TODO: Remove in SB11
export async function detectPnp() {
return !!find.any(['.pnp.js', '.pnp.cjs'], { last: getProjectRoot() });
}
🤖 Prompt for AI Agents
In code/core/src/cli/detect.ts around lines 174–177, the detectPnp function
currently calls find.any() without a boundary which can traverse parent
directories and yield false positives; change the call to constrain the search
to the project root (use the same pattern/options used by detectBuilder at lines
115–116) so that find.any only checks the project root for '.pnp.js' or
'.pnp.cjs' and does not traverse upward.

@vanessayuenn vanessayuenn added this to the 10 blocking milestone Oct 21, 2025
@ndelangen ndelangen added the yarn label Oct 26, 2025
@ndelangen
Copy link
Member Author

I've opened a GitHub discussion post here, where we can discuss this further:
#32845

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal maintenance User-facing maintenance tasks yarn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants