Skip to content

Commit

Permalink
Merge pull request #109 from vuejs/main
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Tomxuetao authored Jul 11, 2023
2 parents f2eea79 + 3decc57 commit 99d373b
Show file tree
Hide file tree
Showing 162 changed files with 1,402 additions and 657 deletions.
4 changes: 2 additions & 2 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ import { h } from '@vue/runtime-core'
This is made possible via several configurations:

- For TypeScript, `compilerOptions.paths` in `tsconfig.json`
- Vitest and Rollup share the sae set of aliases from `scripts/aliases.js`
- Vitest and Rollup share the same set of aliases from `scripts/aliases.js`
- For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).

### Package Dependencies
Expand Down Expand Up @@ -330,4 +330,4 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu

Thank you to all the people who have already contributed to Vue.js!

<a href="https://github.com/vuejs/vue/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
<a href="https://github.com/vuejs/core/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
2 changes: 1 addition & 1 deletion BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Vue.js is an MIT-licensed open source project with its ongoing development made

<p align="center">
<a target="_blank" href="https://sponsors.vuejs.org/backers.svg">
<img alt="sponsors" src="https://sponsors.vuejs.org/backers.svg">
<img alt="sponsors" src="https://sponsors.vuejs.org/backers.svg?v1">
</a>
</p>
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [3.3.4](https://github.com/vuejs/core/compare/v3.3.3...v3.3.4) (2023-05-18)


### Bug Fixes

* **build:** ensure correct typing for node esm ([d621d4c](https://github.com/vuejs/core/commit/d621d4c646b2d7b190fbd44ad1fd04512b3de300))
* **build:** fix __DEV__ flag replacement edge case ([8b7c04b](https://github.com/vuejs/core/commit/8b7c04b18f73aad9a08dd57eba90101b5b2aef28)), closes [#8353](https://github.com/vuejs/core/issues/8353)
* **compiler-sfc:** handle imported types from default exports ([5aec717](https://github.com/vuejs/core/commit/5aec717a2402652306085f58432ba3ab91848a74)), closes [#8355](https://github.com/vuejs/core/issues/8355)



## [3.3.3](https://github.com/vuejs/core/compare/v3.3.2...v3.3.3) (2023-05-18)


### Bug Fixes

* avoid regex s flag for old browsers ([91f1c62](https://github.com/vuejs/core/commit/91f1c62e6384a8b09f90e7e43b8d347901e529a0)), closes [#8316](https://github.com/vuejs/core/issues/8316)
* **build:** fix dev flag replacement in esm-builder builds ([#8314](https://github.com/vuejs/core/issues/8314)) ([003836f](https://github.com/vuejs/core/commit/003836f90e1f00ebd04b77ec07ccfa4e649a2ff4)), closes [#8312](https://github.com/vuejs/core/issues/8312)
* **compiler-sfc:** don't hoist regexp literial ([#8300](https://github.com/vuejs/core/issues/8300)) ([8ec73a3](https://github.com/vuejs/core/commit/8ec73a3aea7a52e9479f107ae5737761166ddae6))
* **compiler-sfc:** fix props destructing default value type checking with unresolved type ([#8340](https://github.com/vuejs/core/issues/8340)) ([f69dbab](https://github.com/vuejs/core/commit/f69dbabf8794426c3e9ed33ae77dd8ce655eafd2)), closes [#8326](https://github.com/vuejs/core/issues/8326)
* **compiler-sfc:** fix type import from path aliased vue file ([fab9c72](https://github.com/vuejs/core/commit/fab9c727805c6186c490f99023e8cf5401b0b5a9)), closes [#8348](https://github.com/vuejs/core/issues/8348)
* **compiler-sfc:** handle ts files with relative imports with .js extension ([b36addd](https://github.com/vuejs/core/commit/b36addd3bde07467e9ff5641bd1c2bdc3085944c)), closes [#8339](https://github.com/vuejs/core/issues/8339)
* **compiler-sfc:** parses correctly when inline mode is off ([#8337](https://github.com/vuejs/core/issues/8337)) ([ecbd42a](https://github.com/vuejs/core/commit/ecbd42a1444e3c599e464dec002e43d548d99669)), closes [#6088](https://github.com/vuejs/core/issues/6088)
* **compiler-sfc:** support defineEmits type reference with unions ([#8299](https://github.com/vuejs/core/issues/8299)) ([b133e0f](https://github.com/vuejs/core/commit/b133e0fd97b0b4fabbb43151c19031b8fb47c05b)), closes [#7943](https://github.com/vuejs/core/issues/7943)
* **types:** support generic usage with withDefaults + defineProps ([#8335](https://github.com/vuejs/core/issues/8335)) ([216f269](https://github.com/vuejs/core/commit/216f26995b63c2df26ca0f39f390fe8d59cdabfa)), closes [#8310](https://github.com/vuejs/core/issues/8310) [#8331](https://github.com/vuejs/core/issues/8331) [#8325](https://github.com/vuejs/core/issues/8325)



## [3.3.2](https://github.com/vuejs/core/compare/v3.3.1...v3.3.2) (2023-05-12)


Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.3.2",
"packageManager": "pnpm@8.4.0",
"version": "3.3.4",
"packageManager": "pnpm@8.6.2",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"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",
"build-ssr-esm": "node scripts/build.js compiler-sfc server-renderer -f esm-browser",
"build-sfc-playground-self": "cd packages/sfc-playground && npm run build",
"preinstall": "node ./scripts/preinstall.js",
"preinstall": "npx only-allow pnpm",
"postinstall": "simple-git-hooks"
},
"simple-git-hooks": {
Expand Down
1 change: 0 additions & 1 deletion 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 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
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
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
1 change: 0 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
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
4 changes: 2 additions & 2 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.2",
"version": "3.3.4",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
Expand Down Expand Up @@ -33,7 +33,7 @@
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
"dependencies": {
"@babel/parser": "^7.21.3",
"@vue/shared": "3.3.2",
"@vue/shared": "3.3.4",
"estree-walker": "^2.0.2",
"source-map-js": "^1.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/src/babelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function walkIdentifiers(
root.body[0].type === 'ExpressionStatement' &&
root.body[0].expression

;(walk as any)(root, {
walk(root, {
enter(node: Node & { scopeIds?: Set<string> }, parent: Node | undefined) {
parent && parentStack.push(parent)
if (
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-core/src/transforms/transformExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '../babelUtils'
import { advancePositionWithClone, isSimpleIdentifier } from '../utils'
import {
isGloballyWhitelisted,
isGloballyAllowed,
makeMap,
hasOwn,
isString,
Expand Down Expand Up @@ -225,7 +225,7 @@ export function processExpression(

if (isSimpleIdentifier(rawExp)) {
const isScopeVarReference = context.identifiers[rawExp]
const isAllowedGlobal = isGloballyWhitelisted(rawExp)
const isAllowedGlobal = isGloballyAllowed(rawExp)
const isLiteral = isLiteralWhitelisted(rawExp)
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
// const bindings exposed from setup can be skipped for patching but
Expand Down Expand Up @@ -358,7 +358,7 @@ export function processExpression(

function canPrefix(id: Identifier) {
// skip whitelisted globals
if (isGloballyWhitelisted(id.name)) {
if (isGloballyAllowed(id.name)) {
return false
}
// special case for webpack compilation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { compile } from '../../src'

describe('Transition multi children warnings', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-dom/__tests__/transforms/vHtml.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-dom/__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
1 change: 0 additions & 1 deletion packages/compiler-dom/__tests__/transforms/vShow.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-dom/__tests__/transforms/vText.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
6 changes: 3 additions & 3 deletions packages/compiler-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.3.2",
"version": "3.3.4",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
"dependencies": {
"@vue/shared": "3.3.2",
"@vue/compiler-core": "3.3.2"
"@vue/shared": "3.3.4",
"@vue/compiler-core": "3.3.4"
}
}
4 changes: 2 additions & 2 deletions packages/compiler-dom/src/decodeHtmlBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function decodeHtmlBrowser(raw: string, asAttr = false): string {
}
if (asAttr) {
decoder.innerHTML = `<div foo="${raw.replace(/"/g, '&quot;')}">`
return decoder.children[0].getAttribute('foo') as string
return decoder.children[0].getAttribute('foo')!
} else {
decoder.innerHTML = raw
return decoder.textContent as string
return decoder.textContent!
}
}
19 changes: 19 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,25 @@ describe('SFC compile <script setup>', () => {
expect(content).toMatch(`"--${mockId}-count": (count.value)`)
assertCode(content)
})

test('the v-for wrapped in parentheses can be correctly parsed & inline is false', () => {
expect(() =>
compile(
`
<script setup lang="ts">
import { ref } from 'vue'
const stacks = ref([])
</script>
<template>
<div v-for="({ file: efile }) of stacks"></div>
</template>
`,
{
inlineTemplate: false
}
)
).not.toThrowError()
})
})

describe('with TypeScript', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ export default /*#__PURE__*/_defineComponent({
return { emit }
}
})"
`;

exports[`defineEmits > w/ type (type references in union) 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
type BaseEmit = \\"change\\"
type Emit = \\"some\\" | \\"emit\\" | BaseEmit
export default /*#__PURE__*/_defineComponent({
emits: [\\"some\\", \\"emit\\", \\"change\\", \\"another\\"],
setup(__props, { expose: __expose, emit }) {
__expose();
return { emit }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ exports[`sfc hoist static > should hoist literal value 1`] = `
const nil = null
const bigint = 100n
const template = \`str\`
const regex = /.*/g
export default {
setup(__props) {
Expand Down Expand Up @@ -124,6 +123,8 @@ exports[`sfc hoist static > should not hoist a variable 1`] = `
let KEY1 = 'default value'
var KEY2 = 123
const regex = /.*/g
const undef = undefined
return () => {}
}
Expand Down
17 changes: 17 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ const emit = defineEmits(['a', 'b'])
assertCode(content)
})

// #7943
test('w/ type (type references in union)', () => {
const { content } = compile(`
<script setup lang="ts">
type BaseEmit = "change"
type Emit = "some" | "emit" | BaseEmit
const emit = defineEmits<{
(e: Emit): void;
(e: "another", val: string): void;
}>();
</script>
`)

expect(content).toMatch(`emits: ["some", "emit", "change", "another"]`)
assertCode(content)
})

describe('errors', () => {
test('w/ both type and non-type args', () => {
expect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('sfc hoist static', () => {
const nil = null
const bigint = 100n
const template = \`str\`
const regex = /.*/g
`.trim()
const { content, bindings } = compile(`
<script setup>
Expand All @@ -35,8 +34,7 @@ describe('sfc hoist static', () => {
boolean: BindingTypes.LITERAL_CONST,
nil: BindingTypes.LITERAL_CONST,
bigint: BindingTypes.LITERAL_CONST,
template: BindingTypes.LITERAL_CONST,
regex: BindingTypes.LITERAL_CONST
template: BindingTypes.LITERAL_CONST
})
assertCode(content)
})
Expand Down Expand Up @@ -90,6 +88,8 @@ describe('sfc hoist static', () => {
const code = `
let KEY1 = 'default value'
var KEY2 = 123
const regex = /.*/g
const undef = undefined
`.trim()
const { content, bindings } = compile(`
<script setup>
Expand All @@ -98,7 +98,9 @@ describe('sfc hoist static', () => {
`)
expect(bindings).toStrictEqual({
KEY1: BindingTypes.SETUP_LET,
KEY2: BindingTypes.SETUP_LET
KEY2: BindingTypes.SETUP_LET,
regex: BindingTypes.SETUP_CONST,
undef: BindingTypes.SETUP_MAYBE_REF
})
expect(content).toMatch(`setup(__props) {\n\n ${code}`)
assertCode(content)
Expand Down
Loading

0 comments on commit 99d373b

Please sign in to comment.