Skip to content

Commit 88d78a8

Browse files
authored
Merge branch 'vuejs:main' into fix/7095
2 parents 60c1b91 + 0002567 commit 88d78a8

File tree

113 files changed

+2345
-1921
lines changed

Some content is hidden

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

113 files changed

+2345
-1921
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports = {
7676
{
7777
files: [
7878
'scripts/**',
79-
'./*.js',
79+
'*.{js,ts}',
8080
'packages/**/index.js',
8181
'packages/size-check/**'
8282
],

.github/workflows/canary.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: canary release
2+
on:
3+
# Runs every Monday at 1 AM UTC (9:00 AM in Singapore)
4+
schedule:
5+
- cron: 0 1 * * MON
6+
workflow_dispatch:
7+
8+
jobs:
9+
canary:
10+
# prevents this action from running on forks
11+
if: github.repository == 'vuejs/core'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@v2
18+
19+
- name: Set node version to 18
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 18
23+
registry-url: 'https://registry.npmjs.org'
24+
cache: 'pnpm'
25+
26+
- run: pnpm install
27+
28+
- run: pnpm release --canary
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ permissions:
1313
jobs:
1414
unit-test:
1515
runs-on: ubuntu-latest
16+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
1617
steps:
1718
- uses: actions/checkout@v3
1819

@@ -32,6 +33,7 @@ jobs:
3233

3334
e2e-test:
3435
runs-on: ubuntu-latest
36+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
3537
steps:
3638
- uses: actions/checkout@v3
3739

@@ -57,6 +59,7 @@ jobs:
5759

5860
lint-and-test-dts:
5961
runs-on: ubuntu-latest
62+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
6063
steps:
6164
- uses: actions/checkout@v3
6265

@@ -82,6 +85,7 @@ jobs:
8285

8386
size:
8487
runs-on: ubuntu-latest
88+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
8589
env:
8690
CI_JOB_NUMBER: 1
8791
steps:
@@ -98,10 +102,3 @@ jobs:
98102

99103
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
100104
- run: pnpm run size
101-
102-
# - name: Check build size
103-
# uses: posva/[email protected]
104-
# with:
105-
# github_token: ${{ secrets.GITHUB_TOKEN }}
106-
# build_script: size
107-
# files: packages/vue/dist/vue.global.prod.js packages/runtime-dom/dist/runtime-dom.global.prod.js packages/size-check/dist/index.js

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# [3.3.0-alpha.5](https://github.com/vuejs/core/compare/v3.3.0-alpha.4...v3.3.0-alpha.5) (2023-03-26)
2+
3+
### Bug Fixes
4+
5+
* **runtime-core:** support `getCurrentInstance` across mutiple builds of Vue ([8d2d5bf](https://github.com/vuejs/core/commit/8d2d5bf48a24dab44e5b03cb8fa0c5faa4b696e3))
6+
* **types:** ensure defineProps with generics return correct types ([c288c7b](https://github.com/vuejs/core/commit/c288c7b0bd6077d690f42153c3fc49a45454a66a))
7+
8+
9+
### Features
10+
11+
* **dx:** improve readability of displayed types for props ([4c9bfd2](https://github.com/vuejs/core/commit/4c9bfd2b999ce472f7481aae4f9dc5bb9f76628e))
12+
* **types/jsx:** support jsxImportSource, avoid global JSX conflict ([#7958](https://github.com/vuejs/core/issues/7958)) ([d0b7ef3](https://github.com/vuejs/core/commit/d0b7ef3b61d5f83e35e5854b3c2c874e23463102))
13+
14+
### Note on JSX Types Change
15+
16+
* In the next minor (3.4), Vue no longer registers the global `JSX` namespace by default. This is necessary to avoid global namespace collision with React so that TSX of both libs can co-exist in the same project. This should not affect SFC-only users with latest version of Volar.
17+
18+
For TSX users, it is suggested to set [jsxImportSource](https://www.typescriptlang.org/tsconfig#jsxImportSource) to `'vue'` in `tsconfig.json` after upgrading to 3.3, or opt-in per file with `/* @jsxImportSource vue */`. This will allow you to opt-in to the new behavior now and upgrade seamlessly when 3.4 releases.
19+
20+
If there is code that depends on the presence of the global `JSX` namespace, you can retain the exact pre-3.4 global behavior by explicitly referencing `vue/jsx`, which registers the global `JSX` namespace.
21+
22+
Note that the planned change in 3.4 is a type-only breaking change in a minor release, which adheres to our [release policy](https://vuejs.org/about/releases.html#semantic-versioning-edge-cases).
23+
124
# [3.3.0-alpha.4](https://github.com/vuejs/core/compare/v3.3.0-alpha.3...v3.3.0-alpha.4) (2023-02-06)
225

326

package.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "3.3.0-alpha.4",
3+
"version": "3.3.0-alpha.5",
44
"packageManager": "[email protected]",
55
"type": "module",
66
"scripts": {
@@ -57,17 +57,17 @@
5757
"devDependencies": {
5858
"@babel/parser": "^7.20.15",
5959
"@babel/types": "^7.20.7",
60-
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
60+
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
6161
"@rollup/plugin-alias": "^4.0.3",
62-
"@rollup/plugin-commonjs": "^23.0.2",
63-
"@rollup/plugin-json": "^5.0.1",
62+
"@rollup/plugin-commonjs": "^24.0.1",
63+
"@rollup/plugin-json": "^6.0.0",
6464
"@rollup/plugin-node-resolve": "^15.0.1",
65-
"@rollup/plugin-replace": "^5.0.1",
66-
"@rollup/plugin-terser": "^0.1.0",
65+
"@rollup/plugin-replace": "^5.0.2",
66+
"@rollup/plugin-terser": "^0.4.0",
6767
"@types/hash-sum": "^1.0.0",
6868
"@types/node": "^16.4.7",
69-
"@typescript-eslint/parser": "^5.23.0",
70-
"@vitest/coverage-istanbul": "^0.28.2",
69+
"@typescript-eslint/parser": "^5.56.0",
70+
"@vitest/coverage-istanbul": "^0.29.7",
7171
"@vue/consolidate": "0.17.3",
7272
"brotli": "^1.3.2",
7373
"chalk": "^4.1.0",
@@ -82,27 +82,25 @@
8282
"jsdom": "^21.1.0",
8383
"lint-staged": "^10.2.10",
8484
"lodash": "^4.17.15",
85-
"magic-string": "^0.27.0",
85+
"magic-string": "^0.30.0",
8686
"marked": "^4.0.10",
8787
"minimist": "^1.2.0",
8888
"npm-run-all": "^4.1.5",
8989
"prettier": "^2.7.1",
9090
"pug": "^3.0.1",
9191
"puppeteer": "^19.6.3",
92-
"rollup": "~3.10.0",
93-
"rollup-plugin-dts": "^5.1.1",
92+
"rollup": "^3.20.2",
93+
"rollup-plugin-dts": "^5.3.0",
9494
"rollup-plugin-esbuild": "^5.0.0",
95-
"rollup-plugin-node-builtins": "^2.1.2",
96-
"rollup-plugin-node-globals": "^1.4.0",
97-
"rollup-plugin-polyfill-node": "^0.11.0",
95+
"rollup-plugin-polyfill-node": "^0.12.0",
9896
"semver": "^7.3.2",
9997
"serve": "^12.0.0",
10098
"simple-git-hooks": "^2.8.1",
10199
"terser": "^5.15.1",
102100
"todomvc-app-css": "^2.3.0",
103-
"tslib": "^2.4.0",
104-
"typescript": "^4.9.0",
105-
"vite": "^4.0.4",
106-
"vitest": "^0.28.5"
101+
"tslib": "^2.5.0",
102+
"typescript": "^5.0.0",
103+
"vite": "^4.2.0",
104+
"vitest": "^0.29.7"
107105
}
108106
}

packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: codegen > ArrayExpression 1`] = `
44
"

packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: integration tests > function mode 1`] = `
44
"const _Vue = Vue

packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: parse > Errors > ABRUPT_CLOSING_OF_EMPTY_COMMENT > <template><!--></template> 1`] = `
44
{

packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`scopeId compiler support > should push scopeId for hoisted nodes 1`] = `
44
"import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: hoistStatic transform > hoist element with static key 1`] = `
44
"const _Vue = Vue

packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: expression transform > bindingMetadata > inline mode 1`] = `
44
"(_ctx, _cache) => {

packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: transform text > <template v-for> 1`] = `
44
"const _Vue = Vue

packages/compiler-core/__tests__/transforms/__snapshots__/vFor.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: v-for > codegen > basic v-for 1`] = `
44
"const _Vue = Vue

packages/compiler-core/__tests__/transforms/__snapshots__/vIf.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: v-if > codegen > basic v-if 1`] = `
44
"const _Vue = Vue

packages/compiler-core/__tests__/transforms/__snapshots__/vMemo.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: v-memo transform > on component 1`] = `
44
"import { resolveComponent as _resolveComponent, createVNode as _createVNode, withMemo as _withMemo, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"

packages/compiler-core/__tests__/transforms/__snapshots__/vModel.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: transform v-model > compound expression (with prefixIdentifiers) 1`] = `
44
"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"

packages/compiler-core/__tests__/transforms/__snapshots__/vOnce.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: v-once transform > as root node 1`] = `
44
"const _Vue = Vue

packages/compiler-core/__tests__/transforms/__snapshots__/vSlot.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: transform component slots > dynamically named slots 1`] = `
44
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = Vue

packages/compiler-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-core",
3-
"version": "3.3.0-alpha.4",
3+
"version": "3.3.0-alpha.5",
44
"description": "@vue/compiler-core",
55
"main": "index.js",
66
"module": "dist/compiler-core.esm-bundler.js",
@@ -32,7 +32,7 @@
3232
},
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
3434
"dependencies": {
35-
"@vue/shared": "3.3.0-alpha.4",
35+
"@vue/shared": "3.3.0-alpha.5",
3636
"@babel/parser": "^7.20.15",
3737
"estree-walker": "^2.0.2",
3838
"source-map": "^0.6.1"

packages/compiler-core/src/ast.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import {
77
OPEN_BLOCK,
88
FRAGMENT,
99
WITH_DIRECTIVES,
10-
WITH_MEMO
10+
WITH_MEMO,
11+
CREATE_VNODE,
12+
CREATE_ELEMENT_VNODE,
13+
CREATE_BLOCK,
14+
CREATE_ELEMENT_BLOCK
1115
} from './runtimeHelpers'
1216
import { PropsExpression } from './transforms/transformElement'
1317
import { ImportItem, TransformContext } from './transform'
14-
import { getVNodeBlockHelper, getVNodeHelper } from './utils'
1518

1619
// Vue template is a platform-agnostic superset of HTML (syntax only).
1720
// More namespaces like SVG and MathML are declared by platform specific
@@ -810,3 +813,23 @@ export function createReturnStatement(
810813
loc: locStub
811814
}
812815
}
816+
817+
export function getVNodeHelper(ssr: boolean, isComponent: boolean) {
818+
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE
819+
}
820+
821+
export function getVNodeBlockHelper(ssr: boolean, isComponent: boolean) {
822+
return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK
823+
}
824+
825+
export function convertToBlock(
826+
node: VNodeCall,
827+
{ helper, removeHelper, inSSR }: TransformContext
828+
) {
829+
if (!node.isBlock) {
830+
node.isBlock = true
831+
removeHelper(getVNodeHelper(inSSR, node.isComponent))
832+
helper(OPEN_BLOCK)
833+
helper(getVNodeBlockHelper(inSSR, node.isComponent))
834+
}
835+
}

packages/compiler-core/src/babelUtils.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import type {
66
Function,
77
ObjectProperty,
88
BlockStatement,
9-
Program
9+
Program,
10+
ImportDefaultSpecifier,
11+
ImportNamespaceSpecifier,
12+
ImportSpecifier
1013
} from '@babel/types'
1114
import { walk } from 'estree-walker'
1215

@@ -38,9 +41,7 @@ export function walkIdentifiers(
3841
if (
3942
parent &&
4043
parent.type.startsWith('TS') &&
41-
parent.type !== 'TSAsExpression' &&
42-
parent.type !== 'TSNonNullExpression' &&
43-
parent.type !== 'TSTypeAssertion'
44+
!TS_NODE_TYPES.includes(parent.type)
4445
) {
4546
return this.skip()
4647
}
@@ -245,6 +246,17 @@ export const isStaticProperty = (node: Node): node is ObjectProperty =>
245246
export const isStaticPropertyKey = (node: Node, parent: Node) =>
246247
isStaticProperty(parent) && parent.key === node
247248

249+
export function getImportedName(
250+
specifier: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
251+
) {
252+
if (specifier.type === 'ImportSpecifier')
253+
return specifier.imported.type === 'Identifier'
254+
? specifier.imported.name
255+
: specifier.imported.value
256+
else if (specifier.type === 'ImportNamespaceSpecifier') return '*'
257+
return 'default'
258+
}
259+
248260
/**
249261
* Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
250262
* To avoid runtime dependency on @babel/types (which includes process references)
@@ -422,3 +434,18 @@ function isReferenced(node: Node, parent: Node, grandparent?: Node): boolean {
422434

423435
return true
424436
}
437+
438+
export const TS_NODE_TYPES = [
439+
'TSAsExpression', // foo as number
440+
'TSTypeAssertion', // (<number>foo)
441+
'TSNonNullExpression', // foo!
442+
'TSInstantiationExpression', // foo<string>
443+
'TSSatisfiesExpression' // foo satisfies T
444+
]
445+
export function unwrapTSNode(node: Node): Node {
446+
if (TS_NODE_TYPES.includes(node.type)) {
447+
return unwrapTSNode((node as any).expression)
448+
} else {
449+
return node
450+
}
451+
}

packages/compiler-core/src/codegen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import {
2424
AssignmentExpression,
2525
ReturnStatement,
2626
VNodeCall,
27-
SequenceExpression
27+
SequenceExpression,
28+
getVNodeBlockHelper,
29+
getVNodeHelper
2830
} from './ast'
2931
import { SourceMapGenerator, RawSourceMap } from 'source-map'
3032
import {
3133
advancePositionWithMutation,
3234
assert,
33-
getVNodeBlockHelper,
34-
getVNodeHelper,
3535
isSimpleIdentifier,
3636
toValidAssetId
3737
} from './utils'

0 commit comments

Comments
 (0)