Skip to content

Commit 0aec658

Browse files
committed
refactor: remove reactivity transform
1 parent b8fc18c commit 0aec658

27 files changed

+43
-2537
lines changed

.eslintrc.cjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ module.exports = {
5656
},
5757
// Packages targeting Node
5858
{
59-
files: [
60-
'packages/{compiler-sfc,compiler-ssr,server-renderer,reactivity-transform}/**'
61-
],
59+
files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
6260
rules: {
6361
'no-restricted-globals': ['error', ...DOMGlobals],
6462
'no-restricted-syntax': 'off'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"serve": "serve",
3434
"open": "open http://localhost:3000/packages/template-explorer/local.html",
3535
"build-sfc-playground": "run-s build-compiler-cjs build-runtime-esm build-ssr-esm build-sfc-playground-self",
36-
"build-compiler-cjs": "node scripts/build.js compiler reactivity-transform shared -af cjs",
36+
"build-compiler-cjs": "node scripts/build.js compiler shared -af cjs",
3737
"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",
3838
"build-ssr-esm": "node scripts/build.js compiler-sfc server-renderer -f esm-browser",
3939
"build-sfc-playground-self": "cd packages/sfc-playground && npm run build",

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

+11-7
Original file line numberDiff line numberDiff line change
@@ -515,20 +515,20 @@ return { }
515515
`;
516516
517517
exports[`SFC compile <script setup> > async/await detection > ref 1`] = `
518-
"import { withAsyncContext as _withAsyncContext, ref as _ref } from 'vue'
518+
"import { withAsyncContext as _withAsyncContext } from 'vue'
519519
520520
export default {
521521
async setup(__props, { expose: __expose }) {
522522
__expose();
523523
524524
let __temp, __restore
525-
let a = _ref(1 + ((
525+
let a = ref(1 + ((
526526
([__temp,__restore] = _withAsyncContext(() => foo)),
527527
__temp = await __temp,
528528
__restore(),
529529
__temp
530530
)))
531-
return { a }
531+
return { get a() { return a }, set a(v) { a = v } }
532532
}
533533
534534
}"
@@ -818,16 +818,20 @@ return { bar }
818818
`;
819819
820820
exports[`SFC compile <script setup> > imports > dedupe between user & helper 1`] = `
821-
"import { ref as _ref } from 'vue'
822-
import { ref } from 'vue'
821+
"import { useCssVars as _useCssVars, unref as _unref } from 'vue'
822+
import { useCssVars, ref } from 'vue'
823823
824824
export default {
825825
setup(__props, { expose: __expose }) {
826826
__expose();
827827
828-
let foo = _ref(1)
828+
_useCssVars(_ctx => ({
829+
\\"xxxxxxxx-msg\\": (msg.value)
830+
}))
831+
832+
const msg = ref()
829833
830-
return { foo, ref }
834+
return { msg, useCssVars, ref }
831835
}
832836
833837
}"

packages/compiler-sfc/__tests__/compileScript.spec.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,22 @@ describe('SFC compile <script setup>', () => {
240240
const { content } = compile(
241241
`
242242
<script setup>
243-
import { ref } from 'vue'
244-
let foo = $ref(1)
243+
import { useCssVars, ref } from 'vue'
244+
const msg = ref()
245245
</script>
246-
`,
247-
{ reactivityTransform: true }
246+
247+
<style>
248+
.foo {
249+
color: v-bind(msg)
250+
}
251+
</style>
252+
`
248253
)
249254
assertCode(content)
250-
expect(content).toMatch(`import { ref } from 'vue'`)
255+
expect(content).toMatch(
256+
`import { useCssVars as _useCssVars, unref as _unref } from 'vue'`
257+
)
258+
expect(content).toMatch(`import { useCssVars, ref } from 'vue'`)
251259
})
252260

253261
test('import dedupe between <script> and <script setup>', () => {
@@ -890,9 +898,7 @@ describe('SFC compile <script setup>', () => {
890898

891899
describe('async/await detection', () => {
892900
function assertAwaitDetection(code: string, shouldAsync = true) {
893-
const { content } = compile(`<script setup>${code}</script>`, {
894-
reactivityTransform: true
895-
})
901+
const { content } = compile(`<script setup>${code}</script>`)
896902
if (shouldAsync) {
897903
expect(content).toMatch(`let __temp, __restore`)
898904
}
@@ -910,7 +916,7 @@ describe('SFC compile <script setup>', () => {
910916
})
911917

912918
test('ref', () => {
913-
assertAwaitDetection(`let a = $ref(1 + (await foo))`)
919+
assertAwaitDetection(`let a = ref(1 + (await foo))`)
914920
})
915921

916922
// #4448

packages/compiler-sfc/__tests__/compileScript/__snapshots__/reactivityTransform.spec.ts.snap

-113
This file was deleted.

0 commit comments

Comments
 (0)