feat(kit): add /kit export with addControlledCookie helper#323
feat(kit): add /kit export with addControlledCookie helper#323BlueBazze wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new @dargmuesli/nuxt-cookie-control/kit subpath export intended for other Nuxt modules to programmatically register cookies into this module’s configuration during module setup.
Changes:
- Introduces
src/kit.tswith anaddControlledCookiehelper and re-exports ofCookieType/Cookie. - Exposes the new
./kitentry viapackage.jsonexports +typesVersions. - Adds module-builder config and a playground module to demonstrate usage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/kit.ts | Adds addControlledCookie helper to mutate nuxt.options.cookieControl.cookies programmatically. |
| playground/modules/auth.ts | Adds a playground module example that uses the new kit entry. |
| package.json | Adds ./kit subpath export and TS type resolution for it. |
| build.config.ts | Configures module-builder entries to produce the new kit build output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
dargmuesli
left a comment
There was a problem hiding this comment.
Code LGTM 💚
Just some prettier lint logs remaining
|
Great, so it sounds like you are on board with this feature. The module order was important, even though moduleOptions was only added to runtime config in the Since other modules modified the nuxt options, these options were not being passed into cookie-control moduleOptions, but rather they lived in
I actually thought moduleOptions was a proxy to the unctx context from the options. Anyway, hooks will most likely become unnecessary. Since in You can see my "test" on https://github.com/BlueBazze/cookie-control-kit-test |
dargmuesli
left a comment
There was a problem hiding this comment.
oh sorry, I forgot to hit submit on this review
| * addControlledCookie({ id: 'analytics', name: 'Analytics' }, CookieType.OPTIONAL) | ||
| * ``` | ||
| */ | ||
| export const addControlledCookie = ( |
There was a problem hiding this comment.
Maybe name this
| export const addControlledCookie = ( | |
| export const addCookieControl = ( |
I prefer "hierarchical" naming. Imagine someone typing addCook and seeing addCookie and addCookieControl (if those were to exist; both related to cookies).
📚 Description
Adds a
@dargmuesli/nuxt-cookie-control/kitsubpath export exposing addControlledCookie, providing other Nuxt modules to helpers to register cookies with cookie-control programmatically during setup.Use case for this could be modules like
nuxt-auth-utilsdefining the session cookie if cookie-control is present.📝 Checklist
Note
defineBuildConfigbut pnpm requires the explicit dependency to be declared, i didnt want to introduce dependencies for this. That is your decision if and when needed.