fastify-vite

Fastify plugin for Vite integration.

MIT License

Downloads
14.7K
Stars
797
Committers
38

Bot releases are hidden (Show)

fastify-vite - @fastify/[email protected]

Published by galvez about 1 month ago

This is a maintenance release making @fastify/vite ready for Fastify v5.

It'll move into the latest tag once Fastify v5 is released.

This release contains updated dependencies for the @fastify/vite package and all examples, also now using Fastify v5.

fastify-vite - @fastify/[email protected]

Published by galvez 3 months ago

This is small patch release containing the following fix:

Many thanks to Wei Wang!

fastify-vite - @fastify/[email protected] Latest Release

Published by galvez 8 months ago

This release removes the accidental inclusion of optionalDependencies in package.json.

They are only used in development for PNPM workspaces to work.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This release includes an experimental implementation of server actions.

A link to a blog post covering this feature will be added shortly.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This release introduces the config.prepareServer(server) and route.configure(server) hooks.

A link to a blog post covering this feature will be added shortly.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This release contains a critical fix for Windows:

And a fix for a bug when attempting graceful shutdown:

Hat off to Shyam-Chen and matt-smarsh.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This patch release contains a fix for a syntax error in the root.vue virtual module.

As both starter templates include their own root.vue with correct syntax, this bug went unnoticed for a bit.

You can now also export mount from root.vue to determine where to mount the Vue application:

<script>
export { default } from '/:router.vue'

// This is what's pased to Vue's mount() method
export const mount = '#root'

export function configure ({ app, router }) {
  // Use this to configure/extend your Vue app and router instance
}
</script>
fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This contains a patch for a bug some users reported where not all CSS imports would be loaded client-side.

Also peerDependencies has been removed from package.json.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This release removes peerDependencies from package.json as it was causing trouble for many users.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This release fixes a bug previously preventing getData() and getMeta() to run in route query updates.

Also peerDependencies have been removed from package.json, once and for all.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This is mostly a maintenance release to support @fastify/vite v6.

Miscellaneous

All starter templates now come with Tailwind + CSS Nesting enabled by default.

I personally prefer unocss, but a run-of-the-mill Tailwind setup stands to benefit the most users.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This is mostly a maintenance release to support @fastify/vite v6.

Features

  • New /:router.vue virtual module to accommodate <router-view> isolatedly.
  • The /:root.vue virtual module can now export configure({ app, router }) for extending your Vue a Vue Router instances:

Both the vue-base and vue-kitchensink starter templates now come with root.vue defined as follows:

<script>
export { default } from '/:router.vue'

export function configure ({ app, router }) {
  // Use this to configure/extend your Vue app and router instance
}
</script>

Miscellaneous

All starter templates now come with Tailwind + CSS Nesting enabled by default.

I personally prefer unocss, but a run-of-the-mill Tailwind setup stands to benefit the most users.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

A small but important patch containing the following fix:

See the release notes for v6.0.0 here.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This release contains a small addition allowingdecorateReply and decorateRequest to be exported from route modules, for purposes of preinitialisation of properties added to either object (and avoiding changing the V8 shape of them in runtime).

export const decorateRequest = ['data']

export function preHandler (req, _, done) {
  req.data = {}
  done()
}

export default () => (
  <>
    <h1>Page</h1>
  </>
)

Note that all of Fastify's route-level hooks can be already exported from route modules, as demonstrated above. This feature is provided by default in @fastify/vite, namely, in its default definition for the createRoute() hook.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This is the first patch following the v6.0.0 release and contains:

  • A fix for HMR when using createRouteHandler() and createRoute() directly (no createRenderFunction()).
  • Files from Vite's public/ folder are now automatically served in production, closes #105.

See the release notes for v6.0.0 here.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This is the first release for an experimental HTMX renderer for @fastify/vite, with JSX support provided via @kitajs/html.

This is currently the fastest SSR option for @fastify/vite.

Documentation and benchmarks will be added soon. For now here's a rundown of its features:

  • All route modules server-side rendered only.
    • But if they import *.css, *.svg and *.client.js files, these are also loaded on the client.
    • Head tags with prefetch tags are precomputed at boot time, leveraging Vite's ssr-manifest.json.
  • Route modules automatically loaded from /views folder, need to export path.
  • Route layout modules automatically loaded from /layouts folder.
  • Fragment route modules automatically loaded from /fragments folder.
    • Fragments are just endpoints that return raw HTML, without the <html> and <body> shells.
  • Tailwind and CSS Nesting enabled out of the box.

Play with the example in starters/htmx-kitchensink to learn more.

fastify-vite - @fastify/[email protected]

Published by galvez 8 months ago

This is the sixth major release of @fastify/vite.

It has important changes that required the introduction of a couple of breaking changes, thus the new major release.

Both @fastify/[email protected] and @fastify/[email protected] still require @fastify/vite@5 to run.

Updated versions of these packages will be released soon.

New features

  • Type definitions have been comprehensively expanded, hat off to @Gehbt.

  • The default reply.html() function, returned by createHtmlTemplateFunction(), now always returns a Readable. And any parameter passed to it can also be a Readable. In addition, placeholders now also support the dot notation, and receive app (the Fastify plugin scope), req, reply, client and route as part of their default context in the default createRouteHandler() definition . For the following index.html:

    <head><!-- req.head --></head>
    

    The following reply.html() call should work:

     import { Readable } from 'node:stream'
    
     async function * head () {
        yield '<title>Streaming title</title>'
     }
    
     req.head = Redable.from(head())
     reply.html({ req })
    
  • If no createRenderFunction function is provided, createRouteHandler() will now by default call the route module's default export, as follows:

    createRouteHandler({ client, route }, scope, config) {
      // ...
      return async (req, reply) => {
        const page = await route.default({ app: scope, req, reply })
        return reply.html({
          app: scope,
          req,
          reply,
          route,
          client,
          element: page,
        })
      }
    
  • The plugin's config object now has two injected readonly properties:

    • hasRenderFunction indicates whether or createRenderFunction was provided.
    • ssrManifest contains the parsed JSON from the ssr-manifest.json file (production only).

Breaking changes

  • The default call signature of reply.render() in createRouteHandler() changed as follows:

    - const page = await reply.render(scope, req, reply)
    - return reply.html(page)
    + const page = await reply.render({
    +   app: scope,
    +   req,
    +   reply,
    +   route,
    +   client, 
    +  })
    
  • The default call signature of createRouteHandler() and createErrorHandler() have changed as follows:

    - createRouteHandler (client, scope, config) {
    + createRouteHandler({ client, route }, scope, config) {
    - createErrorHandler (client, scope, config) {
    + createErrorHandler({ client, route }, scope, config) {
    

In both cases, route is a reference to the route module, and client is a reference to the client module.

Fixes

Many thanks to the contributors!

Miscellaneous

Node v20+ is now used in development.

Vitest has been replaced with Node's native test runner.

ESLint has been replaced with Biome for speed[^1].

[^1]: Biome is lacking a formatting option that makes it not fully StandardJS-compliant, but it's an acceptable compromise since it was possible to remove several ESLint plugins from the dependencies and still have superior performance.

fastify-vite - @fastify/[email protected]

Published by galvez 10 months ago

This is a new minor release for @fastiffy/react containing an important change:

Which makes route modules able to receive POST, PUT and DELETE requests.

fastify-vite - @fastify/[email protected]

Published by galvez 10 months ago

This is a new minor release for @fastiffy/vue containing an important change:

Which makes route modules able to receive POST, PUT and DELETE requests.

fastify-vite - @fastify/[email protected]

Published by galvez 10 months ago

This is a patch for the v5 release line including: