Skip to content

Commit

Permalink
feat(sfc): deprecate reactivity transform
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 27, 2023
1 parent ea5bf12 commit efb54e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 48 deletions.
29 changes: 5 additions & 24 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,11 @@ export interface SFCScriptCompileOptions {
/**
* (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
/**
* (Experimental) Enable syntax transform for using refs without `.value`
* https://github.com/vuejs/rfcs/discussions/369
* @deprecated now part of `reactivityTransform`
* @default false
*/
refTransform?: boolean
/**
* (Experimental) Enable syntax transform for destructuring from defineProps()
* https://github.com/vuejs/rfcs/discussions/394
* @deprecated now part of `reactivityTransform`
* @default false
*/
propsDestructureTransform?: boolean
/**
* @deprecated use `reactivityTransform` instead.
*/
refSugar?: boolean
/**
* Compile the template and inline the resulting render function
* directly inside setup().
Expand Down Expand Up @@ -154,12 +139,8 @@ export function compileScript(
let { script, scriptSetup, source, filename } = sfc
// feature flags
// TODO remove support for deprecated options when out of experimental
const enableReactivityTransform =
!!options.reactivityTransform ||
!!options.refSugar ||
!!options.refTransform
const enablePropsTransform =
!!options.reactivityTransform || !!options.propsDestructureTransform
const enableReactivityTransform = !!options.reactivityTransform
const enablePropsTransform = !!options.reactivityTransform
const isProd = !!options.isProd
const genSourceMap = options.sourceMap !== false
let refBindings: string[] | undefined
Expand Down
6 changes: 4 additions & 2 deletions packages/reactivity-transform/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# @vue/reactivity-transform

> ⚠️ This is experimental and currently only provided for testing and feedback. It may break during patches or even be removed. Use at your own risk!
> ⚠️ This is experimental and the proposal has been dropped.
> The feature is now marked as deprecated and will be removed from Vue core
> in 3.4.
>
> Follow https://github.com/vuejs/rfcs/discussions/369 for details and updates.
> See reason for deprecation [here](https://github.com/vuejs/rfcs/discussions/369#discussioncomment-5059028).
## Basic Rules

Expand Down
26 changes: 4 additions & 22 deletions packages/reactivity-transform/src/reactivityTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export function transformAST(
rootRefs: string[]
importedHelpers: string[]
} {
// TODO remove when out of experimental
warnExperimental()

const userImports: Record<string, ImportBinding> = Object.create(null)
Expand Down Expand Up @@ -729,22 +728,6 @@ export function transformAST(
}
}
}

// TODO remove when out of experimental
if (callee === '$raw') {
error(
`$raw() has been replaced by $$(). ` +
`See ${RFC_LINK} for latest updates.`,
node
)
}
if (callee === '$fromRef') {
error(
`$fromRef() has been replaced by $(). ` +
`See ${RFC_LINK} for latest updates.`,
node
)
}
}
},
leave(node: Node, parent?: Node) {
Expand All @@ -771,7 +754,6 @@ export function transformAST(
}
}

const RFC_LINK = `https://github.com/vuejs/rfcs/discussions/369`
const hasWarned: Record<string, boolean> = {}

function warnExperimental() {
Expand All @@ -780,10 +762,10 @@ function warnExperimental() {
return
}
warnOnce(
`Reactivity transform is an experimental feature.\n` +
`Experimental features may change behavior between patch versions.\n` +
`It is recommended to pin your vue dependencies to exact versions to avoid breakage.\n` +
`You can follow the proposal's status at ${RFC_LINK}.`
`Reactivity Transform was an experimental feature and has now been deprecated. ` +
`It will be removed from Vue core in 3.4. If you intend to continue using it, ` +
`switch to https://vue-macros.sxzz.moe/features/reactivity-transform.html.\n` +
`See reason for deprecation here: https://github.com/vuejs/rfcs/discussions/369#discussioncomment-5059028`
)
}

Expand Down

0 comments on commit efb54e7

Please sign in to comment.