feat: mark the components, hooks, factories and configureLottie as client modules - #138
Merged
Conversation
…ient modules Under React Server Components a module that only works in the browser says so with a directive, and a server component that imports it receives a client reference instead of evaluating it. Without the line, importing `Lottie` from a server component evaluated the context modules on the server and the build failed on `createContext`; the only route was the consumer's own client file. Every component, every hook, the interaction factories and `configureLottie` now start with `"use client"`, so a server component imports `<Lottie>` directly, and a server-side call of `configureLottie` fails at build time instead of configuring a copy the browser never sees. The barrel and the vocabulary maps stay unmarked: the barrel must be evaluated to re-export, and a server component may read `LottieDirection.reverse`. tsdown keeps the directive at the top of each emitted file; the rule is recorded in the build contract.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #138 +/- ##
=======================================
Coverage 99.92% 99.92%
=======================================
Files 48 48
Lines 1253 1269 +16
Branches 365 365
=======================================
+ Hits 1252 1268 +16
Misses 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
What
Under React Server Components a module that only works in the browser says so with
"use client", and a server component that imports it receives a client reference instead of evaluating it. Without the line,import { Lottie } from "lottie-react"in a server component made the Next build fail at page-data collection withTypeError: createContext is not a function(React's server build has nocreateContext, and our context modules evaluate it when the barrel is imported); the only route was the consumer's own"use client"file.Now every component, every hook, the interaction factories and
configureLottiestart with the directive (16 modules). The barrel and the vocabulary maps stay unmarked: the barrel must be evaluated to re-export, and a server component may readLottieDirection.reverse. The rule is recorded inCLAUDE.mdunder "Modules and exports". Docs: the installation page says a server component can import the components directly, and thatconfigureLottie, like the hooks, is called from client code; the configuring page says a server-side call fails at build time rather than configuring a copy the browser never sees.Verified
Lottiedirectly builds, prerenders (element in the HTML), hydrates and plays; a server component callingconfigureLottiefails at build time with React's message ("Attempted to call configureLottie() from the server but configureLottie is on the client…"); client-component pages unchanged.pnpm checkgreen: 488 tests, coverage 100 / 97.46 / 100 / 100, 36 pages rendered.