diff --git a/CHANGELOG.md b/CHANGELOG.md index bc98f138f33..4c75474b8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,83 @@ +## [2.7.13](https://github.com/vuejs/vue/compare/v2.7.12...v2.7.13) (2022-10-14) + + +### Bug Fixes + +* **effectScope:** calling off() of a detached scope should not break currentScope ([800207c](https://github.com/vuejs/vue/commit/800207c473c7d6dfcdc883100a3d443fc5ad2e39)), closes [#12825](https://github.com/vuejs/vue/issues/12825) +* **types:** style attribute svg ([#12800](https://github.com/vuejs/vue/issues/12800)) ([8e26261](https://github.com/vuejs/vue/commit/8e262618cdc3251ca9630b17de4a000567ffb007)) +* **watch:** avoid traversing objects that are marked non-reactive ([#12806](https://github.com/vuejs/vue/issues/12806)) ([5960f05](https://github.com/vuejs/vue/commit/5960f05c69099c174062b6672c7a21d717a3bccf)) + + + +## [2.7.12](https://github.com/vuejs/vue/compare/v2.7.11...v2.7.12) (2022-10-12) + + +### Reverts + +* Revert "fix(setup): setup hook should be called before beforeCreate" ([e80cd09](https://github.com/vuejs/vue/commit/e80cd09fff570df57d608f8f5aaccee6d7f31917)), closes [#12802](https://github.com/vuejs/vue/issues/12802) [#12821](https://github.com/vuejs/vue/issues/12821) [#12822](https://github.com/vuejs/vue/issues/12822) + + + +## [2.7.11](https://github.com/vuejs/vue/compare/v2.7.10...v2.7.11) (2022-10-11) + + +### Bug Fixes + +* **build:** enforce LF line ending in built files ([738f4b3](https://github.com/vuejs/vue/commit/738f4b3c570dc3a1818924a203a9f8e4b1ec90f0)), closes [#12819](https://github.com/vuejs/vue/issues/12819) +* **compiler-sfc:** export parseComponent for compat with fork-ts-checker-webpack-plugin ([0d6d972](https://github.com/vuejs/vue/commit/0d6d972b32521fd18eb853b1073c0a19859a499a)), closes [#12719](https://github.com/vuejs/vue/issues/12719) +* **reactivity:** check skip first before checking ref when creating observer ([#12813](https://github.com/vuejs/vue/issues/12813)) ([5d26f81](https://github.com/vuejs/vue/commit/5d26f815c643d41e6ca6f29329593223b981fc24)), closes [#12812](https://github.com/vuejs/vue/issues/12812) +* **reactivity:** use WeakMap for proxy/raw checks, compat with non-extensible objects ([4a0d88e](https://github.com/vuejs/vue/commit/4a0d88e46e4180edc7f22e36c25df3f8ac5d60d2)), closes [#12799](https://github.com/vuejs/vue/issues/12799) [#12798](https://github.com/vuejs/vue/issues/12798) +* **setup:** setup hook should be called before beforeCreate ([e1342df](https://github.com/vuejs/vue/commit/e1342df7847a51c75192fec74e94378178e046b0)), closes [#12802](https://github.com/vuejs/vue/issues/12802) +* **sfc:** prune returned bindings for non-TS as well ([fb13930](https://github.com/vuejs/vue/commit/fb1393009660b38046b1f6dfb532b481cc53b3b7)), closes [#12765](https://github.com/vuejs/vue/issues/12765) +* **sfc:** remove sfc scoped deep syntax deprecation warnings ([2f335b2](https://github.com/vuejs/vue/commit/2f335b2f9d09b962f40e38740826d444e4fff073)) +* **types:** fix error with options watch ([#12779](https://github.com/vuejs/vue/issues/12779)) ([bc5b92a](https://github.com/vuejs/vue/commit/bc5b92adde147436f2adb25e457f0c967829467f)), closes [#12780](https://github.com/vuejs/vue/issues/12780) +* **types:** support Ref and function types in tsx ref attribute ([#12759](https://github.com/vuejs/vue/issues/12759)) ([87f69aa](https://github.com/vuejs/vue/commit/87f69aa26f195390b948fbb0ff62cf954b58c82c)), closes [#12758](https://github.com/vuejs/vue/issues/12758) +* **types:** vue 3 directive type compatibility ([#12792](https://github.com/vuejs/vue/issues/12792)) ([27eed82](https://github.com/vuejs/vue/commit/27eed829ccf9978a63b8cd989ff4c03897276bc2)) + + +### Performance Improvements + +* improve unsub perf for deps with massive amount of subs ([8880b55](https://github.com/vuejs/vue/commit/8880b55d52f8d873f79ef67436217c8752cddef5)), closes [#12696](https://github.com/vuejs/vue/issues/12696) + + + +## [2.7.10](https://github.com/vuejs/vue/compare/v2.7.9...v2.7.10) (2022-08-23) + + +### Bug Fixes + +* **compiler-sfc:** avoid deindent when lang is jsx/tsx ([46ca7bc](https://github.com/vuejs/vue/commit/46ca7bcddc06c50796ccff82d8c45693f1f14f47)), closes [#12755](https://github.com/vuejs/vue/issues/12755) +* fix parent of multi-nested HOC $el not updating ([#12757](https://github.com/vuejs/vue/issues/12757)) ([e0b26c4](https://github.com/vuejs/vue/commit/e0b26c483a1ba407a818b1fcba1a439df24e84a8)), closes [#12589](https://github.com/vuejs/vue/issues/12589) +* **types:** Add missing type parameter constraints ([#12754](https://github.com/vuejs/vue/issues/12754)) ([810f6d1](https://github.com/vuejs/vue/commit/810f6d12edea47cde7f39eaf7ec3ae1b7300d40c)) + + + +## [2.7.9](https://github.com/vuejs/vue/compare/v2.7.8...v2.7.9) (2022-08-19) + + +### Bug Fixes + +* **compiler-sfc:** allow full hostnames in asset url base ([#12732](https://github.com/vuejs/vue/issues/12732)) ([5c742eb](https://github.com/vuejs/vue/commit/5c742eb2e0d8dad268fb29ed4f92d286b5e0f4b5)), closes [#12731](https://github.com/vuejs/vue/issues/12731) +* **compiler-sfc:** rewriteDefault for class with decorators ([#12747](https://github.com/vuejs/vue/issues/12747)) ([5221d4d](https://github.com/vuejs/vue/commit/5221d4d3b6049c87d196d99dbb64bcd3f3b07279)) +* directives shorthand normalize error ([#12744](https://github.com/vuejs/vue/issues/12744)) ([2263948](https://github.com/vuejs/vue/commit/2263948c249e7486403bc5880712e6d9fd15c17f)), closes [#12743](https://github.com/vuejs/vue/issues/12743) +* ensure render watcher of manually created instance is correctly tracked in owner scope ([bd89ce5](https://github.com/vuejs/vue/commit/bd89ce53a9de417a9372630bb5d433a40acc1a53)), closes [#12701](https://github.com/vuejs/vue/issues/12701) +* fix effect scope tracking for manually created instances ([7161176](https://github.com/vuejs/vue/commit/7161176cd0dff10d65ab58e266018aff2660610f)), closes [#12705](https://github.com/vuejs/vue/issues/12705) +* **ssr:** fix on-component directives rendering ([#12661](https://github.com/vuejs/vue/issues/12661)) ([165a14a](https://github.com/vuejs/vue/commit/165a14a6c6c406176037465d2961259c5c980399)), closes [#10733](https://github.com/vuejs/vue/issues/10733) +* **types:** allow attaching unknown options to defined component ([b4bf4c5](https://github.com/vuejs/vue/commit/b4bf4c52ad31e02307cfd4d643dc5610c893e3ba)), closes [#12742](https://github.com/vuejs/vue/issues/12742) +* **types:** fix missing error for accessing undefined instance properties ([8521f9d](https://github.com/vuejs/vue/commit/8521f9d3f63d26bde99b747f0cb14d0ac5ba5971)), closes [#12718](https://github.com/vuejs/vue/issues/12718) +* **types:** fix options suggestions when using defineComponent ([4b37b56](https://github.com/vuejs/vue/commit/4b37b568c7c3fd238aa61fcc956f882223f8e87f)), closes [#12736](https://github.com/vuejs/vue/issues/12736) +* **types:** Make SetupBindings optional on ExtendedVue and CombinedVueInstance ([#12727](https://github.com/vuejs/vue/issues/12727)) ([00458cd](https://github.com/vuejs/vue/commit/00458cd38d209410d3c675729230a42a0a34a4b9)), closes [#12726](https://github.com/vuejs/vue/issues/12726) [#12717](https://github.com/vuejs/vue/issues/12717) +* **watch:** avoid pre watcher firing on unmount ([f0057b1](https://github.com/vuejs/vue/commit/f0057b101e6451d5095cdb7fd6308fd31ac0450c)), closes [#12703](https://github.com/vuejs/vue/issues/12703) + + +### Features + +* **types:** enhance type for onErrorCaptured ([#12735](https://github.com/vuejs/vue/issues/12735)) ([bba6b3d](https://github.com/vuejs/vue/commit/bba6b3d6b4e3e26d28abbf20e74ec2f3e64f1a92)) +* **types:** export DefineComponent ([80d1baf](https://github.com/vuejs/vue/commit/80d1baf92050da411fb1bfe714401c498001dd36)), closes [#12748](https://github.com/vuejs/vue/issues/12748) +* **types:** support mixins inference for new Vue() ([#12737](https://github.com/vuejs/vue/issues/12737)) ([89a6b5e](https://github.com/vuejs/vue/commit/89a6b5e8658a6e3ae2cf649829901784ac9deb3c)), closes [#12730](https://github.com/vuejs/vue/issues/12730) + + + ## [2.7.8](https://github.com/vuejs/vue/compare/v2.7.7...v2.7.8) (2022-07-22) diff --git a/README.md b/README.md index 5a3f576d716..bca41a49405 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,19 @@ You are looking at the repository for Vue 2. The repo for Vue 3 is [vuejs/core]( Vue.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome [backers](https://github.com/vuejs/core/blob/main/BACKERS.md). If you'd like to join them, please consider [ sponsor Vue's development](https://vuejs.org/sponsor/). +

