Skip to content

Commit 4bc0ed9

Browse files
authored
Merge branch 'main' into fix/5168
2 parents 3944b75 + 7374e93 commit 4bc0ed9

File tree

76 files changed

+1802
-1017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1802
-1017
lines changed

.eslintrc.cjs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-restricted-globals */
2+
13
const DOMGlobals = ['window', 'document']
24
const NodeGlobals = ['module', 'require']
35

@@ -9,12 +11,6 @@ module.exports = {
911
plugins: ['jest'],
1012
rules: {
1113
'no-debugger': 'error',
12-
'no-unused-vars': [
13-
'error',
14-
// we are only using this rule to check for unused arguments since TS
15-
// catches unused variables but not args.
16-
{ varsIgnorePattern: '.*', args: 'none' }
17-
],
1814
// most of the codebase are expected to be env agnostic
1915
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
2016

@@ -72,6 +68,14 @@ module.exports = {
7268
'no-restricted-syntax': 'off'
7369
}
7470
},
71+
// JavaScript files
72+
{
73+
files: ['*.js', '*.cjs'],
74+
rules: {
75+
// We only do `no-unused-vars` checks for js files, TS files are checked by TypeScript itself.
76+
'no-unused-vars': ['error', { vars: 'all', args: 'none' }]
77+
}
78+
},
7579
// Node scripts
7680
{
7781
files: ['scripts/**', '*.{js,ts}', 'packages/**/index.js'],

.github/workflows/canary.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
- name: Install pnpm
1818
uses: pnpm/action-setup@v2
1919

20-
- name: Set node version to 18
20+
- name: Install Node.js
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18
23+
node-version-file: '.node-version'
2424
registry-url: 'https://registry.npmjs.org'
2525
cache: 'pnpm'
2626

.github/workflows/ci.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
- name: Install pnpm
2323
uses: pnpm/action-setup@v2
2424

25-
- name: Set node version to 18
25+
- name: Install Node.js
2626
uses: actions/setup-node@v3
2727
with:
28-
node-version: 18
28+
node-version-file: '.node-version'
2929
cache: 'pnpm'
3030

3131
- run: pnpm install
@@ -44,10 +44,10 @@ jobs:
4444
- name: Install pnpm
4545
uses: pnpm/action-setup@v2
4646

47-
- name: Set node version to 18
47+
- name: Install Node.js
4848
uses: actions/setup-node@v3
4949
with:
50-
node-version: 18
50+
node-version-file: '.node-version'
5151
cache: 'pnpm'
5252

5353
- run: pnpm install
@@ -73,14 +73,14 @@ jobs:
7373
- name: Install pnpm
7474
uses: pnpm/action-setup@v2
7575

76-
- name: Set node version to 18
76+
- name: Install Node.js
7777
uses: actions/setup-node@v3
7878
with:
79-
node-version: 18
79+
node-version-file: '.node-version'
8080
cache: 'pnpm'
8181

8282
- run: pnpm install
83-
- run: node node_modules/puppeteer/install.js
83+
- run: node node_modules/puppeteer/install.mjs
8484

8585
- name: Run e2e tests
8686
run: pnpm run test-e2e
@@ -96,10 +96,10 @@ jobs:
9696
- name: Install pnpm
9797
uses: pnpm/action-setup@v2
9898

99-
- name: Set node version to 18
99+
- name: Install Node.js
100100
uses: actions/setup-node@v3
101101
with:
102-
node-version: 18
102+
node-version-file: '.node-version'
103103
cache: 'pnpm'
104104

105105
- run: pnpm install

.github/workflows/size-data.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
- name: Install pnpm
2525
uses: pnpm/action-setup@v2
2626

27-
- name: Set node version to LTS
27+
- name: Install Node.js
2828
uses: actions/setup-node@v3
2929
with:
30-
node-version: lts/*
30+
node-version-file: '.node-version'
3131
cache: pnpm
3232

3333
- name: Install dependencies

.github/workflows/size-report.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
- name: Install pnpm
2727
uses: pnpm/action-setup@v2
2828

29-
- name: Set node version to LTS
29+
- name: Install Node.js
3030
uses: actions/setup-node@v3
3131
with:
32-
node-version: lts/*
32+
node-version-file: '.node-version'
3333
cache: pnpm
3434

3535
- name: Install dependencies

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

CHANGELOG.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1+
## [3.3.6](https://github.com/vuejs/core/compare/v3.3.5...v3.3.6) (2023-10-20)
2+
3+
4+
### Bug Fixes
5+
6+
* **compiler-sfc:** model name conflict ([#8798](https://github.com/vuejs/core/issues/8798)) ([df81da8](https://github.com/vuejs/core/commit/df81da8be97c8a1366563c7e3e01076ef02eb8f7))
7+
* **compiler-sfc:** support asset paths containing spaces ([#8752](https://github.com/vuejs/core/issues/8752)) ([36c99a9](https://github.com/vuejs/core/commit/36c99a9c6bb6bc306be054c3c8a85ff8ce50605a))
8+
* **compiler-ssr:** fix missing scopeId on server-rendered TransitionGroup ([#7557](https://github.com/vuejs/core/issues/7557)) ([61c1357](https://github.com/vuejs/core/commit/61c135742795aa5e3189a79c7dec6afa21bbc8d9)), closes [#7554](https://github.com/vuejs/core/issues/7554)
9+
* **compiler-ssr:** fix ssr compile error for select with non-option children ([#9442](https://github.com/vuejs/core/issues/9442)) ([cdb2e72](https://github.com/vuejs/core/commit/cdb2e725e7ea297f1f4180fb04889a3b757bc84e)), closes [#9440](https://github.com/vuejs/core/issues/9440)
10+
* **runtime-core:** delete stale slots which are present but undefined ([#6484](https://github.com/vuejs/core/issues/6484)) ([75b8722](https://github.com/vuejs/core/commit/75b872213574cb37e2c9e8a15f65613f867ca9a6)), closes [#9109](https://github.com/vuejs/core/issues/9109)
11+
* **runtime-core:** fix error when using cssvars with disabled teleport ([#7341](https://github.com/vuejs/core/issues/7341)) ([8f0472c](https://github.com/vuejs/core/commit/8f0472c9abedb337dc256143b69d8ab8759dbf5c)), closes [#7342](https://github.com/vuejs/core/issues/7342)
12+
* **teleport:** ensure descendent component would be unmounted correctly ([#6529](https://github.com/vuejs/core/issues/6529)) ([4162311](https://github.com/vuejs/core/commit/4162311efdb0db5ca458542e1604b19efa2fae0e)), closes [#6347](https://github.com/vuejs/core/issues/6347)
13+
* **types:** support contenteditable="plaintext-only" ([#8796](https://github.com/vuejs/core/issues/8796)) ([26ca89e](https://github.com/vuejs/core/commit/26ca89e5cf734fbef81e182050d2a215ec8a437b))
14+
15+
16+
### Performance Improvements
17+
18+
* replace Map/Set with WeakMap/WeakSet ([#8549](https://github.com/vuejs/core/issues/8549)) ([712f96d](https://github.com/vuejs/core/commit/712f96d6ac4d3d984732cba448cb84624daba850))
19+
20+
21+
122
## [3.3.5](https://github.com/vuejs/core/compare/v3.3.4...v3.3.5) (2023-10-20)
223

324

425
### Bug Fixes
526

6-
* add isGloballyWhitelisted back, but deprecated ([#8556](https://github.com/vuejs/core/issues/8556)) ([63dfe8e](https://github.com/vuejs/core/commit/63dfe8eab499979bcc2f7829e82464e13899c895)), closes [/github.com/vuejs/core/issues/8416#issuecomment-1566583260](https://github.com//github.com/vuejs/core/issues/8416/issues/issuecomment-1566583260)
27+
* add isGloballyWhitelisted back, but deprecated ([#8556](https://github.com/vuejs/core/issues/8556)) ([63dfe8e](https://github.com/vuejs/core/commit/63dfe8eab499979bcc2f7829e82464e13899c895)), closes [#8416](https://github.com/vuejs/core/issues/8416)
728
* **build:** disable useDefineForClassFields in esbuild ([#9252](https://github.com/vuejs/core/issues/9252)) ([6d14fa8](https://github.com/vuejs/core/commit/6d14fa88e85d4c9e264be394ddb37a54ca6738a8))
829
* **compat:** return value of vue compat set() ([#9377](https://github.com/vuejs/core/issues/9377)) ([e3c2d69](https://github.com/vuejs/core/commit/e3c2d699f694d9500ddee78571172a24f0e3b17a))
930
* **compiler-sfc:** don't hoist props and emit ([#8535](https://github.com/vuejs/core/issues/8535)) ([24db951](https://github.com/vuejs/core/commit/24db9516d8b4857182ec1a3af86cb7346691679b)), closes [#7805](https://github.com/vuejs/core/issues/7805) [#7812](https://github.com/vuejs/core/issues/7812)

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "3.3.5",
3+
"version": "3.3.6",
44
"packageManager": "[email protected]",
55
"type": "module",
66
"scripts": {
@@ -66,16 +66,16 @@
6666
"@rollup/plugin-replace": "^5.0.4",
6767
"@rollup/plugin-terser": "^0.4.4",
6868
"@types/hash-sum": "^1.0.1",
69-
"@types/node": "^18.18.6",
69+
"@types/node": "^20.8.7",
7070
"@typescript-eslint/parser": "^6.8.0",
71-
"@vitest/coverage-istanbul": "^0.34.4",
71+
"@vitest/coverage-istanbul": "^0.34.6",
7272
"@vue/consolidate": "0.17.3",
7373
"conventional-changelog-cli": "^4.1.0",
7474
"enquirer": "^2.4.1",
7575
"esbuild": "^0.19.5",
7676
"esbuild-plugin-polyfill-node": "^0.3.0",
77-
"eslint": "^8.51.0",
78-
"eslint-plugin-jest": "^27.4.2",
77+
"eslint": "^8.52.0",
78+
"eslint-plugin-jest": "^27.4.3",
7979
"estree-walker": "^2.0.2",
8080
"execa": "^8.0.1",
8181
"jsdom": "^22.1.0",
@@ -90,21 +90,21 @@
9090
"prettier": "^3.0.3",
9191
"pretty-bytes": "^6.1.1",
9292
"pug": "^3.0.2",
93-
"puppeteer": "~21.2.1",
93+
"puppeteer": "~21.4.0",
9494
"rimraf": "^5.0.5",
95-
"rollup": "^3.29.4",
95+
"rollup": "^4.1.4",
9696
"rollup-plugin-dts": "^6.1.0",
9797
"rollup-plugin-esbuild": "^6.1.0",
9898
"rollup-plugin-polyfill-node": "^0.12.0",
9999
"semver": "^7.5.4",
100100
"serve": "^14.2.1",
101101
"simple-git-hooks": "^2.9.0",
102102
"terser": "^5.22.0",
103-
"todomvc-app-css": "^2.4.2",
103+
"todomvc-app-css": "^2.4.3",
104104
"tslib": "^2.6.2",
105105
"tsx": "^3.14.0",
106-
"typescript": "^5.1.6",
107-
"vite": "^4.3.0",
108-
"vitest": "^0.34.4"
106+
"typescript": "^5.2.2",
107+
"vite": "^4.5.0",
108+
"vitest": "^0.34.6"
109109
}
110110
}

packages/compiler-core/__tests__/transforms/hoistStatic.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -593,5 +593,17 @@ describe('compiler: hoistStatic transform', () => {
593593
expect(root.hoists.length).toBe(2)
594594
expect(generate(root).code).toMatchSnapshot()
595595
})
596+
597+
test('clone hoisted array children in HMR mode', () => {
598+
const root = transformWithHoist(`<div><span class="hi"></span></div>`, {
599+
hmr: true
600+
})
601+
expect(root.hoists.length).toBe(2)
602+
expect(root.codegenNode).toMatchObject({
603+
children: {
604+
content: '[..._hoisted_2]'
605+
}
606+
})
607+
})
596608
})
597609
})

packages/compiler-core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-core",
3-
"version": "3.3.5",
3+
"version": "3.3.6",
44
"description": "@vue/compiler-core",
55
"main": "index.js",
66
"module": "dist/compiler-core.esm-bundler.js",
@@ -33,7 +33,7 @@
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
3434
"dependencies": {
3535
"@babel/parser": "^7.23.0",
36-
"@vue/shared": "3.3.5",
36+
"@vue/shared": "3.3.6",
3737
"estree-walker": "^2.0.2",
3838
"source-map-js": "^1.0.2"
3939
},

packages/compiler-core/src/options.ts

+6
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ export interface TransformOptions
256256
* needed to render inline CSS variables on component root
257257
*/
258258
ssrCssVars?: string
259+
/**
260+
* Whether to compile the template assuming it needs to handle HMR.
261+
* Some edge cases may need to generate different code for HMR to work
262+
* correctly, e.g. #6938, #7138
263+
*/
264+
hmr?: boolean
259265
}
260266

261267
export interface CodegenOptions extends SharedTransformCodegenOptions {

packages/compiler-core/src/transform.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export interface TransformContext
117117
removeIdentifiers(exp: ExpressionNode | string): void
118118
hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode
119119
cache<T extends JSChildNode>(exp: T, isVNode?: boolean): CacheExpression | T
120-
constantCache: Map<TemplateChildNode, ConstantTypes>
120+
constantCache: WeakMap<TemplateChildNode, ConstantTypes>
121121

122122
// 2.x Compat only
123123
filters?: Set<string>
@@ -129,6 +129,7 @@ export function createTransformContext(
129129
filename = '',
130130
prefixIdentifiers = false,
131131
hoistStatic = false,
132+
hmr = false,
132133
cacheHandlers = false,
133134
nodeTransforms = [],
134135
directiveTransforms = {},
@@ -155,6 +156,7 @@ export function createTransformContext(
155156
selfName: nameMatch && capitalize(camelize(nameMatch[1])),
156157
prefixIdentifiers,
157158
hoistStatic,
159+
hmr,
158160
cacheHandlers,
159161
nodeTransforms,
160162
directiveTransforms,
@@ -181,7 +183,7 @@ export function createTransformContext(
181183
directives: new Set(),
182184
hoists: [],
183185
imports: [],
184-
constantCache: new Map(),
186+
constantCache: new WeakMap(),
185187
temps: 0,
186188
cached: 0,
187189
identifiers: Object.create(null),

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,16 @@ function walk(
140140
node.codegenNode.type === NodeTypes.VNODE_CALL &&
141141
isArray(node.codegenNode.children)
142142
) {
143-
node.codegenNode.children = context.hoist(
143+
const hoisted = context.hoist(
144144
createArrayExpression(node.codegenNode.children)
145145
)
146+
// #6978, #7138, #7114
147+
// a hoisted children array inside v-for can caused HMR errors since
148+
// it might be mutated when mounting the v-for list
149+
if (context.hmr) {
150+
hoisted.content = `[...${hoisted.content}]`
151+
}
152+
node.codegenNode.children = hoisted
146153
}
147154
}
148155

packages/compiler-dom/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-dom",
3-
"version": "3.3.5",
3+
"version": "3.3.6",
44
"description": "@vue/compiler-dom",
55
"main": "index.js",
66
"module": "dist/compiler-dom.esm-bundler.js",
@@ -37,7 +37,7 @@
3737
},
3838
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
3939
"dependencies": {
40-
"@vue/shared": "3.3.5",
41-
"@vue/compiler-core": "3.3.5"
40+
"@vue/shared": "3.3.6",
41+
"@vue/compiler-core": "3.3.6"
4242
}
4343
}

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ export default {
77
props: {
88
\\"modelValue\\": { required: true },
99
\\"count\\": {},
10+
\\"toString\\": { type: Function },
1011
},
11-
emits: [\\"update:modelValue\\", \\"update:count\\"],
12+
emits: [\\"update:modelValue\\", \\"update:count\\", \\"update:toString\\"],
1213
setup(__props, { expose: __expose }) {
1314
__expose();
1415
1516
const modelValue = _useModel(__props, \\"modelValue\\")
1617
const c = _useModel(__props, \\"count\\")
18+
const toString = _useModel(__props, \\"toString\\")
1719
18-
return { modelValue, c }
20+
return { modelValue, c, toString }
1921
}
2022
2123
}"

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('defineModel()', () => {
88
<script setup>
99
const modelValue = defineModel({ required: true })
1010
const c = defineModel('count')
11+
const toString = defineModel('toString', { type: Function })
1112
</script>
1213
`,
1314
{ defineModel: true }
@@ -16,18 +17,22 @@ describe('defineModel()', () => {
1617
expect(content).toMatch('props: {')
1718
expect(content).toMatch('"modelValue": { required: true },')
1819
expect(content).toMatch('"count": {},')
19-
expect(content).toMatch('emits: ["update:modelValue", "update:count"],')
20+
expect(content).toMatch('"toString": { type: Function },')
21+
expect(content).toMatch(
22+
'emits: ["update:modelValue", "update:count", "update:toString"],'
23+
)
2024
expect(content).toMatch(
2125
`const modelValue = _useModel(__props, "modelValue")`
2226
)
2327
expect(content).toMatch(`const c = _useModel(__props, "count")`)
24-
expect(content).toMatch(`return { modelValue, c }`)
28+
expect(content).toMatch(`return { modelValue, c, toString }`)
2529
expect(content).not.toMatch('defineModel')
2630

2731
expect(bindings).toStrictEqual({
2832
modelValue: BindingTypes.SETUP_REF,
2933
count: BindingTypes.PROPS,
30-
c: BindingTypes.SETUP_REF
34+
c: BindingTypes.SETUP_REF,
35+
toString: BindingTypes.SETUP_REF
3136
})
3237
})
3338

0 commit comments

Comments
 (0)