Skip to content

Commit

Permalink
feat!: drop reactivity transform support
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Reactivity Transform is no longer supported as part of
this plugin, in coordination with Vue 3.4. Use VueMacros if you wish to
continue using this feature.
  • Loading branch information
yyx990803 committed Nov 25, 2023
1 parent 2ac1045 commit 85b2f5b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 45 deletions.
21 changes: 0 additions & 21 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
SFCTemplateCompileOptions,
} from 'vue/compiler-sfc'
import type * as _compiler from 'vue/compiler-sfc'
import type { ExistingRawSourceMap } from 'rollup'
/* eslint-enable import/no-duplicates */
import { computed, shallowRef } from 'vue'
import { version } from '../package.json'
Expand Down Expand Up @@ -124,13 +123,6 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
? () => options.value.customElement as boolean
: createFilter(options.value.customElement),
)
const refTransformFilter = computed(() =>
options.value.reactivityTransform === false
? () => false
: options.value.reactivityTransform === true
? createFilter(/\.(j|t)sx?$/, /node_modules/)
: createFilter(options.value.reactivityTransform),
)

return {
name: 'vite:vue',
Expand Down Expand Up @@ -255,19 +247,6 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
}

if (!filter.value(filename) && !query.vue) {
if (
!query.vue &&
refTransformFilter.value(filename) &&
options.value.compiler.shouldTransformRef(code)
) {
const result = options.value.compiler.transformRef(code, {
filename,
sourceMap: true,
})
return result as Omit<typeof result, 'map'> & {
map: ExistingRawSourceMap | null
}
}
return
}

Expand Down
2 changes: 0 additions & 2 deletions playground/vue/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<Suspense>
<AsyncComponent />
</Suspense>
<ReactivityTransform :foo="time" />
<SetupImportTemplate />
<WorkerTest />
<Url />
Expand All @@ -50,7 +49,6 @@ import Slotted from './Slotted.vue'
import ScanDep from './ScanDep.vue'
import TsImport from './TsImport.vue'
import AsyncComponent from './AsyncComponent.vue'
import ReactivityTransform from './ReactivityTransform.vue'
import SetupImportTemplate from './setup-import-template/SetupImportTemplate.vue'
import WorkerTest from './worker.vue'
import { ref } from 'vue'
Expand Down
12 changes: 0 additions & 12 deletions playground/vue/ReactivityTransform.vue

This file was deleted.

8 changes: 0 additions & 8 deletions playground/vue/__tests__/vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,6 @@ describe('async component', () => {
})
})

describe('ref transform', () => {
test('should work', async () => {
expect(await page.textContent('.ref-transform')).toMatch('0')
await page.click('.ref-transform')
expect(await page.textContent('.ref-transform')).toMatch('1')
})
})

describe('custom element', () => {
test('should work', async () => {
await page.click('.custom-element')
Expand Down
5 changes: 3 additions & 2 deletions playground/vue/setup-import-template/SetupImportTemplate.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template src="./template.html"></template>
<script setup>
let count = $ref(0)
const inc = () => count++
import { ref } from 'vue'
const count = ref(0)
const inc = () => count.value++
</script>

0 comments on commit 85b2f5b

Please sign in to comment.