diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 4296d0f39..70135b103 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -52,9 +52,7 @@ module.exports = {
},
// Packages targeting Node
{
- files: [
- 'packages/{compiler-sfc,compiler-ssr,server-renderer,reactivity-transform}/**'
- ],
+ files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
rules: {
'no-restricted-globals': ['error', ...DOMGlobals],
'no-restricted-syntax': 'off'
diff --git a/package.json b/package.json
index 7f0a46bc1..59a9f322e 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
"serve": "serve",
"open": "open http://localhost:3000/packages/template-explorer/local.html",
"build-sfc-playground": "run-s build-all-cjs build-runtime-esm build-ssr-esm build-sfc-playground-self",
- "build-all-cjs": "node scripts/build.js vue runtime compiler reactivity reactivity-transform shared -af cjs",
+ "build-all-cjs": "node scripts/build.js vue runtime compiler reactivity shared -af cjs",
"build-runtime-esm": "node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime",
"build-ssr-esm": "node scripts/build.js compiler-sfc server-renderer -f esm-browser",
"build-sfc-playground-self": "cd packages/sfc-playground && npm run build",
diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
index 073874363..f4f44284b 100644
--- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
+++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
@@ -515,20 +515,20 @@ return { }
`;
exports[`SFC compile
- `,
- { reactivityTransform: true }
+
+
+ `
)
assertCode(content)
- expect(content).toMatch(`import { ref } from 'vue'`)
+ expect(content).toMatch(
+ `import { useCssVars as _useCssVars, unref as _unref } from 'vue'`
+ )
+ expect(content).toMatch(`import { useCssVars, ref } from 'vue'`)
})
test('import dedupe between `, {
- reactivityTransform: true
- })
+ const { content } = compile(``)
if (shouldAsync) {
expect(content).toMatch(`let __temp, __restore`)
}
@@ -911,7 +917,7 @@ describe('SFC compile `)
- expect(content).not.toMatch(`$(ref())`)
- expect(content).not.toMatch(`$(ref(1))`)
- expect(content).not.toMatch(`$(shallowRef({`)
- expect(content).toMatch(`let foo = (ref())`)
- expect(content).toMatch(`let a = (ref(1))`)
- expect(content).toMatch(`
- let b = (shallowRef({
- count: 0
- }))
- `)
- // normal declarations left untouched
- expect(content).toMatch(`let c = () => {}`)
- expect(content).toMatch(`let d`)
- expect(content).toMatch(
- `return { foo, a, b, get c() { return c }, set c(v) { c = v }, ` +
- `get d() { return d }, set d(v) { d = v }, ref, shallowRef }`
- )
- assertCode(content)
- expect(bindings).toStrictEqual({
- foo: BindingTypes.SETUP_REF,
- a: BindingTypes.SETUP_REF,
- b: BindingTypes.SETUP_REF,
- c: BindingTypes.SETUP_LET,
- d: BindingTypes.SETUP_LET,
- ref: BindingTypes.SETUP_CONST,
- shallowRef: BindingTypes.SETUP_CONST
- })
- })
-
- test('$ref & $shallowRef declarations', () => {
- const { content, bindings } = compileWithReactivityTransform(``)
- expect(content).toMatch(
- `import { ref as _ref, shallowRef as _shallowRef } from 'vue'`
- )
- expect(content).not.toMatch(`$ref()`)
- expect(content).not.toMatch(`$ref(1)`)
- expect(content).not.toMatch(`$shallowRef({`)
- expect(content).toMatch(`let foo = _ref()`)
- expect(content).toMatch(`let a = _ref(1)`)
- expect(content).toMatch(`
- let b = _shallowRef({
- count: 0
- })
- `)
- // normal declarations left untouched
- expect(content).toMatch(`let c = () => {}`)
- expect(content).toMatch(`let d`)
- assertCode(content)
- expect(bindings).toStrictEqual({
- foo: BindingTypes.SETUP_REF,
- a: BindingTypes.SETUP_REF,
- b: BindingTypes.SETUP_REF,
- c: BindingTypes.SETUP_LET,
- d: BindingTypes.SETUP_LET
- })
- })
-
- test('usage in normal `)
- expect(content).not.toMatch(`$ref(0)`)
- expect(content).toMatch(`import { ref as _ref } from 'vue'`)
- expect(content).toMatch(`let count = _ref(0)`)
- expect(content).toMatch(`count.value++`)
- expect(content).toMatch(`return ({ count })`)
- assertCode(content)
- })
-
- test('usage /w typescript', () => {
- const { content } = compileWithReactivityTransform(`
-
- `)
- expect(content).toMatch(`import { ref as _ref`)
- expect(content).toMatch(`let msg = _ref('foo')`)
- expect(content).toMatch(`let bar = _ref ('bar')`)
- assertCode(content)
- })
-
- test('usage with normal
- `)
- // should dedupe helper imports
- expect(content).toMatch(`import { ref as _ref } from 'vue'`)
-
- expect(content).toMatch(`let a = _ref(0)`)
- expect(content).toMatch(`let b = _ref(0)`)
-
- // root level ref binding declared in
-
- `)
- expect(content).toMatch(`console.log(data.value)`)
- assertCode(content)
- })
-
- describe('errors', () => {
- test('defineProps/Emit() referencing ref declarations', () => {
- expect(() =>
- compile(
- ``,
- { reactivityTransform: true }
- )
- ).toThrow(`cannot reference locally declared variables`)
-
- expect(() =>
- compile(
- ``,
- { reactivityTransform: true }
- )
- ).toThrow(`cannot reference locally declared variables`)
- })
- })
-})
diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json
index b253078b8..407e14fb4 100644
--- a/packages/compiler-sfc/package.json
+++ b/packages/compiler-sfc/package.json
@@ -36,7 +36,6 @@
"@vue/compiler-core": "workspace:*",
"@vue/compiler-dom": "workspace:*",
"@vue/compiler-ssr": "workspace:*",
- "@vue/reactivity-transform": "workspace:*",
"@vue/shared": "workspace:*",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.5",
diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts
index 9a05d3b32..867280c6f 100644
--- a/packages/compiler-sfc/src/compileScript.ts
+++ b/packages/compiler-sfc/src/compileScript.ts
@@ -26,7 +26,6 @@ import {
import { CSS_VARS_HELPER, genCssVarsCode } from './style/cssVars'
import { compileTemplate, SFCTemplateCompileOptions } from './compileTemplate'
import { warnOnce } from './warn'
-import { shouldTransform, transformAST } from '@vue/reactivity-transform'
import { transformDestructuredProps } from './script/definePropsDestructure'
import { ScriptCompileContext } from './script/context'
import {
@@ -122,14 +121,6 @@ export interface SFCScriptCompileOptions {
fileExists(file: string): boolean
readFile(file: string): string | undefined
}
- /**
- * (Experimental) Enable syntax transform for using refs without `.value` and
- * using destructured props with reactivity
- * @deprecated the Reactivity Transform proposal has been dropped. This
- * feature will be removed from Vue core in 3.4. If you intend to continue
- * using it, disable this and switch to the [Vue Macros implementation](https://vue-macros.sxzz.moe/features/reactivity-transform.html).
- */
- reactivityTransform?: boolean
}
export interface ImportBinding {
@@ -165,8 +156,6 @@ export function compileScript(
const scriptLang = script && script.lang
const scriptSetupLang = scriptSetup && scriptSetup.lang
- // TODO remove in 3.4
- const enableReactivityTransform = !!options.reactivityTransform
let refBindings: string[] | undefined
if (!scriptSetup) {
@@ -477,20 +466,6 @@ export function compileScript(
}
}
- // apply reactivity transform
- // TODO remove in 3.4
- if (enableReactivityTransform && shouldTransform(script.content)) {
- const { rootRefs, importedHelpers } = transformAST(
- scriptAst,
- ctx.s,
- scriptStartOffset!
- )
- refBindings = rootRefs
- for (const h of importedHelpers) {
- ctx.helperImports.add(h)
- }
- }
-
//