Skip to content

Conversation

@ndelangen
Copy link
Member

@ndelangen ndelangen commented Oct 10, 2025

What I did

NextJS ships with a invalid postcss config file.

Storybook then fails to run, the solution is a simple change to the postcss config file.
We've asked users to make this change manually, but that breaks the onboarding flow, so this PR attempts to fix the postcss config file automatically.

We make a string-replacement on the contents of the file, and if that does not solve the issue, we revert the file and throw the error we did before.

Related to this PR/Issue:
vercel/next.js#79949

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

I've manually tested this on my machine using a sandbox.

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 publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • New Features

    • Improved PostCSS config discovery across many file types/locations with automatic fallback and an automatic fix for a common Tailwind plugin format to avoid build failures.
  • Refactor

    • Centralized and simplified PostCSS config handling for more reliable resolution and reduced error noise.
  • Chores

    • Added development tooling to support enhanced configuration discovery.

- Added `lilconfig` dependency to manage PostCSS configurations.
- Introduced `find-postcss-config.ts` to locate and load PostCSS config files with a fallback mechanism.
- Updated `preset.ts` to utilize the new PostCSS loading functionality, improving error handling for incompatible configurations.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Adds devDependency lilconfig. Introduces a new PostCSS config discovery/loading utility that uses lilconfig with JS/TS/CJS/MJS/CTS/MTS/YAML loaders, exposes search/load helpers and a normalizePostCssConfig function that may rewrite certain Tailwind plugin shapes on disk. Updates preset logic to call the new normalizer and removes prior inline postcss-load-config handling.

Changes

Cohort / File(s) Summary of Changes
Dependencies
code/frameworks/nextjs-vite/package.json
Added devDependency lilconfig@^3.0.0.
PostCSS config discovery & normalization
code/frameworks/nextjs-vite/src/find-postcss-config.ts
New module: configures lilconfig loaders (JS/TS/CJS/MJS/CTS/MTS and YAML), defines search places, implements postCssFindConfig to locate a PostCSS config, exposes postCssLoadConfig, and exports normalizePostCssConfig(searchPath) which attempts to load a config, rewrites certain Tailwind plugin array entries to object form when needed, retries load, and maps failure cases to boolean or throws IncompatiblePostCssConfigError. Side-effect: may modify the config file to fix plugin shape.
Preset integration
code/frameworks/nextjs-vite/src/preset.ts
Replaced direct postcss-load-config usage and detailed try/catch handling with a call to normalizePostCssConfig(searchPath); removed now-unused imports and simplified control flow. No public API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller as Preset caller
  participant Preset as preset.ts
  participant Finder as find-postcss-config.ts
  participant Lil as lilconfig("postcss")
  participant Loader as postcss config loader
  participant FS as File System

  Caller->>Preset: initialize preset (config, options)
  Preset->>Preset: compute searchPath
  alt searchPath exists
    Preset->>Finder: normalizePostCssConfig(searchPath)
    Finder->>Lil: search(searchPath) with custom loaders
    Lil-->>Finder: configPath or null
    alt configPath found
      Finder->>Loader: load(configPath)
      alt load succeeds
        Loader-->>Finder: config
        Finder-->>Preset: return true
      else Invalid PostCSS Plugin error
        Finder->>FS: read configPath
        Finder->>FS: rewrite Tailwind plugin entry (array -> object)
        Finder->>Loader: retry load(configPath)
        alt retry succeeds
          Loader-->>Finder: config
          Finder-->>Preset: return true
        else
          Finder-->>Preset: throw IncompatiblePostCssConfigError
        end
      else other load error
        Finder-->>Preset: return false
      end
    else no config found
      Finder-->>Preset: return true
    end
  else no searchPath
    Preset->>Preset: skip PostCSS processing
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ 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/postcss-config-modification

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

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: 3

🧹 Nitpick comments (1)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (1)

1-1: Remove redundant directive.

The @ts-check comment is unnecessary in TypeScript files as type checking is enabled by default.

Apply this diff:

-// @ts-check
 import { readFile, writeFile } from 'node:fs/promises';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a4b5af and 1cafff7.

⛔ Files ignored due to path filters (1)
  • code/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • code/frameworks/nextjs-vite/package.json (1 hunks)
  • code/frameworks/nextjs-vite/src/find-postcss-config.ts (1 hunks)
  • code/frameworks/nextjs-vite/src/preset.ts (2 hunks)
🧰 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/frameworks/nextjs-vite/src/preset.ts
  • code/frameworks/nextjs-vite/src/find-postcss-config.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/frameworks/nextjs-vite/src/preset.ts
  • code/frameworks/nextjs-vite/src/find-postcss-config.ts
