Skip to content

Commit

Permalink
Merge branch 'main' into feat/v-model-details-dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Jun 7, 2023
2 parents 43839c3 + a95e612 commit 3e2efe0
Show file tree
Hide file tree
Showing 213 changed files with 12,609 additions and 8,986 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,40 @@ jobs:
node-version: 18
cache: 'pnpm'

- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
- name: Skip Puppeteer download
run: echo "PUPPETEER_SKIP_DOWNLOAD=1" >> $GITHUB_ENV

- run: pnpm install

- name: Run unit tests
run: pnpm run test-unit

unit-test-windows:
runs-on: windows-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node version to 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Skip Puppeteer download
run: echo "PUPPETEER_SKIP_DOWNLOAD=1" >> $env:GITHUB_ENV

- run: pnpm install

- name: Run compiler unit tests
run: pnpm run test-unit compiler

- name: Run ssr unit tests
run: pnpm run test-unit server-renderer

e2e-test:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand Down Expand Up @@ -72,7 +101,10 @@ jobs:
node-version: 18
cache: 'pnpm'

- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
- name: Skip Puppeteer download
run: echo "PUPPETEER_SKIP_DOWNLOAD=1" >> $GITHUB_ENV

- run: pnpm install

- name: Run eslint
run: pnpm run lint
Expand Down
3,160 changes: 200 additions & 2,960 deletions CHANGELOG.md

Large diffs are not rendered by default.

1,617 changes: 1,617 additions & 0 deletions changelogs/CHANGELOG-3.0.md

Large diffs are not rendered by default.

320 changes: 320 additions & 0 deletions changelogs/CHANGELOG-3.1.md

Large diffs are not rendered by default.

1,067 changes: 1,067 additions & 0 deletions changelogs/CHANGELOG-3.2.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.3.0-alpha.9",
"packageManager": "pnpm@7.26.0",
"version": "3.3.4",
"packageManager": "pnpm@8.4.0",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
Expand Down Expand Up @@ -57,7 +57,6 @@
"devDependencies": {
"@babel/parser": "^7.21.3",
"@babel/types": "^7.21.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@rollup/plugin-alias": "^4.0.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-json": "^6.0.0",
Expand All @@ -69,11 +68,11 @@
"@typescript-eslint/parser": "^5.56.0",
"@vitest/coverage-istanbul": "^0.29.7",
"@vue/consolidate": "0.17.3",
"brotli": "^1.3.2",
"chalk": "^4.1.0",
"conventional-changelog-cli": "^2.0.31",
"enquirer": "^2.3.2",
"esbuild": "^0.17.4",
"esbuild-plugin-polyfill-node": "^0.2.0",
"eslint": "^8.33.0",
"eslint-plugin-jest": "^27.2.1",
"estree-walker": "^2.0.2",
Expand All @@ -99,7 +98,7 @@
"todomvc-app-css": "^2.3.0",
"tslib": "^2.5.0",
"typescript": "^5.0.0",
"vite": "^4.2.0",
"vitest": "^0.29.7"
"vite": "^4.3.0",
"vitest": "^0.30.1"
}
}
2 changes: 1 addition & 1 deletion packages/compiler-core/__tests__/compile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { baseCompile as compile } from '../src'
import { SourceMapConsumer, RawSourceMap } from 'source-map'
import { SourceMapConsumer, RawSourceMap } from 'source-map-js'

