Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/1.getting-started/4.assets.md
#	docs/1.getting-started/5.transitions.md
#	docs/1.getting-started/6.data-fetching.md
#	docs/2.guide/1.concepts/8.typescript.md
#	docs/2.guide/2.directory-structure/1.server.md
#	docs/3.api/2.composables/on-prehydrate.md
#	docs/3.api/2.composables/use-fetch.md
  • Loading branch information
Ivan Bochkarev committed Dec 1, 2024
2 parents bca4534 + 1c418d0 commit cb20888
Show file tree
Hide file tree
Showing 52 changed files with 1,902 additions and 1,565 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: pnpm build

- name: Run benchmarks
uses: CodSpeedHQ/action@fa1dcde8d58f2ab0b407a6a24d6cc5a8c1444a8c # v3.1.0
uses: CodSpeedHQ/action@513a19673a831f139e8717bf45ead67e47f00044 # v3.2.0
with:
run: pnpm vitest bench
token: ${{ secrets.CODSPEED_TOKEN }}
56 changes: 0 additions & 56 deletions docs/1.getting-started/4.assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,59 +46,3 @@ Nuxt использует [Vite](https://vitejs.dev/guide/assets.html) (по у
::note
Nuxt не будет предоставлять файлы в директории [`assets/`](/docs/guide/directory-structure/assets) по статическому URL наподобие `/assets/my-file.png`. Если вам нужен статический URL, используйте директорию [`public/`](#директория-public).
::

### Глобальные импорты стилей

Чтобы глобально добавлять выражения в стили компонентов Nuxt, вы можете использовать опцию [`Vite`](/docs/api/nuxt-config#vite) в файле [`nuxt.config`](/docs/api/nuxt-config).

#### Пример

В этом примере, есть файл [sass partial](https://sass-lang.com/documentation/at-rules/use#partials), содержащий переменные с цветами, которые будут использованы [страницами](/docs/guide/directory-structure/pages) и [компонентами](/docs/guide/directory-structure/components) Nuxt.

::code-group

```scss [assets/_colors.scss]
$primary: #49240F;
$secondary: #E4A79D;
```

```sass [assets/_colors.sass]
$primary: #49240F
$secondary: #E4A79D
```

::

В файле `nuxt.config`

::code-group

```ts twoslash [SCSS]
export default defineNuxtConfig({
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: '@use "~/assets/_colors.scss" as *;'
}
}
}
}
})
```

```ts twoslash [SASS]
export default defineNuxtConfig({
vite: {
css: {
preprocessorOptions: {
sass: {
additionalData: '@use "~/assets/_colors.sass" as *\n'
}
}
}
}
})
```

::
2 changes: 1 addition & 1 deletion docs/2.guide/1.concepts/8.typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ description: Nuxt является полностью типизированны
npx nuxi typecheck
```

Чтобы включить проверку типов во время сборки, вы также можете использовать опцию [`typescript.typeCheck`](/docs/api/nuxt-config#typecheck) в своем файле `nuxt.config`:
Чтобы включить проверку типов во время сборки или разработки, вы также можете использовать опцию [`typescript.typeCheck`](/docs/api/nuxt-config#typecheck) в своем файле `nuxt.config`:

```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({
Expand Down
20 changes: 20 additions & 0 deletions docs/2.guide/2.directory-structure/1.server.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ export default defineEventHandler((event) => {
Заголовки, которые **не предназначены** для передачи, **не будут включены** в запрос. К таким заголовкам относятся, например: `transfer-encoding`, `connection`, `keep-alive`, `upgrade`, `expect`, `host`, `accept`
::

### Awaiting Promises After Response

When handling server requests, you might need to perform asynchronous tasks that shouldn't block the response to the client (for example, caching and logging). You can use `event.waitUntil` to await a promise in the background without delaying the response.

The `event.waitUntil` method accepts a promise that will be awaited before the handler terminates, ensuring the task is completed even if the server would otherwise terminate the handler right after the response is sent. This integrates with runtime providers to leverage their native capabilities for handling asynchronous operations after the response is sent.

```ts [server/api/background-task.ts]
const timeConsumingBackgroundTask = async () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
};

export default eventHandler((event) => {
// schedule a background task without blocking the response
event.waitUntil(timeConsumingBackgroundTask())

// immediately send the response to the client
return 'done'
});
```

## Расширенное использование

### Конфиг Nitro
Expand Down
29 changes: 29 additions & 0 deletions docs/2.guide/3.going-further/1.experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,35 @@ bun.lockb
Сохраняется не более 10 tarball'ов кэша.
::

## extraPageMetaExtractionKeys

The `definePageMeta()` macro is a useful way to collect build-time meta about pages. Nuxt itself provides a set list of supported keys which is used to power some of the internal features such as redirects, page aliases and custom paths.

This option allows passing additional keys to extract from the page metadata when using `scanPageMeta`.

```vue
<script lang="ts" setup>
definePageMeta({
foo: 'bar'
})
</script>
```

```ts
export default defineNuxtConfig({
experimental: {
extraPageMetaExtractionKeys: ['foo'],
},
hooks: {
'pages:resolved' (ctx) {
// ✅ foo is available
},
},
})
```

This allows modules to access additional metadata from the page metadata in the build context. If you are using this within a module, it's recommended also to [augment the `NuxtPage` types with your keys](/docs/guide/directory-structure/pages#typing-custom-metadata).

## normalizeComponentNames

Убедитесь, что автогенерируемые имена компонентов Vue совпадают с полным именем компонента,
Expand Down
43 changes: 38 additions & 5 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignoreBinaries": [
"prepack"
],
"ignoreWorkspaces": ["test/fixtures/basic"],
"ignoreDependencies": [
"bing",
"uno.css"
],
"workspaces": {
".": {
"entry": [
"scripts/*",
"test/*",
"test/fixtures/*"
"scripts/*"
]
},
"test/fixtures/*": {
"entry": [
"nuxt.config.{js,ts}",
"modules/*.ts",
"types.ts"
]
},
"packages/*": {
"entry": [
"src/index.ts",
"src/runtime/**/*.ts"
"src/runtime/**/*.{js,ts,mjs}"
]
},
"packages/nuxt": {
"entry": [
"src/app/**/*.ts",
"src/app/*.ts",
"src/*/runtime/**/*.ts",
"src/*/runtime/**/*.{ts,js}",
"src/core/templates.ts",
"src/index.ts"
]
},
"packages/rspack": {
"entry": [
"../webpack/src/index.ts",
"../webpack/src/runtime/**/*.{js,ts,mjs}",
"builder.mjs"
]
},
"packages/ui-templates": {
"entry": [
"lib/*.ts",
"styles.ts"
]
},
"packages/webpack": {
"entry": [
"src/index.ts",
"src/runtime/**/*.{js,ts,mjs}",
"builder.mjs"
]
}
}
}
5 changes: 4 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ export default defineNuxtConfig({
},
],
pages: process.env.DOCS_TYPECHECK === 'true',
typescript: { shim: process.env.DOCS_TYPECHECK === 'true' },
typescript: {
shim: process.env.DOCS_TYPECHECK === 'true',
hoist: ['@vitejs/plugin-vue', 'vue-router'],
},
})
52 changes: 24 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint:fix": "eslint . --cache --fix",
"lint:docs": "markdownlint ./docs && case-police 'docs/**/*.md' *.md",
"lint:docs:fix": "markdownlint ./docs --fix && case-police 'docs/**/*.md' *.md --fix",
"lint:knip": "pnpx knip",
"lint:knip": "knip",
"play": "nuxi dev playground",
"play:build": "nuxi build playground",
"play:generate": "nuxi generate playground",
Expand All @@ -37,70 +37,67 @@
"@nuxt/kit": "workspace:*",
"@nuxt/rspack-builder": "workspace:*",
"@nuxt/schema": "workspace:*",
"@nuxt/ui-templates": "workspace:*",
"@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "workspace:*",
"@types/node": "22.9.1",
"@unhead/dom": "1.11.11",
"@unhead/shared": "1.11.11",
"@unhead/vue": "1.11.11",
"@unhead/schema": "1.11.11",
"@unhead/ssr": "1.11.11",
"@types/node": "22.10.1",
"@unhead/dom": "1.11.13",
"@unhead/schema": "1.11.13",
"@unhead/shared": "1.11.13",
"@unhead/ssr": "1.11.13",
"@unhead/vue": "1.11.13",
"@vue/compiler-core": "3.5.13",
"@vue/compiler-dom": "3.5.13",
"@vue/shared": "3.5.13",
"c12": "2.0.1",
"h3": "npm:[email protected]",
"jiti": "2.4.0",
"magic-string": "^0.30.13",
"magic-string": "^0.30.14",
"nitro": "npm:[email protected]",
"nuxt": "workspace:*",
"ohash": "1.1.4",
"postcss": "8.4.49",
"rollup": "4.27.3",
"rollup": "4.27.4",
"send": ">=1.1.0",
"typescript": "5.6.3",
"ufo": "1.5.4",
"unbuild": "3.0.0-rc.11",
"unhead": "1.11.11",
"vite": "5.4.11",
"unhead": "1.11.13",
"vite": "6.0.1",
"vue": "3.5.13"
},
"devDependencies": {
"@eslint/js": "9.15.0",
"@nuxt/eslint-config": "0.7.1",
"@nuxt/eslint-config": "0.7.2",
"@nuxt/kit": "workspace:*",
"@nuxt/rspack-builder": "workspace:*",
"@nuxt/test-utils": "3.14.4",
"@nuxt/webpack-builder": "workspace:*",
"@testing-library/vue": "8.1.0",
"@types/eslint__js": "8.42.3",
"@types/node": "22.9.1",
"@types/node": "22.10.1",
"@types/semver": "7.5.8",
"@unhead/schema": "1.11.11",
"@unhead/vue": "1.11.11",
"@vitejs/plugin-vue": "5.2.0",
"@vitest/coverage-v8": "2.1.5",
"@unhead/schema": "1.11.13",
"@unhead/vue": "1.11.13",
"@vitest/coverage-v8": "2.1.6",
"@vue/test-utils": "2.4.6",
"autoprefixer": "10.4.20",
"case-police": "0.7.0",
"case-police": "0.7.2",
"changelogen": "0.5.7",
"consola": "3.2.3",
"cssnano": "7.0.6",
"destr": "2.0.3",
"devalue": "5.1.1",
"eslint": "9.15.0",
"eslint-plugin-no-only-tests": "3.3.0",
"eslint-plugin-perfectionist": "4.0.3",
"eslint-plugin-perfectionist": "4.1.2",
"eslint-typegen": "0.3.2",
"h3": "npm:[email protected]",
"happy-dom": "15.11.6",
"happy-dom": "15.11.7",
"jiti": "2.4.0",
"markdownlint-cli": "0.42.0",
"knip": "5.38.2",
"markdownlint-cli": "0.43.0",
"nitro": "npm:[email protected]",
"nuxi": "3.15.0",
"nuxi": "3.16.0",
"nuxt": "workspace:*",
"nuxt-content-twoslash": "0.1.1",
"nuxt-content-twoslash": "0.1.2",
"ofetch": "1.4.1",
"pathe": "1.1.2",
"playwright-core": "1.49.0",
Expand All @@ -112,10 +109,9 @@
"tinyglobby": "0.2.10",
"typescript": "5.6.3",
"ufo": "1.5.4",
"vitest": "2.1.5",
"vitest": "2.1.6",
"vitest-environment-nuxt": "1.0.1",
"vue": "3.5.13",
"vue-router": "4.4.5",
"vue-tsc": "2.1.10"
},
"packageManager": "[email protected]",
Expand Down
11 changes: 5 additions & 6 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,27 @@
"destr": "^2.0.3",
"errx": "^0.1.0",
"globby": "^14.0.2",
"hash-sum": "^2.0.0",
"ignore": "^6.0.2",
"jiti": "^2.4.0",
"klona": "^2.0.6",
"mlly": "^1.7.3",
"ohash": "^1.1.4",
"pathe": "^1.1.2",
"pkg-types": "^1.2.1",
"scule": "^1.3.0",
"semver": "^7.6.3",
"ufo": "^1.5.4",
"unctx": "^2.3.1",
"unimport": "^3.13.2",
"unimport": "^3.13.4",
"untyped": "^1.5.1"
},
"devDependencies": {
"@rspack/core": "1.1.3",
"@types/hash-sum": "1.0.2",
"@rspack/core": "1.1.4",
"@types/semver": "7.5.8",
"nitro": "npm:[email protected]",
"unbuild": "3.0.0-rc.11",
"vite": "5.4.11",
"vitest": "2.1.5",
"vite": "6.0.1",
"vitest": "2.1.6",
"webpack": "5.96.1"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type { AddPluginOptions } from './plugin'
export { createResolver, findPath, resolveAlias, resolveFiles, resolveNuxtModule, resolvePath } from './resolve'
export type { ResolvePathOptions, Resolver } from './resolve'
export { addServerHandler, addDevServerHandler, addServerPlugin, addPrerenderRoutes, useNitro, addServerImports, addServerImportsDir, addServerScanDir } from './nitro'
export { addTemplate, addTypeTemplate, normalizeTemplate, updateTemplates, writeTypes } from './template'
export { addTemplate, addServerTemplate, addTypeTemplate, normalizeTemplate, updateTemplates, writeTypes } from './template'
export { logger, useLogger } from './logger'

// Internal Utils
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/module/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _defineNuxtModule<

const optionsDefaults: TOptionsDefaults =
module.defaults instanceof Function
? module.defaults(nuxt)
? await module.defaults(nuxt)
: module.defaults ?? <TOptionsDefaults> {}

let options = defu(inlineOptions, nuxtConfigOptions, optionsDefaults)
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync, promises as fsp } from 'node:fs'
import { basename, isAbsolute, join, parse, relative, resolve } from 'pathe'
import hash from 'hash-sum'
import { hash } from 'ohash'
import type { Nuxt, NuxtServerTemplate, NuxtTemplate, NuxtTypeTemplate, ResolvedNuxtTemplate, TSReference } from '@nuxt/schema'
import { withTrailingSlash } from 'ufo'
import { defu } from 'defu'
Expand Down
Loading

0 comments on commit cb20888

Please sign in to comment.