🧬 Code graph analysis (2)
code/frameworks/nextjs-vite/src/preset.ts (1)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (1)
  • loadPostCssConfigWithFallback (79-120)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)
code/core/src/common/utils/paths.ts (1)
  • getProjectRoot (11-57)
code/core/src/server-errors.ts (1)
  • IncompatiblePostCssConfigError (498-526)
⏰ 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 (4)
code/frameworks/nextjs-vite/package.json (1)

90-90: LGTM!

The addition of lilconfig as a devDependency is appropriate for the new PostCSS config discovery functionality.

code/frameworks/nextjs-vite/src/preset.ts (1)

64-69: LGTM!

The refactored PostCSS config loading logic correctly determines the search path and delegates to the new utility function, simplifying error handling.

code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)

24-61: LGTM!

The withLoaders function correctly configures lilconfig with comprehensive file extension support and search locations for PostCSS configs.


70-74: LGTM!

The postCssFindConfig function correctly uses lilconfig to locate PostCSS configuration files.

@ndelangen ndelangen self-assigned this Oct 10, 2025
@ndelangen ndelangen marked this pull request as draft October 10, 2025 09:34
@nx-cloud
Copy link

nx-cloud bot commented Oct 10, 2025

View your CI Pipeline Execution ↗ for commit 857bfc4

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

☁️ Nx Cloud last updated this comment at 2025-10-10 12:16:39 UTC

Comment on lines +105 to +108
const modifiedContent = originalContent.replace(
'plugins: ["@tailwindcss/postcss"]',
'plugins: { "@tailwindcss/postcss": {} }'
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach will not work for yml files.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not think we need it.

I had to copy code from here:
https://github.com/postcss/postcss-load-config/blob/main/src/index.js

And i wanted to keep it close to the original code.

yaml is already included in the bundle.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't support modifying YAML-based PostCSS files, we should clean up the code above (searching for YAML files, registering a YAML config loader,...). Then we can also actually remove the yaml dependency.

Copy link
Member Author

@ndelangen ndelangen Oct 10, 2025

Choose a reason for hiding this comment

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

You would rather not keep the code similar to where we got it from? Okay.

Their code seems to prefer yaml config files, so our code skipping/not looking for them, might cause their code to find different files, if the user has many different ones, possibly on multiple levels.

The replacement code, also does not "work" for JSON files, should I remove handling for those as well?

- Refactored PostCSS configuration loading by renaming `loadPostCssConfigWithFallback` to `normalizePostCssConfig` for clarity.
- Enhanced error handling in `normalizePostCssConfig` to manage incompatible configurations more effectively.
- Added `yaml` dependency version `2.8.1` to `package.json` and updated `yarn.lock` accordingly.
@ndelangen ndelangen marked this pull request as ready for review October 10, 2025 11:00
@ndelangen ndelangen added this to the 10 blocking milestone Oct 10, 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: 2

♻️ Duplicate comments (1)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (1)

146-146: Unhandled errors should be thrown, not silently returned as false.

Returning false for unexpected errors masks real failures. If an error occurs that doesn't match the expected patterns ("No PostCSS Config found" or "Invalid PostCSS Plugin found"), it should be thrown to surface the issue to the caller.

Apply this diff to throw unhandled errors:

-  return false;
+  // Unhandled error - rethrow to surface the issue
+  throw error;
 };
🧹 Nitpick comments (2)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)

1-1: Remove redundant @ts-check directive in TypeScript file.

The @ts-check comment is unnecessary in .ts files where TypeScript type checking is already enabled by default. This directive is typically used in .js files to opt into TypeScript checking.

Apply this diff:

-// @ts-check
 import { readFile, writeFile } from 'node:fs/promises';

70-74: Consider documenting why postCssFindConfig is not exported.

Based on past review comments, this function was intentionally kept internal. However, since it has comprehensive JSDoc documentation suggesting it's part of the public API, consider either:

  1. Adding a note in the JSDoc explaining it's internal-only, or
  2. Removing the JSDoc if it's truly internal

This will prevent confusion about the module's public API surface.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cafff7 and 4ad2494.

⛔ Files ignored due to path filters (1)
  • code/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • code/frameworks/nextjs-vite/package.json (1 hunks)
  • code/frameworks/nextjs-vite/src/find-postcss-config.ts (1 hunks)
  • code/frameworks/nextjs-vite/src/preset.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/frameworks/nextjs-vite/src/preset.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/frameworks/nextjs-vite/src/find-postcss-config.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/frameworks/nextjs-vite/src/find-postcss-config.ts
🧠 Learnings (1)
📚 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 **/*.{ts,tsx} : Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Applied to files:

  • code/frameworks/nextjs-vite/src/find-postcss-config.ts
🧬 Code graph analysis (1)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)
code/core/src/common/utils/paths.ts (1)
  • getProjectRoot (11-57)
code/core/src/server-errors.ts (1)
  • IncompatiblePostCssConfigError (498-526)
⏰ 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
🔇 Additional comments (3)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)

16-22: LGTM: Loaders are correctly implemented.

The custom loaders for JavaScript/TypeScript modules and YAML files are properly implemented. The use of createRequire for ES module compatibility is appropriate.


129-132: Robustify PostCSS plugin replacement
The current replace('plugins: ["@tailwindcss/postcss"]', …) only matches the exact default format and will break on formatting changes, multiple plugins, or plugin options—either document this limitation (in a comment or the error message) or switch to a regex/AST-based transform.

code/frameworks/nextjs-vite/package.json (1)

90-90: Dependencies correctly added.

The lilconfig and yaml devDependencies are now properly declared, resolving the previous review concern about undeclared dependencies.

Note: A past review comment questioned whether yaml support adds unnecessary bundle size, since the primary use case is handling Next.js's default JavaScript config. This is a maintainer decision, but consider measuring the bundle size impact if this becomes a concern.

Based on past review comments.

Also applies to: 95-95

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

♻️ Duplicate comments (3)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (3)

76-76: Reconsider this re-export to keep the API surface minimal.

This export might not be necessary if callers only need normalizePostCssConfig. Evaluate whether any code directly imports postCssLoadConfig from this module.

Based on learnings from past review.


140-143: Fix: Use unknown instead of any for error variable.

Line 140 uses any type for the caught error, which bypasses TypeScript's type safety. This violates the coding guidelines requiring strict mode compliance.

As per coding guidelines.

Apply this diff:

-    } catch (e: any) {
+    } catch (e: unknown) {
       // We were unable to fix the config, so we throw an error
       throw new IncompatiblePostCssConfigError({ error });
     }

Note: Since you're only using the original error variable (not e) when constructing IncompatiblePostCssConfigError, the type change won't affect the throw statement.


146-146: Fix: Throw unhandled errors instead of returning false.

Returning false for unexpected errors silently masks real failures. If an error doesn't match the known patterns (e.g., neither "No PostCSS Config found" nor "Invalid PostCSS Plugin found"), it should be thrown to surface the issue.

Apply this diff:

-  return false;
+  // Unhandled error case - rethrow to surface the issue
+  throw error;
 };

This ensures that unexpected errors during PostCSS config loading are properly propagated to the caller.

🧹 Nitpick comments (2)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)

20-22: Consider renaming unused parameter for clarity.

The first parameter of yamlLoader is unused. Convention is to name it with a leading underscore (which you did), but consider naming it descriptively (e.g., _filepath) for better self-documentation.

-async function yamlLoader(_: string, content: string) {
+async function yamlLoader(_filepath: string, content: string) {
   return yaml.parse(content);
 }

40-59: Potential duplication in searchPlaces array.

Line 41 spreads options.searchPlaces ?? [] before the explicit list. If callers provide overlapping search places, this could lead to duplicate searches. Consider whether the spread should come after the explicit list or if deduplication is needed.

If you want caller-provided paths to take precedence:

 searchPlaces: [
-  ...(options.searchPlaces ?? []),
   'package.json',
   `.${moduleName}rc`,
   // ... rest of the list
   `${moduleName}.config.mjs`,
+  ...(options.searchPlaces ?? []),
 ],

Or deduplicate using a Set if order and uniqueness both matter:

searchPlaces: Array.from(new Set([
  ...(options.searchPlaces ?? []),
  'package.json',
  // ... rest
])),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cafff7 and 4ad2494.

⛔ Files ignored due to path filters (1)
  • code/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • code/frameworks/nextjs-vite/package.json (1 hunks)
  • code/frameworks/nextjs-vite/src/find-postcss-config.ts (1 hunks)
  • code/frameworks/nextjs-vite/src/preset.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/frameworks/nextjs-vite/package.json
🧰 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/frameworks/nextjs-vite/src/find-postcss-config.ts
  • code/frameworks/nextjs-vite/src/preset.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/frameworks/nextjs-vite/src/find-postcss-config.ts
  • code/frameworks/nextjs-vite/src/preset.ts
🧠 Learnings (1)
📚 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 **/*.{ts,tsx} : Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Applied to files:

  • code/frameworks/nextjs-vite/src/find-postcss-config.ts
🧬 Code graph analysis (2)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)
code/core/src/common/utils/paths.ts (1)
  • getProjectRoot (11-57)
code/core/src/server-errors.ts (1)
  • IncompatiblePostCssConfigError (498-526)
code/frameworks/nextjs-vite/src/preset.ts (1)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (1)
  • normalizePostCssConfig (97-147)
⏰ 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
🔇 Additional comments (3)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)

63-74: LGTM!

The postCssFindConfig helper is well-implemented with clear JSDoc and appropriate encapsulation as a private function.


129-132: Ensure plugin replacement handles all PostCSS config variants
The current replace only matches the exact string plugins: ["@tailwindcss/postcss"] and will miss different spacing, quotes, or multiple plugins—either document that Next.js always scaffolds this exact format or switch to a regex/AST-based approach to cover all variants.

code/frameworks/nextjs-vite/src/preset.ts (1)

64-69: No additional guard required for undefined searchPath
The existing if (searchPath) check already prevents calling normalizePostCssConfig when both config.css?.postcss and config.root are undefined.

@ndelangen ndelangen changed the title Enhance PostCSS configuration handling NextJS: Enhance PostCSS configuration handling Oct 10, 2025
@storybookjs storybookjs deleted a comment from coderabbitai bot Oct 10, 2025
- Eliminated the YAML loader and related search places from the PostCSS configuration handling.
- Simplified the code structure in `find-postcss-config.ts` for better maintainability.
- Ensured compatibility with existing PostCSS configurations while enhancing error handling.
@storybookjs storybookjs deleted a comment from coderabbitai bot Oct 10, 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: 2

♻️ Duplicate comments (2)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)

138-138: Unhandled errors should be thrown, not silently returned.

Returning false for unexpected errors masks real failures. Although a previous review marked this as "addressed in commit c874228", the code still returns false instead of throwing.

Apply this diff to throw unhandled errors:

-  return false;
+  // Unhandled error - rethrow to surface the issue
+  throw error;
 };

66-66: Remove unused export of postCssLoadConfig.

postCssLoadConfig isn’t referenced anywhere else—remove this export to keep the module’s API surface clean.

- export { postCssLoadConfig };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad2494 and 857bfc4.

⛔ Files ignored due to path filters (1)
  • code/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • code/frameworks/nextjs-vite/package.json (1 hunks)
  • code/frameworks/nextjs-vite/src/find-postcss-config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/frameworks/nextjs-vite/package.json
🧰 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/frameworks/nextjs-vite/src/find-postcss-config.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/frameworks/nextjs-vite/src/find-postcss-config.ts
🧠 Learnings (1)
📚 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 **/*.{ts,tsx} : Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Applied to files:

  • code/frameworks/nextjs-vite/src/find-postcss-config.ts
🧬 Code graph analysis (1)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (2)
code/core/src/common/utils/paths.ts (1)
  • getProjectRoot (11-57)
code/core/src/server-errors.ts (1)
  • IncompatiblePostCssConfigError (498-526)
⏰ 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
🔇 Additional comments (4)
code/frameworks/nextjs-vite/src/find-postcss-config.ts (4)

1-12: LGTM! Clean imports.

The imports are well-organized and appropriate for the PostCSS config handling functionality.


14-51: LGTM! Appropriate loader configuration.

The loader setup correctly handles JS/TS variants without adding yaml complexity, aligning with the decision to keep the implementation simple.


60-64: LGTM! Clean helper function.

The function appropriately remains unexported, keeping the module's API surface minimal.


93-103: LGTM! Proper error handling.

The error handling correctly uses Error | undefined and properly type-guards with instanceof Error, addressing previous review feedback.

@ndelangen ndelangen removed this from the 10 blocking milestone Oct 10, 2025
@ndelangen ndelangen merged commit e9a2317 into next Oct 10, 2025
58 checks passed
@ndelangen ndelangen deleted the norbert/postcss-config-modification branch October 10, 2025 12:57
@github-actions github-actions bot mentioned this pull request Oct 10, 2025
13 tasks
@shilman shilman changed the title NextJS: Enhance PostCSS configuration handling NextJS-Vite: Enhance PostCSS configuration handling Oct 10, 2025
@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 10, 2025
@shilman shilman changed the title NextJS-Vite: Enhance PostCSS configuration handling NextJS-Vite: Automatically fix bad PostCSS configuration Oct 10, 2025
@github-actions github-actions bot mentioned this pull request Oct 10, 2025
13 tasks
ndelangen added a commit that referenced this pull request Oct 15, 2025
…ification

NextJS: Enhance PostCSS configuration handling
(cherry picked from commit e9a2317)
@github-actions github-actions bot mentioned this pull request Oct 15, 2025
13 tasks
@ndelangen ndelangen mentioned this pull request Oct 16, 2025
13 tasks
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Oct 16, 2025
@ndelangen ndelangen mentioned this pull request Oct 16, 2025
3 tasks
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal nextjs patch:done Patch/release PRs already cherry-picked to main/release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants