MyGit

v3.3.1

nuxt/nuxt

版本发布时间: 2023-03-14 21:31:23

nuxt/nuxt最新发布版本:v3.14.1592(2024-11-20 04:54:11)

3.3.0 is a minor (feature) release with lots of new features to play with. 3.3.1 was a swiftly following release to patch an issue with nuxi on Windows.

👀 Highlights

✨ Local module development DX

We've landed a raft of changes to enable local modules and improve DX. We now auto-scan your ~/modules folder and register top level files there as modules in your project (https://github.com/nuxt/nuxt/pull/19394). When these files are changed, we'll automatically restart the nuxt server.

  export default defineNuxtConfig({
    modules: [
      '@nuxtjs/tailwindcss',
-     '~/modules/purge-comments'
    ]
  })

We also now expose nuxt/kit for easy access to kit composables in your local project without having to install @nuxt/kit (https://github.com/nuxt/nuxt/pull/19422).

♻️ Restarting Nuxt

You can add files to the watch array to automatically restart the server (https://github.com/nuxt/nuxt/pull/19530). This is likely to be particularly useful for module authors. You can also trigger a restart of the Nuxt server with the new restart hook (https://github.com/nuxt/nuxt/pull/19084). We also landed a couple of fixes on restarting the Nuxt server which should improve your experience when developing.

🔥 Performance improvements

We've increased static asset maxAge to 1yr as a matter of best practice (https://github.com/nuxt/nuxt/pull/19335), and support tree-shaking more of your build (https://github.com/nuxt/nuxt/pull/19508). We also now support preloading <NuxtLink>s with a route in object-syntax (https://github.com/nuxt/nuxt/pull/19120).

CleanShot 2023-03-14 at 12 19 50

We also track how long it takes each module you use to perform its setup, and warn if it takes too long. You can see all these values by running your dev server with DEBUG=1

You can also opt-in to some of Nuxt's internal optimisations by configuring composables to be treeshaken in a particular environment (https://github.com/nuxt/nuxt/pull/19383), or to have magic keys automatically injected (https://github.com/nuxt/nuxt/pull/19490) - primarily useful for module authors.

🐛 Error handling

We now handle chunk errors by default (https://github.com/nuxt/nuxt/pull/19086), meaning if your site updates with a redeploy, we automatically handle reloading it on navigation. You can disable this and handle it yourself with the new reloadNuxtApp composable. You can also set experimental.restoreState to preserve some of your app state across reloads.

We also have a new experimental error handling component: <NuxtClientFallback> (https://github.com/nuxt/framework/pull/8216) which can capture errors rendering on server, replace them with fallback content, and granularly trigger rerendering the part with an error on the client. This can be enabled with experimental.clientFallback - feedback very welcome!

⚡️ Head improvements

We've migrated to use unhead directly (https://github.com/nuxt/nuxt/pull/19519) - and automatically tree-shake server-only head composables like useServerHead from your client build (https://github.com/nuxt/nuxt/pull/19576), meaning you can have great SEO without needing to include meta tag logic that's relevant only for crawlers in your client build.

There's also a new useHeadSafe composable that handles santising untrusted user input (https://github.com/nuxt/nuxt/pull/19548).

🪵 Better logging in browser DevTools

Working with the Chrome DevTools team, we've landed a couple of features across the unjs + Nuxt ecosystem meaning we now have first-class support for hiding Nuxt internal stack traces from logs in your (Chromium-based, for now) browser (https://github.com/nuxt/nuxt/pull/19243). We also landed a couple of improvements with stacktraces involving Nuxt hooks (https://github.com/unjs/hookable/pull/69 and https://github.com/unjs/hookable/pull/68) implementing console.createTask.

Before After
CleanShot 2023-03-14 at 11 55 00 CleanShot 2023-03-14 at 11 52 27

💪 Type improvements

Types for server API routes are now more correct - with non-serialisable types stripped out of the return type (https://github.com/unjs/nitro/pull/1002).

We also now type more of NuxtApp and correctly type unknown injections for greater type-safety (https://github.com/nuxt/nuxt/pull/19643).

CleanShot 2023-03-14 at 11 59 58

And if you were struggling with correct types when using transform + default with Nuxt data fetching composables, fear no more - we now infer the types correctly (https://github.com/nuxt/nuxt/pull/19487).

⚗️ Nitro enhancements

This release comes with Nitro v2.3, which brings lots of improvements of its own. Check out the release for more info.

We now support useAppConfig in nitro server routes (https://github.com/nuxt/nuxt/pull/19489) - a long-awaited change. Now useAppConfig is consistently available throughout your app for non-runtime configuration from layers, modules, etc.

We've also added a nitro:build:public-assets hook to allow modifying assets output from nitro's prerender/build phase (https://github.com/nuxt/nuxt/pull/19638).

🛠️ Build changes

As part of moving towards first-class support for PNP and pnpm support without --shamefully-hoist, we've dropped support for some internal (deprecated) utilities using CJS resolve patterns (https://github.com/nuxt/nuxt/pull/19537, https://github.com/nuxt/nuxt/pull/19608). We also now resolve dependencies like nuxt, @nuxt/kit and more using ESM search-paths. We'll be keeping a close eye on this.

We're also preparing the groundwork for support of new TypeScript Node16 module resolution (https://github.com/nuxt/nuxt/issues/19606), and as part of this have changed the format of our runtime output (using .js instead of .mjs extensions, providing types fields for subpath exports, and more).

🗺️ Custom config schema (advanced)

We've been testing out an experimental feature to allow modules and users to extend the Nuxt config schema (https://github.com/nuxt/nuxt/issues/15592), and we've now enabled this by default (https://github.com/nuxt/nuxt/pull/19172). We expect this will be particularly useful for module and layer/theme authors, and should result in some nicer DX for their users.

Changelog

compare changes

🚀 Enhancements

🔥 Performance

🩹 Fixes

💅 Refactors

📖 Documentation

🏡 Chore

✅ Tests

🤖 CI

⚠️ Breaking Changes

❤️ Contributors

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-03-14发行的版本