Skip to content

fix: export postcss config subpath with file extension - #654

Merged
blvdmitry merged 1 commit into
mainfrom
claude/postcss-vite-config-error-vd8bz2
Aug 15, 2026
Merged

fix: export postcss config subpath with file extension#654
blvdmitry merged 1 commit into
mainfrom
claude/postcss-vite-config-error-vd8bz2

Conversation

@blvdmitry

Copy link
Copy Markdown
Contributor

Summary

A user reported that a Vite project fails to start with [plugin:vite:css] Failed to load PostCSS config when their postcss.config.js contains:

export { config as default } from 'reshaped/config/postcss.js';

The underlying error is ERR_PACKAGE_PATH_NOT_EXPORTED: the exports map in packages/reshaped/package.json only declared the extensionless ./config/postcss subpath, so the .js-suffixed form — the one that reads naturally in an ESM config file, where relative specifiers do require extensions — was not resolvable. Node's exports resolution is exact string matching, so ./config/postcss does not cover ./config/postcss.js.

This adds two aliases alongside the existing subpath:

  • ./config/postcss.js — same targets as the extensionless entry (ESM build for import, CJS build for require, since requiring the ESM file would throw).
  • ./config/postcss.cjs — points at the CommonJS build and its dist/config/postcss.d.cts types. Both files are already published in the tarball, but .d.cts was not reachable through any subpath.

Verified all four call styles resolve against the published reshaped tarball with the patched exports map:

specifier context result
reshaped/config/postcss ESM import resolves
reshaped/config/postcss.js ESM import resolves (was ERR_PACKAGE_PATH_NOT_EXPORTED)
reshaped/config/postcss CJS require resolves
reshaped/config/postcss.cjs CJS require resolves (was ERR_PACKAGE_PATH_NOT_EXPORTED)

Related Issue

Screenshots / Recordings

No UI changes — packaging only.

Notes for Reviewers

  • The existing ./config/postcss entry is untouched, so this is additive and cannot change resolution for anyone already working today.
  • The alternative would have been to keep the exports map as-is and correct the docs to drop the extension. Adding the alias seemed better since both forms are idiomatic depending on the project, and the extension form is what people reach for in an ESM config file.
  • Worth a sanity check on whether the docs site examples show the .js form — if so, they now match reality either way.

Generated by Claude Code

Importing the PostCSS config as `reshaped/config/postcss.js` — the form
that reads naturally in an ESM `postcss.config.js` — failed with
ERR_PACKAGE_PATH_NOT_EXPORTED because the exports map only declared the
extensionless `./config/postcss` subpath. Vite surfaced this as
"Failed to load PostCSS config".

Add `./config/postcss.js` and `./config/postcss.cjs` aliases so both the
extensionless and extension-suffixed forms resolve. The `.cjs` alias
points at the CommonJS build and its `.d.cts` types, which were shipped
but not reachable through any subpath.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgWbR7T7YW1ni45Qy4Um8A
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Library / JS 49.15 KB (0%) 983 ms (0%) 1.1 s (-42.96% 🔽) 2.1 s
Library / CSS 23.06 KB (0%) 462 ms (0%) 0 ms (+100% 🔺) 462 ms
Theming / JS 7.79 KB (0%) 156 ms (0%) 59 ms (-26.74% 🔽) 215 ms
Theming with a default theme definition / JS 8.67 KB (0%) 174 ms (0%) 164 ms (-0.64% 🔽) 338 ms

@blvdmitry
blvdmitry marked this pull request as ready for review August 15, 2026 09:23
@blvdmitry
blvdmitry merged commit b919629 into main Aug 15, 2026
12 checks passed
@blvdmitry
blvdmitry deleted the claude/postcss-vite-config-error-vd8bz2 branch August 15, 2026 09:24
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.

2 participants