diff --git a/.stackblitz/config.json b/.stackblitz/config.json new file mode 100644 index 00000000000..41af21c43bc --- /dev/null +++ b/.stackblitz/config.json @@ -0,0 +1,3 @@ +{ + "startCommand": "pnpm build:stub && pnpm play" +} diff --git a/docs/content/1.getting-started/10.deployment.md b/docs/content/1.getting-started/10.deployment.md index 435f0fcdff7..d7f2af80792 100644 --- a/docs/content/1.getting-started/10.deployment.md +++ b/docs/content/1.getting-started/10.deployment.md @@ -139,6 +139,7 @@ Nuxt 3 can be deployed to several cloud providers with a minimal amount of confi - :IconCloud{class="h-5 w-4 inline mb-2"} [AWS](https://nitro.unjs.io/deploy/providers/aws) - :LogoAzure{class="h-5 w-4 inline mb-2"} [Azure](https://nitro.unjs.io/deploy/providers/azure) +- :IconCloud{class="h-5 w-4 inline mb-2"} [Cleavr](https://nitro.unjs.io/deploy/providers/cleavr) - :LogoCloudFlare{class="h-5 w-4 inline mb-2"} [CloudFlare](https://nitro.unjs.io/deploy/providers/cloudflare) - :IconCloud{class="h-5 w-4 inline mb-2"} [Digital Ocean](https://nitro.unjs.io/deploy/providers/digitalocean) - :LogoFirebase{class="h-5 w-4 inline mb-2"} [Firebase](https://nitro.unjs.io/deploy/providers/firebase) diff --git a/docs/content/2.guide/1.concepts/2.vuejs-development.md b/docs/content/2.guide/1.concepts/2.vuejs-development.md index f3bbc850a16..030dc1b11ea 100644 --- a/docs/content/2.guide/1.concepts/2.vuejs-development.md +++ b/docs/content/2.guide/1.concepts/2.vuejs-development.md @@ -31,7 +31,7 @@ Most applications need multiple pages and a way to navigate between them. This i ### Example -:button-link[Open on StackBlitz]{href="https://stackblitz.com/edit/github-9hzuns?file=app.vue" blank} +:button-link[Open on StackBlitz]{href="https://stackblitz.com/edit/github-9hzuns?file=app.vue" blank .mr-2} :button-link[Open on CodeSandbox]{href="https://codesandbox.io/s/nuxt-3-components-auto-import-2xq9z?file=/app.vue" blank} The `app.vue` file is the entry point, which represents the page displayed in the browser window. diff --git a/docs/content/2.guide/1.concepts/3.rendering.md b/docs/content/2.guide/1.concepts/3.rendering.md index 74baa3608d6..ab37405028c 100644 --- a/docs/content/2.guide/1.concepts/3.rendering.md +++ b/docs/content/2.guide/1.concepts/3.rendering.md @@ -69,14 +69,46 @@ In most cases, universal rendering as performed in Nuxt 2 offers a good user and ### Hybrid Rendering -Hybrid rendering allows different caching rules per route and decides how the Server should respond to a new request on a given URL. - -At the moment, every page (or **route**) of a Nuxt application must use the same rendering mode, client-side or universal. But in various cases, some pages could be generated at build time, while others should be client-side rendered. For example, think of a content website with an admin section. Every content page should be primarily static and generated once, but the admin section requires registration and behaves more like a dynamic application. - -[Read the open RFC discussing implementation and gathering community feedback.](https://github.com/nuxt/framework/discussions/560) +Hybrid rendering allows different caching rules per route using **Route Rules** and decides how the Server should respond to a new request on a given URL. ### Rendering on CDN Edge Workers Traditionally, server-side and universal rendering was only possible using Node.js. Nuxt 3 takes it to another level by directly rendering code in CDN edge workers, reducing latency and costs. Nitro is the new [server engine](/guide/concepts/server-engine) that powers Nuxt 3. It offers cross-platform support for Node.js, Deno, Workers, and more. Nitro's design is platform-agnostic and allows rendering a Nuxt application at the edge, closer to your users, allowing replication and further optimizations. + +### Route Rules + +> 🧪 Route rules are still under active development, and subject to change. + +Previously every route/page of a Nuxt application and server must use the same rendering mode, client-side or universal. But in various cases, some pages could be generated at build time, while others should be client-side rendered. For example, think of a content website with an admin section. Every content page should be primarily static and generated once, but the admin section requires registration and behaves more like a dynamic application. + +Nuxt 3 starting from rc.12 comes with the public beta for route rules and hybrid rendering support. Using route rules you can define rules for a group of nuxt routes, change rendering mode or assign a cache strategy based on route! Nuxt server will automatically register corresponding middleware and wrap routes with cache handlers using [nitro caching layer](https://nitro.unjs.io/guide/introduction/cache). Whenever possible, route rules will be automatically applied to the deployment platform's native rules (currently Netlify and Vercel are supported). + +- `redirect` - Define server-side redirects. +- `ssr` - Disables server-side rendering for sections of your app and make them SPA-only with `ssr: false` +- `cors` - Automatically adds cors headers with `cors: true` - you can customize the output by overriding with `headers` +- `headers` - Add specific headers to sections of your site - for example, your assets +- `static` and `swr` - `static` enables a single (on-demand) build; `swr` enables a static build, that lasts for a configurable TTL. (currently enables full incremental static generation on Netlify, with Vercel coming soon) + +**Examples:** + +```ts +export default defineNuxtConfig({ + routeRules: { + // Static page generated on-demand, revalidates in background + '/blog/**': { swr: true }, + // Static page generated on-demand once + '/articles/**': { static: true }, + // Set custom headers matching paths + '/_nuxt/**': { headers: { 'cache-control': 's-maxage=0' } }, + // Render these routes with SPA + '/admin/**': { ssr: false }, + // Add cors headers + '/api/v1/**': { cors: true }, + // Add redirect headers + '/old-page': { redirect: '/new-page' }, + '/old-page2': { redirect: { to: '/new-page', statusCode: 302 } } + } +}) +``` diff --git a/docs/content/2.guide/2.directory-structure/1.server.md b/docs/content/2.guide/2.directory-structure/1.server.md index 8503aa043f9..e4a7d1c6ae2 100644 --- a/docs/content/2.guide/2.directory-structure/1.server.md +++ b/docs/content/2.guide/2.directory-structure/1.server.md @@ -141,7 +141,7 @@ export default defineEventHandler(() => `Default api handler`) ```ts [server/api/submit.post.ts] export default defineEventHandler(async (event) => { - const body = await useBody(event) + const body = await readBody(event) return { body } }) ``` @@ -149,7 +149,7 @@ export default defineEventHandler(async (event) => { You can now universally call this API using `$fetch('/api/submit', { method: 'post', body: { test: 123 } })`. ::alert{type=warning title=Attention} -We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `useBody` within a GET request, `useBody` will throw a `405 Method Not Allowed` HTTP error. +We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `readBody` within a GET request, `readBody` will throw a `405 Method Not Allowed` HTTP error. :: ### Handling Requests With Query Parameters @@ -275,7 +275,7 @@ Create a new file in `server/api/test.post.ts`: ```ts [server/api/test.post.ts] export default defineEventHandler(async (event) => { - const body = await useBody(event) + const body = await readBody(event) await useStorage().setItem('redis:test', body) return 'Data is set' }) diff --git a/docs/content/5.community/2.reporting-bugs.md b/docs/content/5.community/2.reporting-bugs.md index b06f73bde58..560bc462f9a 100644 --- a/docs/content/5.community/2.reporting-bugs.md +++ b/docs/content/5.community/2.reporting-bugs.md @@ -32,7 +32,7 @@ If your issue concerns Vue 3 or Vite, please try to reproduce it first with the **Nuxt 3**: -:button-link[Nuxt 3 on StackBlitz]{href="https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz" blank} +:button-link[Nuxt 3 on StackBlitz]{href="https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz" blank .mr-2} :button-link[Nuxt 3 on CodeSandbox]{href="https://codesandbox.io/p/github/nuxt/starter/v3-codesandbox" blank} **Nuxt Bridge**: @@ -41,8 +41,8 @@ If your issue concerns Vue 3 or Vite, please try to reproduce it first with the **Vue 3**: -:button-link[Vue 3 SSR on StackBlitz]{href="https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main?terminal=dev" blank} -:button-link[Vue 3 SSR on CodeSandbox]{href="https://codesandbox.io/p/github/nuxt-contrib/vue3-ssr-starter/main" blank} +:button-link[Vue 3 SSR on StackBlitz]{href="https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main?terminal=dev" blank .mr-2} +:button-link[Vue 3 SSR on CodeSandbox]{href="https://codesandbox.io/p/github/nuxt-contrib/vue3-ssr-starter/main" blank .mr-2} :button-link[Vue 3 SSR Template]{href="https://github.com/nuxt-contrib/vue3-ssr-starter/generate" blank} Once you've reproduced the issue, remove as much code from your reproduction as you can (while still recreating the bug). The time spent making the reproduction as minimal as possible will make a huge difference to whoever sets out to fix the issue. diff --git a/docs/public/_redirects b/docs/public/_redirects index d3743bf79a9..bcf4ce6f6be 100644 --- a/docs/public/_redirects +++ b/docs/public/_redirects @@ -74,4 +74,5 @@ /guide/deploy/providers/render https://nitro.unjs.io/deploy/providers/render 302! /guide/deploy/providers/stormkit https://nitro.unjs.io/deploy/providers/stormkit 302! /guide/deploy/providers/vercel https://nitro.unjs.io/deploy/providers/vercel 302! +/guide/deploy/providers/cleavr https://nitro.unjs.io/deploy/providers/cleavr 302! diff --git a/examples/advanced/config-extends/package.json b/examples/advanced/config-extends/package.json index 81abde4fc40..11bb431d3e2 100644 --- a/examples/advanced/config-extends/package.json +++ b/examples/advanced/config-extends/package.json @@ -3,7 +3,7 @@ "private": true, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" }, "scripts": { "dev": "nuxi dev", diff --git a/examples/advanced/jsx/package.json b/examples/advanced/jsx/package.json index 3dd2e2c2bce..24f56476d10 100644 --- a/examples/advanced/jsx/package.json +++ b/examples/advanced/jsx/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/advanced/module-extend-pages/package.json b/examples/advanced/module-extend-pages/package.json index 280d71e3f8d..1775183a7f0 100644 --- a/examples/advanced/module-extend-pages/package.json +++ b/examples/advanced/module-extend-pages/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/advanced/testing/package.json b/examples/advanced/testing/package.json index 4998b089e3f..2ad6032e4e0 100644 --- a/examples/advanced/testing/package.json +++ b/examples/advanced/testing/package.json @@ -7,6 +7,6 @@ "start": "nuxi preview" }, "devDependencies": { - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/app-config/package.json b/examples/app-config/package.json index 657e5a56f2e..575c41ab7cc 100644 --- a/examples/app-config/package.json +++ b/examples/app-config/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/app/error-handling/package.json b/examples/app/error-handling/package.json index b95bff8686d..efe7e9a5f9f 100644 --- a/examples/app/error-handling/package.json +++ b/examples/app/error-handling/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/app/plugins/package.json b/examples/app/plugins/package.json index f4a0ec73f5f..34ff41c9bad 100644 --- a/examples/app/plugins/package.json +++ b/examples/app/plugins/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/app/teleport/package.json b/examples/app/teleport/package.json index f2a1c8972f0..72eda7a3323 100644 --- a/examples/app/teleport/package.json +++ b/examples/app/teleport/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/auto-imports/components/package.json b/examples/auto-imports/components/package.json index eb744cd081b..b1c9d42db5d 100644 --- a/examples/auto-imports/components/package.json +++ b/examples/auto-imports/components/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/auto-imports/composables/package.json b/examples/auto-imports/composables/package.json index 728b08bcd05..eb0f4f93df0 100644 --- a/examples/auto-imports/composables/package.json +++ b/examples/auto-imports/composables/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/composables/use-async-data/package.json b/examples/composables/use-async-data/package.json index 839b2bda721..13bb4cc66f8 100644 --- a/examples/composables/use-async-data/package.json +++ b/examples/composables/use-async-data/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/composables/use-cookie/package.json b/examples/composables/use-cookie/package.json index c086f9be4fd..1015f1e58cf 100644 --- a/examples/composables/use-cookie/package.json +++ b/examples/composables/use-cookie/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/composables/use-fetch/package.json b/examples/composables/use-fetch/package.json index babb876b16c..627b0f7cbee 100644 --- a/examples/composables/use-fetch/package.json +++ b/examples/composables/use-fetch/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/composables/use-head/package.json b/examples/composables/use-head/package.json index 81046c69176..47bd9676050 100644 --- a/examples/composables/use-head/package.json +++ b/examples/composables/use-head/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/composables/use-state/package.json b/examples/composables/use-state/package.json index cf501f4a2c2..907ee596dcc 100644 --- a/examples/composables/use-state/package.json +++ b/examples/composables/use-state/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/essentials/hello-world/package.json b/examples/essentials/hello-world/package.json index 8471e35d59d..d32d33ac4e5 100644 --- a/examples/essentials/hello-world/package.json +++ b/examples/essentials/hello-world/package.json @@ -7,6 +7,6 @@ "start": "nuxi preview" }, "devDependencies": { - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/experimental/reactivity-transform/package.json b/examples/experimental/reactivity-transform/package.json index 244aeef142d..e7a05492170 100644 --- a/examples/experimental/reactivity-transform/package.json +++ b/examples/experimental/reactivity-transform/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/experimental/vite-node/package.json b/examples/experimental/vite-node/package.json index edf59ee9947..94cea58bde6 100644 --- a/examples/experimental/vite-node/package.json +++ b/examples/experimental/vite-node/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/experimental/wasm/package.json b/examples/experimental/wasm/package.json index 1c7d8a124f2..06040a826f3 100644 --- a/examples/experimental/wasm/package.json +++ b/examples/experimental/wasm/package.json @@ -3,7 +3,7 @@ "private": true, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" }, "scripts": { "dev": "nuxi dev", diff --git a/examples/other/locale/package.json b/examples/other/locale/package.json index 9bbf38b55c8..6a6c6eb6eb5 100644 --- a/examples/other/locale/package.json +++ b/examples/other/locale/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/routing/layouts/package.json b/examples/routing/layouts/package.json index 9fc6d6f505e..6a6f0cb7ffb 100644 --- a/examples/routing/layouts/package.json +++ b/examples/routing/layouts/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/routing/middleware/package.json b/examples/routing/middleware/package.json index e73e4f8b59b..1698a171626 100644 --- a/examples/routing/middleware/package.json +++ b/examples/routing/middleware/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/routing/nuxt-link/package.json b/examples/routing/nuxt-link/package.json index fcd66059ee1..b7fb1a206d8 100644 --- a/examples/routing/nuxt-link/package.json +++ b/examples/routing/nuxt-link/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/routing/pages/package.json b/examples/routing/pages/package.json index 9312c291ba8..074981653d4 100644 --- a/examples/routing/pages/package.json +++ b/examples/routing/pages/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/routing/universal-router/package.json b/examples/routing/universal-router/package.json index c729527aedf..96cbd4a87a5 100644 --- a/examples/routing/universal-router/package.json +++ b/examples/routing/universal-router/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/examples/server/routes/package.json b/examples/server/routes/package.json index 285b8b59791..f472b0a0d4d 100644 --- a/examples/server/routes/package.json +++ b/examples/server/routes/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "@nuxt/ui": "^0.3.3", - "nuxt": "^3.0.0-rc.11" + "nuxt": "^3.0.0-rc.12" } } diff --git a/package.json b/package.json index 897770f374a..d8eaf39d15f 100644 --- a/package.json +++ b/package.json @@ -48,15 +48,15 @@ "@nuxt/webpack-builder": "workspace:*", "@nuxtjs/eslint-config-typescript": "^11.0.0", "@types/crawler": "^1.2.2", - "@types/node": "^16.11.66", + "@types/node": "^16.11.68", "@types/rimraf": "^3", "@types/semver": "^7", - "@unocss/reset": "^0.45.29", + "@unocss/reset": "^0.45.30", "case-police": "^0.5.10", "changelogen": "^0.3.5", "crawler": "^1.3.0", "eslint": "^8.25.0", - "eslint-plugin-jsdoc": "^39.3.6", + "eslint-plugin-jsdoc": "^39.3.14", "execa": "^6.1.0", "expect-type": "^0.14.2", "globby": "^13.1.2", @@ -64,7 +64,7 @@ "markdownlint-cli": "^0.32.2", "nuxi": "workspace:*", "nuxt": "workspace:*", - "ohmyfetch": "^0.4.19", + "ohmyfetch": "^0.4.20", "pathe": "^0.3.9", "rimraf": "^3.0.2", "semver": "^7.3.8", diff --git a/packages/kit/package.json b/packages/kit/package.json index 3a38aa9e356..d4e67ba9519 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,6 +1,6 @@ { "name": "@nuxt/kit", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -13,7 +13,7 @@ "prepack": "unbuild" }, "dependencies": { - "@nuxt/schema": "3.0.0-rc.11", + "@nuxt/schema": "3.0.0-rc.12", "c12": "^0.2.13", "consola": "^2.15.3", "defu": "^6.1.0", diff --git a/packages/kit/src/build.ts b/packages/kit/src/build.ts index b28384397c1..b602b8a45d8 100644 --- a/packages/kit/src/build.ts +++ b/packages/kit/src/build.ts @@ -117,19 +117,27 @@ export function extendViteConfig ( /** * Append Webpack plugin to the config. */ -export function addWebpackPlugin (plugin: WebpackPluginInstance, options?: ExtendWebpackConfigOptions) { +export function addWebpackPlugin (plugin: WebpackPluginInstance | WebpackPluginInstance[], options?: ExtendWebpackConfigOptions) { extendWebpackConfig((config) => { config.plugins = config.plugins || [] - config.plugins.push(plugin) + if (Array.isArray(plugin)) { + config.plugins.push(...plugin) + } else { + config.plugins.push(plugin) + } }, options) } /** * Append Vite plugin to the config. */ -export function addVitePlugin (plugin: VitePlugin, options?: ExtendViteConfigOptions) { +export function addVitePlugin (plugin: VitePlugin | VitePlugin[], options?: ExtendViteConfigOptions) { extendViteConfig((config) => { config.plugins = config.plugins || [] - config.plugins.push(plugin) + if (Array.isArray(plugin)) { + config.plugins.push(...plugin) + } else { + config.plugins.push(plugin) + } }, options) } diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index 08c79414591..c7b0e68799e 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -1,6 +1,6 @@ { "name": "nuxi", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -18,8 +18,8 @@ "prepack": "unbuild" }, "devDependencies": { - "@nuxt/kit": "3.0.0-rc.11", - "@nuxt/schema": "3.0.0-rc.11", + "@nuxt/kit": "3.0.0-rc.12", + "@nuxt/schema": "3.0.0-rc.12", "@types/clear": "^0", "@types/flat": "^5.0.2", "@types/mri": "^1.1.1", @@ -35,7 +35,7 @@ "execa": "^6.1.0", "flat": "^5.0.2", "giget": "^0.1.7", - "h3": "^0.8.1", + "h3": "^0.8.4", "jiti": "^1.16.0", "listhen": "^0.3.4", "mlly": "^0.5.16", diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 9442ab0d19b..c624a624ee7 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -1,6 +1,6 @@ { "name": "nuxt", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -37,11 +37,11 @@ }, "dependencies": { "@nuxt/devalue": "^2.0.0", - "@nuxt/kit": "3.0.0-rc.11", - "@nuxt/schema": "3.0.0-rc.11", + "@nuxt/kit": "3.0.0-rc.12", + "@nuxt/schema": "3.0.0-rc.12", "@nuxt/telemetry": "^2.1.6", "@nuxt/ui-templates": "^0.4.0", - "@nuxt/vite-builder": "3.0.0-rc.11", + "@nuxt/vite-builder": "3.0.0-rc.12", "@vue/reactivity": "^3.2.41", "@vue/shared": "^3.2.41", "@vueuse/head": "~1.0.0-rc.9", @@ -52,16 +52,16 @@ "escape-string-regexp": "^5.0.0", "fs-extra": "^10.1.0", "globby": "^13.1.2", - "h3": "^0.8.1", + "h3": "^0.8.4", "hash-sum": "^2.0.0", "hookable": "^5.4.1", "knitwork": "^0.1.2", "magic-string": "^0.26.7", "mlly": "^0.5.16", - "nitropack": "npm:nitropack-edge@0.6.0-27766876.4ff7082", - "nuxi": "3.0.0-rc.11", + "nitropack": "^0.6.0", + "nuxi": "3.0.0-rc.12", "ohash": "^0.1.5", - "ohmyfetch": "^0.4.19", + "ohmyfetch": "^0.4.20", "pathe": "^0.3.9", "perfect-debounce": "^0.1.3", "scule": "^0.3.2", @@ -71,10 +71,10 @@ "unctx": "^2.0.2", "unenv": "^0.6.2", "unimport": "^0.6.8", - "unplugin": "^0.9.6", + "unplugin": "^0.10.0", "untyped": "^0.5.0", "vue": "^3.2.41", - "vue-bundle-renderer": "^0.4.3", + "vue-bundle-renderer": "^0.4.4", "vue-devtools-stub": "^0.1.0", "vue-router": "^4.1.5" }, diff --git a/packages/nuxt/src/app/composables/preload.ts b/packages/nuxt/src/app/composables/preload.ts index 308b40c4b9f..b58c0af1f56 100644 --- a/packages/nuxt/src/app/composables/preload.ts +++ b/packages/nuxt/src/app/composables/preload.ts @@ -41,7 +41,7 @@ export async function preloadRouteComponents (to: string, router: Router & { _ro if (router._routePreloaded.has(to)) { return } router._routePreloaded.add(to) - const promises = router._preloadPromises ||= [] + const promises = router._preloadPromises = router._preloadPromises || [] if (promises.length > 4) { // Defer adding new preload requests until the existing ones have resolved diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 58310c1226c..0fc7dcc1f95 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -7,6 +7,7 @@ import { resolvePath } from '@nuxt/kit' import defu from 'defu' import fsExtra from 'fs-extra' import { dynamicEventHandler } from 'h3' +import type { Plugin } from 'rollup' import { distDir } from '../dirs' import { ImportProtectionPlugin } from './plugins/import-protection' @@ -36,6 +37,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { devHandlers: [], baseURL: nuxt.options.app.baseURL, virtual: {}, + routeRules: { + '/__nuxt_error': { cache: false } + }, runtimeConfig: { ...nuxt.options.runtimeConfig, nitro: { @@ -121,14 +125,16 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { } // Register nuxt protection patterns - nitroConfig.rollupConfig!.plugins!.push(ImportProtectionPlugin.rollup({ - rootDir: nuxt.options.rootDir, - patterns: [ - ...['#app', /^#build(\/|$)/] - .map(p => [p, 'Vue app aliases are not allowed in server routes.']) as [RegExp | string, string][] - ], - exclude: [/core[\\/]runtime[\\/]nitro[\\/]renderer/] - })) + nitroConfig.rollupConfig!.plugins!.push( + ImportProtectionPlugin.rollup({ + rootDir: nuxt.options.rootDir, + patterns: [ + ...['#app', /^#build(\/|$)/] + .map(p => [p, 'Vue app aliases are not allowed in server routes.']) as [RegExp | string, string][] + ], + exclude: [/core[\\/]runtime[\\/]nitro[\\/]renderer/] + }) as Plugin + ) // Extend nitro config with hook await nuxt.callHook('nitro:config', nitroConfig) diff --git a/packages/nuxt/src/core/runtime/nitro/error.ts b/packages/nuxt/src/core/runtime/nitro/error.ts index 896c5179fa4..ea557cea492 100644 --- a/packages/nuxt/src/core/runtime/nitro/error.ts +++ b/packages/nuxt/src/core/runtime/nitro/error.ts @@ -20,9 +20,10 @@ export default async function errorhandler (error: H3Error, } // Set response code and message - event.res.statusCode = errorObject.statusCode as any as number - event.res.statusMessage = errorObject.statusMessage - + event.res.statusCode = (errorObject.statusCode !== 200 && errorObject.statusCode) as any as number || 500 + if (errorObject.statusMessage) { + event.res.statusMessage = errorObject.statusMessage + } // Console output if (error.unhandled || error.fatal) { const tags = [ diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index 24199f51e8e..ceff0fd6257 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -10,7 +10,12 @@ import { useRuntimeConfig, useNitroApp, defineRenderHandler, getRouteRules } fro import type { NuxtApp, NuxtSSRContext } from '#app' // @ts-ignore -import { buildAssetsURL } from '#paths' +import { buildAssetsURL, publicAssetsURL } from '#paths' + +// @ts-ignore +globalThis.__buildAssetsURL = buildAssetsURL +// @ts-ignore +globalThis.__publicAssetsURL = publicAssetsURL export interface NuxtRenderHTMLContext { htmlAttrs: string[] @@ -198,7 +203,7 @@ export default defineRenderHandler(async (event) => { const renderedMeta = await ssrContext.renderMeta?.() ?? {} // Render inline styles - const inlinedStyles = process.env.NUXT_INLINE_STYLES && !(process.env.NUXT_NO_SSR || ssrContext.noSSR) + const inlinedStyles = process.env.NUXT_INLINE_STYLES ? await renderInlineStyles(ssrContext.modules ?? ssrContext._registeredComponents ?? []) : '' @@ -284,6 +289,7 @@ function renderHTMLDocument (html: NuxtRenderHTMLContext) { } async function renderInlineStyles (usedModules: Set | string[]) { + const { entryCSS } = await getClientManifest() const styleMap = await getSSRStyles() const inlinedStyles = new Set() for (const mod of ['entry', ...usedModules]) { @@ -293,6 +299,9 @@ async function renderInlineStyles (usedModules: Set | string[]) { } } } + for (const css of entryCSS?.css || []) { + inlinedStyles.add(``) + } return Array.from(inlinedStyles).join('') } diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index 4aa110f9124..76d914672d6 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -240,8 +240,11 @@ export const publicPathTemplate: NuxtTemplate = { ' return path.length ? joinURL(publicBase, ...path) : publicBase', '}', - 'globalThis.__buildAssetsURL = buildAssetsURL', - 'globalThis.__publicAssetsURL = publicAssetsURL' + // On server these are registered directly in packages/nuxt/src/core/runtime/nitro/renderer.ts + 'if (process.client) {', + ' globalThis.__buildAssetsURL = buildAssetsURL', + ' globalThis.__publicAssetsURL = publicAssetsURL', + '}' ].filter(Boolean).join('\n') } } diff --git a/packages/nuxt/test/auto-imports.test.ts b/packages/nuxt/test/auto-imports.test.ts index de4a5c10c48..eaa33a5fa94 100644 --- a/packages/nuxt/test/auto-imports.test.ts +++ b/packages/nuxt/test/auto-imports.test.ts @@ -4,6 +4,7 @@ import { join } from 'pathe' import { createCommonJS, findExports } from 'mlly' import * as VueFunctions from 'vue' import { createUnimport, Import } from 'unimport' +import { Plugin } from 'vite' import { TransformPlugin } from '../src/imports/transform' import { defaultPresets } from '../src/imports/presets' @@ -18,9 +19,9 @@ describe('imports:transform', () => { imports }) - const transformPlugin = TransformPlugin.raw({ ctx, options: { transform: { exclude: [/node_modules/] } } }, { framework: 'rollup' }) + const transformPlugin = TransformPlugin.raw({ ctx, options: { transform: { exclude: [/node_modules/] } } }, { framework: 'rollup' }) as Plugin const transform = async (source: string) => { - const result = await transformPlugin.transform!.call({ error: null, warn: null } as any, source, '') + const result = await (transformPlugin.transform! as Function).call({ error: null, warn: null } as any, source, '') return typeof result === 'string' ? result : result?.code } diff --git a/packages/schema/package.json b/packages/schema/package.json index 0688e59e3d7..647fcd5506e 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -1,6 +1,6 @@ { "name": "@nuxt/schema", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -18,7 +18,7 @@ "@types/semver": "^7", "@vitejs/plugin-vue": "^3.1.2", "@vueuse/head": "~1.0.0-rc.9", - "nitropack": "npm:nitropack-edge@0.6.0-27766876.4ff7082", + "nitropack": "^0.6.0", "unbuild": "latest", "vite": "~3.1.8" }, diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index c23378412b2..73b146190cf 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@nuxt/test-utils", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -13,14 +13,14 @@ "prepack": "unbuild" }, "dependencies": { - "@nuxt/kit": "3.0.0-rc.11", - "@nuxt/schema": "3.0.0-rc.11", + "@nuxt/kit": "3.0.0-rc.12", + "@nuxt/schema": "3.0.0-rc.12", "consola": "^2.15.3", "defu": "^6.1.0", "execa": "^6.1.0", "get-port-please": "^2.6.1", "jiti": "^1.16.0", - "ohmyfetch": "^0.4.19" + "ohmyfetch": "^0.4.20" }, "devDependencies": { "playwright": "^1.27.1", diff --git a/packages/vite/package.json b/packages/vite/package.json index c6a43cac406..f7df2a4b7f3 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "@nuxt/vite-builder", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -13,13 +13,13 @@ "prepack": "unbuild" }, "devDependencies": { - "@nuxt/schema": "3.0.0-rc.11", + "@nuxt/schema": "3.0.0-rc.12", "@types/cssnano": "^5", "unbuild": "latest", "vue": "3.2.41" }, "dependencies": { - "@nuxt/kit": "3.0.0-rc.11", + "@nuxt/kit": "3.0.0-rc.12", "@rollup/plugin-replace": "^5.0.0", "@vitejs/plugin-vue": "^3.1.2", "@vitejs/plugin-vue-jsx": "^2.0.1", @@ -33,7 +33,7 @@ "externality": "^0.2.2", "fs-extra": "^10.1.0", "get-port-please": "^2.6.1", - "h3": "^0.8.1", + "h3": "^0.8.4", "knitwork": "^0.1.2", "magic-string": "^0.26.7", "mlly": "^0.5.16", @@ -47,11 +47,11 @@ "rollup": "^2.79.1", "rollup-plugin-visualizer": "^5.8.3", "ufo": "^0.8.6", - "unplugin": "^0.9.6", + "unplugin": "^0.10.0", "vite": "~3.1.8", "vite-node": "^0.24.3", "vite-plugin-checker": "^0.5.1", - "vue-bundle-renderer": "^0.4.3" + "vue-bundle-renderer": "^0.4.4" }, "peerDependencies": { "vue": "^3.2.41" diff --git a/packages/vite/src/server.ts b/packages/vite/src/server.ts index fe99919aa2e..66b0b9b47db 100644 --- a/packages/vite/src/server.ts +++ b/packages/vite/src/server.ts @@ -129,13 +129,13 @@ export async function buildServer (ctx: ViteBuildContext) { } // Add entry CSS as prefetch (non-blocking) if (entry.isEntry) { - manifest[key + '-css'] = { + manifest.entryCSS = { file: '', css: entry.css } entry.css = [] entry.dynamicImports = entry.dynamicImports || [] - entry.dynamicImports.push(key + '-css') + entry.dynamicImports.push('entryCSS') } } }) diff --git a/packages/webpack/package.json b/packages/webpack/package.json index f26da4d1faa..6996dff2b16 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -1,6 +1,6 @@ { "name": "@nuxt/webpack-builder", - "version": "3.0.0-rc.11", + "version": "3.0.0-rc.12", "repository": "nuxt/framework", "license": "MIT", "type": "module", @@ -18,7 +18,7 @@ "dependencies": { "@babel/core": "^7.19.3", "@nuxt/friendly-errors-webpack-plugin": "^2.5.2", - "@nuxt/kit": "3.0.0-rc.11", + "@nuxt/kit": "3.0.0-rc.12", "autoprefixer": "^10.4.12", "css-loader": "^6.7.1", "css-minimizer-webpack-plugin": "^4.2.2", @@ -45,9 +45,9 @@ "style-resources-loader": "^1.5.0", "time-fix-plugin": "^2.0.7", "ufo": "^0.8.6", - "unplugin": "^0.9.6", + "unplugin": "^0.10.0", "url-loader": "^4.1.1", - "vue-bundle-renderer": "^0.4.3", + "vue-bundle-renderer": "^0.4.4", "vue-loader": "^17.0.0", "webpack": "^5.74.0", "webpack-bundle-analyzer": "^4.6.1", @@ -57,7 +57,7 @@ "webpackbar": "^5.0.2" }, "devDependencies": { - "@nuxt/schema": "3.0.0-rc.11", + "@nuxt/schema": "3.0.0-rc.12", "@types/lodash-es": "^4.17.6", "@types/pify": "^5.0.1", "@types/webpack-bundle-analyzer": "^4.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 399ea7d3fb1..4c567145ff3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,15 +25,15 @@ importers: '@nuxt/webpack-builder': workspace:* '@nuxtjs/eslint-config-typescript': ^11.0.0 '@types/crawler': ^1.2.2 - '@types/node': ^16.11.66 + '@types/node': ^16.11.68 '@types/rimraf': ^3 '@types/semver': ^7 - '@unocss/reset': ^0.45.29 + '@unocss/reset': ^0.45.30 case-police: ^0.5.10 changelogen: ^0.3.5 crawler: ^1.3.0 eslint: ^8.25.0 - eslint-plugin-jsdoc: ^39.3.6 + eslint-plugin-jsdoc: ^39.3.14 execa: ^6.1.0 expect-type: ^0.14.2 globby: ^13.1.2 @@ -41,7 +41,7 @@ importers: markdownlint-cli: ^0.32.2 nuxi: workspace:* nuxt: workspace:* - ohmyfetch: ^0.4.19 + ohmyfetch: ^0.4.20 pathe: ^0.3.9 rimraf: ^3.0.2 semver: ^7.3.8 @@ -61,15 +61,15 @@ importers: '@nuxt/webpack-builder': link:packages/webpack '@nuxtjs/eslint-config-typescript': 11.0.0_z4bbprzjrhnsfa24uvmcbu7f5q '@types/crawler': 1.2.2 - '@types/node': 16.11.66 + '@types/node': 16.11.68 '@types/rimraf': 3.0.2 '@types/semver': 7.3.12 - '@unocss/reset': 0.45.29 + '@unocss/reset': 0.45.30 case-police: 0.5.10 changelogen: 0.3.5 crawler: 1.3.0 eslint: 8.25.0 - eslint-plugin-jsdoc: 39.3.6_eslint@8.25.0 + eslint-plugin-jsdoc: 39.3.14_eslint@8.25.0 execa: 6.1.0 expect-type: 0.14.2 globby: 13.1.2 @@ -77,7 +77,7 @@ importers: markdownlint-cli: 0.32.2 nuxi: link:packages/nuxi nuxt: link:packages/nuxt - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 pathe: 0.3.9 rimraf: 3.0.2 semver: 7.3.8 @@ -360,7 +360,7 @@ importers: flat: ^5.0.2 fsevents: ~2.3.2 giget: ^0.1.7 - h3: ^0.8.1 + h3: ^0.8.4 jiti: ^1.16.0 listhen: ^0.3.4 mlly: ^0.5.16 @@ -391,7 +391,7 @@ importers: execa: 6.1.0 flat: 5.0.2 giget: 0.1.7 - h3: 0.8.1 + h3: 0.8.4 jiti: 1.16.0 listhen: 0.3.4 mlly: 0.5.16 @@ -423,16 +423,16 @@ importers: escape-string-regexp: ^5.0.0 fs-extra: ^10.1.0 globby: ^13.1.2 - h3: ^0.8.1 + h3: ^0.8.4 hash-sum: ^2.0.0 hookable: ^5.4.1 knitwork: ^0.1.2 magic-string: ^0.26.7 mlly: ^0.5.16 - nitropack: npm:nitropack-edge@0.6.0-27766876.4ff7082 + nitropack: ^0.6.0 nuxi: workspace:* ohash: ^0.1.5 - ohmyfetch: ^0.4.19 + ohmyfetch: ^0.4.20 pathe: ^0.3.9 perfect-debounce: ^0.1.3 scule: ^0.3.2 @@ -443,10 +443,10 @@ importers: unctx: ^2.0.2 unenv: ^0.6.2 unimport: ^0.6.8 - unplugin: ^0.9.6 + unplugin: ^0.10.0 untyped: ^0.5.0 vue: 3.2.41 - vue-bundle-renderer: ^0.4.3 + vue-bundle-renderer: ^0.4.4 vue-devtools-stub: ^0.1.0 vue-meta: next vue-router: ^4.1.5 @@ -467,16 +467,16 @@ importers: escape-string-regexp: 5.0.0 fs-extra: 10.1.0 globby: 13.1.2 - h3: 0.8.1 + h3: 0.8.4 hash-sum: 2.0.0 hookable: 5.4.1 knitwork: 0.1.2 magic-string: 0.26.7 mlly: 0.5.16 - nitropack: /nitropack-edge/0.6.0-27766876.4ff7082 + nitropack: 0.6.0 nuxi: link:../nuxi ohash: 0.1.5 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 pathe: 0.3.9 perfect-debounce: 0.1.3 scule: 0.3.2 @@ -486,10 +486,10 @@ importers: unctx: 2.0.2 unenv: 0.6.2 unimport: 0.6.8 - unplugin: 0.9.6 + unplugin: 0.10.0 untyped: 0.5.0 vue: 3.2.41 - vue-bundle-renderer: 0.4.3 + vue-bundle-renderer: 0.4.4 vue-devtools-stub: 0.1.0 vue-router: 4.1.5_vue@3.2.41 devDependencies: @@ -508,7 +508,7 @@ importers: create-require: ^1.1.1 defu: ^6.1.0 jiti: ^1.16.0 - nitropack: npm:nitropack-edge@0.6.0-27766876.4ff7082 + nitropack: ^0.6.0 pathe: ^0.3.9 pkg-types: ^0.3.5 postcss-import-resolver: ^2.0.0 @@ -537,7 +537,7 @@ importers: '@types/semver': 7.3.12 '@vitejs/plugin-vue': 3.1.2_vite@3.1.8 '@vueuse/head': 1.0.0-rc.9 - nitropack: /nitropack-edge/0.6.0-27766876.4ff7082 + nitropack: 0.6.0 unbuild: 0.9.4 vite: 3.1.8 @@ -550,7 +550,7 @@ importers: execa: ^6.1.0 get-port-please: ^2.6.1 jiti: ^1.16.0 - ohmyfetch: ^0.4.19 + ohmyfetch: ^0.4.20 playwright: ^1.27.1 unbuild: ^0.9.4 vitest: ~0.19.1 @@ -562,7 +562,7 @@ importers: execa: 6.1.0 get-port-please: 2.6.1 jiti: 1.16.0 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 devDependencies: playwright: 1.27.1 unbuild: 0.9.4 @@ -586,7 +586,7 @@ importers: externality: ^0.2.2 fs-extra: ^10.1.0 get-port-please: ^2.6.1 - h3: ^0.8.1 + h3: ^0.8.4 knitwork: ^0.1.2 magic-string: ^0.26.7 mlly: ^0.5.16 @@ -601,12 +601,12 @@ importers: rollup-plugin-visualizer: ^5.8.3 ufo: ^0.8.6 unbuild: ^0.9.4 - unplugin: ^0.9.6 + unplugin: ^0.10.0 vite: ^3.1.8 vite-node: ^0.24.3 vite-plugin-checker: ^0.5.1 vue: 3.2.41 - vue-bundle-renderer: ^0.4.3 + vue-bundle-renderer: ^0.4.4 dependencies: '@nuxt/kit': link:../kit '@rollup/plugin-replace': 5.0.0_rollup@2.79.1 @@ -622,7 +622,7 @@ importers: externality: 0.2.2 fs-extra: 10.1.0 get-port-please: 2.6.1 - h3: 0.8.1 + h3: 0.8.4 knitwork: 0.1.2 magic-string: 0.26.7 mlly: 0.5.16 @@ -636,11 +636,11 @@ importers: rollup: 2.79.1 rollup-plugin-visualizer: 5.8.3_rollup@2.79.1 ufo: 0.8.6 - unplugin: 0.9.6 + unplugin: 0.10.0 vite: 3.1.8 vite-node: 0.24.3 vite-plugin-checker: 0.5.1_vite@3.1.8 - vue-bundle-renderer: 0.4.3 + vue-bundle-renderer: 0.4.4 devDependencies: '@nuxt/schema': link:../schema '@types/cssnano': 5.1.0_postcss@8.4.18 @@ -686,10 +686,10 @@ importers: time-fix-plugin: ^2.0.7 ufo: ^0.8.6 unbuild: ^0.9.4 - unplugin: ^0.9.6 + unplugin: ^0.10.0 url-loader: ^4.1.1 vue: 3.2.41 - vue-bundle-renderer: ^0.4.3 + vue-bundle-renderer: ^0.4.4 vue-loader: ^17.0.0 webpack: ^5.74.0 webpack-bundle-analyzer: ^4.6.1 @@ -727,9 +727,9 @@ importers: style-resources-loader: 1.5.0_webpack@5.74.0 time-fix-plugin: 2.0.7_webpack@5.74.0 ufo: 0.8.6 - unplugin: 0.9.6 + unplugin: 0.10.0 url-loader: 4.1.1_u4acmn7fe6yqgbrqzialkgh5lu - vue-bundle-renderer: 0.4.3 + vue-bundle-renderer: 0.4.4 vue-loader: 17.0.0_webpack@5.74.0 webpack: 5.74.0 webpack-bundle-analyzer: 4.6.1 @@ -1068,9 +1068,9 @@ packages: dependencies: mime: 3.0.0 - /@es-joy/jsdoccomment/0.31.0: - resolution: {integrity: sha512-tc1/iuQcnaiSIUVad72PBierDFpsxdUHtEF/OrfqvM1CBAsIoMP51j52jTMb3dXriwhieTo289InzZj72jL3EQ==} - engines: {node: ^14 || ^16 || ^17 || ^18} + /@es-joy/jsdoccomment/0.33.0: + resolution: {integrity: sha512-bkxMGTlHPE4vfarXt1L1fOm81O18jTRFNgh3Fm4iPKctfWxcpJw4cpth5BhLkGZy4HFzGn/KfD/zGks/J+ZIIw==} + engines: {node: ^14 || ^16 || ^17 || ^18 || ^19} dependencies: comment-parser: 1.3.1 esquery: 1.4.0 @@ -1316,7 +1316,7 @@ packages: mri: 1.2.0 nanoid: 4.0.0 node-fetch: 3.2.10 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 parse-git-config: 3.0.0 rc9: 1.2.2 std-env: 3.3.0 @@ -1766,8 +1766,8 @@ packages: resolution: {integrity: sha512-nJOuiTlsvmClSr3+a/trTSx4DTuY/VURsWGKSf/eeavh0LRMqdsK60ti0TlwM5iHiGOK3/Ibkxsbr7i9rzGreA==} dev: true - /@types/node/16.11.66: - resolution: {integrity: sha512-+xvMrGl3eAygKcf5jm+4zA4tbfEgmKM9o6/glTmN0RFVdu2VuFXMYYtRmuv3zTGCgAYMnEZLde3B7BTp+Yxcig==} + /@types/node/16.11.68: + resolution: {integrity: sha512-JkRpuVz3xCNCWaeQ5EHLR/6woMbHZz/jZ7Kmc63AkU+1HxnoUugzSWMck7dsR4DvNYX8jp9wTi9K7WvnxOIQZQ==} dev: true /@types/node/18.7.23: @@ -2098,7 +2098,7 @@ packages: dependencies: '@iconify/utils': 2.0.0 '@unocss/core': 0.45.25 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 transitivePeerDependencies: - supports-color dev: true @@ -2134,7 +2134,7 @@ packages: resolution: {integrity: sha512-8DTYHtYfmapW2i5HVK8zpX9Npq+DGBtXpBqT4K7We3nbaxoMuOZHKwixFfzw0mXqYcr3BjjwJjmDdMi4GhIKWA==} dependencies: '@unocss/core': 0.45.25 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 pathe: 0.3.9 dev: true @@ -2154,6 +2154,10 @@ packages: resolution: {integrity: sha512-ytnKxyJdjvhjHrZ9yQUnQwiuL4hiXvjZUj88F2JkwgFJX6Y8jEz3V2xU1BPZNOv20/F6P1ngzEPRfrWHG8XG6A==} dev: true + /@unocss/reset/0.45.30: + resolution: {integrity: sha512-m6+M3E2cTPhX+2aKocRfDqQt7ebEtjJHH8sVYpX8xJoN0vOqjSNmUYc6AIkwUYljx4QbEC3thcQSbqel82RbXQ==} + dev: true + /@unocss/scope/0.45.25: resolution: {integrity: sha512-ZAQYWfgVhjlswY31f4v7wcQ9PdKLYYHPch3rACPalbPJOc7NVmIWe3gU5H2gUZfeX+SwY9V8zw89DyM8DiRHPw==} dev: true @@ -3053,6 +3057,12 @@ packages: semver: 7.3.8 dev: true + /busboy/1.6.0: + resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} + engines: {node: '>=10.16.0'} + dependencies: + streamsearch: 1.1.0 + /c12/0.2.13: resolution: {integrity: sha512-wJL0/knDbqM/3moLb+8Xd+w3JdkggkIIhiNBkxZ1mWlskKC/vajb85wM3UPg/D9nK6RbI1NgaVTg6AeXBVbknA==} dependencies: @@ -3803,7 +3813,7 @@ packages: dev: true /ee-first/1.1.1: - resolution: {integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=} + resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} /electron-to-chromium/1.4.266: resolution: {integrity: sha512-saJTYECxUSv7eSpnXw0XIEvUkP9x4s/x2mm3TVX7k4rIFS6f5TjBih1B5h437WzIhHQjid+d8ouQzPQskMervQ==} @@ -4670,13 +4680,13 @@ packages: - supports-color dev: true - /eslint-plugin-jsdoc/39.3.6_eslint@8.25.0: - resolution: {integrity: sha512-R6dZ4t83qPdMhIOGr7g2QII2pwCjYyKP+z0tPOfO1bbAbQyKC20Y2Rd6z1te86Lq3T7uM8bNo+VD9YFpE8HU/g==} - engines: {node: ^14 || ^16 || ^17 || ^18} + /eslint-plugin-jsdoc/39.3.14_eslint@8.25.0: + resolution: {integrity: sha512-kle7ot5xvzXwWzg7ElzTPM/y1IWUo0kfa5X+ZwOC/7Jw81OJaqIaNEk+2ZH+HcKkbwRUQ3RTdK9qsm4p5vbXAQ==} + engines: {node: ^14 || ^16 || ^17 || ^18 || ^19} peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - '@es-joy/jsdoccomment': 0.31.0 + '@es-joy/jsdoccomment': 0.33.0 comment-parser: 1.3.1 debug: 4.3.4 escape-string-regexp: 4.0.0 @@ -5402,8 +5412,8 @@ packages: dependencies: duplexer: 0.1.2 - /h3/0.8.1: - resolution: {integrity: sha512-HWTShxx4RKpse3f2h5KOWTEAIZLKq9SHWaVBZkOhBH+fH8uRGYY1iNO7VDwImFwARtR/Pg+bVI8feXX9NIdQRQ==} + /h3/0.8.4: + resolution: {integrity: sha512-U7ZD/Te+LBS1IpUvsZRe+E+ZiA3zQS0u43DMrZ+raiVObeYe0G5F4Kr/g6Fn2fH92Np0ROkij/wEhkAMbUsBdQ==} dependencies: cookie-es: 0.5.0 destr: 1.1.1 @@ -6443,8 +6453,8 @@ packages: /neo-async/2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - /nitropack-edge/0.6.0-27766876.4ff7082: - resolution: {integrity: sha512-tG7CPQ7qj2Z7nAXfHyXXyTxp5Q8hlEALKHQCAIrNP9dZYKrdJJRh2ntlIpsLv72oAGUGZUsNoxxzlyWoq1O1Pg==} + /nitropack/0.6.0: + resolution: {integrity: sha512-pmBOBAvrOxnTCKLOn0V6f2hRUt2g+Uthhi5JCx2/29vQKWi0ri0I6IZ+qnN8bVkkbBp4DLmmWG8vxo7ZH/irig==} engines: {node: ^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0} hasBin: true dependencies: @@ -6474,7 +6484,7 @@ packages: fs-extra: 10.1.0 globby: 13.1.2 gzip-size: 7.0.0 - h3: 0.8.1 + h3: 0.8.4 hookable: 5.4.1 http-proxy: 1.18.1 is-primitive: 3.0.1 @@ -6487,7 +6497,7 @@ packages: mri: 1.2.0 node-fetch-native: 0.1.8 ohash: 0.1.5 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 pathe: 0.3.9 perfect-debounce: 0.1.3 pkg-types: 0.3.5 @@ -6663,13 +6673,13 @@ packages: /ohash/0.1.5: resolution: {integrity: sha512-qynly1AFIpGWEAW88p6DhMNqok/Swb52/KsiU+Toi7er058Ptvno3tkfTML6wYcEgFgp2GsUziW4Nqn62ciuyw==} - /ohmyfetch/0.4.19: - resolution: {integrity: sha512-OH2xVeRPNsHkx+JFdq1ewe9EwVDfTrv6lsBHpIx8wIWXowP5FyLhhYVaXIVlPsW542rt7gmwK14FwIDWUXEO+Q==} + /ohmyfetch/0.4.20: + resolution: {integrity: sha512-+c3/l+X91owrT1reTos1R13rb2j8NGZpKi0bRWwrnxIHlr1FZ8NzghIsNBKpUvk9nsnFoNK4phw+nTnXrcALzA==} dependencies: destr: 1.1.1 - node-fetch-native: 0.1.7 + node-fetch-native: 0.1.8 ufo: 0.8.6 - undici: 5.10.0 + undici: 5.11.0 /on-finished/2.4.1: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} @@ -7819,6 +7829,10 @@ packages: /std-env/3.3.0: resolution: {integrity: sha512-cNNS+VYsXIs5gI6gJipO4qZ8YYT274JHvNnQ1/R/x8Q8mdP0qj0zoMchRXmBNPqp/0eOEhX+3g7g6Fgb7meLIQ==} + /streamsearch/1.1.0: + resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} + engines: {node: '>=10.0.0'} + /string-width/4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -8301,9 +8315,11 @@ packages: unplugin: 0.9.6 dev: false - /undici/5.10.0: - resolution: {integrity: sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==} + /undici/5.11.0: + resolution: {integrity: sha512-oWjWJHzFet0Ow4YZBkyiJwiK5vWqEYoH7BINzJAJOLedZ++JpAlCbUktW2GQ2DS2FpKmxD/JMtWUUWl1BtghGw==} engines: {node: '>=12.18'} + dependencies: + busboy: 1.6.0 /unenv/0.6.2: resolution: {integrity: sha512-IdQfYsHsGKDkiBdeOmtU4MjWvPYfMDOC63cvFqZPodAc5aVezvfD9Bwr7FL/G78cAMMCaDm5Jux3vYo+Z8c/Dg==} @@ -8394,6 +8410,15 @@ packages: - vite dev: true + /unplugin/0.10.0: + resolution: {integrity: sha512-QIoQDNxTceO8QneUMQc96qabJnPVijU9SnaWWAH60HqpkCQSFXTcDAcr8qM4Y7Nq8Q3NafyX3lG5S1g62+KD6g==} + dependencies: + acorn: 8.8.0 + chokidar: 3.5.3 + webpack-sources: 3.2.3 + webpack-virtual-modules: 0.4.5 + dev: false + /unplugin/0.9.6: resolution: {integrity: sha512-YYLtfoNiie/lxswy1GOsKXgnLJTE27la/PeCGznSItk+8METYZErO+zzV9KQ/hXhPwzIJsfJ4s0m1Rl7ZCWZ4Q==} dependencies: @@ -8408,12 +8433,12 @@ packages: anymatch: 3.1.2 chokidar: 3.5.3 destr: 1.1.1 - h3: 0.8.1 + h3: 0.8.4 ioredis: 5.2.3 listhen: 0.3.4 mkdir: 0.0.2 mri: 1.2.0 - ohmyfetch: 0.4.19 + ohmyfetch: 0.4.20 ufo: 0.8.6 ws: 8.9.0 transitivePeerDependencies: @@ -8655,8 +8680,8 @@ packages: resolution: {integrity: sha512-fmL7V1eiDBFRRnu+gfRWTzyPpNIHJTc4mWnFkwBUmO9U3KPgJAmTx7oxi2bl/Rh6HLdU7+4C9wlj0k2E4AdKFQ==} dev: false - /vue-bundle-renderer/0.4.3: - resolution: {integrity: sha512-l4mqMiMSF3wO7h4y9hrdVA97XftD457C+sbbECpZhqjzXf0MzYhdxXJc9JbMjO7fIez1M5s5wFd1YN/d1Em7sg==} + /vue-bundle-renderer/0.4.4: + resolution: {integrity: sha512-kjJWPayzup8QFynETVpoYD0gDM2nbwN//bpt86hAHpZ+FPdTJFDQqKpouSLQgb2XjkOYM1uB/yc6Zb3iCvS7Gw==} dependencies: ufo: 0.8.6 dev: false diff --git a/renovate.json b/renovate.json index f83e4b742e1..3b0e629c40d 100644 --- a/renovate.json +++ b/renovate.json @@ -4,6 +4,9 @@ ], "ignoreDeps": [ "@vueuse/head", - "vitest" + "vitest", + "nuxt", + "nuxt3", + "@nuxt/kit" ] } diff --git a/test/basic.test.ts b/test/basic.test.ts index 848989fa1d3..7d95f6712c1 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -611,7 +611,7 @@ describe.skipIf(process.env.NUXT_TEST_DEV || process.env.TEST_WITH_WEBPACK)('inl const html: string = await $fetch('/styles') expect(html.match(/]*href="[^"]*\.css">/)?.map(m => m.replace(/\.[^.]*\.css/, '.css'))).toMatchInlineSnapshot(` [ - "", + "", ] `) }) diff --git a/test/fixtures/basic/extends/node_modules/foo/server/api/foo.ts b/test/fixtures/basic/extends/node_modules/foo/server/api/foo.ts index f759e165008..4529f026397 100644 --- a/test/fixtures/basic/extends/node_modules/foo/server/api/foo.ts +++ b/test/fixtures/basic/extends/node_modules/foo/server/api/foo.ts @@ -1 +1,3 @@ -export default () => 'foo' +import { eventHandler } from 'h3' + +export default eventHandler(() => 'foo') diff --git a/test/fixtures/basic/extends/node_modules/foo/server/middleware/foo.ts b/test/fixtures/basic/extends/node_modules/foo/server/middleware/foo.ts index 0af570f235f..aedbcc3fbf4 100644 --- a/test/fixtures/basic/extends/node_modules/foo/server/middleware/foo.ts +++ b/test/fixtures/basic/extends/node_modules/foo/server/middleware/foo.ts @@ -1,4 +1,6 @@ // TODO: add back TypeScript and auto-importing once Nitro supports it -export default (event) => { +import { eventHandler } from 'h3' + +export default eventHandler((event) => { event.res.setHeader('injected-header', 'foo') -} +}) diff --git a/test/fixtures/basic/server/api/counter.ts b/test/fixtures/basic/server/api/counter.ts index 8c33e3545d9..8cdb1c14aa7 100644 --- a/test/fixtures/basic/server/api/counter.ts +++ b/test/fixtures/basic/server/api/counter.ts @@ -1,3 +1,3 @@ let counter = 0 -export default () => ({ count: counter++ }) +export default defineEventHandler(() => ({ count: counter++ })) diff --git a/test/fixtures/basic/server/api/hello.ts b/test/fixtures/basic/server/api/hello.ts index 2d81ce2188a..569613d6f79 100644 --- a/test/fixtures/basic/server/api/hello.ts +++ b/test/fixtures/basic/server/api/hello.ts @@ -1 +1 @@ -export default () => 'Hello API' +export default defineEventHandler(() => 'Hello API') diff --git a/test/fixtures/basic/server/api/hey/index.ts b/test/fixtures/basic/server/api/hey/index.ts index a7f6bd9616e..7ae4e47bf96 100644 --- a/test/fixtures/basic/server/api/hey/index.ts +++ b/test/fixtures/basic/server/api/hey/index.ts @@ -1,4 +1,4 @@ -export default () => ({ +export default defineEventHandler(() => ({ foo: 'bar', baz: 'qux' -}) +})) diff --git a/test/fixtures/basic/server/api/random.ts b/test/fixtures/basic/server/api/random.ts index 6ab0aed5199..e30a14cdba0 100644 --- a/test/fixtures/basic/server/api/random.ts +++ b/test/fixtures/basic/server/api/random.ts @@ -1,3 +1,3 @@ -export default eventHandler(() => { +export default defineEventHandler(() => { return new Array(10).fill(0).map(() => Math.round(Math.random() * 10000)) }) diff --git a/test/fixtures/basic/server/api/useAsyncData/count.ts b/test/fixtures/basic/server/api/useAsyncData/count.ts index 8c33e3545d9..8cdb1c14aa7 100644 --- a/test/fixtures/basic/server/api/useAsyncData/count.ts +++ b/test/fixtures/basic/server/api/useAsyncData/count.ts @@ -1,3 +1,3 @@ let counter = 0 -export default () => ({ count: counter++ }) +export default defineEventHandler(() => ({ count: counter++ }))