Skip to content

Fixed postcss plugin resolution for consumers of the design system config - #29185

Merged
9larsons merged 1 commit into
mainfrom
slars/fix-admin-x-settings-postcss-resolution
Jul 8, 2026
Merged

Fixed postcss plugin resolution for consumers of the design system config#29185
9larsons merged 1 commit into
mainfrom
slars/fix-admin-x-settings-postcss-resolution

Conversation

@9larsons

@9larsons 9larsons commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

apps/admin-x-settings/postcss.config.cjs re-exports the design system's config. That config named its plugins as strings, and postcss-load-config resolves string plugin names relative to the searchPath — the directory the consuming build discovered a config in — not the file that declared the list.

So the plugin names resolve from apps/admin-x-settings, which declares none of postcss-import, @tailwindcss/postcss or autoprefixer. Under pnpm's strict isolation they are not linked there, and none of the three resolve from that directory.

Why now, if the build is green?

It is currently masked. The plugins genuinely cannot be resolved from admin-x-settings — that is verifiable with a require.resolve probe from that directory — so today's successful build depends on the loader not using the consumer as its anchor. That is one loader change away from breaking, and it broke in a real working tree.

The fix

require() the three plugins inside apps/admin-x-design-system/postcss.config.cjs and pass instances rather than names, so resolution is anchored to the package that declares them. No string resolution happens at the consumer at all. postcss(fn) auto-invokes factories carrying .postcss === true, which all three do, so postcssImport() is exactly equivalent to 'postcss-import': {}.

Alternatives rejected:

  • Adding postcss-import et al as devDependencies of each consumer — papers over the resolution bug and has to be repeated for every package that reuses the config.
  • Deleting the postcss configs — they are not vestigial. The centralized Tailwind v4 pipeline applies to apps/admin's @tailwindcss/vite setup; admin-x-settings still builds a standalone bundle through adminXViteConfig, which has no Tailwind plugin. Its src/styles/index.css does @import 'tailwindcss/utilities.css', and postcss expands that into ~470 kB of real utilities. Deleting the config would silently strip every utility class from that bundle.

Verification

  • pnpm --filter @tryghost/admin-x-settings build — exit 0
  • pnpm --filter @tryghost/admin-x-settings lint and pnpm --filter @tryghost/admin-x-design-system lint — exit 0
  • NX_NO_CLOUD=true pnpm nx build @tryghost/admin --skip-nx-cache — exit 0, all 15 dependent tasks genuinely executed. (The plain nx reset && nx build run replayed 9/16 tasks from Nx Cloud's remote cache, which would have masked a failure.)
  • Emitted CSS is unchanged. The build was first confirmed deterministic (two unchanged builds → identical checksum) so the comparison is meaningful. The postcss product is byte-identical at 469,587 bytes, and all 31 files of apps/admin-x-settings/dist match before and after.

Same three plugins, same order, same empty options — only where they resolve from has changed.

…nfig

- admin-x-settings re-exports the design system's postcss.config.cjs, but the
  config named its plugins as strings. postcss-load-config resolves string
  plugin names relative to the searchPath (the consuming package), not the file
  that declared them, so it looked for postcss-import, @tailwindcss/postcss and
  autoprefixer under apps/admin-x-settings, which does not declare them. Under
  pnpm's strict isolation they are not linked there, so the lookup failed with
  "Loading PostCSS Plugin failed: Cannot find module 'postcss-import'".
- Requiring the plugins in the config file itself anchors resolution to the
  design system, which does declare all three. The plugin list is now passed as
  instances, so no string resolution happens at the consumer at all.
- Preferred over adding postcss-import et al as devDependencies of every
  consumer: that papers over the resolution bug and would have to be repeated
  for each new package that reuses this config.
- Preferred over deleting the config: it is not vestigial. The design system
  and admin-x-settings still build standalone bundles through postcss, and the
  pipeline expands `@import 'tailwindcss/utilities.css'` into ~470kB of CSS.
  Dropping it would silently strip every utility class from those bundles.
- Verified the emitted CSS is unchanged: the postcss product is byte-identical
  and admin-x-settings/dist is unchanged across all 31 files.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ab0125ae-9f42-43f8-b2b4-d403331dcca6

📥 Commits

Reviewing files that changed from the base of the PR and between 65fc69d and a77bd1d.

📒 Files selected for processing (1)
  • apps/admin-x-design-system/postcss.config.cjs

Walkthrough

The PostCSS configuration file for admin-x-design-system was modified to change how plugins are declared. Instead of an object mapping plugin names to configuration, the file now requires each plugin (postcss-import, @tailwindcss/postcss, autoprefixer) and defines the exports as an array of instantiated plugin functions. Explanatory comments were added describing why plugins are instantiated locally, related to resolution behavior of postcss-load-config and consistency with how admin-x-settings re-exports the configuration.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing PostCSS plugin resolution for design system consumers.
Description check ✅ Passed The description is directly about the PostCSS config resolution fix and matches the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/fix-admin-x-settings-postcss-resolution

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nx-cloud

nx-cloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit a77bd1d

Command Status Duration Result
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 9m 22s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-d... ✅ Succeeded 2m 41s View ↗
nx run ghost-admin:test ✅ Succeeded 2m 39s View ↗
nx run-many -t lint -p @tryghost/admin-x-design... ✅ Succeeded 1m 42s View ↗
nx run @tryghost/admin:build ✅ Succeeded 8s View ↗
nx run @tryghost/activitypub:test:acceptance ✅ Succeeded 45s View ↗
nx run ghost:build:assets ✅ Succeeded 2s View ↗
nx run ghost:build:tsc ✅ Succeeded 7s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-08 20:32:25 UTC

@9larsons
9larsons merged commit d3edc2c into main Jul 8, 2026
44 checks passed
@9larsons
9larsons deleted the slars/fix-admin-x-settings-postcss-resolution branch July 8, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant