Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 1a8f974

Browse files
authored
Merge branch 'main' into fix/watch-more-things
2 parents cf5e505 + 1449e70 commit 1a8f974

File tree

38 files changed

+253
-452
lines changed

38 files changed

+253
-452
lines changed

docs/content/2.guide/3.directory-structure/6.layouts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ head.title: Layouts directory
88

99
Nuxt provides a customizable layouts framework you can use throughout your application, ideal for extracting common UI or code patterns into reusable layout components.
1010

11-
Layouts are placed in the `layouts/` directory and will be automatically loaded via asynchronous import when used. Layouts are used by setting a `layout` property as part of your page metadata (if you are using the `~/pages` integration), or by using the `<NuxtLayout>` component.
11+
Layouts are placed in the `layouts/` directory and will be automatically loaded via asynchronous import when used. Layouts are used by setting a `layout` property as part of your page metadata (if you are using the `~/pages` integration), or by using the `<NuxtLayout>` component. (**Note**: The layout name is normalized to kebab-case, so `someLayout` becomes `some-layout`.)
1212

1313
If you only have a single layout in your application, we recommend using [app.vue](/guide/directory-structure/app) instead.
1414

docs/content/2.guide/3.directory-structure/7.middleware.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Route middleware run within the Vue part of your Nuxt app. Despite the similar n
1515
There are three kinds of route middleware:
1616

1717
1. Anonymous (or inline) route middleware, which are defined directly in the pages where they are used.
18-
2. Named route middleware, which are placed in the `middleware/` directory and will be automatically loaded via asynchronous import when used on a page.
18+
2. Named route middleware, which are placed in the `middleware/` directory and will be automatically loaded via asynchronous import when used on a page. (**Note**: The route middleware name is normalized to kebab-case, so `someMiddleware` becomes `some-middleware`.)
1919
3. Global route middleware, which are placed in the `middleware/` directory (with a `.global` suffix) and will be automatically run on every route change.
2020

2121
The first two kinds of route middleware can be [defined in `definePageMeta`](/guide/directory-structure/pages).

docs/content/3.api/1.composables/use-cookie.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,16 @@ You can use `useCookie` and `setCookie` from [`h3`](https://github.com/unjs/h3)
143143
**Example:**
144144

145145
```js
146-
import { useCookie, setCookie } from 'h3'
147-
148-
export default (req, res) => {
146+
export default defineEventHandler(event => {
149147
// Read counter cookie
150-
let counter = useCookie(req, 'counter') || 0
148+
let counter = useCookie(event, 'counter') || 0
151149

152150
// Increase counter cookie by 1
153-
setCookie(res, 'counter', ++counter)
151+
setCookie(event, 'counter', ++counter)
154152

155153
// Send JSON response
156154
return { counter }
157-
}
155+
})
158156
```
159157

160158
:LinkExample{link="/examples/composables/use-cookie"}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"nuxi": "link:./packages/nuxi",
4343
"nuxt": "link:./packages/nuxt",
4444
"nuxt3": "link:./packages/nuxt",
45+
"vite": "^2.9.11",
4546
"unbuild": "^0.7.4"
4647
},
4748
"devDependencies": {
@@ -63,7 +64,7 @@
6364
"rimraf": "^3.0.2",
6465
"typescript": "^4.7.3",
6566
"unbuild": "^0.7.4",
66-
"vitest": "^0.14.1",
67+
"vitest": "^0.14.2",
6768
"vue-tsc": "^0.37.3"
6869
},
6970
"packageManager": "[email protected]",

packages/kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"hash-sum": "^2.0.0",
2222
"ignore": "^5.2.0",
2323
"jiti": "^1.13.0",
24-
"knitwork": "^0.1.1",
24+
"knitwork": "^0.1.2",
2525
"lodash.template": "^4.5.0",
2626
"mlly": "^0.5.2",
2727
"pathe": "^0.3.0",

