Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a workaround for Next.js production build bug #421

Merged
merged 2 commits into from
Feb 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ export default function serialize (color, {
?? color.space.getFormat("default")
?? ColorSpace.DEFAULT_FORMAT;

inGamut ||= format.toGamut;
// The assignment to coords and inGamut needs to stay in the order they are now
// The order of the assignment was changed as a workaround for a bug in Next.js
// See this issue for details: https://github.com/color-js/color.js/issues/260

let coords = color.coords.slice(); // clone so we can manipulate it

inGamut ||= format.toGamut;

if (inGamut && !checkInGamut(color)) {
// FIXME what happens if the color contains NaNs?
coords = toGamut(clone(color), inGamut === true ? undefined : inGamut).coords;
Expand Down