mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
Compare commits
9 Commits
e93bce7c92
...
954207b035
Author | SHA1 | Date | |
---|---|---|---|
|
954207b035 | ||
|
edc299a043 | ||
|
ad3ab4d310 | ||
|
9bf8465806 | ||
|
83a6a12e1b | ||
|
417a64cdaa | ||
|
a61a14ad92 | ||
|
be07940021 | ||
|
be9e77186f |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -248,7 +248,7 @@ jobs:
|
|||||||
TEST_PAYLOAD: ${{ matrix.payload }}
|
TEST_PAYLOAD: ${{ matrix.payload }}
|
||||||
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }}
|
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }}
|
||||||
|
|
||||||
- uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2
|
- uses: codecov/codecov-action@985343d70564a82044c1b7fcb84c2fa05405c1a2 # v5.0.4
|
||||||
if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on'
|
if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on'
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
@ -21,8 +21,8 @@ Or follow the steps below to set up a new Nuxt project on your computer.
|
|||||||
<!-- markdownlint-disable-next-line MD001 -->
|
<!-- markdownlint-disable-next-line MD001 -->
|
||||||
#### Prerequisites
|
#### Prerequisites
|
||||||
|
|
||||||
- **Node.js** - [`v18.0.0`](https://nodejs.org/en) or newer
|
- **Node.js** - [`18.x`](https://nodejs.org/en) or newer (but we recommend the [active LTS release](https://github.com/nodejs/release#release-schedule))
|
||||||
- **Text editor** - We recommend [Visual Studio Code](https://code.visualstudio.com/) with the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously known as Volar)
|
- **Text editor** - There is no IDE requirement, but we recommend [Visual Studio Code](https://code.visualstudio.com/) with the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously known as Volar) or [WebStorm](https://www.jetbrains.com/webstorm/), which, along with [other JetBrains IDEs](https://www.jetbrains.com/ides/), offers great Nuxt support right out-of-the-box.
|
||||||
- **Terminal** - In order to run Nuxt commands
|
- **Terminal** - In order to run Nuxt commands
|
||||||
|
|
||||||
::note
|
::note
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
"devalue": "5.1.1",
|
"devalue": "5.1.1",
|
||||||
"eslint": "9.15.0",
|
"eslint": "9.15.0",
|
||||||
"eslint-plugin-no-only-tests": "3.3.0",
|
"eslint-plugin-no-only-tests": "3.3.0",
|
||||||
"eslint-plugin-perfectionist": "4.0.2",
|
"eslint-plugin-perfectionist": "4.0.3",
|
||||||
"eslint-typegen": "0.3.2",
|
"eslint-typegen": "0.3.2",
|
||||||
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
||||||
"happy-dom": "15.11.6",
|
"happy-dom": "15.11.6",
|
||||||
@ -118,7 +118,7 @@
|
|||||||
"vue-router": "4.4.5",
|
"vue-router": "4.4.5",
|
||||||
"vue-tsc": "2.1.10"
|
"vue-tsc": "2.1.10"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.13.2",
|
"packageManager": "pnpm@9.14.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^16.10.0 || >=18.0.0"
|
"node": "^16.10.0 || >=18.0.0"
|
||||||
},
|
},
|
||||||
|
@ -114,8 +114,8 @@ importers:
|
|||||||
specifier: 3.3.0
|
specifier: 3.3.0
|
||||||
version: 3.3.0
|
version: 3.3.0
|
||||||
eslint-plugin-perfectionist:
|
eslint-plugin-perfectionist:
|
||||||
specifier: 4.0.2
|
specifier: 4.0.3
|
||||||
version: 4.0.2(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
version: 4.0.3(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
||||||
eslint-typegen:
|
eslint-typegen:
|
||||||
specifier: 0.3.2
|
specifier: 0.3.2
|
||||||
version: 0.3.2(eslint@9.15.0(jiti@2.4.0))
|
version: 0.3.2(eslint@9.15.0(jiti@2.4.0))
|
||||||
@ -4373,8 +4373,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==}
|
resolution: {integrity: sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==}
|
||||||
engines: {node: '>=5.0.0'}
|
engines: {node: '>=5.0.0'}
|
||||||
|
|
||||||
eslint-plugin-perfectionist@4.0.2:
|
eslint-plugin-perfectionist@4.0.3:
|
||||||
resolution: {integrity: sha512-zWdgyg2SdHqhp/P9d9vKwo5qD9is28xMAGzBslHqkZz5mVIikjyz1qvuJ4yS7Wrsf4KlbGorORefb4Kbe7Puzg==}
|
resolution: {integrity: sha512-CyafnreF6boy4lf1XaF72U8NbkwrfjU/mOf1y6doaDMS9zGXhUU1DSk+ZPf/rVwCf1PL1m+rhHqFs+IcB8kDmA==}
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: '>=8.0.0'
|
eslint: '>=8.0.0'
|
||||||
@ -11519,7 +11519,7 @@ snapshots:
|
|||||||
|
|
||||||
eslint-plugin-no-only-tests@3.3.0: {}
|
eslint-plugin-no-only-tests@3.3.0: {}
|
||||||
|
|
||||||
eslint-plugin-perfectionist@4.0.2(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3):
|
eslint-plugin-perfectionist@4.0.3(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.15.0
|
'@typescript-eslint/types': 8.15.0
|
||||||
'@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
'@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
||||||
|
@ -2619,6 +2619,70 @@ describe.skipIf(isWindows)('useAsyncData', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('useAsyncData regression with immediate:false', () => {
|
||||||
|
it('shared data, pending', async () => {
|
||||||
|
const page = await createPage('/useAsyncData/shared')
|
||||||
|
await page.waitForLoadState('networkidle')
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => window.useNuxtApp?.()._route.fullPath === '/useAsyncData/shared'
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__data').innerText()).toContain('default data')
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__pending').innerText()).toContain('true')
|
||||||
|
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__data').innerText()).toContain(
|
||||||
|
'default data'
|
||||||
|
)
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__pending').innerText()).toContain(
|
||||||
|
'true'
|
||||||
|
)
|
||||||
|
|
||||||
|
await page.click('#pageWithSharedAsyncData__execute')
|
||||||
|
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__data').innerText()).toContain('some data')
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__pending').innerText()).toContain('false')
|
||||||
|
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__data').innerText()).toContain(
|
||||||
|
'some data'
|
||||||
|
)
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__pending').innerText()).toContain(
|
||||||
|
'false'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('watch', async () => {
|
||||||
|
const page = await createPage('/useAsyncData/shared')
|
||||||
|
await page.waitForLoadState('networkidle')
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => window.useNuxtApp?.()._route.fullPath === '/useAsyncData/shared'
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__data').innerText()).toContain('default data')
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__pending').innerText()).toContain('true')
|
||||||
|
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__data').innerText()).toContain(
|
||||||
|
'default data'
|
||||||
|
)
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__pending').innerText()).toContain(
|
||||||
|
'true'
|
||||||
|
)
|
||||||
|
|
||||||
|
await page.click('#pageWithSharedAsyncData__changeQuery')
|
||||||
|
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__data').innerText()).toContain('some data')
|
||||||
|
expect(await page.locator('#pageWithSharedAsyncData__pending').innerText()).toContain('false')
|
||||||
|
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__data').innerText()).toContain(
|
||||||
|
'some data'
|
||||||
|
)
|
||||||
|
expect(await page.locator('#componentWithSharedUseAsyncData__pending').innerText()).toContain(
|
||||||
|
'false'
|
||||||
|
)
|
||||||
|
|
||||||
|
await page.close()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe.runIf(isDev())('component testing', () => {
|
describe.runIf(isDev())('component testing', () => {
|
||||||
it('should work', async () => {
|
it('should work', async () => {
|
||||||
const comp1 = await $fetchComponent('components/Counter.vue', { multiplier: 2 })
|
const comp1 = await $fetchComponent('components/Counter.vue', { multiplier: 2 })
|
||||||
|
15
test/fixtures/basic/components/ComponentWithSharedUseAsyncData.vue
vendored
Normal file
15
test/fixtures/basic/components/ComponentWithSharedUseAsyncData.vue
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useSharedAsyncData } from '../composables/asyncDataTests'
|
||||||
|
const { data, pending } = await useSharedAsyncData()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div id="componentWithSharedUseAsyncData__data">
|
||||||
|
{{ data }}
|
||||||
|
</div>
|
||||||
|
<div id="componentWithSharedUseAsyncData__pending">
|
||||||
|
{{ pending }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -5,3 +5,23 @@ export const useSleep = () => useAsyncData('sleep', async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const useCounter = () => useFetch('/api/useAsyncData/count')
|
export const useCounter = () => useFetch('/api/useAsyncData/count')
|
||||||
|
|
||||||
|
export const useSharedAsyncData = async () => {
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const { data, execute, pending } = await useAsyncData(
|
||||||
|
'sharedAsyncData',
|
||||||
|
() => Promise.resolve('some data'),
|
||||||
|
{
|
||||||
|
default: () => 'default data',
|
||||||
|
immediate: false,
|
||||||
|
watch: [() => route.query]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
execute,
|
||||||
|
pending
|
||||||
|
}
|
||||||
|
}
|
||||||
|
43
test/fixtures/basic/pages/useAsyncData/shared.vue
vendored
Normal file
43
test/fixtures/basic/pages/useAsyncData/shared.vue
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useSharedAsyncData } from '../../composables/asyncDataTests'
|
||||||
|
import ComponentWithSharedUseAsyncData from '../../components/ComponentWithSharedUseAsyncData.vue'
|
||||||
|
|
||||||
|
const { data, pending, execute } = await useSharedAsyncData()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const page = ref(1)
|
||||||
|
const changeQuery = () => {
|
||||||
|
page.value += 1
|
||||||
|
router.push({
|
||||||
|
query: {
|
||||||
|
page: page.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
id="pageWithSharedAsyncData__execute"
|
||||||
|
@click="() => execute()"
|
||||||
|
>
|
||||||
|
execute
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
id="pageWithSharedAsyncData__changeQuery"
|
||||||
|
@click="changeQuery"
|
||||||
|
>
|
||||||
|
changeQuery
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pageWithSharedAsyncData__data">
|
||||||
|
{{ data }}
|
||||||
|
</div>
|
||||||
|
<div id="pageWithSharedAsyncData__pending">
|
||||||
|
{{ pending }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ComponentWithSharedUseAsyncData />
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue
Block a user