mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-20 15:41:11 +00:00
Merge branch 'main' into docs/kit
This commit is contained in:
commit
6ec5389158
2
.github/workflows/autofix-docs.yml
vendored
2
.github/workflows/autofix-docs.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
2
.github/workflows/autofix.yml
vendored
2
.github/workflows/autofix.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
2
.github/workflows/changelogensets.yml
vendored
2
.github/workflows/changelogensets.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
@ -77,7 +77,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
@ -116,7 +116,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
@ -144,7 +144,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
@ -180,7 +180,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: "pnpm"
|
||||
@ -254,7 +254,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
@ -293,7 +293,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
2
.github/workflows/docs-e2e.yml
vendored
2
.github/workflows/docs-e2e.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
cache: "pnpm"
|
||||
|
||||
|
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
2
.github/workflows/nuxt2-edge.yml
vendored
2
.github/workflows/nuxt2-edge.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
fetch-depth: 0 # All history
|
||||
- name: fetch tags
|
||||
run: git fetch --depth=1 origin "+refs/tags/*:refs/tags/*"
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 16
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
2
.github/workflows/release-pr.yml
vendored
2
.github/workflows/release-pr.yml
vendored
@ -35,7 +35,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # v3.8.0
|
||||
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
@ -59,6 +59,10 @@ npx nuxi@latest init <project-name>
|
||||
pnpm dlx nuxi@latest init <project-name>
|
||||
```
|
||||
|
||||
```bash [bun]
|
||||
bunx nuxi@latest init <project-name>
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
Open your project folder in Visual Studio Code:
|
||||
|
@ -74,12 +74,12 @@ export const useLocale = () => useState<string>('locale', () => useDefaultLocale
|
||||
|
||||
export const useDefaultLocale = (fallback = 'en-US') => {
|
||||
const locale = ref(fallback)
|
||||
if (import.meta.server) {
|
||||
if (process.server) {
|
||||
const reqLocale = useRequestHeaders()['accept-language']?.split(',')[0]
|
||||
if (reqLocale) {
|
||||
locale.value = reqLocale
|
||||
}
|
||||
} else if (import.meta.client) {
|
||||
} else if (process.client) {
|
||||
const navLang = navigator.language
|
||||
if (navLang) {
|
||||
locale.value = navLang
|
||||
|
@ -34,7 +34,20 @@ By default, only the `~/components` directory is scanned. If you want to add oth
|
||||
```ts [nuxt.config.ts]
|
||||
export default defineNuxtConfig({
|
||||
components: [
|
||||
// ~/calendar-module/components/event/Update.vue => <EventUpdate />
|
||||
{ path: '~/calendar-module/components' },
|
||||
|
||||
// ~/user-module/components/account/UserDeleteDialog.vue => <UserDeleteDialog />
|
||||
{ path: '~/user-module/components', pathPrefix: false },
|
||||
|
||||
// ~/components/special-components/Btn.vue => <SpecialBtn />
|
||||
{ path: '~/components/special-components', prefix: 'Special' },
|
||||
|
||||
// It's important that this comes last if you have overrides you wish to apply
|
||||
// to sub-directories of `~/components`.
|
||||
//
|
||||
// ~/components/Btn.vue => <Btn />
|
||||
// ~/components/base/Btn.vue => <BaseBtn />
|
||||
'~/components'
|
||||
]
|
||||
})
|
||||
@ -299,6 +312,8 @@ Now you can register server-only components with the `.server` suffix and use th
|
||||
</template>
|
||||
```
|
||||
|
||||
Server-only components use `<NuxtIsland>` under the hood, meaning that `lazy` prop and `#fallback` slot are both passed down to `<NuxtIsland>`.
|
||||
|
||||
::alert{type=info}
|
||||
Slots can be interactive and are wrapped within a `<div>` with `display: contents;`
|
||||
::
|
||||
|
@ -38,6 +38,10 @@ Install the `@nuxt/content` module in your project:
|
||||
pnpm add -D @nuxt/content
|
||||
```
|
||||
|
||||
```bash [bun]
|
||||
bun add -D @nuxt/content
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
Then, add `@nuxt/content` to the `modules` section of `nuxt.config.ts`:
|
||||
|
@ -125,12 +125,12 @@ However, if you want to avoid this behaviour you can do so:
|
||||
```js
|
||||
export default defineNuxtRouteMiddleware(to => {
|
||||
// skip middleware on server
|
||||
if (import.meta.server) return
|
||||
if (process.server) return
|
||||
// skip middleware on client side entirely
|
||||
if (import.meta.client) return
|
||||
if (process.client) return
|
||||
// or only skip middleware on initial client load
|
||||
const nuxtApp = useNuxtApp()
|
||||
if (import.meta.client && nuxtApp.isHydrating && nuxtApp.payload.serverRendered) return
|
||||
if (process.client && nuxtApp.isHydrating && nuxtApp.payload.serverRendered) return
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -62,7 +62,7 @@ export default defineNuxtPlugin({
|
||||
```
|
||||
|
||||
::alert
|
||||
If you are using an object-syntax plugin, the properties may be statically analyzed in future to produce a more optimized build. So you should not define them at runtime. For example, setting `enforce: import.meta.server ? 'pre' : 'post'` would defeat any future optimization Nuxt is able to do for your plugins.
|
||||
If you are using an object-syntax plugin, the properties may be statically analyzed in future to produce a more optimized build. So you should not define them at runtime. For example, setting `enforce: process.server ? 'pre' : 'post'` would defeat any future optimization Nuxt is able to do for your plugins.
|
||||
::
|
||||
|
||||
## Plugin Registration Order
|
||||
|
@ -94,7 +94,7 @@ The entire runtime config is available on the server-side, but it is read-only t
|
||||
<script setup lang="ts">
|
||||
const config = useRuntimeConfig()
|
||||
console.log('Runtime config:', config)
|
||||
if (import.meta.server) {
|
||||
if (process.server) {
|
||||
console.log('API secret:', config.apiSecret)
|
||||
}
|
||||
</script>
|
||||
|
@ -138,6 +138,6 @@ import { createMemoryHistory } from 'vue-router'
|
||||
|
||||
// https://router.vuejs.org/api/interfaces/routeroptions.html
|
||||
export default <RouterConfig> {
|
||||
history: base => import.meta.client ? createMemoryHistory(base) : null /* default */
|
||||
history: base => process.client ? createMemoryHistory(base) : null /* default */
|
||||
}
|
||||
```
|
||||
|
@ -45,7 +45,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
})
|
||||
nuxtApp.hook('vue:error', (..._args) => {
|
||||
console.log('vue:error')
|
||||
// if (import.meta.client) {
|
||||
// if (process.client) {
|
||||
// console.log(..._args)
|
||||
// }
|
||||
})
|
||||
@ -105,7 +105,7 @@ When accessing the same `payload.data` from [ssrcontext](#ssrcontext), you can a
|
||||
export const useColor = () => useState<string>('color', () => 'pink')
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
if (import.meta.server) {
|
||||
if (process.server) {
|
||||
const color = useColor()
|
||||
}
|
||||
})
|
||||
@ -137,7 +137,7 @@ export default defineComponent({
|
||||
setup (_props, { slots, emit }) {
|
||||
const nuxtApp = useNuxtApp()
|
||||
onErrorCaptured((err) => {
|
||||
if (import.meta.client && !nuxtApp.isHydrating) {
|
||||
if (process.client && !nuxtApp.isHydrating) {
|
||||
// ...
|
||||
}
|
||||
})
|
||||
|
12
package.json
12
package.json
@ -45,7 +45,7 @@
|
||||
"@nuxt/webpack-builder": "workspace:*",
|
||||
"@nuxtjs/eslint-config-typescript": "12.0.0",
|
||||
"@types/fs-extra": "11.0.1",
|
||||
"@types/node": "18.17.5",
|
||||
"@types/node": "18.17.6",
|
||||
"@types/semver": "7.5.0",
|
||||
"case-police": "0.6.1",
|
||||
"chalk": "5.3.0",
|
||||
@ -54,15 +54,15 @@
|
||||
"consola": "3.2.3",
|
||||
"devalue": "4.3.2",
|
||||
"eslint": "8.47.0",
|
||||
"eslint-plugin-import": "2.28.0",
|
||||
"eslint-plugin-import": "2.28.1",
|
||||
"eslint-plugin-jsdoc": "41.1.2",
|
||||
"eslint-plugin-no-only-tests": "3.1.0",
|
||||
"execa": "7.2.0",
|
||||
"fs-extra": "11.1.1",
|
||||
"globby": "13.2.2",
|
||||
"h3": "1.8.0",
|
||||
"happy-dom": "10.10.0",
|
||||
"jiti": "1.19.1",
|
||||
"happy-dom": "10.10.4",
|
||||
"jiti": "1.19.3",
|
||||
"markdownlint-cli": "^0.33.0",
|
||||
"nitropack": "2.5.2",
|
||||
"nuxi": "workspace:*",
|
||||
@ -70,10 +70,10 @@
|
||||
"nuxt-vitest": "0.10.2",
|
||||
"ofetch": "1.1.1",
|
||||
"pathe": "1.1.1",
|
||||
"playwright-core": "1.37.0",
|
||||
"playwright-core": "1.37.1",
|
||||
"rimraf": "5.0.1",
|
||||
"semver": "7.5.4",
|
||||
"std-env": "3.3.3",
|
||||
"std-env": "3.4.0",
|
||||
"typescript": "5.1.6",
|
||||
"ufo": "1.2.0",
|
||||
"vite": "4.4.9",
|
||||
|
@ -27,7 +27,7 @@
|
||||
"globby": "^13.2.2",
|
||||
"hash-sum": "^2.0.0",
|
||||
"ignore": "^5.2.4",
|
||||
"jiti": "^1.19.1",
|
||||
"jiti": "^1.19.3",
|
||||
"knitwork": "^1.0.0",
|
||||
"mlly": "^1.4.0",
|
||||
"pathe": "^1.1.1",
|
||||
|
@ -37,7 +37,7 @@
|
||||
"flat": "5.0.2",
|
||||
"giget": "1.1.2",
|
||||
"h3": "1.8.0",
|
||||
"jiti": "1.19.1",
|
||||
"jiti": "1.19.3",
|
||||
"listhen": "1.3.0",
|
||||
"mlly": "1.4.0",
|
||||
"mri": "1.2.0",
|
||||
|
@ -6,7 +6,8 @@ import { findup } from './fs'
|
||||
export const packageManagerLocks = {
|
||||
yarn: 'yarn.lock',
|
||||
npm: 'package-lock.json',
|
||||
pnpm: 'pnpm-lock.yaml'
|
||||
pnpm: 'pnpm-lock.yaml',
|
||||
bun: 'bun.lockb'
|
||||
}
|
||||
|
||||
type PackageManager = keyof typeof packageManagerLocks
|
||||
|
@ -58,9 +58,9 @@
|
||||
"@nuxt/telemetry": "^2.4.1",
|
||||
"@nuxt/ui-templates": "^1.3.1",
|
||||
"@nuxt/vite-builder": "workspace:../vite",
|
||||
"@unhead/dom": "^1.3.4",
|
||||
"@unhead/ssr": "^1.3.4",
|
||||
"@unhead/vue": "^1.3.4",
|
||||
"@unhead/dom": "^1.3.5",
|
||||
"@unhead/ssr": "^1.3.5",
|
||||
"@unhead/vue": "^1.3.5",
|
||||
"@vue/shared": "^3.3.4",
|
||||
"acorn": "8.10.0",
|
||||
"c12": "^1.4.2",
|
||||
@ -76,7 +76,7 @@
|
||||
"globby": "^13.2.2",
|
||||
"h3": "^1.8.0",
|
||||
"hookable": "^5.5.3",
|
||||
"jiti": "^1.19.1",
|
||||
"jiti": "^1.19.3",
|
||||
"klona": "^2.0.6",
|
||||
"knitwork": "^1.0.0",
|
||||
"magic-string": "^0.30.2",
|
||||
@ -91,7 +91,7 @@
|
||||
"pkg-types": "^1.0.3",
|
||||
"prompts": "^2.4.2",
|
||||
"scule": "^1.0.0",
|
||||
"std-env": "^3.3.3",
|
||||
"std-env": "^3.4.0",
|
||||
"strip-literal": "^1.3.0",
|
||||
"ufo": "^1.2.0",
|
||||
"ultrahtml": "^1.3.0",
|
||||
@ -112,7 +112,7 @@
|
||||
"@types/estree": "1.0.1",
|
||||
"@types/fs-extra": "11.0.1",
|
||||
"@types/prompts": "2.4.4",
|
||||
"@vitejs/plugin-vue": "4.2.3",
|
||||
"@vitejs/plugin-vue": "4.3.1",
|
||||
"unbuild": "latest",
|
||||
"vite": "4.4.9",
|
||||
"vitest": "0.33.0"
|
||||
|
@ -30,11 +30,11 @@
|
||||
"@types/file-loader": "5.0.1",
|
||||
"@types/pug": "2.0.6",
|
||||
"@types/sass-loader": "8.0.5",
|
||||
"@unhead/schema": "1.3.4",
|
||||
"@vitejs/plugin-vue": "4.2.3",
|
||||
"@vitejs/plugin-vue-jsx": "3.0.1",
|
||||
"@unhead/schema": "1.3.5",
|
||||
"@vitejs/plugin-vue": "4.3.1",
|
||||
"@vitejs/plugin-vue-jsx": "3.0.2",
|
||||
"@vue/compiler-core": "3.3.4",
|
||||
"esbuild-loader": "4.0.0",
|
||||
"esbuild-loader": "4.0.1",
|
||||
"h3": "1.8.0",
|
||||
"ignore": "5.2.4",
|
||||
"nitropack": "2.5.2",
|
||||
@ -55,7 +55,7 @@
|
||||
"pathe": "^1.1.1",
|
||||
"pkg-types": "^1.0.3",
|
||||
"postcss-import-resolver": "^2.0.0",
|
||||
"std-env": "^3.3.3",
|
||||
"std-env": "^3.4.0",
|
||||
"ufo": "^1.2.0",
|
||||
"unimport": "^3.1.3",
|
||||
"untyped": "^1.4.0"
|
||||
|
@ -34,7 +34,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/globals": "29.6.2",
|
||||
"playwright-core": "1.37.0",
|
||||
"playwright-core": "1.37.1",
|
||||
"unbuild": "latest",
|
||||
"vitest": "0.33.0"
|
||||
},
|
||||
|
@ -28,8 +28,8 @@
|
||||
"dependencies": {
|
||||
"@nuxt/kit": "workspace:../kit",
|
||||
"@rollup/plugin-replace": "^5.0.2",
|
||||
"@vitejs/plugin-vue": "^4.2.3",
|
||||
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
||||
"@vitejs/plugin-vue": "^4.3.1",
|
||||
"@vitejs/plugin-vue-jsx": "^3.0.2",
|
||||
"autoprefixer": "^10.4.15",
|
||||
"clear": "^0.1.0",
|
||||
"consola": "^3.2.3",
|
||||
@ -53,13 +53,13 @@
|
||||
"postcss-import": "^15.1.0",
|
||||
"postcss-url": "^10.1.3",
|
||||
"rollup-plugin-visualizer": "^5.9.2",
|
||||
"std-env": "^3.3.3",
|
||||
"std-env": "^3.4.0",
|
||||
"strip-literal": "^1.3.0",
|
||||
"ufo": "^1.2.0",
|
||||
"unplugin": "^1.4.0",
|
||||
"vite": "^4.4.9",
|
||||
"vite-node": "^0.33.0",
|
||||
"vite-plugin-checker": "^0.6.1",
|
||||
"vite-plugin-checker": "^0.6.2",
|
||||
"vue-bundle-renderer": "^2.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -141,14 +141,26 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
* track scopes with unique keys. for example
|
||||
* ```js
|
||||
* // root scope, marked as ''
|
||||
* function a () { // '0'
|
||||
* function b () {} // '0-0'
|
||||
* function c () {} // '0-1'
|
||||
* }
|
||||
* function d () {} // '1'
|
||||
* // ''
|
||||
* ```
|
||||
* */
|
||||
class ScopeTracker {
|
||||
// the top of the stack is not a part of current key, it is used for next level
|
||||
scopeIndexStack: number[]
|
||||
curScopeKey: string
|
||||
|
||||
constructor () {
|
||||
// top level
|
||||
this.scopeIndexStack = [0]
|
||||
this.curScopeKey = '0'
|
||||
this.curScopeKey = ''
|
||||
}
|
||||
|
||||
getKey () {
|
||||
@ -173,8 +185,7 @@ class ScopedVarsCollector {
|
||||
|
||||
constructor () {
|
||||
this.all = new Map()
|
||||
// top level
|
||||
this.curScopeKey = '0'
|
||||
this.curScopeKey = ''
|
||||
}
|
||||
|
||||
refresh (scopeKey: string) {
|
||||
@ -192,7 +203,7 @@ class ScopedVarsCollector {
|
||||
|
||||
hasVar (scopeKey: string, name: string) {
|
||||
const indices = scopeKey.split('-').map(Number)
|
||||
for (let i = indices.length; i > 0; i--) {
|
||||
for (let i = indices.length; i >= 0; i--) {
|
||||
if (this.all.get(indices.slice(0, i).join('-'))?.has(name)) {
|
||||
return true
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
"css-minimizer-webpack-plugin": "^5.0.1",
|
||||
"cssnano": "^6.0.1",
|
||||
"defu": "^6.1.2",
|
||||
"esbuild-loader": "^4.0.0",
|
||||
"esbuild-loader": "^4.0.1",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"estree-walker": "^3.0.3",
|
||||
"file-loader": "^6.2.0",
|
||||
@ -47,7 +47,7 @@
|
||||
"postcss-loader": "^7.3.3",
|
||||
"postcss-url": "^10.1.3",
|
||||
"pug-plain-loader": "^1.1.0",
|
||||
"std-env": "^3.3.3",
|
||||
"std-env": "^3.4.0",
|
||||
"time-fix-plugin": "^2.0.7",
|
||||
"ufo": "^1.2.0",
|
||||
"unplugin": "^1.4.0",
|
||||
|
772
pnpm-lock.yaml
772
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -35,7 +35,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
||||
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"64.6k"')
|
||||
|
||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2352k"')
|
||||
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2348k"')
|
||||
|
||||
const packages = modules.files
|
||||
.filter(m => m.endsWith('package.json'))
|
||||
|
2
test/fixtures/basic-types/package.json
vendored
2
test/fixtures/basic-types/package.json
vendored
@ -10,7 +10,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"ofetch": "latest",
|
||||
"vitest": "latest",
|
||||
"vitest": "0.33.0",
|
||||
"vue-router": "latest",
|
||||
"vue": "latest"
|
||||
}
|
||||
|
5
test/fixtures/basic/other-composables-folder/local.ts
vendored
Normal file
5
test/fixtures/basic/other-composables-folder/local.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
function useAsyncData (s?: any) { return s }
|
||||
|
||||
export const ShouldNotBeKeyed = (() => {
|
||||
return useAsyncData()
|
||||
})()
|
@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ShouldNotBeKeyed } from '~/other-composables-folder/local'
|
||||
|
||||
function localScopedComposables () {
|
||||
const _assert = (key?: string) => key ?? 'was not keyed'
|
||||
|
||||
@ -39,11 +41,15 @@ function localScopedComposables () {
|
||||
})()]
|
||||
}
|
||||
|
||||
function fromNonComponentFile () {
|
||||
return [_assert(ShouldNotBeKeyed)]
|
||||
}
|
||||
|
||||
function useCustomKeyedComposable (arg?: string) {
|
||||
return _assert(arg)
|
||||
}
|
||||
|
||||
return [...basic(), ...hoisting(), ...complex(), ...deeperScope(), useCustomKeyedComposable()]
|
||||
return [...basic(), ...hoisting(), ...complex(), ...deeperScope(), ...fromNonComponentFile(), useCustomKeyedComposable()]
|
||||
}
|
||||
const skippedLocalScopedComposables = localScopedComposables().every(res => res === 'was not keyed')
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user