+

Special Sponsor

+

+ +

+ + special sponsor appwrite + +

+

- sponsors + sponsors

@@ -73,7 +83,7 @@ Vue.js supports all browsers that are [ES5-compliant](https://kangax.github.io/c ## Documentation -To check out [live examples](https://vuejs.org/v2/examples/) and docs, visit [vuejs.org](https://vuejs.org). +To check out [live examples](https://v2.vuejs.org/v2/examples/) and docs, visit [vuejs.org](https://v2.vuejs.org). ## Questions diff --git a/dist/vue.runtime.mjs b/dist/vue.runtime.mjs index 886d9f163ca..83d889271bd 100644 --- a/dist/vue.runtime.mjs +++ b/dist/vue.runtime.mjs @@ -1,76 +1,76 @@ -import Vue from './vue.runtime.common.js' -export default Vue - -// this should be kept in sync with src/v3/index.ts -export const { - version, - - // refs - ref, - shallowRef, - isRef, - toRef, - toRefs, - unref, - proxyRefs, - customRef, - triggerRef, - computed, - - // reactive - reactive, - isReactive, - isReadonly, - isShallow, - isProxy, - shallowReactive, - markRaw, - toRaw, - readonly, - shallowReadonly, - - // watch - watch, - watchEffect, - watchPostEffect, - watchSyncEffect, - - // effectScope - effectScope, - onScopeDispose, - getCurrentScope, - - // provide / inject - provide, - inject, - - // lifecycle - onBeforeMount, - onMounted, - onBeforeUpdate, - onUpdated, - onBeforeUnmount, - onUnmounted, - onErrorCaptured, - onActivated, - onDeactivated, - onServerPrefetch, - onRenderTracked, - onRenderTriggered, - - // v2 only - set, - del, - - // v3 compat - h, - getCurrentInstance, - useSlots, - useAttrs, - mergeDefaults, - nextTick, - useCssModule, - useCssVars, - defineComponent, - defineAsyncComponent -} = Vue +import Vue from './vue.runtime.common.js' +export default Vue + +// this should be kept in sync with src/v3/index.ts +export const { + version, + + // refs + ref, + shallowRef, + isRef, + toRef, + toRefs, + unref, + proxyRefs, + customRef, + triggerRef, + computed, + + // reactive + reactive, + isReactive, + isReadonly, + isShallow, + isProxy, + shallowReactive, + markRaw, + toRaw, + readonly, + shallowReadonly, + + // watch + watch, + watchEffect, + watchPostEffect, + watchSyncEffect, + + // effectScope + effectScope, + onScopeDispose, + getCurrentScope, + + // provide / inject + provide, + inject, + + // lifecycle + onBeforeMount, + onMounted, + onBeforeUpdate, + onUpdated, + onBeforeUnmount, + onUnmounted, + onErrorCaptured, + onActivated, + onDeactivated, + onServerPrefetch, + onRenderTracked, + onRenderTriggered, + + // v2 only + set, + del, + + // v3 compat + h, + getCurrentInstance, + useSlots, + useAttrs, + mergeDefaults, + nextTick, + useCssModule, + useCssVars, + defineComponent, + defineAsyncComponent +} = Vue diff --git a/package.json b/package.json index 039c8882375..33eff56cac0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue", - "version": "2.7.8", + "version": "2.7.13", "packageManager": "pnpm@7.1.0", "description": "Reactive, component-oriented view layer for modern web interfaces.", "main": "dist/vue.runtime.common.js", @@ -117,15 +117,15 @@ "prettier": "^2.6.2", "puppeteer": "^14.3.0", "rimraf": "^3.0.2", - "rollup": "^2.75.6", - "rollup-plugin-typescript2": "^0.31.2", + "rollup": "^2.79.1", + "rollup-plugin-typescript2": "^0.32.0", "semver": "^7.3.7", "shelljs": "^0.8.5", "terser": "^5.14.0", "todomvc-app-css": "^2.4.2", "ts-node": "^10.8.1", "tslib": "^2.4.0", - "typescript": "^4.7.3", + "typescript": "^4.8.4", "vitest": "^0.12.10", "yorkie": "^2.0.0" } diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index 6a6037a3111..5159c5cce04 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-sfc", - "version": "2.7.8", + "version": "2.7.13", "description": "compiler-sfc for Vue 2", "main": "dist/compiler-sfc.js", "types": "dist/compiler-sfc.d.ts", @@ -13,7 +13,7 @@ "source-map": "^0.6.1" }, "devDependencies": { - "@babel/types": "^7.18.4", + "@babel/types": "^7.19.4", "@types/estree": "^0.0.48", "@types/hash-sum": "^1.0.0", "@types/lru-cache": "^5.1.1", diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 094120c38f7..548fc592423 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -284,11 +284,9 @@ export function compileScript( userImportAlias[imported] = local } - // template usage check is only needed in non-inline mode, so we can skip - // the work if inlineTemplate is true. let isUsedInTemplate = true - if (isTS && sfc.template && !sfc.template.src && !sfc.template.lang) { - isUsedInTemplate = isImportUsed(local, sfc) + if (sfc.template && !sfc.template.src && !sfc.template.lang) { + isUsedInTemplate = isImportUsed(local, sfc, isTS) } userImports[local] = { @@ -782,7 +780,7 @@ export function compileScript( if (node.trailingComments && node.trailingComments.length > 0) { const lastCommentNode = node.trailingComments[node.trailingComments.length - 1] - end = lastCommentNode.end + startOffset + end = lastCommentNode.end! + startOffset } // locate the end of whitespace between this statement and the next while (end <= source.length) { @@ -1584,14 +1582,18 @@ function extractEventNames( ) { const typeNode = eventName.typeAnnotation.typeAnnotation if (typeNode.type === 'TSLiteralType') { - if (typeNode.literal.type !== 'UnaryExpression') { + if ( + typeNode.literal.type !== 'UnaryExpression' && + typeNode.literal.type !== 'TemplateLiteral' + ) { emits.add(String(typeNode.literal.value)) } } else if (typeNode.type === 'TSUnionType') { for (const t of typeNode.types) { if ( t.type === 'TSLiteralType' && - t.literal.type !== 'UnaryExpression' + t.literal.type !== 'UnaryExpression' && + t.literal.type !== 'TemplateLiteral' ) { emits.add(String(t.literal.value)) } @@ -1782,7 +1784,7 @@ function getObjectOrArrayExpressionKeys(value: Node): string[] { const templateUsageCheckCache = new LRU(512) -function resolveTemplateUsageCheckString(sfc: SFCDescriptor) { +function resolveTemplateUsageCheckString(sfc: SFCDescriptor, isTS: boolean) { const { content } = sfc.template! const cached = templateUsageCheckCache.get(content) if (cached) { @@ -1809,7 +1811,7 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) { code += `,v${capitalize(camelize(baseName))}` } if (value) { - code += `,${processExp(value, baseName)}` + code += `,${processExp(value, isTS, baseName)}` } } } @@ -1817,7 +1819,7 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) { chars(text) { const res = parseText(text) if (res) { - code += `,${processExp(res.expression)}` + code += `,${processExp(res.expression, isTS)}` } } }) @@ -1829,8 +1831,8 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) { const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/ -function processExp(exp: string, dir?: string): string { - if (/ as\s+\w|<.*>|:/.test(exp)) { +function processExp(exp: string, isTS: boolean, dir?: string): string { + if (isTS && / as\s+\w|<.*>|:/.test(exp)) { if (dir === 'slot') { exp = `(${exp})=>{}` } else if (dir === 'on') { @@ -1839,7 +1841,7 @@ function processExp(exp: string, dir?: string): string { const inMatch = exp.match(forAliasRE) if (inMatch) { const [, LHS, RHS] = inMatch - return processExp(`(${LHS})=>{}`) + processExp(RHS) + return processExp(`(${LHS})=>{}`, true) + processExp(RHS, true) } } let ret = '' @@ -1867,36 +1869,38 @@ function stripTemplateString(str: string): string { return '' } -function isImportUsed(local: string, sfc: SFCDescriptor): boolean { +function isImportUsed( + local: string, + sfc: SFCDescriptor, + isTS: boolean +): boolean { return new RegExp( // #4274 escape $ since it's a special char in regex // (and is the only regex special char that is valid in identifiers) `[^\\w$_]${local.replace(/\$/g, '\\$')}[^\\w$_]` - ).test(resolveTemplateUsageCheckString(sfc)) + ).test(resolveTemplateUsageCheckString(sfc, isTS)) } /** * Note: this comparison assumes the prev/next script are already identical, - * and only checks the special case where