fix(registry): ship stylesheets as registry:file so shadcn add works - #1050
Open
Agnik47 wants to merge 1 commit into
Open
fix(registry): ship stylesheets as registry:file so shadcn add works#1050Agnik47 wants to merge 1 commit into
shadcn add works#1050Agnik47 wants to merge 1 commit into
Conversation
The shadcn CLI runs every file it installs through its JavaScript/TypeScript transformer unless the file is typed registry:file. Components were shipped as whole folders and a folder cannot declare a type per file, so stylesheets went out as registry:component and got parsed as JavaScript, failing every -CSS variant with "Unexpected token (1:0)" on the first character of the CSS. Declare stylesheets as registry:file, which shadcn copies verbatim. That type requires an explicit target, so point it at @components/<Name>.css: shadcn resolves the alias to the components directory configured in the user's components.json, which is where the component itself lands, keeping the component's relative ./<Name>.css import working. Variants that ship a stylesheet are now listed file by file to give the stylesheet its own type; every other variant still ships as a folder, so all -TW entries are unchanged. Closes DavidHDev#1049
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.
Closes #1049
Problem
npx shadcn add @react-bits/<Component>-JS-CSSfails withUnexpected token (1:0)right after "Checking registry", at the "Updating files" step.It isn't specific to Lanyard — every one of the 292
-CSSregistry entries is affected.-TWvariants ship no stylesheet and were always fine.The shadcn CLI runs every file it installs through its JavaScript/TypeScript transformer unless the file is typed
registry:file.jsrepo.config.tsshipped each component as a whole folder, and a folder can't declare a type per file, so stylesheets went out asregistry:componentand got parsed as JavaScript.Unexpected token (1:0)is the parser choking on the first character of the CSS.Fix
Stylesheets are now declared as
registry:file, which shadcn copies verbatim.registry:filerequires an explicit target, so it is set to@components/<Name>.css— shadcn resolves the@componentsalias to whatever the user configured in theircomponents.json, which is where the component itself lands, so the component's relative./<Name>.cssimport keeps resolving.Because of the per-file type, variants that actually ship a stylesheet are now listed file by file instead of as a folder. Everything else still ships as a folder, so all
-TWentries stay byte-identical.public/r/is regenerated (npm run registry:build). That rebuild also picks up ~57 entries whose committed content had drifted fromsrc/before this PR — those are content-only refreshes, no structural change.Testing
4.16.0,4.17.0and4.18.0— all three fail onLanyard-JS-CSS,Aurora-JS-CSSandAccordionGallery-JS-CSS, whileAurora-JS-TWinstalls fine.npx shadcn addagainst the rebuilt registry on all three CLI versions, in both a JS project ("tsx": false) and a TS project ("tsx": true):Lanyard,Aurora,Hyperspeed,AccordionGallery,Magnet,BlurText,ASCIIText(-JS-CSS/-TS-CSS) plusAurora-JS-TWandSplitText-TS-TW— all install cleanly. Stylesheets land next to their component and every relative import resolves;Hyperspeedstill getsHyperSpeedPresetsalongside it.registry:filewith a matching@components/<Name>.csstarget; every other file stillregistry:componentwith no target; every./*.cssimport in a shipped source file has a matching shipped stylesheet, and no stylesheet is shipped unused.npm run buildpasses.npx prettier --check jsrepo.config.tspasses.npm run lintreports 46 errors, all pre-existing insrc/**/*.jsx— eslint runs with--ext js,jsx, so it doesn't cover either file this PR changes.Out of scope
card.glb/lanyard.pngstill aren't shipped through the registry. They were already excluded before this change, and the component's docs tell users to supply them.dependencyResolution: 'manual'still leaves itsdependenciesempty — separate issue.