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

refactor: use cookie-es for cookie utils #13512

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

pi0
Copy link

@pi0 pi0 commented Feb 27, 2025

I noticed that svelte-kit depends on multiple cookie packages cookie, set-cookie-parser, @types/cookie + workarounds for CJS support.

unjs/cookie-es packs cookie and set-cookie-parser functionality as an ESM-only and typed package (used and tested across UnJS and Nuxt ecosystem).

This PR reduces install size (cookie:45.4/cookie types: 47.1/set-cookie:15.7) 108kB to 20.2kB

Also opened discussion: #13511


Totally unrelavant question: Have you considered trying autofix.ci to auto fix format issues? It is amazing!


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Feb 27, 2025

🦋 Changeset detected

Latest commit: 4fb5630

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@svelte-docs-bot
Copy link

@pi0 pi0 marked this pull request as ready for review February 27, 2025 21:09
@dummdidumm
Copy link
Member

dummdidumm commented Feb 27, 2025

Nice to know, thank you! Since this likely depends on the newest cookie version which has a breaking change we can only do this in 3.0

@dummdidumm dummdidumm added this to the 3.0 milestone Feb 27, 2025
@pi0
Copy link
Author

pi0 commented Feb 27, 2025

Since this likely depends on the newest cookie version which has a breaking change we can only do this in 3.0

Actually, I haven't migrated cookie-es to be like latest upstream major yet (for same concerns of breaking changes). It will happen for cookie-es v3 likely (if we do)

@dummdidumm
Copy link
Member

Oh interesting! Any time frame on that (you said "if we do" which sounds like you might not do for a long time?)

@pi0
Copy link
Author

pi0 commented Feb 27, 2025

I mean unless find a way to reduce/avoid breaking changes surface in cookie-ea during next sync.

I don’t have any time frames for next major, but we can discuss it later if you like general idea of this migration.

@benmccann
Copy link
Member

This might be a nice way to eliminate the security warning associated with the cookie library in the short-term. It's kind of papering over it, but it'd be a breaking change for us to upgrade the cookie library (#13386) so it might be the best option we have in the immediate future

Just to clarify, we don't care about CJS at all. SvelteKit has been ESM-only since day 1

Combining both pieces of functionality into a single package is nice. It looks like the cookie library is considering that as well: jshttp/cookie#200

@eltigerchino eltigerchino linked an issue Mar 3, 2025 that may be closed by this pull request
@eltigerchino
Copy link
Member

We should probably update the Netlify adapter to use the cookie-es package too
https://github.com/sveltejs/kit/blob/main/packages/adapter-netlify/src/headers.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to cookie-es
4 participants