upgrade: cookies package upgrade for Solid 2.0#906
Conversation
🦋 Changeset detectedLatest commit: 12c3078 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cookies/src/index.ts`:
- Around line 69-78: The effect currently calls serialize(cookie()) even when
cookie() is undefined, causing the string "undefined" to be stored; update the
createEffect callback to guard against undefined: if cookie() is undefined,
clear the cookie (e.g., write document.cookie = `${name}=;max-age=0` or
otherwise delete/skip) instead of calling serialize, otherwise call
serialize(cookie()) and write the cookie as before; reference createSignal
(cookie), createEffect, serialize, name and cookieMaxAge to locate and modify
the logic so serialize is never invoked with undefined.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 352a792e-2ae0-4bbc-bc47-baf6df1ffc7b
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
.changeset/cookies-solid2-migration.mdpackages/cookies/README.mdpackages/cookies/package.jsonpackages/cookies/src/index.tspackages/cookies/src/test/index.test.tspackages/cookies/src/test/server.test.ts
Upgrades the cookies package to Solid 2.0 (beta.13), adds a full test suite, and clarifies the intended relationship between this package and
@solid-primitives/storage.Changes:
isServerandgetRequestEventimported from@solidjs/web(wassolid-js/web)createEffectconverted to the required split compute/apply form — reactive tracking of the serialized value is now separated from thedocument.cookiewritecreateSignalinitial value cast toExclude<T | undefined, Function>to satisfy Solid 2.0's strict overload that distinguishes value signals from derived writable signalssolid-js@^2.0.0-beta.13and@solidjs/web@^2.0.0-beta.13package.jsondescription and README updated to clarify scopeArchitectural note — this package should use
@solid-primitives/storage@solid-primitives/cookiescurrently hand-rolls its own cookie read (parseCookie/getCookiesString) and write (document.cookie = ...) logic. The right foundation for this iscookieStoragefrom@solid-primitives/storage, which already provides a battle-tested, isomorphiclocalStorage-compatible cookie API with full attribute support (domain,path,secure,sameSite,httpOnly,expires,maxAge).Once
@solid-primitives/storageis migrated to Solid 2.0, this package should be updated to:parseCookie/getCookiesStringreads withcookieStorage.getItem()document.cookie =write in the effect withcookieStorage.setItem()ServerCookieOptionsto extendCookieOptionsfrom storage, exposing the full attribute surface to callersThe blocker is that
@solid-primitives/storageis currently still onsolid-js@^1.6.12. Pulling it in now would create a version conflict. This PR intentionally defers the integration and documents it in the README so the dependency is tracked at the intent level untilstorageis ready.Summary by CodeRabbit
Chores
Documentation
Tests