fastify / fastify-vite

Fastify plugin for Vite integration
MIT License
894 stars 75 forks source link

Updated unihead package breaks metadata updates #168

Closed jarrodconnolly closed 2 months ago

jarrodconnolly commented 2 months ago

Prerequisites

Last working version

7.0.1

Stopped working in version

7.0.1

Node.js version

22.6.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 22.04.4 LTS

💥 Regression Report

The package unihead has a change between 0.0.6 and 0.0.7 that is breaking client-side header meta updates.

The Proxy wrapper API into HeadManager removed a special case for calling update(), which is used by both fastify-react and fastify-vue

https://github.com/fastify/fastify-vite/blob/dev/packages/fastify-vue/virtual/core.js#L52 https://github.com/fastify/fastify-vite/blob/dev/packages/fastify-react/virtual/core.jsx#L114

Diffing the NPM releases you can see the missing code. https://www.npmjs.com/package/unihead/v/0.0.6?activeTab=code https://www.npmjs.com/package/unihead/v/0.0.7?activeTab=code

        if (elem === 'update') {
          return initialHead => head.update(initialHead)
        }

Steps to Reproduce

Test switching from the home page to the using-data page with the react-kitchensink example.

Update the version of unihead to 0.0.7 and see that this no longer works.

Uncaught TypeError: head.update is not a function

Expected Behavior

No response

jarrodconnolly commented 2 months ago

I realize the issue is in a dependent package, and I bring it up here to begin with because of the following statement:

Under the hood, it uses the unihead library, which has a SSR function and a browser library that allows for dynamic changes during client-side navigation. This is a very small library built specifically for @fastify/vite core renderers

galvez commented 2 months ago

Good catch, I'll try and address this immediately!

jarrodconnolly commented 2 months ago

I'm not sure if you want to fix this here using different calls, but I threw up the option to just bring the update call back if that's the way you want to go.

https://github.com/galvez/unihead/pull/3

galvez commented 2 months ago

Pushed unihead v0.0.8 to npm, thank you!

jarrodconnolly commented 2 months ago

Thank you so much!

( It was pushed as 0.8.0 for reference )