describe('compiler: integration tests', () => {
const source = `
Expand Down
32 changes: 30 additions & 2 deletions packages/compiler-core/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { ParserOptions } from '../src/options'
import { baseParse, TextModes } from '../src/parse'
import { ErrorCodes } from '../src/errors'
Expand All @@ -11,7 +10,8 @@ import {
Position,
TextNode,
InterpolationNode,
ConstantTypes
ConstantTypes,
DirectiveNode
} from '../src/ast'

describe('compiler: parse', () => {
Expand Down Expand Up @@ -1164,6 +1164,34 @@ describe('compiler: parse', () => {
})
})

// #3494
test('directive argument edge case', () => {
const ast = baseParse('<div v-slot:slot />')
const directive = (ast.children[0] as ElementNode)
.props[0] as DirectiveNode
expect(directive.arg).toMatchObject({
loc: {
start: { offset: 12, line: 1, column: 13 },
end: { offset: 16, line: 1, column: 17 },
source: 'slot'
}
})
})

// https://github.com/vuejs/language-tools/issues/2710
test('directive argument edge case (2)', () => {
const ast = baseParse('<div #item.item />')
const directive = (ast.children[0] as ElementNode)
.props[0] as DirectiveNode
expect(directive.arg).toMatchObject({
loc: {
start: { offset: 6, line: 1, column: 7 },
end: { offset: 15, line: 1, column: 16 },
source: 'item.item'
}
})
})

test('directive with dynamic argument', () => {
const ast = baseParse('<div v-on:[event]/>')
const directive = (ast.children[0] as ElementNode).props[0]
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transform.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { baseParse } from '../src/parse'
import { transform, NodeTransform } from '../src/transform'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
CompilerOptions,
baseParse as parse,
Expand Down Expand Up @@ -998,7 +997,7 @@ describe('compiler: element transform', () => {
})

test('NEED_PATCH (vnode hooks)', () => {
const root = baseCompile(`<div @vnodeUpdated="foo" />`, {
const root = baseCompile(`<div @vue:updated="foo" />`, {
prefixIdentifiers: true,
cacheHandlers: true
}).ast
Expand Down Expand Up @@ -1184,6 +1183,7 @@ describe('compiler: element transform', () => {
})
})

// TODO remove in 3.4
test('v-is', () => {
const { node, root } = parseWithBind(`<div v-is="'foo'" />`)
expect(root.helpers).toContain(RESOLVE_DYNAMIC_COMPONENT)
Expand All @@ -1201,6 +1201,7 @@ describe('compiler: element transform', () => {
// should skip v-is runtime check
directives: undefined
})
expect('v-is="component-name" has been deprecated').toHaveBeenWarned()
})

// #3934
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down Expand Up @@ -431,6 +430,16 @@ describe('compiler: expression transform', () => {
})
})

// #8295
test('should treat floating point number literals as constant', () => {
const node = parseWithExpressionTransform(
`{{ [1, 2.1] }}`
) as InterpolationNode
expect(node.content).toMatchObject({
constType: ConstantTypes.CAN_STRINGIFY
})
})

describe('ES Proposals support', () => {
test('bigInt', () => {
const node = parseWithExpressionTransform(
Expand Down Expand Up @@ -549,7 +558,7 @@ describe('compiler: expression transform', () => {

test('literal const handling, non-inline mode', () => {
const { code } = compileWithBindingMetadata(`<div>{{ literal }}</div>`)
expect(code).toMatch(`toDisplayString(literal)`)
expect(code).toMatch(`toDisplayString($setup.literal)`)
// #7973 should skip patch for literal const
expect(code).not.toMatch(
`${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
CompilerOptions,
baseParse as parse,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vBind.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vFor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { baseParse as parse } from '../../src/parse'
import { transform } from '../../src/transform'
import { transformIf } from '../../src/transforms/vIf'
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vIf.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { baseParse as parse } from '../../src/parse'
import { transform } from '../../src/transform'
import { transformIf } from '../../src/transforms/vIf'
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vModel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-core/__tests__/transforms/vOn.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
CompilerOptions,
Expand Down Expand Up @@ -438,6 +437,7 @@ describe('compiler: transform v-on', () => {
})
})

// TODO remove in 3.4
test('case conversion for vnode hooks', () => {
const { node } = parseWithVOn(`<div v-on:vnode-mounted="onMount"/>`)
expect((node.codegenNode as VNodeCall).props).toMatchObject({
Expand All @@ -452,6 +452,7 @@ describe('compiler: transform v-on', () => {
}
]
})
expect('@vnode-* hooks in templates are deprecated').toHaveBeenWarned()
})

test('vue: prefixed events', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vSlot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
CompilerOptions,
baseParse as parse,
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.3.0-alpha.9",
"version": "3.3.4",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
Expand Down Expand Up @@ -33,9 +33,9 @@
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
"dependencies": {
"@babel/parser": "^7.21.3",
"@vue/shared": "3.3.0-alpha.9",
"@vue/shared": "3.3.4",
"estree-walker": "^2.0.2",
"source-map": "^0.6.1"
"source-map-js": "^1.0.2"
},
"devDependencies": {
"@babel/types": "^7.21.3"
Expand Down
39 changes: 1 addition & 38 deletions packages/compiler-core/src/babelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import type {
Function,
ObjectProperty,
BlockStatement,
Program,
ImportDefaultSpecifier,
ImportNamespaceSpecifier,
ImportSpecifier,
CallExpression
Program
} from '@babel/types'
import { walk } from 'estree-walker'

Expand Down Expand Up @@ -247,17 +243,6 @@ export const isStaticProperty = (node: Node): node is ObjectProperty =>
export const isStaticPropertyKey = (node: Node, parent: Node) =>
isStaticProperty(parent) && parent.key === node

export function getImportedName(
specifier: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
) {
if (specifier.type === 'ImportSpecifier')
return specifier.imported.type === 'Identifier'
? specifier.imported.name
: specifier.imported.value
else if (specifier.type === 'ImportNamespaceSpecifier') return '*'
return 'default'
}

/**
* Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
* To avoid runtime dependency on @babel/types (which includes process references)
Expand Down Expand Up @@ -443,25 +428,3 @@ export const TS_NODE_TYPES = [
'TSInstantiationExpression', // foo<string>
'TSSatisfiesExpression' // foo satisfies T
]
export function unwrapTSNode(node: Node): Node {
if (TS_NODE_TYPES.includes(node.type)) {
return unwrapTSNode((node as any).expression)
} else {
return node
}
}

export function isCallOf(
node: Node | null | undefined,
test: string | ((id: string) => boolean) | null | undefined
): node is CallExpression {
return !!(
node &&
test &&
node.type === 'CallExpression' &&
node.callee.type === 'Identifier' &&
(typeof test === 'string'
? node.callee.name === test
: test(node.callee.name))
)
}
2 changes: 1 addition & 1 deletion packages/compiler-core/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
getVNodeBlockHelper,
getVNodeHelper
} from './ast'
import { SourceMapGenerator, RawSourceMap } from 'source-map'
import { SourceMapGenerator, RawSourceMap } from 'source-map-js'
import {
advancePositionWithMutation,
assert,
Expand Down
8 changes: 8 additions & 0 deletions packages/compiler-core/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export const enum ErrorCodes {
X_CACHE_HANDLER_NOT_SUPPORTED,
X_SCOPE_ID_NOT_SUPPORTED,

// deprecations
DEPRECATION_VNODE_HOOKS,
DEPRECATION_V_IS,

// Special value for higher-order compilers to pick up the last code
// to avoid collision of error codes. This should always be kept as the last
// item.
Expand Down Expand Up @@ -179,6 +183,10 @@ export const errorMessages: Record<ErrorCodes, string> = {
[ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
[ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED]: `"scopeId" option is only supported in module mode.`,

// deprecations
[ErrorCodes.DEPRECATION_VNODE_HOOKS]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
[ErrorCodes.DEPRECATION_V_IS]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,

// just to fulfill types
[ErrorCodes.__EXTEND_POINT__]: ``
}
7 changes: 5 additions & 2 deletions packages/compiler-core/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ function isComponent(
}
} else {
// directive
// v-is (TODO Deprecate)
// v-is (TODO: remove in 3.4)
if (p.name === 'is') {
return true
} else if (
Expand Down Expand Up @@ -817,7 +817,10 @@ function parseAttribute(

if (match[2]) {
const isSlot = dirName === 'slot'
const startOffset = name.lastIndexOf(match[2])
const startOffset = name.lastIndexOf(
match[2],
name.length - (match[3]?.length || 0)
)
const loc = getSelection(
context,
getNewPosition(context, start, startOffset),
Expand Down
Loading

0 comments on commit 3e2efe0

Please sign in to comment.