fix: export postcss config subpath with file extension - #654
Merged
Conversation
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
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A user reported that a Vite project fails to start with
[plugin:vite:css] Failed to load PostCSS configwhen theirpostcss.config.jscontains:The underlying error is
ERR_PACKAGE_PATH_NOT_EXPORTED: the exports map inpackages/reshaped/package.jsononly declared the extensionless./config/postcsssubpath, 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/postcssdoes not cover./config/postcss.js.This adds two aliases alongside the existing subpath:
./config/postcss.js— same targets as the extensionless entry (ESM build forimport, CJS build forrequire, since requiring the ESM file would throw)../config/postcss.cjs— points at the CommonJS build and itsdist/config/postcss.d.ctstypes. Both files are already published in the tarball, but.d.ctswas not reachable through any subpath.Verified all four call styles resolve against the published
reshapedtarball with the patched exports map:reshaped/config/postcssimportreshaped/config/postcss.jsimportERR_PACKAGE_PATH_NOT_EXPORTED)reshaped/config/postcssrequirereshaped/config/postcss.cjsrequireERR_PACKAGE_PATH_NOT_EXPORTED)Related Issue
Screenshots / Recordings
No UI changes — packaging only.
Notes for Reviewers
./config/postcssentry is untouched, so this is additive and cannot change resolution for anyone already working today..jsform — if so, they now match reality either way.Generated by Claude Code