packages/kit/src/internal/template.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { promises as fsp } from 'node:fs'
22
import lodashTemplate from 'lodash.template'
3-
import hash from 'hash-sum'
4-
import { camelCase } from 'scule'
5-
import { basename, extname } from 'pathe'
6-
import { genDynamicImport, genImport } from 'knitwork'
3+
import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork'
74

85
import type { NuxtTemplate } from '@nuxt/schema'
96

@@ -26,18 +23,16 @@ export async function compileTemplate (template: NuxtTemplate, ctx: any) {
2623

2724
const serialize = (data: any) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, r => JSON.parse(r).replace(/^{(.*)}$/, '$1'))
2825

29-
const importName = (src: string) => `${camelCase(basename(src, extname(src))).replace(/[^a-zA-Z?\d\s:]/g, '')}_${hash(src)}`
30-
3126
const importSources = (sources: string | string[], { lazy = false } = {}) => {
3227
if (!Array.isArray(sources)) {
3328
sources = [sources]
3429
}
3530
return sources.map((src) => {
3631
if (lazy) {
37-
return `const ${importName(src)} = ${genDynamicImport(src, { comment: `webpackChunkName: ${JSON.stringify(src)}` })}`
32+
return `const ${genSafeVariableName(src)} = ${genDynamicImport(src, { comment: `webpackChunkName: ${JSON.stringify(src)}` })}`
3833
}
39-
return genImport(src, importName(src))
34+
return genImport(src, genSafeVariableName(src))
4035
}).join('\n')
4136
}
4237

43-
export const templateUtils = { serialize, importName, importSources }
38+
export const templateUtils = { serialize, importName: genSafeVariableName, importSources }

packages/kit/src/resolve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,5 @@ async function existsSensitive (path: string) {
148148

149149
export async function resolveFiles (path: string, pattern: string | string[]) {
150150
const files = await globby(pattern, { cwd: path, followSymbolicLinks: true })
151-
return files.filter(p => !isIgnored(p)).map(p => resolve(path, p))
151+
return files.map(p => resolve(path, p)).filter(p => !isIgnored(p))
152152
}

packages/nuxt/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
"escape-string-regexp": "^5.0.0",
4747
"fs-extra": "^10.1.0",
4848
"globby": "^13.1.1",
49-
"h3": "^0.7.8",
49+
"h3": "^0.7.9",
5050
"hash-sum": "^2.0.0",
5151
"hookable": "^5.1.1",
52-
"knitwork": "^0.1.1",
52+
"knitwork": "^0.1.2",
5353
"magic-string": "^0.26.2",
5454
"mlly": "^0.5.2",
5555
"nitropack": "^0.4.4",
@@ -66,7 +66,7 @@
6666
"unplugin": "^0.7.0",
6767
"untyped": "^0.4.4",
6868
"vue": "^3.2.37",
69-
"vue-bundle-renderer": "^0.3.8",
69+
"vue-bundle-renderer": "^0.3.9",
7070
"vue-router": "^4.0.16"
7171
},
7272
"devDependencies": {

packages/nuxt/src/auto-imports/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default defineNuxtModule<Partial<AutoImportsOptions>>({
1616
imports: [],
1717
dirs: [],
1818
transform: {
19+
include: [],
1920
exclude: undefined
2021
}
2122
},

packages/nuxt/src/auto-imports/transform.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ export const TransformPlugin = createUnplugin(({ ctx, options, sourcemap }: {ctx
1515
const exclude = options.transform?.exclude || [/[\\/]node_modules[\\/]/]
1616
const include = options.transform?.include || []
1717

18-
// Exclude node_modules by default
19-
if (exclude.some(pattern => id.match(pattern))) {
20-
return false
21-
}
22-
2318
// Custom includes
2419
if (include.some(pattern => id.match(pattern))) {
2520
return true
2621
}
2722

23+
// Exclude node_modules by default
24+
if (exclude.some(pattern => id.match(pattern))) {
25+
return false
26+
}
27+
2828
// vue files
2929
if (
3030
pathname.endsWith('.vue') &&

0 commit comments

Comments
 (0)