Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): remove experimental reactivityTransform (vue 3.4) #24477

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/1.getting-started/3.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
danielroe marked this conversation as resolved.
Show resolved Hide resolved

:read-more{to="/docs/api/configuration/nuxt-config#vue-1"}
14 changes: 0 additions & 14 deletions docs/2.guide/3.going-further/1.experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Externalizes `vue`, `@vue/*` and `vue-router` when building.
Expand Down
4 changes: 0 additions & 4 deletions packages/kit/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ export async function writeTypes (nuxt: Nuxt) {
.filter(f => typeof f === 'string')
.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[] = []

await nuxt.callHook('prepare:types', { references, declarations, tsConfig })
Expand Down
10 changes: 0 additions & 10 deletions packages/schema/src/config/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ export default defineUntypedSchema({
$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
// https://github.com/unjs/nitro/issues/1118
/**
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
virtual(nuxt.vfs)
],
vue: {
reactivityTransform: nuxt.options.experimental.reactivityTransform,
template: {
transformAssetUrls: {
video: ['src', 'poster'],
Expand Down
5 changes: 1 addition & 4 deletions packages/webpack/src/presets/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ export function vue (ctx: WebpackConfigContext) {
ctx.config.module!.rules!.push({
test: /\.vue$/i,
loader: 'vue-loader',
options: {
reactivityTransform: ctx.nuxt.options.experimental.reactivityTransform,
...ctx.userConfig.loaders.vue
}
options: ctx.userConfig.loaders.vue
})

if (ctx.isClient) {
Expand Down
12 changes: 2 additions & 10 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
it('should work', async () => {
const html = await $fetch('/tree-shake')
Expand Down Expand Up @@ -2020,10 +2012,10 @@ describe.skipIf(isWindows)('useAsyncData', () => {

describe.runIf(isDev())('component testing', () => {
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')

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')
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!-- eslint-disable vue/multi-word-component-names -->
<script setup lang="ts">
const props = defineProps<{
multiplier: number
}>()
const count = $ref(12)
const doubled = $computed(() => count * props.multiplier)
const count = ref(12)
const doubled = computed(() => count.value * props.multiplier)
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ defineProps({

<template>
<div>
<SugarCounter :multiplier="multiplier" />
<Counter :multiplier="multiplier" />
</div>
</template>
2 changes: 1 addition & 1 deletion test/fixtures/basic/components/Tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default defineComponent({
return <div>
TSX component
<custom-component>custom</custom-component>
<SugarCounter multiplier={2} />
<Counter multiplier={2} />
</div>
}
})
1 change: 0 additions & 1 deletion test/fixtures/basic/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export default defineNuxtConfig({
restoreState: true,
inlineSSRStyles: id => !!id && !id.includes('assets.vue'),
componentIslands: true,
reactivityTransform: true,
treeshakeClientOnly: true,
asyncContext: process.env.TEST_CONTEXT === 'async',
appManifest: process.env.TEST_MANIFEST !== 'manifest-off',
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/basic/pages/client-fallback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- don't render if one child fails in ssr -->
<NuxtClientFallback>
<BreakInSetup />
<SugarCounter
<Counter
id="sugar-counter"
:multiplier="multiplier"
/>
Expand All @@ -28,7 +28,7 @@
<div>
<BreakInSetup />
</div>
<SugarCounter :multiplier="multiplier" />
<Counter :multiplier="multiplier" />
</NuxtClientFallback>
<!-- should be rendered -->
<NuxtClientFallback fallback-tag="p">
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/basic/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<NuxtLink to="/no-scripts">
to no script
</NuxtLink>
<NestedSugarCounter :multiplier="2" />
<NestedCounter :multiplier="2" />
<CustomComponent />
<component :is="`global${'-'.toString()}sync`" />
<Spin>Test</Spin>
Expand Down Expand Up @@ -100,8 +100,8 @@ const config = useRuntimeConfig()

const someValue = useState('val', () => 1)

const NestedSugarCounter = resolveComponent('NestedSugarCounter')
if (!NestedSugarCounter) {
const NestedCounter = resolveComponent('NestedCounter')
if (!NestedCounter) {
throw new Error('Component not found')
}

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/basic/pages/islands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const count = ref(0)
>
<div>Interactive testing slot</div>
<div id="first-sugar-counter">
<SugarCounter :multiplier="testCount" />
<Counter :multiplier="testCount" />
</div>
<template #test="scoped">
<div id="test-slot">
Expand Down Expand Up @@ -101,7 +101,7 @@ const count = ref(0)
:props="{ count }"
>
<div>Interactive testing slot post SSR</div>
<SugarCounter :multiplier="testCount" />
<Counter :multiplier="testCount" />
</NuxtIsland>
</div>
</div>
Expand Down