Skip to content

Commit a6eb043

Browse files
committed
chore: merge branch 'main' into feat/onEffectCleanup-and-baseWatch
2 parents 8dd0c1f + 0275dd3 commit a6eb043

40 files changed

+739
-285
lines changed

.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
plugins: ['jest', 'import', '@typescript-eslint'],
2020
rules: {
2121
'no-debugger': 'error',
22+
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
2223
// most of the codebase are expected to be env agnostic
2324
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
2425

@@ -58,6 +59,7 @@ module.exports = {
5859
{
5960
files: ['**/__tests__/**', 'packages/dts-test/**'],
6061
rules: {
62+
'no-console': 'off',
6163
'no-restricted-globals': 'off',
6264
'no-restricted-syntax': 'off',
6365
'jest/no-disabled-tests': 'error',
@@ -92,6 +94,7 @@ module.exports = {
9294
rules: {
9395
'no-restricted-globals': ['error', ...NodeGlobals],
9496
'no-restricted-syntax': ['error', banConstEnum],
97+
'no-console': 'off',
9598
},
9699
},
97100
// JavaScript files
@@ -113,6 +116,7 @@ module.exports = {
113116
rules: {
114117
'no-restricted-globals': 'off',
115118
'no-restricted-syntax': ['error', banConstEnum],
119+
'no-console': 'off',
116120
},
117121
},
118122
// Import nodejs modules in compiler-sfc

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
## [3.4.5](https://github.com/vuejs/core/compare/v3.4.4...v3.4.5) (2024-01-04)
2+
3+
4+
### Bug Fixes
5+
6+
* **compiler-sfc:** fix co-usage of defineModel transform options and props destructure ([b20350d](https://github.com/vuejs/core/commit/b20350ded562d27e5901f308d0bc13344f840c4a)), closes [#9972](https://github.com/vuejs/core/issues/9972)
7+
* **compiler-sfc:** fix sfc template unref rewrite for class instantiation ([ae60a91](https://github.com/vuejs/core/commit/ae60a91cc23424493071ad9088782763eb1e8ff7)), closes [#6483](https://github.com/vuejs/core/issues/6483) [#6491](https://github.com/vuejs/core/issues/6491)
8+
* **compiler-ssr:** fix node clone edge case caused by AST reuse ([#9983](https://github.com/vuejs/core/issues/9983)) ([7dbdb3e](https://github.com/vuejs/core/commit/7dbdb3edf0ab648965331ca42f069387c97a1c8a)), closes [#9981](https://github.com/vuejs/core/issues/9981)
9+
* **watch:** cleanup watcher effect from scope when manually stopped ([#9978](https://github.com/vuejs/core/issues/9978)) ([d2d8955](https://github.com/vuejs/core/commit/d2d89551bb06dc05cb7ae0496b8f345ae0de78ed))
10+
11+
12+
13+
## [3.4.4](https://github.com/vuejs/core/compare/v3.4.3...v3.4.4) (2024-01-03)
14+
15+
16+
### Bug Fixes
17+
18+
* **compiler-sfc:** fix scss source map regression ([71d3121](https://github.com/vuejs/core/commit/71d3121b72c449351e718ee1539bdfa35b68bb32)), closes [#9970](https://github.com/vuejs/core/issues/9970) [#9969](https://github.com/vuejs/core/issues/9969)
19+
* **compiler-sfc:** use compilerOptions when re-parsing consumed AST ([d94d8d4](https://github.com/vuejs/core/commit/d94d8d4bffd1daf171a655b292745ffc3e63052d))
20+
* **defineModel:** support kebab-case/camelCase mismatches ([#9950](https://github.com/vuejs/core/issues/9950)) ([10ccb9b](https://github.com/vuejs/core/commit/10ccb9bfa0f5f3016207fc32b9611bab98e6f090))
21+
* **runtime-core:** correctly assign suspenseId to avoid conflicts with the default id ([#9966](https://github.com/vuejs/core/issues/9966)) ([0648804](https://github.com/vuejs/core/commit/06488047c184dae3070d0008379716690edceb46)), closes [#9944](https://github.com/vuejs/core/issues/9944)
22+
* **ssr:** avoid rendering transition-group slot content as a fragment ([#9961](https://github.com/vuejs/core/issues/9961)) ([0160264](https://github.com/vuejs/core/commit/0160264d677478ee928e8e851f39a9e94f97e337)), closes [#9933](https://github.com/vuejs/core/issues/9933)
23+
* **watch:** remove instance unmounted short circuit in getter of `watchEffect` ([#9948](https://github.com/vuejs/core/issues/9948)) ([f300a40](https://github.com/vuejs/core/commit/f300a4001ec40cadef2520267eb5841ab48cf005))
24+
* **watch:** revert watch behavior when watching shallow reactive objects ([a9f781a](https://github.com/vuejs/core/commit/a9f781a92cbc7de7b25c9e3d5b1295ca99eb6d86)), closes [#9965](https://github.com/vuejs/core/issues/9965)
25+
26+
27+
### Performance Improvements
28+
29+
* **watch:** avoid double traverse for reactive source ([24d77c2](https://github.com/vuejs/core/commit/24d77c25ce5d5356adb5367beef1d23e6e340b35))
30+
31+
32+
33+
## [3.4.3](https://github.com/vuejs/core/compare/v3.4.2...v3.4.3) (2023-12-30)
34+
35+
36+
### Bug Fixes
37+
38+
* **compiler-sfc:** respect sfc parse options in cache key ([b8d58ec](https://github.com/vuejs/core/commit/b8d58ec4f42cbeb9443bf06138add46158db9af0))
39+
40+
41+
142
## [3.4.2](https://github.com/vuejs/core/compare/v3.4.1...v3.4.2) (2023-12-30)
243

344

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
3-
"version": "3.4.2",
4-
"packageManager": "pnpm@8.12.1",
3+
"version": "3.4.5",
4+
"packageManager": "pnpm@8.14.0",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -70,11 +70,11 @@
7070
"@rollup/plugin-terser": "^0.4.4",
7171
"@types/hash-sum": "^1.0.2",
7272
"@types/minimist": "^1.2.5",
73-
"@types/node": "^20.10.5",
74-
"@types/semver": "^7.5.5",
75-
"@typescript-eslint/eslint-plugin": "^6.16.0",
76-
"@typescript-eslint/parser": "^6.15.0",
77-
"@vitest/coverage-istanbul": "^1.1.0",
73+
"@types/node": "^20.10.6",
74+
"@types/semver": "^7.5.6",
75+
"@typescript-eslint/eslint-plugin": "^6.17.0",
76+
"@typescript-eslint/parser": "^6.17.0",
77+
"@vitest/coverage-istanbul": "^1.1.1",
7878
"@vue/consolidate": "0.17.3",
7979
"conventional-changelog-cli": "^4.1.0",
8080
"enquirer": "^2.4.1",
@@ -83,15 +83,15 @@
8383
"eslint": "^8.56.0",
8484
"eslint-define-config": "^1.24.1",
8585
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
86-
"eslint-plugin-jest": "^27.6.0",
86+
"eslint-plugin-jest": "^27.6.1",
8787
"estree-walker": "^2.0.2",
8888
"execa": "^8.0.1",
8989
"jsdom": "^23.0.1",
9090
"lint-staged": "^15.2.0",
9191
"lodash": "^4.17.21",
9292
"magic-string": "^0.30.5",
9393
"markdown-table": "^3.0.3",
94-
"marked": "^11.1.0",
94+
"marked": "^11.1.1",
9595
"minimist": "^1.2.8",
9696
"npm-run-all": "^4.1.5",
9797
"picocolors": "^1.0.0",
@@ -113,6 +113,6 @@
113113
"tsx": "^4.7.0",
114114
"typescript": "^5.2.2",
115115
"vite": "^5.0.5",
116-
"vitest": "^1.1.0"
116+
"vitest": "^1.1.1"
117117
}
118118
}

packages/compiler-core/package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-core",
3-
"version": "3.4.2",
3+
"version": "3.4.5",
44
"description": "@vue/compiler-core",
55
"main": "index.js",
66
"module": "dist/compiler-core.esm-bundler.js",
@@ -9,6 +9,19 @@
99
"index.js",
1010
"dist"
1111
],
12+
"exports": {
13+
".": {
14+
"types": "./dist/compiler-core.d.ts",
15+
"node": {
16+
"production": "./dist/compiler-core.cjs.prod.js",
17+
"development": "./dist/compiler-core.cjs.js",
18+
"default": "./index.js"
19+
},
20+
"import": "./dist/compiler-core.esm-bundler.js",
21+
"require": "./index.js"
22+
},
23+
"./*": "./*"
24+
},
1225
"buildOptions": {
1326
"name": "VueCompilerCore",
1427
"compat": true,

packages/compiler-core/src/babelUtils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ export function isInDestructureAssignment(
146146
return false
147147
}
148148

149+
export function isInNewExpression(parentStack: Node[]): boolean {
150+
let i = parentStack.length
151+
while (i--) {
152+
const p = parentStack[i]
153+
if (p.type === 'NewExpression') {
154+
return true
155+
} else if (p.type !== 'MemberExpression') {
156+
break
157+
}
158+
}
159+
return false
160+
}
161+
149162
export function walkFunctionParams(
150163
node: Function,
151164
onIdent: (id: Identifier) => void,

packages/compiler-core/src/transforms/transformExpression.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from '../ast'
2020
import {
2121
isInDestructureAssignment,
22+
isInNewExpression,
2223
isStaticProperty,
2324
isStaticPropertyKey,
2425
walkIdentifiers,
@@ -131,6 +132,11 @@ export function processExpression(
131132
// ({ x } = y)
132133
const isDestructureAssignment =
133134
parent && isInDestructureAssignment(parent, parentStack)
135+
const isNewExpression = parent && isInNewExpression(parentStack)
136+
const wrapWithUnref = (raw: string) => {
137+
const wrapped = `${context.helperString(UNREF)}(${raw})`
138+
return isNewExpression ? `(${wrapped})` : wrapped
139+
}
134140

135141
if (
136142
isConst(type) ||
@@ -147,7 +153,7 @@ export function processExpression(
147153
// that assumes the value to be a ref for more efficiency
148154
return isAssignmentLVal || isUpdateArg || isDestructureAssignment
149155
? `${raw}.value`
150-
: `${context.helperString(UNREF)}(${raw})`
156+
: wrapWithUnref(raw)
151157
} else if (type === BindingTypes.SETUP_LET) {
152158
if (isAssignmentLVal) {
153159
// let binding.
@@ -190,7 +196,7 @@ export function processExpression(
190196
// for now
191197
return raw
192198
} else {
193-
return `${context.helperString(UNREF)}(${raw})`
199+
return wrapWithUnref(raw)
194200
}
195201
} else if (type === BindingTypes.PROPS) {
196202
// use __props which is generated by compileScript so in ts mode

packages/compiler-dom/package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-dom",
3-
"version": "3.4.2",
3+
"version": "3.4.5",
44
"description": "@vue/compiler-dom",
55
"main": "index.js",
66
"module": "dist/compiler-dom.esm-bundler.js",
@@ -11,6 +11,19 @@
1111
"index.js",
1212
"dist"
1313
],
14+
"exports": {
15+
".": {
16+
"types": "./dist/compiler-dom.d.ts",
17+
"node": {
18+
"production": "./dist/compiler-dom.cjs.prod.js",
19+
"development": "./dist/compiler-dom.cjs.js",
20+
"default": "./index.js"
21+
},
22+
"import": "./dist/compiler-dom.esm-bundler.js",
23+
"require": "./index.js"
24+
},
25+
"./*": "./*"
26+
},
1427
"sideEffects": false,
1528
"buildOptions": {
1629
"name": "VueCompilerDOM",

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,26 @@ return (_ctx, _cache) => {
10281028
}"
10291029
`;
10301030
1031+
exports[`SFC compile <script setup> > inlineTemplate mode > unref + new expression 1`] = `
1032+
"import { unref as _unref, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
1033+
1034+
import Foo from './foo'
1035+
1036+
export default {
1037+
setup(__props) {
1038+
1039+
1040+
return (_ctx, _cache) => {
1041+
return (_openBlock(), _createElementBlock(_Fragment, null, [
1042+
_createElementVNode("div", null, _toDisplayString(new (_unref(Foo))()), 1 /* TEXT */),
1043+
_createElementVNode("div", null, _toDisplayString(new (_unref(Foo)).Bar()), 1 /* TEXT */)
1044+
], 64 /* STABLE_FRAGMENT */))
1045+
}
1046+
}
1047+
1048+
}"
1049+
`;
1050+
10311051
exports[`SFC compile <script setup> > inlineTemplate mode > v-model codegen 1`] = `
10321052
"import { vModelText as _vModelText, createElementVNode as _createElementVNode, withDirectives as _withDirectives, unref as _unref, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
10331053

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,24 @@ describe('SFC compile <script setup>', () => {
650650
),
651651
).not.toThrowError()
652652
})
653+
654+
test('unref + new expression', () => {
655+
const { content } = compile(
656+
`
657+
<script setup>
658+
import Foo from './foo'
659+
</script>
660+
<template>
661+
<div>{{ new Foo() }}</div>
662+
<div>{{ new Foo.Bar() }}</div>
663+
</template>
664+
`,
665+
{ inlineTemplate: true },
666+
)
667+
expect(content).toMatch(`new (_unref(Foo))()`)
668+
expect(content).toMatch(`new (_unref(Foo)).Bar()`)
669+
assertCode(content)
670+
})
653671
})
654672

655673
describe('with TypeScript', () => {

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

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default {
1717
__expose();
1818
1919
const modelValue = _useModel(__props, "modelValue")
20-
const c = _useModel(__props, "count")
21-
const toString = _useModel(__props, "toString")
20+
const c = _useModel(__props, 'count')
21+
const toString = _useModel(__props, 'toString')
2222
2323
return { modelValue, c, toString }
2424
}
@@ -40,7 +40,10 @@ export default /*#__PURE__*/_defineComponent({
4040
setup(__props, { expose: __expose }) {
4141
__expose();
4242
43-
const modelValue = _useModel(__props, "modelValue", { get(v) { return v - 1 }, set: (v) => { return v + 1 }, })
43+
const modelValue = _useModel(__props, "modelValue", {
44+
get(v) { return v - 1 },
45+
set: (v) => { return v + 1 },
46+
})
4447
4548
return { modelValue }
4649
}
@@ -63,7 +66,36 @@ export default /*#__PURE__*/_defineComponent({
6366
setup(__props, { expose: __expose }) {
6467
__expose();
6568
66-
const modelValue = _useModel(__props, "modelValue", { get(v) { return v - 1 }, set: (v) => { return v + 1 }, })
69+
const modelValue = _useModel(__props, "modelValue", {
70+
get(v) { return v - 1 },
71+
set: (v) => { return v + 1 },
72+
})
73+
74+
return { modelValue }
75+
}
76+
77+
})"
78+
`;
79+
80+
exports[`defineModel() > usage w/ props destructure 1`] = `
81+
"import { useModel as _useModel, mergeModels as _mergeModels, defineComponent as _defineComponent } from 'vue'
82+
83+
export default /*#__PURE__*/_defineComponent({
84+
props: /*#__PURE__*/_mergeModels({
85+
x: { type: Number, required: true }
86+
}, {
87+
"modelValue": {
88+
},
89+
"modelModifiers": {},
90+
}),
91+
emits: ["update:modelValue"],
92+
setup(__props: any, { expose: __expose }) {
93+
__expose();
94+
95+
96+
const modelValue = _useModel(__props, "modelValue", {
97+
set: (v) => { return v + __props.x }
98+
})
6799
68100
return { modelValue }
69101
}
@@ -84,7 +116,7 @@ export default {
84116
__expose();
85117
86118
87-
const count = _useModel(__props, "count")
119+
const count = _useModel(__props, 'count')
88120
89121
return { count }
90122
}
@@ -132,10 +164,10 @@ export default /*#__PURE__*/_defineComponent({
132164
setup(__props, { expose: __expose }) {
133165
__expose();
134166
135-
const modelValue = _useModel(__props, "modelValue")
136-
const count = _useModel(__props, "count")
137-
const disabled = _useModel(__props, "disabled")
138-
const any = _useModel(__props, "any")
167+
const modelValue = _useModel<boolean | string>(__props, "modelValue")
168+
const count = _useModel<number>(__props, 'count')
169+
const disabled = _useModel<number>(__props, 'disabled')
170+
const any = _useModel<any | boolean>(__props, 'any')
139171
140172
return { modelValue, count, disabled, any }
141173
}
@@ -163,11 +195,11 @@ export default /*#__PURE__*/_defineComponent({
163195
setup(__props, { expose: __expose }) {
164196
__expose();
165197
166-
const modelValue = _useModel(__props, "modelValue")
167-
const fn = _useModel(__props, "fn")
168-
const fnWithDefault = _useModel(__props, "fnWithDefault")
169-
const str = _useModel(__props, "str")
170-
const optional = _useModel(__props, "optional")
198+
const modelValue = _useModel<boolean>(__props, "modelValue")
199+
const fn = _useModel<() => void>(__props, 'fn')
200+
const fnWithDefault = _useModel<() => void>(__props, 'fnWithDefault')
201+
const str = _useModel<string>(__props, 'str')
202+
const optional = _useModel<string>(__props, 'optional')
171203
172204
return { modelValue, fn, fnWithDefault, str, optional }
173205
}

0 commit comments

Comments
 (0)