Skip to content

Commit 1ec2d15

Browse files
committed
feat!: drop reactivity transform support
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.
1 parent 2249635 commit 1ec2d15

File tree

6 files changed

+28
-71
lines changed

6 files changed

+28
-71
lines changed

src/core/index.ts

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export interface Options {
5050
| 'defineModel'
5151
| 'propsDestructure'
5252
| 'fs'
53-
| 'reactivityTransform'
5453
| 'hoistStatic'
5554
>
5655
>
@@ -75,19 +74,6 @@ export interface Options {
7574
*/
7675
customElement?: boolean | string | RegExp | (string | RegExp)[]
7776

78-
/**
79-
* Enable Vue reactivity transform (experimental).
80-
* https://vuejs.org/guide/extras/reactivity-transform.html
81-
* - `true`: transform will be enabled for all vue,js(x),ts(x) files except
82-
* those inside node_modules
83-
* - `string | RegExp`: apply to vue + only matched files (will include
84-
* node_modules, so specify directories if necessary)
85-
* - `false`: disable in all cases
86-
*
87-
* @default false
88-
*/
89-
reactivityTransform?: boolean | string | RegExp | (string | RegExp)[]
90-
9177
/**
9278
* Use custom compiler-sfc instance. Can be used to force a specific version.
9379
*/
@@ -111,7 +97,6 @@ export type ResolvedOptions = Options &
11197
| 'sourceMap'
11298
| 'root'
11399
| 'customElement'
114-
| 'reactivityTransform'
115100
| 'compiler'
116101
| 'inlineTemplate'
117102
>
@@ -134,7 +119,6 @@ function resolveOptions(rawOptions: Options): ResolvedOptions {
134119
sourceMap: rawOptions.sourceMap ?? true,
135120
root,
136121
customElement: rawOptions.customElement ?? /\.ce\.vue$/,
137-
reactivityTransform: rawOptions.reactivityTransform ?? false,
138122
compiler: rawOptions.compiler as any, // to be set in buildStart
139123
devToolsEnabled: !isProduction,
140124
cssDevSourcemap: false,
@@ -156,14 +140,6 @@ export const plugin = createUnplugin<Options | undefined, false>(
156140
: createFilter(options.value.customElement),
157141
)
158142

159-
const refTransformFilter = computed(() =>
160-
options.value.reactivityTransform === false
161-
? () => false
162-
: options.value.reactivityTransform === true
163-
? createFilter(/\.(j|t)sx?$/, /node_modules/)
164-
: createFilter(options.value.reactivityTransform),
165-
)
166-
167143
const api = {
168144
get options() {
169145
return options.value
@@ -299,32 +275,16 @@ export const plugin = createUnplugin<Options | undefined, false>(
299275
transformInclude(id) {
300276
const { filename, query } = parseVueRequest(id)
301277
if (query.raw || query.url) return false
302-
303-
// Not Vue SFC and refTransform
304-
if (
305-
!filter.value(filename) &&
306-
!query.vue &&
307-
!refTransformFilter.value(filename)
308-
)
309-
return false
278+
if (!filter.value(filename) && !query.vue) return false
310279

311280
return true
312281
},
313282

314283
transform(code, id) {
315284
const ssr = options.value.ssr
316285
const { filename, query } = parseVueRequest(id)
317-
if (!filter.value(filename) && !query.vue) {
318-
if (options.value.compiler.shouldTransformRef(code)) {
319-
return options.value.compiler.transformRef(code, {
320-
filename,
321-
sourceMap: true,
322-
})
323-
}
324-
return
325-
}
326-
327286
const context = Object.assign({}, this, meta)
287+
328288
if (!query.vue) {
329289
// main request
330290
return transformMain(

src/core/script.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export function resolveScript(
7373
id: descriptor.id,
7474
isProd: options.isProduction,
7575
inlineTemplate: isUseInlineTemplate(options, descriptor),
76-
reactivityTransform: options.reactivityTransform !== false,
7776
templateOptions: resolveTemplateCompilerOptions(descriptor, options, ssr),
7877
sourceMap: options.sourceMap,
7978
genDefaultAs: canInlineMain(pluginContext, descriptor, options)
-86 Bytes
Binary file not shown.

tests/__snapshots__/rollup.test.ts.snap

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ exports[`transform > fixtures > tests/fixtures/reactivity-transform.ts > isProdu
6464
"//reactivity-transform.js
6565
import { ref } from 'vue';
6666
67-
const ref1 = ref(\\"hello\\");
68-
const ref2 = ref(\\"hello\\");
69-
console.log(ref1.value);
70-
console.log(ref2.value);
67+
const ref1 = $ref(\\"hello\\");
68+
const ref2 = $(ref(\\"hello\\"));
7169
console.log(ref1);
7270
console.log(ref2);
71+
console.log($$(ref1));
72+
console.log($$(ref2));
7373
"
7474
`;
7575

7676
exports[`transform > fixtures > tests/fixtures/reactivity-transform.ts > isProduction is true 1`] = `
7777
"//reactivity-transform.js
7878
import { ref } from 'vue';
7979
80-
const ref1 = ref(\\"hello\\");
81-
const ref2 = ref(\\"hello\\");
82-
console.log(ref1.value);
83-
console.log(ref2.value);
80+
const ref1 = $ref(\\"hello\\");
81+
const ref2 = $(ref(\\"hello\\"));
8482
console.log(ref1);
8583
console.log(ref2);
84+
console.log($$(ref1));
85+
console.log($$(ref2));
8686
"
8787
`;
8888

@@ -102,13 +102,13 @@ const _sfc_main = {
102102
__name: 'reactivity-transform',
103103
setup(__props) {
104104
105-
const ref1 = ref('hello');
106-
const ref2 = (ref('hello'));
105+
const ref1 = $ref('hello');
106+
const ref2 = $(ref('hello'));
107107
108-
console.log(ref1.value);
109-
console.log(ref2.value);
110-
console.log((ref1));
111-
console.log((ref2));
108+
console.log(ref1);
109+
console.log(ref2);
110+
console.log($$(ref1));
111+
console.log($$(ref2));
112112
113113
return () => {}
114114
}
@@ -128,13 +128,13 @@ const _sfc_main = {
128128
__name: 'reactivity-transform',
129129
setup(__props) {
130130
131-
const ref1 = ref('hello');
132-
const ref2 = (ref('hello'));
131+
const ref1 = $ref('hello');
132+
const ref2 = $(ref('hello'));
133133
134-
console.log(ref1.value);
135-
console.log(ref2.value);
136-
console.log((ref1));
137-
console.log((ref2));
134+
console.log(ref1);
135+
console.log(ref2);
136+
console.log($$(ref1));
137+
console.log($$(ref2));
138138
139139
return () => {}
140140
}
@@ -222,9 +222,9 @@ const str = \\"bar\\";
222222
var script_setup_ts_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
223223
__name: \\"script-setup-ts\\",
224224
props: {
225-
foo: { default: \\"123\\" },
226-
bar: { default: 123 },
227-
baz: { type: Boolean, default: true }
225+
foo: {},
226+
bar: {},
227+
baz: { type: Boolean }
228228
},
229229
setup(__props, { expose: __expose }) {
230230
__expose({
@@ -268,9 +268,9 @@ const str = \\"bar\\";
268268
var script_setup_ts_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
269269
__name: \\"script-setup-ts\\",
270270
props: {
271-
foo: { default: \\"123\\" },
272-
bar: { default: 123 },
273-
baz: { type: Boolean, default: true }
271+
foo: {},
272+
bar: {},
273+
baz: { type: Boolean }
274274
},
275275
setup(__props, { expose: __expose }) {
276276
__expose({

tests/esbuild.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('transform', () => {
3131
Vue({
3232
root,
3333
compiler: vueCompiler,
34-
reactivityTransform: true,
3534
isProduction,
3635
}),
3736
],

tests/rollup.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ describe('transform', () => {
6363
const { unplugin, vite } = createPlugins({
6464
root,
6565
compiler: vueCompiler,
66-
reactivityTransform: true,
6766
isProduction,
6867
})
6968

0 commit comments

Comments
 (0)