mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): remove experimental reactivityTransform
(vue 3.4) (#24477)
This commit is contained in:
parent
e3f349f612
commit
0eb9caf0c2
@ -210,4 +210,8 @@ export default defineNuxtConfig({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### experimental `reactivityTransform` migration from Vue 3.4 and Nuxt 3.9
|
||||||
|
|
||||||
|
Since Nuxt 3.9 and Vue 3.4, `reactivityTransform` has been moved from Vue to Vue Macros which has a [Nuxt integration](https://vue-macros.dev/guide/nuxt-integration.html).
|
||||||
|
|
||||||
:read-more{to="/docs/api/configuration/nuxt-config#vue-1"}
|
:read-more{to="/docs/api/configuration/nuxt-config#vue-1"}
|
||||||
|
@ -39,20 +39,6 @@ export defineNuxtConfig({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## reactivityTransform
|
|
||||||
|
|
||||||
Enables Vue's reactivity transform. Note that this feature has been marked as deprecated in Vue 3.3 and is planned to be removed from core in Vue 3.4.
|
|
||||||
|
|
||||||
```ts [nuxt.config.ts]
|
|
||||||
export defineNuxtConfig({
|
|
||||||
experimental: {
|
|
||||||
reactivityTransform: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
:read-more{to="/docs/getting-started/configuration#enabling-experimental-vue-features"}
|
|
||||||
|
|
||||||
## externalVue
|
## externalVue
|
||||||
|
|
||||||
Externalizes `vue`, `@vue/*` and `vue-router` when building.
|
Externalizes `vue`, `@vue/*` and `vue-router` when building.
|
||||||
|
@ -218,10 +218,6 @@ export async function writeTypes (nuxt: Nuxt) {
|
|||||||
.filter(f => typeof f === 'string')
|
.filter(f => typeof f === 'string')
|
||||||
.map(async id => ({ types: (await readPackageJSON(id, { url: nodeModulePaths }).catch(() => null))?.name || id })))
|
.map(async id => ({ types: (await readPackageJSON(id, { url: nodeModulePaths }).catch(() => null))?.name || id })))
|
||||||
|
|
||||||
if (nuxt.options.experimental?.reactivityTransform) {
|
|
||||||
references.push({ types: 'vue/macros-global' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const declarations: string[] = []
|
const declarations: string[] = []
|
||||||
|
|
||||||
await nuxt.callHook('prepare:types', { references, declarations, tsConfig })
|
await nuxt.callHook('prepare:types', { references, declarations, tsConfig })
|
||||||
|
@ -9,16 +9,6 @@ export default defineUntypedSchema({
|
|||||||
$resolve: val => val ?? false
|
$resolve: val => val ?? false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable Vue's reactivity transform
|
|
||||||
* @see [Vue Reactivity Transform Docs](https://vuejs.org/guide/extras/reactivity-transform.html)
|
|
||||||
*
|
|
||||||
* Warning: Reactivity transform feature has been marked as deprecated in Vue 3.3 and is planned to be
|
|
||||||
* removed from core in Vue 3.4.
|
|
||||||
* @see [Vue RFC#369](https://github.com/vuejs/rfcs/discussions/369#discussioncomment-5059028)
|
|
||||||
*/
|
|
||||||
reactivityTransform: false,
|
|
||||||
|
|
||||||
// TODO: Remove when nitro has support for mocking traced dependencies
|
// TODO: Remove when nitro has support for mocking traced dependencies
|
||||||
// https://github.com/unjs/nitro/issues/1118
|
// https://github.com/unjs/nitro/issues/1118
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,6 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
|||||||
virtual(nuxt.vfs)
|
virtual(nuxt.vfs)
|
||||||
],
|
],
|
||||||
vue: {
|
vue: {
|
||||||
reactivityTransform: nuxt.options.experimental.reactivityTransform,
|
|
||||||
template: {
|
template: {
|
||||||
transformAssetUrls: {
|
transformAssetUrls: {
|
||||||
video: ['src', 'poster'],
|
video: ['src', 'poster'],
|
||||||
|
@ -12,10 +12,7 @@ export function vue (ctx: WebpackConfigContext) {
|
|||||||
ctx.config.module!.rules!.push({
|
ctx.config.module!.rules!.push({
|
||||||
test: /\.vue$/i,
|
test: /\.vue$/i,
|
||||||
loader: 'vue-loader',
|
loader: 'vue-loader',
|
||||||
options: {
|
options: ctx.userConfig.loaders.vue
|
||||||
reactivityTransform: ctx.nuxt.options.experimental.reactivityTransform,
|
|
||||||
...ctx.userConfig.loaders.vue
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (ctx.isClient) {
|
if (ctx.isClient) {
|
||||||
|
@ -963,14 +963,6 @@ describe('layouts', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('reactivity transform', () => {
|
|
||||||
it('should works', async () => {
|
|
||||||
const html = await $fetch('/')
|
|
||||||
|
|
||||||
expect(html).toContain('Sugar Counter 12 x 2 = 24')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('composable tree shaking', () => {
|
describe('composable tree shaking', () => {
|
||||||
it('should work', async () => {
|
it('should work', async () => {
|
||||||
const html = await $fetch('/tree-shake')
|
const html = await $fetch('/tree-shake')
|
||||||
@ -2020,10 +2012,10 @@ describe.skipIf(isWindows)('useAsyncData', () => {
|
|||||||
|
|
||||||
describe.runIf(isDev())('component testing', () => {
|
describe.runIf(isDev())('component testing', () => {
|
||||||
it('should work', async () => {
|
it('should work', async () => {
|
||||||
const comp1 = await $fetchComponent('components/SugarCounter.vue', { multiplier: 2 })
|
const comp1 = await $fetchComponent('components/Counter.vue', { multiplier: 2 })
|
||||||
expect(comp1).toContain('12 x 2 = 24')
|
expect(comp1).toContain('12 x 2 = 24')
|
||||||
|
|
||||||
const comp2 = await $fetchComponent('components/SugarCounter.vue', { multiplier: 4 })
|
const comp2 = await $fetchComponent('components/Counter.vue', { multiplier: 4 })
|
||||||
expect(comp2).toContain('12 x 4 = 48')
|
expect(comp2).toContain('12 x 4 = 48')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
<!-- eslint-disable vue/multi-word-component-names -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
multiplier: number
|
multiplier: number
|
||||||
}>()
|
}>()
|
||||||
const count = $ref(12)
|
const count = ref(12)
|
||||||
const doubled = $computed(() => count * props.multiplier)
|
const doubled = computed(() => count.value * props.multiplier)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
@ -9,6 +9,6 @@ defineProps({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<SugarCounter :multiplier="multiplier" />
|
<Counter :multiplier="multiplier" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
2
test/fixtures/basic/components/Tsx.tsx
vendored
2
test/fixtures/basic/components/Tsx.tsx
vendored
@ -3,7 +3,7 @@ export default defineComponent({
|
|||||||
return <div>
|
return <div>
|
||||||
TSX component
|
TSX component
|
||||||
<custom-component>custom</custom-component>
|
<custom-component>custom</custom-component>
|
||||||
<SugarCounter multiplier={2} />
|
<Counter multiplier={2} />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
1
test/fixtures/basic/nuxt.config.ts
vendored
1
test/fixtures/basic/nuxt.config.ts
vendored
@ -198,7 +198,6 @@ export default defineNuxtConfig({
|
|||||||
restoreState: true,
|
restoreState: true,
|
||||||
inlineSSRStyles: id => !!id && !id.includes('assets.vue'),
|
inlineSSRStyles: id => !!id && !id.includes('assets.vue'),
|
||||||
componentIslands: true,
|
componentIslands: true,
|
||||||
reactivityTransform: true,
|
|
||||||
treeshakeClientOnly: true,
|
treeshakeClientOnly: true,
|
||||||
asyncContext: process.env.TEST_CONTEXT === 'async',
|
asyncContext: process.env.TEST_CONTEXT === 'async',
|
||||||
appManifest: process.env.TEST_MANIFEST !== 'manifest-off',
|
appManifest: process.env.TEST_MANIFEST !== 'manifest-off',
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<!-- don't render if one child fails in ssr -->
|
<!-- don't render if one child fails in ssr -->
|
||||||
<NuxtClientFallback>
|
<NuxtClientFallback>
|
||||||
<BreakInSetup />
|
<BreakInSetup />
|
||||||
<SugarCounter
|
<Counter
|
||||||
id="sugar-counter"
|
id="sugar-counter"
|
||||||
:multiplier="multiplier"
|
:multiplier="multiplier"
|
||||||
/>
|
/>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<BreakInSetup />
|
<BreakInSetup />
|
||||||
</div>
|
</div>
|
||||||
<SugarCounter :multiplier="multiplier" />
|
<Counter :multiplier="multiplier" />
|
||||||
</NuxtClientFallback>
|
</NuxtClientFallback>
|
||||||
<!-- should be rendered -->
|
<!-- should be rendered -->
|
||||||
<NuxtClientFallback fallback-tag="p">
|
<NuxtClientFallback fallback-tag="p">
|
||||||
|
6
test/fixtures/basic/pages/index.vue
vendored
6
test/fixtures/basic/pages/index.vue
vendored
@ -68,7 +68,7 @@
|
|||||||
<NuxtLink to="/no-scripts">
|
<NuxtLink to="/no-scripts">
|
||||||
to no script
|
to no script
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NestedSugarCounter :multiplier="2" />
|
<NestedCounter :multiplier="2" />
|
||||||
<CustomComponent />
|
<CustomComponent />
|
||||||
<component :is="`global${'-'.toString()}sync`" />
|
<component :is="`global${'-'.toString()}sync`" />
|
||||||
<Spin>Test</Spin>
|
<Spin>Test</Spin>
|
||||||
@ -100,8 +100,8 @@ const config = useRuntimeConfig()
|
|||||||
|
|
||||||
const someValue = useState('val', () => 1)
|
const someValue = useState('val', () => 1)
|
||||||
|
|
||||||
const NestedSugarCounter = resolveComponent('NestedSugarCounter')
|
const NestedCounter = resolveComponent('NestedCounter')
|
||||||
if (!NestedSugarCounter) {
|
if (!NestedCounter) {
|
||||||
throw new Error('Component not found')
|
throw new Error('Component not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
test/fixtures/basic/pages/islands.vue
vendored
4
test/fixtures/basic/pages/islands.vue
vendored
@ -65,7 +65,7 @@ const count = ref(0)
|
|||||||
>
|
>
|
||||||
<div>Interactive testing slot</div>
|
<div>Interactive testing slot</div>
|
||||||
<div id="first-sugar-counter">
|
<div id="first-sugar-counter">
|
||||||
<SugarCounter :multiplier="testCount" />
|
<Counter :multiplier="testCount" />
|
||||||
</div>
|
</div>
|
||||||
<template #test="scoped">
|
<template #test="scoped">
|
||||||
<div id="test-slot">
|
<div id="test-slot">
|
||||||
@ -101,7 +101,7 @@ const count = ref(0)
|
|||||||
:props="{ count }"
|
:props="{ count }"
|
||||||
>
|
>
|
||||||
<div>Interactive testing slot post SSR</div>
|
<div>Interactive testing slot post SSR</div>
|
||||||
<SugarCounter :multiplier="testCount" />
|
<Counter :multiplier="testCount" />
|
||||||
</NuxtIsland>
|
</NuxtIsland>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user