From 2b506d7df6c9e2e03726e034c85e9be8c1324a13 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 4 Jan 2022 17:09:13 +0800 Subject: [PATCH 01/23] chore: fix template exploerer boot with no storage --- packages/template-explorer/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/template-explorer/src/index.ts b/packages/template-explorer/src/index.ts index 1e8efdb95d6..5efe07eb83e 100644 --- a/packages/template-explorer/src/index.ts +++ b/packages/template-explorer/src/index.ts @@ -42,7 +42,9 @@ window.init = () => { ) // functions are not persistable, so delete it in case we sometimes need // to debug with custom nodeTransforms - delete persistedState.options.nodeTransforms + if (persistedState.options) { + delete persistedState.options.nodeTransforms + } ssrMode.value = persistedState.ssr Object.assign(compilerOptions, persistedState.options) From eb721d49c004abf5eff0a4e7da71bad904aa6bac Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 4 Jan 2022 17:32:25 +0800 Subject: [PATCH 02/23] workflow: improve template explorer hash persistence --- packages/template-explorer/src/index.ts | 59 +++++++++++++++++------ packages/template-explorer/src/options.ts | 8 ++- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/packages/template-explorer/src/index.ts b/packages/template-explorer/src/index.ts index 5efe07eb83e..7b7e2ae273a 100644 --- a/packages/template-explorer/src/index.ts +++ b/packages/template-explorer/src/index.ts @@ -1,7 +1,12 @@ import * as m from 'monaco-editor' import { compile, CompilerError, CompilerOptions } from '@vue/compiler-dom' import { compile as ssrCompile } from '@vue/compiler-ssr' -import { compilerOptions, initOptions, ssrMode } from './options' +import { + defaultOptions, + compilerOptions, + initOptions, + ssrMode +} from './options' import { toRaw, watchEffect } from '@vue/runtime-dom' import { SourceMapConsumer } from 'source-map' import theme from './theme' @@ -35,19 +40,32 @@ window.init = () => { monaco.editor.defineTheme('my-theme', theme) monaco.editor.setTheme('my-theme') - const persistedState: PersistedState = JSON.parse( - decodeURIComponent(window.location.hash.slice(1)) || - localStorage.getItem('state') || - `{}` - ) - // functions are not persistable, so delete it in case we sometimes need - // to debug with custom nodeTransforms - if (persistedState.options) { - delete persistedState.options.nodeTransforms + let persistedState: PersistedState | undefined + + try { + let hash = window.location.hash.slice(1) + try { + hash = escape(atob(hash)) + } catch (e) {} + persistedState = JSON.parse( + decodeURIComponent(hash) || localStorage.getItem('state') || `{}` + ) + } catch (e: any) { + // bad stored state, clear it + console.warn( + 'Persisted state in localStorage seems to be corrupted, please reload.\n' + + e.message + ) + localStorage.clear() } - ssrMode.value = persistedState.ssr - Object.assign(compilerOptions, persistedState.options) + if (persistedState) { + // functions are not persistable, so delete it in case we sometimes need + // to debug with custom nodeTransforms + delete persistedState.options.nodeTransforms + ssrMode.value = persistedState.ssr + Object.assign(compilerOptions, persistedState.options) + } let lastSuccessfulCode: string let lastSuccessfulMap: SourceMapConsumer | undefined = undefined @@ -99,13 +117,24 @@ window.init = () => { function reCompile() { const src = editor.getValue() // every time we re-compile, persist current state + + const optionsToSave = {} + let key: keyof CompilerOptions + for (key in compilerOptions) { + const val = compilerOptions[key] + if (typeof val !== 'object' && val !== defaultOptions[key]) { + // @ts-ignore + optionsToSave[key] = val + } + } + const state = JSON.stringify({ src, ssr: ssrMode.value, - options: compilerOptions + options: optionsToSave } as PersistedState) localStorage.setItem('state', state) - window.location.hash = encodeURIComponent(state) + window.location.hash = btoa(unescape(encodeURIComponent(state))) const res = compileCode(src) if (res) { output.setValue(res) @@ -113,7 +142,7 @@ window.init = () => { } const editor = monaco.editor.create(document.getElementById('source')!, { - value: persistedState.src || `
Hello World!
`, + value: persistedState?.src || `
Hello World!
`, language: 'html', ...sharedEditorOptions, wordWrap: 'bounded' diff --git a/packages/template-explorer/src/options.ts b/packages/template-explorer/src/options.ts index c5c5eba5a47..2b66b2e70d9 100644 --- a/packages/template-explorer/src/options.ts +++ b/packages/template-explorer/src/options.ts @@ -4,7 +4,7 @@ import { BindingTypes } from '@vue/compiler-core' export const ssrMode = ref(false) -export const compilerOptions: CompilerOptions = reactive({ +export const defaultOptions: CompilerOptions = { mode: 'module', filename: 'Foo.vue', prefixIdentifiers: false, @@ -24,7 +24,11 @@ export const compilerOptions: CompilerOptions = reactive({ setupProp: BindingTypes.PROPS, vMySetupDir: BindingTypes.SETUP_CONST } -}) +} + +export const compilerOptions: CompilerOptions = reactive( + Object.assign({}, defaultOptions) +) const App = { setup() { From 92f11d6740929f5b591740e30ae5fba50940ec82 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 10 Jan 2022 15:05:07 +0800 Subject: [PATCH 03/23] fix(types): fix shallowReadonly type --- packages/reactivity/src/reactive.ts | 4 +--- test-dts/reactivity.test-d.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index b56cb3627b5..4716230e40f 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -166,9 +166,7 @@ export function readonly( * returned properties. * This is used for creating the props proxy object for stateful components. */ -export function shallowReadonly( - target: T -): Readonly<{ [K in keyof T]: UnwrapNestedRefs }> { +export function shallowReadonly(target: T): Readonly { return createReactiveObject( target, true, diff --git a/test-dts/reactivity.test-d.ts b/test-dts/reactivity.test-d.ts index 3c35ea58a01..4c22765e742 100644 --- a/test-dts/reactivity.test-d.ts +++ b/test-dts/reactivity.test-d.ts @@ -1,3 +1,4 @@ +import { shallowReadonly } from '@vue/reactivity' import { ref, readonly, describe, expectError, expectType, Ref } from './index' describe('should support DeepReadonly', () => { @@ -13,3 +14,11 @@ describe('readonly ref', () => { const r = readonly(ref({ count: 1 })) expectType(r) }) + +describe('shallowReadonly ref unwrap', () => { + const r = shallowReadonly({ count: { n: ref(1) } }) + // @ts-expect-error + r.count = 2 + expectType(r.count.n) + r.count.n.value = 123 +}) From 3007d5b4cafed1da445bc498f771bd2c79eda6fc Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 12 Jan 2022 22:07:19 +0800 Subject: [PATCH 04/23] fix(types): KeepAlive match pattern should allow mixed array --- packages/runtime-core/src/components/KeepAlive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index c6180019f86..08e28616e9c 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -43,7 +43,7 @@ import { ComponentRenderContext } from '../componentPublicInstance' import { devtoolsComponentAdded } from '../devtools' import { isAsyncWrapper } from '../apiAsyncComponent' -type MatchPattern = string | RegExp | string[] | RegExp[] +type MatchPattern = string | RegExp | (string | RegExp)[] export interface KeepAliveProps { include?: MatchPattern From ce49fdf999967e838fe6b61373c00cb61ff87f33 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 12 Jan 2022 22:07:47 +0800 Subject: [PATCH 05/23] refactor: more readable type names for watch cleanup function --- packages/runtime-core/src/apiWatch.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index 092491d3b0d..b26c3ee2388 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/packages/runtime-core/src/apiWatch.ts @@ -40,14 +40,14 @@ import { DeprecationTypes } from './compat/compatConfig' import { checkCompatEnabled, isCompatEnabled } from './compat/compatConfig' import { ObjectWatchOptionItem } from './componentOptions' -export type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void +export type WatchEffect = (onCleanup: OnCleanup) => void export type WatchSource = Ref | ComputedRef | (() => T) export type WatchCallback = ( value: V, oldValue: OV, - onInvalidate: InvalidateCbRegistrator + onCleanup: OnCleanup ) => any type MapSources = { @@ -62,7 +62,7 @@ type MapSources = { : never } -type InvalidateCbRegistrator = (cb: () => void) => void +type OnCleanup = (cleanupFn: () => void) => void export interface WatchOptionsBase extends DebuggerOptions { flush?: 'pre' | 'post' | 'sync' @@ -242,7 +242,7 @@ function doWatch( source, instance, ErrorCodes.WATCH_CALLBACK, - [onInvalidate] + [onCleanup] ) } } @@ -272,7 +272,7 @@ function doWatch( } let cleanup: () => void - let onInvalidate: InvalidateCbRegistrator = (fn: () => void) => { + let onCleanup: OnCleanup = (fn: () => void) => { cleanup = effect.onStop = () => { callWithErrorHandling(fn, instance, ErrorCodes.WATCH_CLEANUP) } @@ -282,14 +282,14 @@ function doWatch( // unless it's eager if (__SSR__ && isInSSRComponentSetup) { // we will also not call the invalidate callback (+ runner is not set up) - onInvalidate = NOOP + onCleanup = NOOP if (!cb) { getter() } else if (immediate) { callWithAsyncErrorHandling(cb, instance, ErrorCodes.WATCH_CALLBACK, [ getter(), isMultiSource ? [] : undefined, - onInvalidate + onCleanup ]) } return NOOP @@ -323,7 +323,7 @@ function doWatch( newValue, // pass undefined as the old value when it's changed for the first time oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, - onInvalidate + onCleanup ]) oldValue = newValue } From ff2d6d1cb7c63645fa3c1721fdff3d60e8792750 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 12 Jan 2022 22:08:05 +0800 Subject: [PATCH 06/23] chore: comment usage of short property name --- packages/server-renderer/src/render.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server-renderer/src/render.ts b/packages/server-renderer/src/render.ts index 2b78dda03d9..3b629be435c 100644 --- a/packages/server-renderer/src/render.ts +++ b/packages/server-renderer/src/render.ts @@ -86,7 +86,7 @@ export function renderComponentVNode( const instance = createComponentInstance(vnode, parentComponent, null) const res = setupComponent(instance, true /* isSSR */) const hasAsyncSetup = isPromise(res) - const prefetches = instance.sp + const prefetches = instance.sp /* LifecycleHooks.SERVER_PREFETCH */ if (hasAsyncSetup || prefetches) { let p: Promise = hasAsyncSetup ? (res as Promise) From 77283f4c942ffb16ef8bb501732af80a1e3ac3c2 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 14 Jan 2022 14:13:03 +0800 Subject: [PATCH 07/23] test(types): test ComponentCustomProps --- test-dts/defineComponent.test-d.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 6c8da0591c0..49634ef57c0 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -15,6 +15,12 @@ import { h } from './index' +declare module 'vue' { + interface ComponentCustomProps { + hello?: string + } +} + describe('with object props', () => { interface ExpectedProps { a?: number | undefined @@ -294,6 +300,7 @@ describe('with object props', () => { fff={(a, b) => ({ a: a > +b })} hhh={false} jjj={() => ''} + hello="hello" /> ) From 92fcb9db0599ae633ae5ff829353612113749996 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 14 Jan 2022 16:21:50 +0800 Subject: [PATCH 08/23] workflow: use esbuild for dev scripts --- .github/contributing.md | 9 +- package.json | 8 +- packages/template-explorer/src/index.ts | 4 +- pnpm-lock.yaml | 203 +++++++++++++++++++++++- scripts/dev.js | 137 +++++++++++----- 5 files changed, 314 insertions(+), 47 deletions(-) diff --git a/.github/contributing.md b/.github/contributing.md index 5c50f8a9670..2b0995a1ef1 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -123,16 +123,19 @@ The `dev` script bundles a target package (default: `vue`) in a specified format ```bash $ nr dev -> rollup v1.19.4 -> bundles packages/vue/src/index.ts → packages/vue/dist/vue.global.js... +> watching: packages/vue/dist/vue.global.js ``` -- The `dev` script also supports fuzzy match for the target package, but will only match the first package matched. +- **Important:** output of the `dev` script is for development and debugging only. While it has the same runtime behavior, the generated code should never be published to npm. + +- The `dev` script does not support fuzzy match - you must specify the full package name, e.g. `nr dev runtime-core`. - The `dev` script supports specifying build format via the `-f` flag just like the `build` script. - The `dev` script also supports the `-s` flag for generating source maps, but it will make rebuilds slower. +- The `dev` script supports the `-i` flag for inlining all deps. This is useful when debugging `esm-bundler` builds which externalizes deps by default. + ### `nr dev-compiler` The `dev-compiler` script builds, watches and serves the [Template Explorer](https://github.com/vuejs/vue-next/tree/master/packages/template-explorer) at `http://localhost:5000`. This is extremely useful when working on the compiler. diff --git a/package.json b/package.json index 5bfd59dc1a8..30762ca3f52 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "release": "node scripts/release.js", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "dev-compiler": "run-p \"dev template-explorer\" serve", - "dev-sfc": "run-p \"dev compiler-sfc -- -f esm-browser\" \"dev runtime-core -- -f esm-bundler\" \"dev runtime-dom -- -f esm-bundler\" serve-sfc-playground", + "dev-sfc": "run-p \"dev compiler-sfc -- -f esm-browser\" \"dev vue -- -if esm-bundler-runtime \" serve-sfc-playground", "serve-sfc-playground": "vite packages/sfc-playground --host", "serve": "serve", "open": "open http://localhost:5000/packages/template-explorer/local.html", @@ -48,6 +48,7 @@ }, "devDependencies": { "@babel/types": "^7.12.0", + "@esbuild-plugins/node-modules-polyfill": "^0.1.4", "@microsoft/api-extractor": "^7.15.1", "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-json": "^4.0.0", @@ -66,6 +67,7 @@ "conventional-changelog-cli": "^2.0.31", "csstype": "^3.0.3", "enquirer": "^2.3.2", + "esbuild": "^0.14.11", "eslint": "^7.7.0", "execa": "^4.0.2", "fs-extra": "^9.0.1", @@ -86,11 +88,11 @@ "semver": "^7.3.2", "serve": "^12.0.0", "todomvc-app-css": "^2.3.0", - "tslib": "^2.3.1", "ts-jest": "^27.0.5", + "tslib": "^2.3.1", "typescript": "^4.2.2", - "vue": "workspace:*", "vite": "^2.7.1", + "vue": "workspace:*", "yorkie": "^2.0.0" } } diff --git a/packages/template-explorer/src/index.ts b/packages/template-explorer/src/index.ts index 7b7e2ae273a..d676c717373 100644 --- a/packages/template-explorer/src/index.ts +++ b/packages/template-explorer/src/index.ts @@ -62,7 +62,7 @@ window.init = () => { if (persistedState) { // functions are not persistable, so delete it in case we sometimes need // to debug with custom nodeTransforms - delete persistedState.options.nodeTransforms + delete persistedState.options?.nodeTransforms ssrMode.value = persistedState.ssr Object.assign(compilerOptions, persistedState.options) } @@ -142,7 +142,7 @@ window.init = () => { } const editor = monaco.editor.create(document.getElementById('source')!, { - value: persistedState?.src || `
Hello World!
`, + value: persistedState?.src || `
Hello World
`, language: 'html', ...sharedEditorOptions, wordWrap: 'bounded' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5a068cfbc6d..4237878a534 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ importers: .: specifiers: '@babel/types': ^7.12.0 + '@esbuild-plugins/node-modules-polyfill': ^0.1.4 '@microsoft/api-extractor': ^7.15.1 '@rollup/plugin-commonjs': ^18.0.0 '@rollup/plugin-json': ^4.0.0 @@ -23,6 +24,7 @@ importers: conventional-changelog-cli: ^2.0.31 csstype: ^3.0.3 enquirer: ^2.3.2 + esbuild: ^0.14.11 eslint: ^7.7.0 execa: ^4.0.2 fs-extra: ^9.0.1 @@ -51,6 +53,7 @@ importers: yorkie: ^2.0.0 devDependencies: '@babel/types': 7.16.0 + '@esbuild-plugins/node-modules-polyfill': 0.1.4_esbuild@0.14.11 '@microsoft/api-extractor': 7.19.2 '@rollup/plugin-commonjs': 18.1.0_rollup@2.38.5 '@rollup/plugin-json': 4.1.0_rollup@2.38.5 @@ -69,6 +72,7 @@ importers: conventional-changelog-cli: 2.1.1 csstype: 3.0.10 enquirer: 2.3.6 + esbuild: 0.14.11 eslint: 7.32.0 execa: 4.1.0 fs-extra: 9.1.0 @@ -89,7 +93,7 @@ importers: semver: 7.3.5 serve: 12.0.1 todomvc-app-css: 2.4.1 - ts-jest: 27.1.1_dc33159234d58f1c7ac35b6119da0e94 + ts-jest: 27.1.1_305b6a4a69ca4f1a88855b62d81fc1b0 tslib: 2.3.1 typescript: 4.5.3 vite: 2.7.1 @@ -629,6 +633,16 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true + /@esbuild-plugins/node-modules-polyfill/0.1.4_esbuild@0.14.11: + resolution: {integrity: sha512-uZbcXi0zbmKC/050p3gJnne5Qdzw8vkXIv+c2BW0Lsc1ji1SkrxbKPUy5Efr0blbTu1SL8w4eyfpnSdPg3G0Qg==} + peerDependencies: + esbuild: '*' + dependencies: + esbuild: 0.14.11 + escape-string-regexp: 4.0.0 + rollup-plugin-node-polyfills: 0.2.1 + dev: true + /@eslint/eslintrc/0.4.3: resolution: {integrity: sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==} engines: {node: ^10.12.0 || >=12.0.0} @@ -2584,6 +2598,14 @@ packages: dev: true optional: true + /esbuild-android-arm64/0.14.11: + resolution: {integrity: sha512-6iHjgvMnC/SzDH8TefL+/3lgCjYWwAd1LixYfmz/TBPbDQlxcuSkX0yiQgcJB9k+ibZ54yjVXziIwGdlc+6WNw==} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + /esbuild-darwin-64/0.13.15: resolution: {integrity: sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==} cpu: [x64] @@ -2592,6 +2614,14 @@ packages: dev: true optional: true + /esbuild-darwin-64/0.14.11: + resolution: {integrity: sha512-olq84ikh6TiBcrs3FnM4eR5VPPlcJcdW8BnUz/lNoEWYifYQ+Po5DuYV1oz1CTFMw4k6bQIZl8T3yxL+ZT2uvQ==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /esbuild-darwin-arm64/0.13.15: resolution: {integrity: sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==} cpu: [arm64] @@ -2600,6 +2630,14 @@ packages: dev: true optional: true + /esbuild-darwin-arm64/0.14.11: + resolution: {integrity: sha512-Jj0ieWLREPBYr/TZJrb2GFH8PVzDqiQWavo1pOFFShrcmHWDBDrlDxPzEZ67NF/Un3t6sNNmeI1TUS/fe1xARg==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /esbuild-freebsd-64/0.13.15: resolution: {integrity: sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==} cpu: [x64] @@ -2608,6 +2646,14 @@ packages: dev: true optional: true + /esbuild-freebsd-64/0.14.11: + resolution: {integrity: sha512-C5sT3/XIztxxz/zwDjPRHyzj/NJFOnakAanXuyfLDwhwupKPd76/PPHHyJx6Po6NI6PomgVp/zi6GRB8PfrOTA==} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /esbuild-freebsd-arm64/0.13.15: resolution: {integrity: sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==} cpu: [arm64] @@ -2616,6 +2662,14 @@ packages: dev: true optional: true + /esbuild-freebsd-arm64/0.14.11: + resolution: {integrity: sha512-y3Llu4wbs0bk4cwjsdAtVOesXb6JkdfZDLKMt+v1U3tOEPBdSu6w8796VTksJgPfqvpX22JmPLClls0h5p+L9w==} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-32/0.13.15: resolution: {integrity: sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==} cpu: [ia32] @@ -2624,6 +2678,14 @@ packages: dev: true optional: true + /esbuild-linux-32/0.14.11: + resolution: {integrity: sha512-Cg3nVsxArjyLke9EuwictFF3Sva+UlDTwHIuIyx8qpxRYAOUTmxr2LzYrhHyTcGOleLGXUXYsnUVwKqnKAgkcg==} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-64/0.13.15: resolution: {integrity: sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==} cpu: [x64] @@ -2632,6 +2694,14 @@ packages: dev: true optional: true + /esbuild-linux-64/0.14.11: + resolution: {integrity: sha512-oeR6dIrrojr8DKVrxtH3xl4eencmjsgI6kPkDCRIIFwv4p+K7ySviM85K66BN01oLjzthpUMvBVfWSJkBLeRbg==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-arm/0.13.15: resolution: {integrity: sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==} cpu: [arm] @@ -2640,6 +2710,14 @@ packages: dev: true optional: true + /esbuild-linux-arm/0.14.11: + resolution: {integrity: sha512-vcwskfD9g0tojux/ZaTJptJQU3a7YgTYsptK1y6LQ/rJmw7U5QJvboNawqM98Ca3ToYEucfCRGbl66OTNtp6KQ==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-arm64/0.13.15: resolution: {integrity: sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==} cpu: [arm64] @@ -2648,6 +2726,14 @@ packages: dev: true optional: true + /esbuild-linux-arm64/0.14.11: + resolution: {integrity: sha512-+e6ZCgTFQYZlmg2OqLkg1jHLYtkNDksxWDBWNtI4XG4WxuOCUErLqfEt9qWjvzK3XBcCzHImrajkUjO+rRkbMg==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-mips64le/0.13.15: resolution: {integrity: sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==} cpu: [mips64el] @@ -2656,6 +2742,14 @@ packages: dev: true optional: true + /esbuild-linux-mips64le/0.14.11: + resolution: {integrity: sha512-Rrs99L+p54vepmXIb87xTG6ukrQv+CzrM8eoeR+r/OFL2Rg8RlyEtCeshXJ2+Q66MXZOgPJaokXJZb9snq28bw==} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-ppc64le/0.13.15: resolution: {integrity: sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==} cpu: [ppc64] @@ -2664,6 +2758,22 @@ packages: dev: true optional: true + /esbuild-linux-ppc64le/0.14.11: + resolution: {integrity: sha512-JyzziGAI0D30Vyzt0HDihp4s1IUtJ3ssV2zx9O/c+U/dhUHVP2TmlYjzCfCr2Q6mwXTeloDcLS4qkyvJtYptdQ==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-s390x/0.14.11: + resolution: {integrity: sha512-DoThrkzunZ1nfRGoDN6REwmo8ZZWHd2ztniPVIR5RMw/Il9wiWEYBahb8jnMzQaSOxBsGp0PbyJeVLTUatnlcw==} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-netbsd-64/0.13.15: resolution: {integrity: sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==} cpu: [x64] @@ -2672,6 +2782,14 @@ packages: dev: true optional: true + /esbuild-netbsd-64/0.14.11: + resolution: {integrity: sha512-12luoRQz+6eihKYh1zjrw0CBa2aw3twIiHV/FAfjh2NEBDgJQOY4WCEUEN+Rgon7xmLh4XUxCQjnwrvf8zhACw==} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + /esbuild-openbsd-64/0.13.15: resolution: {integrity: sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==} cpu: [x64] @@ -2680,6 +2798,14 @@ packages: dev: true optional: true + /esbuild-openbsd-64/0.14.11: + resolution: {integrity: sha512-l18TZDjmvwW6cDeR4fmizNoxndyDHamGOOAenwI4SOJbzlJmwfr0jUgjbaXCUuYVOA964siw+Ix+A+bhALWg8Q==} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + /esbuild-sunos-64/0.13.15: resolution: {integrity: sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==} cpu: [x64] @@ -2688,6 +2814,14 @@ packages: dev: true optional: true + /esbuild-sunos-64/0.14.11: + resolution: {integrity: sha512-bmYzDtwASBB8c+0/HVOAiE9diR7+8zLm/i3kEojUH2z0aIs6x/S4KiTuT5/0VKJ4zk69kXel1cNWlHBMkmavQg==} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-32/0.13.15: resolution: {integrity: sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==} cpu: [ia32] @@ -2696,6 +2830,14 @@ packages: dev: true optional: true + /esbuild-windows-32/0.14.11: + resolution: {integrity: sha512-J1Ys5hMid8QgdY00OBvIolXgCQn1ARhYtxPnG6ESWNTty3ashtc4+As5nTrsErnv8ZGUcWZe4WzTP/DmEVX1UQ==} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-64/0.13.15: resolution: {integrity: sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==} cpu: [x64] @@ -2704,6 +2846,14 @@ packages: dev: true optional: true + /esbuild-windows-64/0.14.11: + resolution: {integrity: sha512-h9FmMskMuGeN/9G9+LlHPAoiQk9jlKDUn9yA0MpiGzwLa82E7r1b1u+h2a+InprbSnSLxDq/7p5YGtYVO85Mlg==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-arm64/0.13.15: resolution: {integrity: sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==} cpu: [arm64] @@ -2712,6 +2862,14 @@ packages: dev: true optional: true + /esbuild-windows-arm64/0.14.11: + resolution: {integrity: sha512-dZp7Krv13KpwKklt9/1vBFBMqxEQIO6ri7Azf8C+ob4zOegpJmha2XY9VVWP/OyQ0OWk6cEeIzMJwInRZrzBUQ==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild/0.13.15: resolution: {integrity: sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==} hasBin: true @@ -2736,6 +2894,31 @@ packages: esbuild-windows-arm64: 0.13.15 dev: true + /esbuild/0.14.11: + resolution: {integrity: sha512-xZvPtVj6yecnDeFb3KjjCM6i7B5TCAQZT77kkW/CpXTMnd6VLnRPKrUB1XHI1pSq6a4Zcy3BGueQ8VljqjDGCg==} + hasBin: true + requiresBuild: true + optionalDependencies: + esbuild-android-arm64: 0.14.11 + esbuild-darwin-64: 0.14.11 + esbuild-darwin-arm64: 0.14.11 + esbuild-freebsd-64: 0.14.11 + esbuild-freebsd-arm64: 0.14.11 + esbuild-linux-32: 0.14.11 + esbuild-linux-64: 0.14.11 + esbuild-linux-arm: 0.14.11 + esbuild-linux-arm64: 0.14.11 + esbuild-linux-mips64le: 0.14.11 + esbuild-linux-ppc64le: 0.14.11 + esbuild-linux-s390x: 0.14.11 + esbuild-netbsd-64: 0.14.11 + esbuild-openbsd-64: 0.14.11 + esbuild-sunos-64: 0.14.11 + esbuild-windows-32: 0.14.11 + esbuild-windows-64: 0.14.11 + esbuild-windows-arm64: 0.14.11 + dev: true + /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} @@ -5859,6 +6042,15 @@ packages: inherits: 2.0.4 dev: true + /rollup-plugin-inject/3.0.2: + resolution: {integrity: sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==} + deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject. + dependencies: + estree-walker: 0.6.1 + magic-string: 0.25.7 + rollup-pluginutils: 2.8.2 + dev: true + /rollup-plugin-node-builtins/2.1.2: resolution: {integrity: sha1-JKH+1KQyV7a2Q3HYq8bOGrFFl+k=} dependencies: @@ -5879,6 +6071,12 @@ packages: rollup-pluginutils: 2.8.2 dev: true + /rollup-plugin-node-polyfills/0.2.1: + resolution: {integrity: sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==} + dependencies: + rollup-plugin-inject: 3.0.2 + dev: true + /rollup-plugin-polyfill-node/0.6.2_rollup@2.38.5: resolution: {integrity: sha512-gMCVuR0zsKq0jdBn8pSXN1Ejsc458k2QsFFvQdbHoM0Pot5hEnck+pBP/FDwFS6uAi77pD3rDTytsaUStsOMlA==} dependencies: @@ -6528,7 +6726,7 @@ packages: engines: {node: '>=8'} dev: true - /ts-jest/27.1.1_dc33159234d58f1c7ac35b6119da0e94: + /ts-jest/27.1.1_305b6a4a69ca4f1a88855b62d81fc1b0: resolution: {integrity: sha512-Ds0VkB+cB+8g2JUmP/GKWndeZcCKrbe6jzolGrVWdqVUFByY/2KDHqxJ7yBSon7hDB1TA4PXxjfZ+JjzJisvgA==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} hasBin: true @@ -6551,6 +6749,7 @@ packages: dependencies: '@types/jest': 27.0.3 bs-logger: 0.2.6 + esbuild: 0.14.11 fast-json-stable-stringify: 2.1.0 jest: 27.4.4 jest-util: 27.4.2 diff --git a/scripts/dev.js b/scripts/dev.js index 49418dbf4c1..621cbe63f05 100644 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -1,44 +1,107 @@ -/* -Run Rollup in watch mode for development. +// Using esbuild for faster dev builds. +// We are still using Rollup for production builds because it generates +// smaller files w/ better tree-shaking. -To specific the package to watch, simply pass its name and the desired build -formats to watch (defaults to "global"): +// @ts-check +const { build } = require('esbuild') +const nodePolyfills = require('@esbuild-plugins/node-modules-polyfill') +const { resolve, relative } = require('path') +const args = require('minimist')(process.argv.slice(2)) -``` -# name supports fuzzy match. will watch all packages with name containing "dom" -nr dev dom +const target = args._[0] || 'vue' +const format = args.f || 'global' +const inlineDeps = args.i || args.inline +const pkg = require(resolve(__dirname, `../packages/${target}/package.json`)) -# specify the format to output -nr dev core --formats cjs +// resolve output +const outputFormat = format.startsWith('global') + ? 'iife' + : format === 'cjs' + ? 'cjs' + : 'esm' -# Can also drop all __DEV__ blocks with: -__DEV__=false nr dev -``` -*/ +const postfix = format.endsWith('-runtime') + ? `runtime.${format.replace(/-runtime$/, '')}` + : format -const execa = require('execa') -const { fuzzyMatchTarget } = require('./utils') -const args = require('minimist')(process.argv.slice(2)) -const target = args._.length ? fuzzyMatchTarget(args._)[0] : 'vue' -const formats = args.formats || args.f -const sourceMap = args.sourcemap || args.s -const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7) - -execa( - 'rollup', - [ - '-wc', - '--environment', - [ - `COMMIT:${commit}`, - `TARGET:${target}`, - `FORMATS:${formats || 'global'}`, - sourceMap ? `SOURCE_MAP:true` : `` +const outfile = resolve( + __dirname, + `../packages/${target}/dist/${target}.${postfix}.js` +) +const relativeOutfile = relative(process.cwd(), outfile) + +// resolve extenrals +// TODO this logic is largely duplicated from rollup.config.js +let external = [] +if (!inlineDeps) { + // cjs & esm-bundler: external all deps + if (format === 'cjs' || format.includes('esm-bundler')) { + external = [ + ...external, + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + // for @vue/compiler-sfc / server-renderer + 'path', + 'url', + 'stream' ] - .filter(Boolean) - .join(',') - ], - { - stdio: 'inherit' } -) + + if (target === 'compiler-sfc') { + const consolidateDeps = require.resolve('@vue/consolidate/package.json', { + paths: [resolve(__dirname, `../packages/${target}/`)] + }) + external = [ + ...external, + ...Object.keys(require(consolidateDeps).devDependencies), + 'fs', + 'vm', + 'crypto', + 'react-dom/server', + 'teacup/lib/express', + 'arc-templates/dist/es5', + 'then-pug', + 'then-jade' + ] + } +} + +build({ + entryPoints: [resolve(__dirname, `../packages/${target}/src/index.ts`)], + outfile, + bundle: true, + external, + sourcemap: true, + format: outputFormat, + globalName: pkg.buildOptions?.name, + platform: format === 'cjs' ? 'node' : 'browser', + plugins: + format === 'cjs' || pkg.buildOptions?.enableNonBrowserBranches + ? [nodePolyfills.default()] + : undefined, + define: { + __COMMIT__: `"dev"`, + __VERSION__: `"${pkg.version}"`, + __DEV__: `true`, + __TEST__: `false`, + __BROWSER__: String( + format !== 'cjs' && !pkg.buildOptions?.enableNonBrowserBranches + ), + __GLOBAL__: String(format === 'global'), + __ESM_BUNDLER__: String(format.includes('esm-bundler')), + __ESM_BROWSER__: String(format.includes('esm-browser')), + __NODE_JS__: String(format === 'cjs'), + __SSR__: String(format === 'cjs' || format.includes('esm-bundler')), + __COMPAT__: `false`, + __FEATURE_SUSPENSE__: `true`, + __FEATURE_OPTIONS_API__: `true`, + __FEATURE_PROD_DEVTOOLS__: `false` + }, + watch: { + onRebuild(error) { + if (!error) console.log(`rebuilt: ${relativeOutfile}`) + } + } +}).then(() => { + console.log(`watching: ${relativeOutfile}`) +}) From 4dd0f34e813147c130de09a5245f03381006da87 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 14 Jan 2022 16:22:55 +0800 Subject: [PATCH 09/23] workflow: bump vite --- package.json | 2 +- pnpm-lock.yaml | 198 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 197 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 30762ca3f52..f17aea784a1 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "ts-jest": "^27.0.5", "tslib": "^2.3.1", "typescript": "^4.2.2", - "vite": "^2.7.1", + "vite": "^2.8.0-beta.2", "vue": "workspace:*", "yorkie": "^2.0.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4237878a534..bfec884a46c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,7 +48,7 @@ importers: ts-jest: ^27.0.5 tslib: ^2.3.1 typescript: ^4.2.2 - vite: ^2.7.1 + vite: ^2.8.0-beta.2 vue: workspace:* yorkie: ^2.0.0 devDependencies: @@ -96,7 +96,7 @@ importers: ts-jest: 27.1.1_305b6a4a69ca4f1a88855b62d81fc1b0 tslib: 2.3.1 typescript: 4.5.3 - vite: 2.7.1 + vite: 2.8.0-beta.2 vue: link:packages/vue yorkie: 2.0.0 @@ -2606,6 +2606,14 @@ packages: dev: true optional: true + /esbuild-android-arm64/0.14.3: + resolution: {integrity: sha512-v/vdnGJiSGWOAXzg422T9qb4S+P3tOaYtc5n3FDR27Bh3/xQDS7PdYz/yY7HhOlVp0eGwWNbPHEi8FcEhXjsuw==} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + /esbuild-darwin-64/0.13.15: resolution: {integrity: sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==} cpu: [x64] @@ -2622,6 +2630,14 @@ packages: dev: true optional: true + /esbuild-darwin-64/0.14.3: + resolution: {integrity: sha512-swY5OtEg6cfWdgc/XEjkBP7wXSyXXeZHEsWMdh1bDiN1D6GmRphk9SgKFKTj+P3ZHhOGIcC1+UdIwHk5bUcOig==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /esbuild-darwin-arm64/0.13.15: resolution: {integrity: sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==} cpu: [arm64] @@ -2638,6 +2654,14 @@ packages: dev: true optional: true + /esbuild-darwin-arm64/0.14.3: + resolution: {integrity: sha512-6i9dXPk8oT87wF6VHmwzSad76eMRU2Rt+GXrwF3Y4DCJgnPssJbabNQ9gurkuEX8M0YnEyJF0d1cR7rpTzcEiA==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /esbuild-freebsd-64/0.13.15: resolution: {integrity: sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==} cpu: [x64] @@ -2654,6 +2678,14 @@ packages: dev: true optional: true + /esbuild-freebsd-64/0.14.3: + resolution: {integrity: sha512-WDY5ENsmyceeE+95U3eI+FM8yARY5akWkf21M/x/+v2P5OVsYqCYELglSeAI5Y7bhteCVV3g4i2fRqtkmprdSA==} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /esbuild-freebsd-arm64/0.13.15: resolution: {integrity: sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==} cpu: [arm64] @@ -2670,6 +2702,14 @@ packages: dev: true optional: true + /esbuild-freebsd-arm64/0.14.3: + resolution: {integrity: sha512-4BEEGcP0wBzg04pCCWXlgaPuksQHHfwHvYgCIsi+7IsuB17ykt6MHhTkHR5b5pjI/jNtRhPfMsDODUyftQJgvw==} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-32/0.13.15: resolution: {integrity: sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==} cpu: [ia32] @@ -2686,6 +2726,14 @@ packages: dev: true optional: true + /esbuild-linux-32/0.14.3: + resolution: {integrity: sha512-8yhsnjLG/GwCA1RAIndjmCHWViRB2Ol0XeOh2fCXS9qF8tlVrJB7qAiHZpm2vXx+yjOA/bFLTxzU+5pMKqkn5A==} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-64/0.13.15: resolution: {integrity: sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==} cpu: [x64] @@ -2702,6 +2750,14 @@ packages: dev: true optional: true + /esbuild-linux-64/0.14.3: + resolution: {integrity: sha512-eNq4aixfbwXHIJq4bQDe+XaSNV1grxqpZYs/zHbp0HGHf6SBNlTI02uyTbYGpIzlXmCEPS9tpPCi7BTU45kcJQ==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-arm/0.13.15: resolution: {integrity: sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==} cpu: [arm] @@ -2718,6 +2774,14 @@ packages: dev: true optional: true + /esbuild-linux-arm/0.14.3: + resolution: {integrity: sha512-YcMvJHAQnWrWKb+eLxN9e/iWUC/3w01UF/RXuMknqOW3prX8UQ63QknWz9/RI8BY/sdrdgPEbSmsTU2jy2cayQ==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-arm64/0.13.15: resolution: {integrity: sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==} cpu: [arm64] @@ -2734,6 +2798,14 @@ packages: dev: true optional: true + /esbuild-linux-arm64/0.14.3: + resolution: {integrity: sha512-wPLyRoqoV/tEMQ7M24DpAmCMyKqBmtgZY35w2tXM8X5O5b2Ohi7fkPSmd6ZgLIxZIApWt88toA8RT0S7qoxcOA==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-mips64le/0.13.15: resolution: {integrity: sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==} cpu: [mips64el] @@ -2750,6 +2822,14 @@ packages: dev: true optional: true + /esbuild-linux-mips64le/0.14.3: + resolution: {integrity: sha512-DdmfM5rcuoqjQL3px5MbquAjZWnySB5LdTrg52SSapp0gXMnGcsM6GY2WVta02CMKn5qi7WPVG4WbqTWE++tJw==} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-ppc64le/0.13.15: resolution: {integrity: sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==} cpu: [ppc64] @@ -2766,6 +2846,14 @@ packages: dev: true optional: true + /esbuild-linux-ppc64le/0.14.3: + resolution: {integrity: sha512-ujdqryj0m135Ms9yaNDVFAcLeRtyftM/v2v7Osji5zElf2TivSMdFxdrYnYICuHfkm8c8gHg1ncwqitL0r+nnA==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-s390x/0.14.11: resolution: {integrity: sha512-DoThrkzunZ1nfRGoDN6REwmo8ZZWHd2ztniPVIR5RMw/Il9wiWEYBahb8jnMzQaSOxBsGp0PbyJeVLTUatnlcw==} cpu: [s390x] @@ -2790,6 +2878,14 @@ packages: dev: true optional: true + /esbuild-netbsd-64/0.14.3: + resolution: {integrity: sha512-Z/UB9OUdwo1KDJCSGnVueDuKowRZRkduLvRMegHtDBHC3lS5LfZ3RdM1i+4MMN9iafyk8Q9FNcqIXI178ZujvA==} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + /esbuild-openbsd-64/0.13.15: resolution: {integrity: sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==} cpu: [x64] @@ -2806,6 +2902,14 @@ packages: dev: true optional: true + /esbuild-openbsd-64/0.14.3: + resolution: {integrity: sha512-9I1uoMDeogq3zQuTe3qygmXYjImnvc6rBn51LLbLniQDlfvqHPBMnAZ/5KshwtXXIIMkCwByytDZdiuzRRlTvQ==} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + /esbuild-sunos-64/0.13.15: resolution: {integrity: sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==} cpu: [x64] @@ -2822,6 +2926,14 @@ packages: dev: true optional: true + /esbuild-sunos-64/0.14.3: + resolution: {integrity: sha512-pldqx/Adxl4V4ymiyKxOOyJmHn6nUIo3wqk2xBx07iDgmL2XTcDDQd7N4U4QGu9LnYN4ZF+8IdOYa3oRRpbjtg==} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-32/0.13.15: resolution: {integrity: sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==} cpu: [ia32] @@ -2838,6 +2950,14 @@ packages: dev: true optional: true + /esbuild-windows-32/0.14.3: + resolution: {integrity: sha512-AqzvA/KbkC2m3kTXGpljLin3EttRbtoPTfBn6w6n2m9MWkTEbhQbE1ONoOBxhO5tExmyJdL/6B87TJJD5jEFBQ==} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-64/0.13.15: resolution: {integrity: sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==} cpu: [x64] @@ -2854,6 +2974,14 @@ packages: dev: true optional: true + /esbuild-windows-64/0.14.3: + resolution: {integrity: sha512-HGg3C6113zLGB5hN41PROTnBuoh/arG2lQdOird6xFl9giff1cAfMQOUJUfODKD57dDqHjQ1YGW8gOkg0/IrWw==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-arm64/0.13.15: resolution: {integrity: sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==} cpu: [arm64] @@ -2870,6 +2998,14 @@ packages: dev: true optional: true + /esbuild-windows-arm64/0.14.3: + resolution: {integrity: sha512-qB2izYu4VpigGnOrAN2Yv7ICYLZWY/AojZtwFfteViDnHgW4jXPYkHQIXTISJbRz25H2cYiv+MfRQYK31RNjlw==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild/0.13.15: resolution: {integrity: sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==} hasBin: true @@ -2919,6 +3055,30 @@ packages: esbuild-windows-arm64: 0.14.11 dev: true + /esbuild/0.14.3: + resolution: {integrity: sha512-zyEC5hkguW2oieXRXp8VJzQdcO/1FxCS5GjzqOHItRlojXnx/cTavsrkxdWvBH9li2lUq0bN+LeeVEmyCwiR/Q==} + hasBin: true + requiresBuild: true + optionalDependencies: + esbuild-android-arm64: 0.14.3 + esbuild-darwin-64: 0.14.3 + esbuild-darwin-arm64: 0.14.3 + esbuild-freebsd-64: 0.14.3 + esbuild-freebsd-arm64: 0.14.3 + esbuild-linux-32: 0.14.3 + esbuild-linux-64: 0.14.3 + esbuild-linux-arm: 0.14.3 + esbuild-linux-arm64: 0.14.3 + esbuild-linux-mips64le: 0.14.3 + esbuild-linux-ppc64le: 0.14.3 + esbuild-netbsd-64: 0.14.3 + esbuild-openbsd-64: 0.14.3 + esbuild-sunos-64: 0.14.3 + esbuild-windows-32: 0.14.3 + esbuild-windows-64: 0.14.3 + esbuild-windows-arm64: 0.14.3 + dev: true + /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} @@ -5587,6 +5747,15 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.1 + /postcss/8.4.5: + resolution: {integrity: sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.1.30 + picocolors: 1.0.0 + source-map-js: 1.0.1 + dev: true + /prelude-ls/1.1.2: resolution: {integrity: sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=} engines: {node: '>= 0.8.0'} @@ -6961,6 +7130,31 @@ packages: fsevents: 2.3.2 dev: true + /vite/2.8.0-beta.2: + resolution: {integrity: sha512-FjaZAFL+Ln3M9C2eSskp54n0Esyx2Hh2STj0mAAPcnYK16yyNmZRe77ZFh3RQuwPcE1tMo7pQzimzcgfrfkJ+Q==} + engines: {node: '>=12.2.0'} + hasBin: true + peerDependencies: + less: '*' + sass: '*' + stylus: '*' + peerDependenciesMeta: + less: + optional: true + sass: + optional: true + stylus: + optional: true + dependencies: + esbuild: 0.14.3 + json5: 2.2.0 + postcss: 8.4.5 + resolve: 1.20.0 + rollup: 2.61.1 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /vlq/0.2.3: resolution: {integrity: sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==} dev: true From 55cc4af25e6f4924b267620bd965e496f260d41a Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 15:20:56 +0800 Subject: [PATCH 10/23] fix(ssr): remove missing ssr directive transform error --- packages/compiler-ssr/src/errors.ts | 4 +--- .../src/transforms/ssrTransformElement.ts | 12 ++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/compiler-ssr/src/errors.ts b/packages/compiler-ssr/src/errors.ts index 5030a56db52..755379fb675 100644 --- a/packages/compiler-ssr/src/errors.ts +++ b/packages/compiler-ssr/src/errors.ts @@ -17,14 +17,12 @@ export function createSSRCompilerError( } export const enum SSRErrorCodes { - X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM = DOMErrorCodes.__EXTEND_POINT__, - X_SSR_UNSAFE_ATTR_NAME, + X_SSR_UNSAFE_ATTR_NAME = DOMErrorCodes.__EXTEND_POINT__, X_SSR_NO_TELEPORT_TARGET, X_SSR_INVALID_AST_NODE } export const SSRErrorMessages: { [code: number]: string } = { - [SSRErrorCodes.X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM]: `Custom directive is missing corresponding SSR transform and will be ignored.`, [SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME]: `Unsafe attribute name for SSR.`, [SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET]: `Missing the 'to' prop on teleport element.`, [SSRErrorCodes.X_SSR_INVALID_AST_NODE]: `Invalid AST node during SSR transform.` diff --git a/packages/compiler-ssr/src/transforms/ssrTransformElement.ts b/packages/compiler-ssr/src/transforms/ssrTransformElement.ts index 659537b2c82..13d8c04f4ce 100644 --- a/packages/compiler-ssr/src/transforms/ssrTransformElement.ts +++ b/packages/compiler-ssr/src/transforms/ssrTransformElement.ts @@ -179,18 +179,10 @@ export const ssrTransformElement: NodeTransform = (node, context) => { if (!hasDynamicVBind) { node.children = [createInterpolation(prop.exp, prop.loc)] } - } else { + } else if (!hasDynamicVBind) { // Directive transforms. const directiveTransform = context.directiveTransforms[prop.name] - if (!directiveTransform) { - // no corresponding ssr directive transform found. - context.onError( - createSSRCompilerError( - SSRErrorCodes.X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM, - prop.loc - ) - ) - } else if (!hasDynamicVBind) { + if (directiveTransform) { const { props, ssrTagParts } = directiveTransform( prop, node, From 2e3e183b4f19c9e25865e35438653cbc9bf01afc Mon Sep 17 00:00:00 2001 From: edison Date: Sun, 16 Jan 2022 15:37:14 +0800 Subject: [PATCH 11/23] fix(KeepAlive): remove cached VNode properly (#5260) fix #5258 --- packages/runtime-core/src/components/KeepAlive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index 08e28616e9c..7a9419f3b63 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -174,7 +174,7 @@ const KeepAliveImpl: ComponentOptions = { function unmount(vnode: VNode) { // reset the shapeFlag so it can be properly unmounted resetShapeFlag(vnode) - _unmount(vnode, instance, parentSuspense) + _unmount(vnode, instance, parentSuspense, true) } function pruneCache(filter?: (name: string) => boolean) { From 6cfd72e7609a7d006678eefb4a9961f1d71b3f11 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 15:43:19 +0800 Subject: [PATCH 12/23] refactor: move type utils to shared --- packages/runtime-core/src/componentEmits.ts | 4 ++-- packages/runtime-core/src/componentOptions.ts | 5 +++-- packages/runtime-core/src/componentProps.ts | 4 ++-- packages/runtime-core/src/componentPublicInstance.ts | 4 ++-- packages/shared/src/index.ts | 1 + .../{runtime-core/src/helpers => shared/src}/typeUtils.ts | 0 6 files changed, 10 insertions(+), 8 deletions(-) rename packages/{runtime-core/src/helpers => shared/src}/typeUtils.ts (100%) diff --git a/packages/runtime-core/src/componentEmits.ts b/packages/runtime-core/src/componentEmits.ts index 390c6350b8c..4d028913d15 100644 --- a/packages/runtime-core/src/componentEmits.ts +++ b/packages/runtime-core/src/componentEmits.ts @@ -8,7 +8,8 @@ import { isArray, isFunction, isOn, - toNumber + toNumber, + UnionToIntersection } from '@vue/shared' import { ComponentInternalInstance, @@ -18,7 +19,6 @@ import { } from './component' import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling' import { warn } from './warning' -import { UnionToIntersection } from './helpers/typeUtils' import { devtoolsComponentEmit } from './devtools' import { AppContext } from './apiCreateApp' import { emit as compatInstanceEmit } from './compat/instanceEventEmitter' diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 41e02c5da0a..139ef6d3967 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -15,7 +15,9 @@ import { isObject, isArray, NOOP, - isPromise + isPromise, + LooseRequired, + UnionToIntersection } from '@vue/shared' import { computed, isRef, Ref } from '@vue/reactivity' import { @@ -60,7 +62,6 @@ import { import { warn } from './warning' import { VNodeChild } from './vnode' import { callWithAsyncErrorHandling } from './errorHandling' -import { LooseRequired, UnionToIntersection } from './helpers/typeUtils' import { deepMergeData } from './compat/data' import { DeprecationTypes } from './compat/compatConfig' import { diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index dbd5453904d..946564b5e4a 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -21,7 +21,8 @@ import { EMPTY_ARR, def, extend, - isOn + isOn, + IfAny } from '@vue/shared' import { warn } from './warning' import { @@ -39,7 +40,6 @@ import { createPropsDefaultThis } from './compat/props' import { isCompatEnabled, softAssertCompatEnabled } from './compat/compatConfig' import { DeprecationTypes } from './compat/compatConfig' import { shouldSkipAttr } from './compat/attrsFallthrough' -import { IfAny } from './helpers/typeUtils' export type ComponentPropsOptions

= | ComponentObjectPropsOptions

diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index 8298aff42b1..1d7cfbdec69 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -13,7 +13,8 @@ import { NOOP, extend, isString, - isFunction + isFunction, + UnionToIntersection } from '@vue/shared' import { toRaw, @@ -40,7 +41,6 @@ import { Slots } from './componentSlots' import { markAttrsAccessed } from './componentRenderUtils' import { currentRenderingInstance } from './componentRenderContext' import { warn } from './warning' -import { UnionToIntersection } from './helpers/typeUtils' import { installCompatInstanceProperties } from './compat/instance' /** diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index c41a1a5fad5..fd4f5c9ddce 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -12,6 +12,7 @@ export * from './domAttrConfig' export * from './escapeHtml' export * from './looseEqual' export * from './toDisplayString' +export * from './typeUtils' export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__ ? Object.freeze({}) diff --git a/packages/runtime-core/src/helpers/typeUtils.ts b/packages/shared/src/typeUtils.ts similarity index 100% rename from packages/runtime-core/src/helpers/typeUtils.ts rename to packages/shared/src/typeUtils.ts From 5ac703055fa83cb1e8a173bbd6a4d6c33707a3c3 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 15:46:49 +0800 Subject: [PATCH 13/23] fix(types): handle ToRef fix #5188 --- packages/reactivity/src/ref.ts | 4 ++-- test-dts/ref.test-d.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 55059485d6c..c972676ac42 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -1,6 +1,6 @@ import { isTracking, trackEffects, triggerEffects } from './effect' import { TrackOpTypes, TriggerOpTypes } from './operations' -import { isArray, hasChanged } from '@vue/shared' +import { isArray, hasChanged, IfAny } from '@vue/shared' import { isProxy, toRaw, isReactive, toReactive } from './reactive' import type { ShallowReactiveMarker } from './reactive' import { CollectionTypes } from './collectionHandlers' @@ -222,7 +222,7 @@ class ObjectRefImpl { } } -export type ToRef = [T] extends [Ref] ? T : Ref +export type ToRef = IfAny, [T] extends [Ref] ? T : Ref> export function toRef( object: T, diff --git a/test-dts/ref.test-d.ts b/test-dts/ref.test-d.ts index f91d6415f70..e585470d5e4 100644 --- a/test-dts/ref.test-d.ts +++ b/test-dts/ref.test-d.ts @@ -222,6 +222,11 @@ expectType>(p2.obj.k) expectType>(toRefResult.value.b) expectType>(toRefsResult.a.value.b) + + // #5188 + const props = { foo: 1 } as { foo: any } + const { foo } = toRefs(props) + expectType>(foo) } // toRef default value From 78df8c78c4539d2408278d1a11612b6bbc47d22f Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 15:54:58 +0800 Subject: [PATCH 14/23] fix(types/tsx): allow ref_for type on tsx elements --- packages/runtime-dom/types/jsx.d.ts | 2 ++ test-dts/defineComponent.test-d.tsx | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/runtime-dom/types/jsx.d.ts b/packages/runtime-dom/types/jsx.d.ts index e86b67fa351..ab34e299de6 100644 --- a/packages/runtime-dom/types/jsx.d.ts +++ b/packages/runtime-dom/types/jsx.d.ts @@ -1312,6 +1312,8 @@ type ReservedProps = { | string | RuntimeCore.Ref | ((ref: Element | RuntimeCore.ComponentPublicInstance | null) => void) + ref_for?: boolean + ref_key?: string } type ElementAttrs = T & ReservedProps diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index 49634ef57c0..c47371ef496 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -288,6 +288,7 @@ describe('with object props', () => { key={'foo'} // should allow ref ref={'foo'} + ref_for={true} /> ) From bc170e68ab452eca98be9dc40217db66a25eae55 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 16:49:58 +0800 Subject: [PATCH 15/23] build: downgrade vite --- package.json | 2 +- pnpm-lock.yaml | 171 ++----------------------------------------------- 2 files changed, 6 insertions(+), 167 deletions(-) diff --git a/package.json b/package.json index f17aea784a1..5fb460ccc3e 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "ts-jest": "^27.0.5", "tslib": "^2.3.1", "typescript": "^4.2.2", - "vite": "^2.8.0-beta.2", + "vite": "^2.7.12", "vue": "workspace:*", "yorkie": "^2.0.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bfec884a46c..714ed713382 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,7 +48,7 @@ importers: ts-jest: ^27.0.5 tslib: ^2.3.1 typescript: ^4.2.2 - vite: ^2.8.0-beta.2 + vite: ^2.7.12 vue: workspace:* yorkie: ^2.0.0 devDependencies: @@ -96,7 +96,7 @@ importers: ts-jest: 27.1.1_305b6a4a69ca4f1a88855b62d81fc1b0 tslib: 2.3.1 typescript: 4.5.3 - vite: 2.8.0-beta.2 + vite: 2.7.12 vue: link:packages/vue yorkie: 2.0.0 @@ -2606,14 +2606,6 @@ packages: dev: true optional: true - /esbuild-android-arm64/0.14.3: - resolution: {integrity: sha512-v/vdnGJiSGWOAXzg422T9qb4S+P3tOaYtc5n3FDR27Bh3/xQDS7PdYz/yY7HhOlVp0eGwWNbPHEi8FcEhXjsuw==} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - /esbuild-darwin-64/0.13.15: resolution: {integrity: sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==} cpu: [x64] @@ -2630,14 +2622,6 @@ packages: dev: true optional: true - /esbuild-darwin-64/0.14.3: - resolution: {integrity: sha512-swY5OtEg6cfWdgc/XEjkBP7wXSyXXeZHEsWMdh1bDiN1D6GmRphk9SgKFKTj+P3ZHhOGIcC1+UdIwHk5bUcOig==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /esbuild-darwin-arm64/0.13.15: resolution: {integrity: sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==} cpu: [arm64] @@ -2654,14 +2638,6 @@ packages: dev: true optional: true - /esbuild-darwin-arm64/0.14.3: - resolution: {integrity: sha512-6i9dXPk8oT87wF6VHmwzSad76eMRU2Rt+GXrwF3Y4DCJgnPssJbabNQ9gurkuEX8M0YnEyJF0d1cR7rpTzcEiA==} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /esbuild-freebsd-64/0.13.15: resolution: {integrity: sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==} cpu: [x64] @@ -2678,14 +2654,6 @@ packages: dev: true optional: true - /esbuild-freebsd-64/0.14.3: - resolution: {integrity: sha512-WDY5ENsmyceeE+95U3eI+FM8yARY5akWkf21M/x/+v2P5OVsYqCYELglSeAI5Y7bhteCVV3g4i2fRqtkmprdSA==} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - /esbuild-freebsd-arm64/0.13.15: resolution: {integrity: sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==} cpu: [arm64] @@ -2702,14 +2670,6 @@ packages: dev: true optional: true - /esbuild-freebsd-arm64/0.14.3: - resolution: {integrity: sha512-4BEEGcP0wBzg04pCCWXlgaPuksQHHfwHvYgCIsi+7IsuB17ykt6MHhTkHR5b5pjI/jNtRhPfMsDODUyftQJgvw==} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-32/0.13.15: resolution: {integrity: sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==} cpu: [ia32] @@ -2726,14 +2686,6 @@ packages: dev: true optional: true - /esbuild-linux-32/0.14.3: - resolution: {integrity: sha512-8yhsnjLG/GwCA1RAIndjmCHWViRB2Ol0XeOh2fCXS9qF8tlVrJB7qAiHZpm2vXx+yjOA/bFLTxzU+5pMKqkn5A==} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-64/0.13.15: resolution: {integrity: sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==} cpu: [x64] @@ -2750,14 +2702,6 @@ packages: dev: true optional: true - /esbuild-linux-64/0.14.3: - resolution: {integrity: sha512-eNq4aixfbwXHIJq4bQDe+XaSNV1grxqpZYs/zHbp0HGHf6SBNlTI02uyTbYGpIzlXmCEPS9tpPCi7BTU45kcJQ==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-arm/0.13.15: resolution: {integrity: sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==} cpu: [arm] @@ -2774,14 +2718,6 @@ packages: dev: true optional: true - /esbuild-linux-arm/0.14.3: - resolution: {integrity: sha512-YcMvJHAQnWrWKb+eLxN9e/iWUC/3w01UF/RXuMknqOW3prX8UQ63QknWz9/RI8BY/sdrdgPEbSmsTU2jy2cayQ==} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-arm64/0.13.15: resolution: {integrity: sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==} cpu: [arm64] @@ -2798,14 +2734,6 @@ packages: dev: true optional: true - /esbuild-linux-arm64/0.14.3: - resolution: {integrity: sha512-wPLyRoqoV/tEMQ7M24DpAmCMyKqBmtgZY35w2tXM8X5O5b2Ohi7fkPSmd6ZgLIxZIApWt88toA8RT0S7qoxcOA==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-mips64le/0.13.15: resolution: {integrity: sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==} cpu: [mips64el] @@ -2822,14 +2750,6 @@ packages: dev: true optional: true - /esbuild-linux-mips64le/0.14.3: - resolution: {integrity: sha512-DdmfM5rcuoqjQL3px5MbquAjZWnySB5LdTrg52SSapp0gXMnGcsM6GY2WVta02CMKn5qi7WPVG4WbqTWE++tJw==} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-ppc64le/0.13.15: resolution: {integrity: sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==} cpu: [ppc64] @@ -2846,14 +2766,6 @@ packages: dev: true optional: true - /esbuild-linux-ppc64le/0.14.3: - resolution: {integrity: sha512-ujdqryj0m135Ms9yaNDVFAcLeRtyftM/v2v7Osji5zElf2TivSMdFxdrYnYICuHfkm8c8gHg1ncwqitL0r+nnA==} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /esbuild-linux-s390x/0.14.11: resolution: {integrity: sha512-DoThrkzunZ1nfRGoDN6REwmo8ZZWHd2ztniPVIR5RMw/Il9wiWEYBahb8jnMzQaSOxBsGp0PbyJeVLTUatnlcw==} cpu: [s390x] @@ -2878,14 +2790,6 @@ packages: dev: true optional: true - /esbuild-netbsd-64/0.14.3: - resolution: {integrity: sha512-Z/UB9OUdwo1KDJCSGnVueDuKowRZRkduLvRMegHtDBHC3lS5LfZ3RdM1i+4MMN9iafyk8Q9FNcqIXI178ZujvA==} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - /esbuild-openbsd-64/0.13.15: resolution: {integrity: sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==} cpu: [x64] @@ -2902,14 +2806,6 @@ packages: dev: true optional: true - /esbuild-openbsd-64/0.14.3: - resolution: {integrity: sha512-9I1uoMDeogq3zQuTe3qygmXYjImnvc6rBn51LLbLniQDlfvqHPBMnAZ/5KshwtXXIIMkCwByytDZdiuzRRlTvQ==} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - /esbuild-sunos-64/0.13.15: resolution: {integrity: sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==} cpu: [x64] @@ -2926,14 +2822,6 @@ packages: dev: true optional: true - /esbuild-sunos-64/0.14.3: - resolution: {integrity: sha512-pldqx/Adxl4V4ymiyKxOOyJmHn6nUIo3wqk2xBx07iDgmL2XTcDDQd7N4U4QGu9LnYN4ZF+8IdOYa3oRRpbjtg==} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - /esbuild-windows-32/0.13.15: resolution: {integrity: sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==} cpu: [ia32] @@ -2950,14 +2838,6 @@ packages: dev: true optional: true - /esbuild-windows-32/0.14.3: - resolution: {integrity: sha512-AqzvA/KbkC2m3kTXGpljLin3EttRbtoPTfBn6w6n2m9MWkTEbhQbE1ONoOBxhO5tExmyJdL/6B87TJJD5jEFBQ==} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - /esbuild-windows-64/0.13.15: resolution: {integrity: sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==} cpu: [x64] @@ -2974,14 +2854,6 @@ packages: dev: true optional: true - /esbuild-windows-64/0.14.3: - resolution: {integrity: sha512-HGg3C6113zLGB5hN41PROTnBuoh/arG2lQdOird6xFl9giff1cAfMQOUJUfODKD57dDqHjQ1YGW8gOkg0/IrWw==} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /esbuild-windows-arm64/0.13.15: resolution: {integrity: sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==} cpu: [arm64] @@ -2998,14 +2870,6 @@ packages: dev: true optional: true - /esbuild-windows-arm64/0.14.3: - resolution: {integrity: sha512-qB2izYu4VpigGnOrAN2Yv7ICYLZWY/AojZtwFfteViDnHgW4jXPYkHQIXTISJbRz25H2cYiv+MfRQYK31RNjlw==} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /esbuild/0.13.15: resolution: {integrity: sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==} hasBin: true @@ -3055,30 +2919,6 @@ packages: esbuild-windows-arm64: 0.14.11 dev: true - /esbuild/0.14.3: - resolution: {integrity: sha512-zyEC5hkguW2oieXRXp8VJzQdcO/1FxCS5GjzqOHItRlojXnx/cTavsrkxdWvBH9li2lUq0bN+LeeVEmyCwiR/Q==} - hasBin: true - requiresBuild: true - optionalDependencies: - esbuild-android-arm64: 0.14.3 - esbuild-darwin-64: 0.14.3 - esbuild-darwin-arm64: 0.14.3 - esbuild-freebsd-64: 0.14.3 - esbuild-freebsd-arm64: 0.14.3 - esbuild-linux-32: 0.14.3 - esbuild-linux-64: 0.14.3 - esbuild-linux-arm: 0.14.3 - esbuild-linux-arm64: 0.14.3 - esbuild-linux-mips64le: 0.14.3 - esbuild-linux-ppc64le: 0.14.3 - esbuild-netbsd-64: 0.14.3 - esbuild-openbsd-64: 0.14.3 - esbuild-sunos-64: 0.14.3 - esbuild-windows-32: 0.14.3 - esbuild-windows-64: 0.14.3 - esbuild-windows-arm64: 0.14.3 - dev: true - /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} @@ -7130,8 +6970,8 @@ packages: fsevents: 2.3.2 dev: true - /vite/2.8.0-beta.2: - resolution: {integrity: sha512-FjaZAFL+Ln3M9C2eSskp54n0Esyx2Hh2STj0mAAPcnYK16yyNmZRe77ZFh3RQuwPcE1tMo7pQzimzcgfrfkJ+Q==} + /vite/2.7.12: + resolution: {integrity: sha512-KvPYToRQWhRfBeVkyhkZ5hASuHQkqZUUdUcE3xyYtq5oYEPIJ0h9LWiWTO6v990glmSac2cEPeYeXzpX5Z6qKQ==} engines: {node: '>=12.2.0'} hasBin: true peerDependencies: @@ -7146,8 +6986,7 @@ packages: stylus: optional: true dependencies: - esbuild: 0.14.3 - json5: 2.2.0 + esbuild: 0.13.15 postcss: 8.4.5 resolve: 1.20.0 rollup: 2.61.1 From 4d07ed809c5de65addbfedb91ac334bf1b029218 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 17:13:52 +0800 Subject: [PATCH 16/23] test: remove module augmentation test which does not work in the setup --- test-dts/defineComponent.test-d.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test-dts/defineComponent.test-d.tsx b/test-dts/defineComponent.test-d.tsx index c47371ef496..031b4a13eb8 100644 --- a/test-dts/defineComponent.test-d.tsx +++ b/test-dts/defineComponent.test-d.tsx @@ -15,12 +15,6 @@ import { h } from './index' -declare module 'vue' { - interface ComponentCustomProps { - hello?: string - } -} - describe('with object props', () => { interface ExpectedProps { a?: number | undefined @@ -301,7 +295,6 @@ describe('with object props', () => { fff={(a, b) => ({ a: a > +b })} hhh={false} jjj={() => ''} - hello="hello" /> ) From f4f0966b33863ac0fca6a20cf9e8ddfbb311ae87 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 18:22:18 +0800 Subject: [PATCH 17/23] fix(ssr): make computed inactive during ssr, fix memory leak fix #5208 --- packages/reactivity/src/computed.ts | 11 +++++++---- packages/runtime-core/src/apiComputed.ts | 7 +++++++ packages/runtime-core/src/index.ts | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 packages/runtime-core/src/apiComputed.ts diff --git a/packages/reactivity/src/computed.ts b/packages/reactivity/src/computed.ts index c7f7b051554..c077d84b209 100644 --- a/packages/reactivity/src/computed.ts +++ b/packages/reactivity/src/computed.ts @@ -36,7 +36,8 @@ class ComputedRefImpl { constructor( getter: ComputedGetter, private readonly _setter: ComputedSetter, - isReadonly: boolean + isReadonly: boolean, + isSSR: boolean ) { this.effect = new ReactiveEffect(getter, () => { if (!this._dirty) { @@ -44,6 +45,7 @@ class ComputedRefImpl { triggerRefValue(this) } }) + this.effect.active = !isSSR this[ReactiveFlags.IS_READONLY] = isReadonly } @@ -73,7 +75,8 @@ export function computed( ): WritableComputedRef export function computed( getterOrOptions: ComputedGetter | WritableComputedOptions, - debugOptions?: DebuggerOptions + debugOptions?: DebuggerOptions, + isSSR = false ) { let getter: ComputedGetter let setter: ComputedSetter @@ -91,9 +94,9 @@ export function computed( setter = getterOrOptions.set } - const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter) + const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR) - if (__DEV__ && debugOptions) { + if (__DEV__ && debugOptions && !isSSR) { cRef.effect.onTrack = debugOptions.onTrack cRef.effect.onTrigger = debugOptions.onTrigger } diff --git a/packages/runtime-core/src/apiComputed.ts b/packages/runtime-core/src/apiComputed.ts new file mode 100644 index 00000000000..3804531bd44 --- /dev/null +++ b/packages/runtime-core/src/apiComputed.ts @@ -0,0 +1,7 @@ +import { computed as _computed } from '@vue/reactivity' +import { isInSSRComponentSetup } from './component' + +export const computed = ((getterOrOptions: any, debugOptions?: any) => { + // @ts-ignore + return _computed(getterOrOptions, debugOptions, isInSSRComponentSetup) +}) as typeof _computed diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 0d5e320e83f..65fc62b3e2f 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -3,7 +3,6 @@ export const version = __VERSION__ export { // core - computed, reactive, ref, readonly, @@ -34,6 +33,7 @@ export { getCurrentScope, onScopeDispose } from '@vue/reactivity' +export { computed } from './apiComputed' export { watch, watchEffect, From ed9eb62e5992bd575d999c4197330d8bad622cfb Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 20:39:55 +0800 Subject: [PATCH 18/23] perf: improve memory usage for static vnodes Use the already mounted nodes as cache instead of separate caching via template. This reduces memory usage by 30%+ in VitePress. --- packages/runtime-core/src/renderer.ts | 8 +++++-- .../runtime-dom/__tests__/nodeOps.spec.ts | 23 +++++++++++++++++++ packages/runtime-dom/src/nodeOps.ts | 22 ++++++++++-------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 04bebdb1f0e..0a215a14b76 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -124,7 +124,9 @@ export interface RendererOptions< content: string, parent: HostElement, anchor: HostNode | null, - isSVG: boolean + isSVG: boolean, + start?: HostNode | null, + end?: HostNode | null ): [HostNode, HostNode] } @@ -511,7 +513,9 @@ function baseCreateRenderer( n2.children as string, container, anchor, - isSVG + isSVG, + n2.el, + n2.anchor ) } diff --git a/packages/runtime-dom/__tests__/nodeOps.spec.ts b/packages/runtime-dom/__tests__/nodeOps.spec.ts index 1944bf0e4f4..dcab9a0a6b9 100644 --- a/packages/runtime-dom/__tests__/nodeOps.spec.ts +++ b/packages/runtime-dom/__tests__/nodeOps.spec.ts @@ -82,5 +82,28 @@ describe('runtime-dom: node-ops', () => { expect((first as Element).namespaceURI).toMatch('svg') expect((last as Element).namespaceURI).toMatch('svg') }) + + test('cached insertion', () => { + const content = `

one
two
three` + const existing = `
existing
` + const parent = document.createElement('div') + parent.innerHTML = existing + const anchor = parent.firstChild + + const cached = document.createElement('div') + cached.innerHTML = content + + const nodes = nodeOps.insertStaticContent!( + content, + parent, + anchor, + false, + cached.firstChild, + cached.lastChild + ) + expect(parent.innerHTML).toBe(content + existing) + expect(nodes[0]).toBe(parent.firstChild) + expect(nodes[1]).toBe(parent.childNodes[parent.childNodes.length - 2]) + }) }) }) diff --git a/packages/runtime-dom/src/nodeOps.ts b/packages/runtime-dom/src/nodeOps.ts index de13d8f19d0..c3a4f4ba642 100644 --- a/packages/runtime-dom/src/nodeOps.ts +++ b/packages/runtime-dom/src/nodeOps.ts @@ -4,7 +4,7 @@ export const svgNS = 'http://www.w3.org/2000/svg' const doc = (typeof document !== 'undefined' ? document : null) as Document -const staticTemplateCache = new Map() +const templateContainer = doc && doc.createElement('template') export const nodeOps: Omit, 'patchProp'> = { insert: (child, parent, anchor) => { @@ -73,14 +73,19 @@ export const nodeOps: Omit, 'patchProp'> = { // Reason: innerHTML. // Static content here can only come from compiled templates. // As long as the user only uses trusted templates, this is safe. - insertStaticContent(content, parent, anchor, isSVG) { + insertStaticContent(content, parent, anchor, isSVG, start, end) { // before | first ... last | anchor const before = anchor ? anchor.previousSibling : parent.lastChild - let template = staticTemplateCache.get(content) - if (!template) { - const t = doc.createElement('template') - t.innerHTML = isSVG ? `${content}` : content - template = t.content + if (start && end) { + // cached + while (true) { + parent.insertBefore(start!.cloneNode(true), anchor) + if (start === end || !(start = start!.nextSibling)) break + } + } else { + // fresh insert + templateContainer.innerHTML = isSVG ? `${content}` : content + const template = templateContainer.content if (isSVG) { // remove outer svg wrapper const wrapper = template.firstChild! @@ -89,9 +94,8 @@ export const nodeOps: Omit, 'patchProp'> = { } template.removeChild(wrapper) } - staticTemplateCache.set(content, template) + parent.insertBefore(template, anchor) } - parent.insertBefore(template.cloneNode(true), anchor) return [ // first before ? before.nextSibling! : parent.firstChild!, From 3adfc0fe9435b70f149cef3f346780ae7a3f0651 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 16 Jan 2022 22:08:18 +0800 Subject: [PATCH 19/23] release: v3.2.27 --- CHANGELOG.md | 27 +++++++++++ package.json | 2 +- packages/compiler-core/package.json | 4 +- packages/compiler-dom/package.json | 6 +-- packages/compiler-sfc/package.json | 12 ++--- packages/compiler-ssr/package.json | 6 +-- packages/reactivity-transform/package.json | 6 +-- packages/reactivity/package.json | 4 +- packages/runtime-core/package.json | 6 +-- packages/runtime-dom/package.json | 6 +-- packages/runtime-test/package.json | 6 +-- packages/server-renderer/package.json | 8 ++-- packages/sfc-playground/package.json | 4 +- packages/shared/package.json | 2 +- packages/size-check/package.json | 2 +- packages/template-explorer/package.json | 2 +- packages/vue-compat/package.json | 4 +- packages/vue/package.json | 12 ++--- pnpm-lock.yaml | 54 +++++++++++----------- 19 files changed, 100 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6e4dc0bb1..ab6b49460c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +## [3.2.27](https://github.com/vuejs/vue-next/compare/v3.2.26...v3.2.27) (2022-01-16) + + +### Bug Fixes + +* **KeepAlive:** remove cached VNode properly ([#5260](https://github.com/vuejs/vue-next/issues/5260)) ([2e3e183](https://github.com/vuejs/vue-next/commit/2e3e183b4f19c9e25865e35438653cbc9bf01afc)), closes [#5258](https://github.com/vuejs/vue-next/issues/5258) +* **reactivity-transform:** should not rewrite for...in / for...of scope variables ([7007ffb](https://github.com/vuejs/vue-next/commit/7007ffb2c796d6d56b9c8e278c54dc1cefd7b58f)) +* **sfc-playground:** hide title to avoid overlap ([#5099](https://github.com/vuejs/vue-next/issues/5099)) ([44b9527](https://github.com/vuejs/vue-next/commit/44b95276f5c086e1d88fa3c686a5f39eb5bb7821)) +* **ssr:** make computed inactive during ssr, fix memory leak ([f4f0966](https://github.com/vuejs/vue-next/commit/f4f0966b33863ac0fca6a20cf9e8ddfbb311ae87)), closes [#5208](https://github.com/vuejs/vue-next/issues/5208) +* **ssr:** remove missing ssr directive transform error ([55cc4af](https://github.com/vuejs/vue-next/commit/55cc4af25e6f4924b267620bd965e496f260d41a)) +* **types/tsx:** allow ref_for type on tsx elements ([78df8c7](https://github.com/vuejs/vue-next/commit/78df8c78c4539d2408278d1a11612b6bbc47d22f)) +* **types:** fix shallowReadonly type ([92f11d6](https://github.com/vuejs/vue-next/commit/92f11d6740929f5b591740e30ae5fba50940ec82)) +* **types:** handle ToRef ([5ac7030](https://github.com/vuejs/vue-next/commit/5ac703055fa83cb1e8a173bbd6a4d6c33707a3c3)), closes [#5188](https://github.com/vuejs/vue-next/issues/5188) +* **types:** KeepAlive match pattern should allow mixed array ([3007d5b](https://github.com/vuejs/vue-next/commit/3007d5b4cafed1da445bc498f771bd2c79eda6fc)) + + +### Features + +* **types:** simplify `ExtractPropTypes` to avoid props JSDocs being removed ([#5166](https://github.com/vuejs/vue-next/issues/5166)) ([a570b38](https://github.com/vuejs/vue-next/commit/a570b38741a7dc259772c5ccce7ea8a1638eb0bd)) + + +### Performance Improvements + +* improve memory usage for static vnodes ([ed9eb62](https://github.com/vuejs/vue-next/commit/ed9eb62e5992bd575d999c4197330d8bad622cfb)) + + + ## [3.2.26](https://github.com/vuejs/vue-next/compare/v3.2.25...v3.2.26) (2021-12-12) diff --git a/package.json b/package.json index 5fb460ccc3e..6fabb1c3bcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "3.2.26", + "version": "3.2.27", "scripts": { "dev": "node scripts/dev.js", "build": "node scripts/build.js", diff --git a/packages/compiler-core/package.json b/packages/compiler-core/package.json index edadd90b1b5..097681e4ce7 100644 --- a/packages/compiler-core/package.json +++ b/packages/compiler-core/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-core", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/compiler-core", "main": "index.js", "module": "dist/compiler-core.esm-bundler.js", @@ -32,7 +32,7 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-core#readme", "dependencies": { - "@vue/shared": "3.2.26", + "@vue/shared": "3.2.27", "@babel/parser": "^7.16.4", "estree-walker": "^2.0.2", "source-map": "^0.6.1" diff --git a/packages/compiler-dom/package.json b/packages/compiler-dom/package.json index b2529f9bbbc..2451f6400af 100644 --- a/packages/compiler-dom/package.json +++ b/packages/compiler-dom/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-dom", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/compiler-dom", "main": "index.js", "module": "dist/compiler-dom.esm-bundler.js", @@ -37,7 +37,7 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-dom#readme", "dependencies": { - "@vue/shared": "3.2.26", - "@vue/compiler-core": "3.2.26" + "@vue/shared": "3.2.27", + "@vue/compiler-core": "3.2.27" } } diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index beb3ef9a2b0..f0f434d486f 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-sfc", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/compiler-sfc", "main": "dist/compiler-sfc.cjs.js", "module": "dist/compiler-sfc.esm-browser.js", @@ -33,11 +33,11 @@ "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-sfc#readme", "dependencies": { "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.26", - "@vue/compiler-dom": "3.2.26", - "@vue/compiler-ssr": "3.2.26", - "@vue/reactivity-transform": "3.2.26", - "@vue/shared": "3.2.26", + "@vue/compiler-core": "3.2.27", + "@vue/compiler-dom": "3.2.27", + "@vue/compiler-ssr": "3.2.27", + "@vue/reactivity-transform": "3.2.27", + "@vue/shared": "3.2.27", "estree-walker": "^2.0.2", "magic-string": "^0.25.7", "source-map": "^0.6.1", diff --git a/packages/compiler-ssr/package.json b/packages/compiler-ssr/package.json index 5d580a56431..d0e24cfeb21 100644 --- a/packages/compiler-ssr/package.json +++ b/packages/compiler-ssr/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-ssr", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/compiler-ssr", "main": "dist/compiler-ssr.cjs.js", "types": "dist/compiler-ssr.d.ts", @@ -28,7 +28,7 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-ssr#readme", "dependencies": { - "@vue/shared": "3.2.26", - "@vue/compiler-dom": "3.2.26" + "@vue/shared": "3.2.27", + "@vue/compiler-dom": "3.2.27" } } diff --git a/packages/reactivity-transform/package.json b/packages/reactivity-transform/package.json index 73e23947f76..1ab3860ab0b 100644 --- a/packages/reactivity-transform/package.json +++ b/packages/reactivity-transform/package.json @@ -1,6 +1,6 @@ { "name": "@vue/reactivity-transform", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/reactivity-transform", "main": "dist/reactivity-transform.cjs.js", "files": [ @@ -29,8 +29,8 @@ "homepage": "https://github.com/vuejs/vue-next/tree/dev/packages/reactivity-transform#readme", "dependencies": { "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.26", - "@vue/shared": "3.2.26", + "@vue/compiler-core": "3.2.27", + "@vue/shared": "3.2.27", "estree-walker": "^2.0.2", "magic-string": "^0.25.7" }, diff --git a/packages/reactivity/package.json b/packages/reactivity/package.json index f799cd314a1..6ff3b7938f0 100644 --- a/packages/reactivity/package.json +++ b/packages/reactivity/package.json @@ -1,6 +1,6 @@ { "name": "@vue/reactivity", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/reactivity", "main": "index.js", "module": "dist/reactivity.esm-bundler.js", @@ -36,6 +36,6 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/reactivity#readme", "dependencies": { - "@vue/shared": "3.2.26" + "@vue/shared": "3.2.27" } } diff --git a/packages/runtime-core/package.json b/packages/runtime-core/package.json index ff5613b37bc..317c7da9b26 100644 --- a/packages/runtime-core/package.json +++ b/packages/runtime-core/package.json @@ -1,6 +1,6 @@ { "name": "@vue/runtime-core", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/runtime-core", "main": "index.js", "module": "dist/runtime-core.esm-bundler.js", @@ -32,7 +32,7 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/runtime-core#readme", "dependencies": { - "@vue/shared": "3.2.26", - "@vue/reactivity": "3.2.26" + "@vue/shared": "3.2.27", + "@vue/reactivity": "3.2.27" } } diff --git a/packages/runtime-dom/package.json b/packages/runtime-dom/package.json index 4203594c1cf..396d4fcd182 100644 --- a/packages/runtime-dom/package.json +++ b/packages/runtime-dom/package.json @@ -1,6 +1,6 @@ { "name": "@vue/runtime-dom", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/runtime-dom", "main": "index.js", "module": "dist/runtime-dom.esm-bundler.js", @@ -35,8 +35,8 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/runtime-dom#readme", "dependencies": { - "@vue/shared": "3.2.26", - "@vue/runtime-core": "3.2.26", + "@vue/shared": "3.2.27", + "@vue/runtime-core": "3.2.27", "csstype": "^2.6.8" } } diff --git a/packages/runtime-test/package.json b/packages/runtime-test/package.json index 10cf10eac9f..23dd5933a1b 100644 --- a/packages/runtime-test/package.json +++ b/packages/runtime-test/package.json @@ -1,6 +1,6 @@ { "name": "@vue/runtime-test", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/runtime-test", "private": true, "main": "index.js", @@ -25,7 +25,7 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/runtime-test#readme", "dependencies": { - "@vue/shared": "3.2.26", - "@vue/runtime-core": "3.2.26" + "@vue/shared": "3.2.27", + "@vue/runtime-core": "3.2.27" } } diff --git a/packages/server-renderer/package.json b/packages/server-renderer/package.json index 0c9eec993c4..90754109125 100644 --- a/packages/server-renderer/package.json +++ b/packages/server-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@vue/server-renderer", - "version": "3.2.26", + "version": "3.2.27", "description": "@vue/server-renderer", "main": "index.js", "module": "dist/server-renderer.esm-bundler.js", @@ -31,10 +31,10 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/server-renderer#readme", "peerDependencies": { - "vue": "3.2.26" + "vue": "3.2.27" }, "dependencies": { - "@vue/shared": "3.2.26", - "@vue/compiler-ssr": "3.2.26" + "@vue/shared": "3.2.27", + "@vue/compiler-ssr": "3.2.27" } } diff --git a/packages/sfc-playground/package.json b/packages/sfc-playground/package.json index fb2178283f0..30d76c9af81 100644 --- a/packages/sfc-playground/package.json +++ b/packages/sfc-playground/package.json @@ -1,6 +1,6 @@ { "name": "@vue/sfc-playground", - "version": "3.2.26", + "version": "3.2.27", "private": true, "scripts": { "dev": "vite", @@ -12,7 +12,7 @@ "vite": "^2.7.1" }, "dependencies": { - "vue": "3.2.26", + "vue": "3.2.27", "@vue/repl": "^0.4.8", "file-saver": "^2.0.5", "jszip": "^3.6.0" diff --git a/packages/shared/package.json b/packages/shared/package.json index a41f9c5fd57..08bd54d15f3 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@vue/shared", - "version": "3.2.26", + "version": "3.2.27", "description": "internal utils shared across @vue packages", "main": "index.js", "module": "dist/shared.esm-bundler.js", diff --git a/packages/size-check/package.json b/packages/size-check/package.json index 3789b7c9096..1bbb29bbee2 100644 --- a/packages/size-check/package.json +++ b/packages/size-check/package.json @@ -1,6 +1,6 @@ { "name": "@vue/size-check", - "version": "3.2.26", + "version": "3.2.27", "private": true, "scripts": { "build": "vite build" diff --git a/packages/template-explorer/package.json b/packages/template-explorer/package.json index 338d6987874..05c02976c74 100644 --- a/packages/template-explorer/package.json +++ b/packages/template-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@vue/template-explorer", - "version": "3.2.26", + "version": "3.2.27", "private": true, "buildOptions": { "formats": [ diff --git a/packages/vue-compat/package.json b/packages/vue-compat/package.json index 7795b639f23..753c56502a3 100644 --- a/packages/vue-compat/package.json +++ b/packages/vue-compat/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compat", - "version": "3.2.26", + "version": "3.2.27", "description": "Vue 3 compatibility build for Vue 2", "main": "index.js", "module": "dist/vue.runtime.esm-bundler.js", @@ -38,6 +38,6 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/vue-compat#readme", "peerDependencies": { - "vue": "3.2.26" + "vue": "3.2.27" } } diff --git a/packages/vue/package.json b/packages/vue/package.json index e31b4aaa476..d62b1bb768e 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,6 +1,6 @@ { "name": "vue", - "version": "3.2.26", + "version": "3.2.27", "description": "The progressive JavaScript framework for building modern web UI.", "main": "index.js", "module": "dist/vue.runtime.esm-bundler.js", @@ -66,10 +66,10 @@ }, "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/vue#readme", "dependencies": { - "@vue/shared": "3.2.26", - "@vue/compiler-dom": "3.2.26", - "@vue/runtime-dom": "3.2.26", - "@vue/compiler-sfc": "3.2.26", - "@vue/server-renderer": "3.2.26" + "@vue/shared": "3.2.27", + "@vue/compiler-dom": "3.2.27", + "@vue/runtime-dom": "3.2.27", + "@vue/compiler-sfc": "3.2.27", + "@vue/server-renderer": "3.2.27" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 714ed713382..79f5d796420 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,7 +104,7 @@ importers: specifiers: '@babel/parser': ^7.16.4 '@babel/types': ^7.16.0 - '@vue/shared': 3.2.26 + '@vue/shared': 3.2.27 estree-walker: ^2.0.2 source-map: ^0.6.1 dependencies: @@ -117,8 +117,8 @@ importers: packages/compiler-dom: specifiers: - '@vue/compiler-core': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/compiler-core': 3.2.27 + '@vue/shared': 3.2.27 dependencies: '@vue/compiler-core': link:../compiler-core '@vue/shared': link:../shared @@ -129,12 +129,12 @@ importers: '@babel/types': ^7.16.0 '@types/estree': ^0.0.48 '@types/lru-cache': ^5.1.0 - '@vue/compiler-core': 3.2.26 - '@vue/compiler-dom': 3.2.26 - '@vue/compiler-ssr': 3.2.26 + '@vue/compiler-core': 3.2.27 + '@vue/compiler-dom': 3.2.27 + '@vue/compiler-ssr': 3.2.27 '@vue/consolidate': ^0.17.3 - '@vue/reactivity-transform': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/reactivity-transform': 3.2.27 + '@vue/shared': 3.2.27 estree-walker: ^2.0.2 hash-sum: ^2.0.0 lru-cache: ^5.1.1 @@ -172,15 +172,15 @@ importers: packages/compiler-ssr: specifiers: - '@vue/compiler-dom': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/compiler-dom': 3.2.27 + '@vue/shared': 3.2.27 dependencies: '@vue/compiler-dom': link:../compiler-dom '@vue/shared': link:../shared packages/reactivity: specifiers: - '@vue/shared': 3.2.26 + '@vue/shared': 3.2.27 dependencies: '@vue/shared': link:../shared @@ -189,8 +189,8 @@ importers: '@babel/core': ^7.16.0 '@babel/parser': ^7.16.4 '@babel/types': ^7.16.0 - '@vue/compiler-core': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/compiler-core': 3.2.27 + '@vue/shared': 3.2.27 estree-walker: ^2.0.2 magic-string: ^0.25.7 dependencies: @@ -205,16 +205,16 @@ importers: packages/runtime-core: specifiers: - '@vue/reactivity': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/reactivity': 3.2.27 + '@vue/shared': 3.2.27 dependencies: '@vue/reactivity': link:../reactivity '@vue/shared': link:../shared packages/runtime-dom: specifiers: - '@vue/runtime-core': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/runtime-core': 3.2.27 + '@vue/shared': 3.2.27 csstype: ^2.6.8 dependencies: '@vue/runtime-core': link:../runtime-core @@ -223,16 +223,16 @@ importers: packages/runtime-test: specifiers: - '@vue/runtime-core': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/runtime-core': 3.2.27 + '@vue/shared': 3.2.27 dependencies: '@vue/runtime-core': link:../runtime-core '@vue/shared': link:../shared packages/server-renderer: specifiers: - '@vue/compiler-ssr': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/compiler-ssr': 3.2.27 + '@vue/shared': 3.2.27 dependencies: '@vue/compiler-ssr': link:../compiler-ssr '@vue/shared': link:../shared @@ -244,7 +244,7 @@ importers: file-saver: ^2.0.5 jszip: ^3.6.0 vite: ^2.7.1 - vue: 3.2.26 + vue: 3.2.27 dependencies: '@vue/repl': 0.4.8 file-saver: 2.0.5 @@ -270,11 +270,11 @@ importers: packages/vue: specifiers: - '@vue/compiler-dom': 3.2.26 - '@vue/compiler-sfc': 3.2.26 - '@vue/runtime-dom': 3.2.26 - '@vue/server-renderer': 3.2.26 - '@vue/shared': 3.2.26 + '@vue/compiler-dom': 3.2.27 + '@vue/compiler-sfc': 3.2.27 + '@vue/runtime-dom': 3.2.27 + '@vue/server-renderer': 3.2.27 + '@vue/shared': 3.2.27 dependencies: '@vue/compiler-dom': link:../compiler-dom '@vue/compiler-sfc': link:../compiler-sfc From 8cbfe092cf9c517e79365151d6a7994c36fbe7c8 Mon Sep 17 00:00:00 2001 From: JayFate <48240828+JayFate@users.noreply.github.com> Date: Tue, 18 Jan 2022 07:34:47 +0800 Subject: [PATCH 20/23] docs(contributing): missing structure info for compiler-sfc (#3559) [ci skip] --- .github/contributing.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/contributing.md b/.github/contributing.md index 2b0995a1ef1..773b942a51a 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -178,6 +178,8 @@ This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) set - `compiler-dom`: Compiler with additional plugins specifically targeting the browser. +- `compiler-sfc`: Lower level utilities for compiling Vue Single File Components. + - `compiler-ssr`: Compiler that produces render functions optimized for server-side rendering. - `template-explorer`: A development tool for debugging compiler output. You can run `nr dev template-explorer` and open its `index.html` to get a repl of template compilation based on current source code. From 0c06c748a511f2e7c38f8a6fb13b99561312d15e Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 18 Jan 2022 07:57:00 +0800 Subject: [PATCH 21/23] chore: bump marked --- package.json | 2 +- packages/vue/examples/classic/markdown.html | 2 +- packages/vue/examples/composition/markdown.html | 2 +- pnpm-lock.yaml | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 6fabb1c3bcc..de73907e213 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "jest": "^27.1.0", "lint-staged": "^10.2.10", "lodash": "^4.17.15", - "marked": "^0.7.0", + "marked": "^4.0.10", "minimist": "^1.2.0", "npm-run-all": "^4.1.5", "prettier": "^2.3.1", diff --git a/packages/vue/examples/classic/markdown.html b/packages/vue/examples/classic/markdown.html index 61e64f6e3cb..f70a75d692e 100644 --- a/packages/vue/examples/classic/markdown.html +++ b/packages/vue/examples/classic/markdown.html @@ -14,7 +14,7 @@ }), computed: { compiledMarkdown() { - return marked(this.input, { sanitize: true }) + return marked.marked(this.input, { sanitize: true }) } }, methods: { diff --git a/packages/vue/examples/composition/markdown.html b/packages/vue/examples/composition/markdown.html index 8734cf6aed2..151a8a8c141 100644 --- a/packages/vue/examples/composition/markdown.html +++ b/packages/vue/examples/composition/markdown.html @@ -13,7 +13,7 @@ Vue.createApp({ setup() { const input = ref('# hello') - const output = computed(() => marked(input.value, { sanitize: true })) + const output = computed(() => marked.marked(input.value, { sanitize: true })) const update = _.debounce(e => { input.value = e.target.value }, 50) return { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79f5d796420..424319db61a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,7 +31,7 @@ importers: jest: ^27.1.0 lint-staged: ^10.2.10 lodash: ^4.17.15 - marked: ^0.7.0 + marked: ^4.0.10 minimist: ^1.2.0 npm-run-all: ^4.1.5 prettier: ^2.3.1 @@ -79,7 +79,7 @@ importers: jest: 27.4.4 lint-staged: 10.5.4 lodash: 4.17.21 - marked: 0.7.0 + marked: 4.0.10 minimist: 1.2.5 npm-run-all: 4.1.5 prettier: 2.5.1 @@ -4978,9 +4978,9 @@ packages: engines: {node: '>=8'} dev: true - /marked/0.7.0: - resolution: {integrity: sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==} - engines: {node: '>=0.10.0'} + /marked/4.0.10: + resolution: {integrity: sha512-+QvuFj0nGgO970fySghXGmuw+Fd0gD2x3+MqCWLIPf5oxdv1Ka6b2q+z9RP01P/IaKPMEramy+7cNy/Lw8c3hw==} + engines: {node: '>= 12'} hasBin: true dev: true From 9fda9411ec92dc703288b229106116dd0f16e5e7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 18 Jan 2022 09:17:22 +0800 Subject: [PATCH 22/23] feat(reactivity): add isShallow api --- packages/reactivity/__tests__/ref.spec.ts | 5 +++++ .../reactivity/__tests__/shallowReactive.spec.ts | 13 ++++++++++++- packages/reactivity/src/baseHandlers.ts | 2 ++ packages/reactivity/src/index.ts | 1 + packages/reactivity/src/reactive.ts | 8 +++++++- packages/reactivity/src/ref.ts | 14 +++++--------- packages/runtime-core/src/apiWatch.ts | 3 ++- packages/runtime-core/src/customFormatter.ts | 7 ++++--- packages/runtime-core/src/index.ts | 1 + 9 files changed, 39 insertions(+), 15 deletions(-) diff --git a/packages/reactivity/__tests__/ref.spec.ts b/packages/reactivity/__tests__/ref.spec.ts index 0db801a5a42..2451c43ab45 100644 --- a/packages/reactivity/__tests__/ref.spec.ts +++ b/packages/reactivity/__tests__/ref.spec.ts @@ -10,6 +10,7 @@ import { } from '../src/index' import { computed } from '@vue/runtime-dom' import { shallowRef, unref, customRef, triggerRef } from '../src/ref' +import { isShallow } from '../src/reactive' describe('reactivity/ref', () => { it('should hold a value', () => { @@ -227,6 +228,10 @@ describe('reactivity/ref', () => { expect(dummy).toBe(2) }) + test('shallowRef isShallow', () => { + expect(isShallow(shallowRef({ a: 1 }))).toBe(true) + }) + test('isRef', () => { expect(isRef(ref(1))).toBe(true) expect(isRef(computed(() => 1))).toBe(true) diff --git a/packages/reactivity/__tests__/shallowReactive.spec.ts b/packages/reactivity/__tests__/shallowReactive.spec.ts index cfd870dc002..f7c7e07b055 100644 --- a/packages/reactivity/__tests__/shallowReactive.spec.ts +++ b/packages/reactivity/__tests__/shallowReactive.spec.ts @@ -1,4 +1,10 @@ -import { isReactive, reactive, shallowReactive } from '../src/reactive' +import { + isReactive, + isShallow, + reactive, + shallowReactive, + shallowReadonly +} from '../src/reactive' import { effect } from '../src/effect' @@ -24,6 +30,11 @@ describe('shallowReactive', () => { expect(isReactive(reactiveProxy.foo)).toBe(true) }) + test('isShallow', () => { + expect(isShallow(shallowReactive({}))).toBe(true) + expect(isShallow(shallowReadonly({}))).toBe(true) + }) + describe('collections', () => { test('should be reactive', () => { const shallowSet = shallowReactive(new Set()) diff --git a/packages/reactivity/src/baseHandlers.ts b/packages/reactivity/src/baseHandlers.ts index 0fa1c4bc2ea..3d2ba661973 100644 --- a/packages/reactivity/src/baseHandlers.ts +++ b/packages/reactivity/src/baseHandlers.ts @@ -84,6 +84,8 @@ function createGetter(isReadonly = false, shallow = false) { return !isReadonly } else if (key === ReactiveFlags.IS_READONLY) { return isReadonly + } else if (key === ReactiveFlags.IS_SHALLOW) { + return shallow } else if ( key === ReactiveFlags.RAW && receiver === diff --git a/packages/reactivity/src/index.ts b/packages/reactivity/src/index.ts index 676f8598fb3..a7a03b8c573 100644 --- a/packages/reactivity/src/index.ts +++ b/packages/reactivity/src/index.ts @@ -22,6 +22,7 @@ export { readonly, isReactive, isReadonly, + isShallow, isProxy, shallowReactive, shallowReadonly, diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 4716230e40f..7d7e591fc4a 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -17,6 +17,7 @@ export const enum ReactiveFlags { SKIP = '__v_skip', IS_REACTIVE = '__v_isReactive', IS_READONLY = '__v_isReadonly', + IS_SHALLOW = '__v_isShallow', RAW = '__v_raw' } @@ -24,6 +25,7 @@ export interface Target { [ReactiveFlags.SKIP]?: boolean [ReactiveFlags.IS_REACTIVE]?: boolean [ReactiveFlags.IS_READONLY]?: boolean + [ReactiveFlags.IS_SHALLOW]?: boolean [ReactiveFlags.RAW]?: any } @@ -87,7 +89,7 @@ export type UnwrapNestedRefs = T extends Ref ? T : UnwrapRefSimple export function reactive(target: T): UnwrapNestedRefs export function reactive(target: object) { // if trying to observe a readonly proxy, return the readonly version. - if (target && (target as Target)[ReactiveFlags.IS_READONLY]) { + if (isReadonly(target)) { return target } return createReactiveObject( @@ -226,6 +228,10 @@ export function isReadonly(value: unknown): boolean { return !!(value && (value as Target)[ReactiveFlags.IS_READONLY]) } +export function isShallow(value: unknown): boolean { + return !!(value && (value as Target)[ReactiveFlags.IS_SHALLOW]) +} + export function isProxy(value: unknown): boolean { return isReactive(value) || isReadonly(value) } diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index c972676ac42..20aa6c0a989 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -16,10 +16,6 @@ export interface Ref { * autocomplete, so we use a private Symbol instead. */ [RefSymbol]: true - /** - * @internal - */ - _shallow?: boolean } type RefBase = { @@ -102,9 +98,9 @@ class RefImpl { public dep?: Dep = undefined public readonly __v_isRef = true - constructor(value: T, public readonly _shallow: boolean) { - this._rawValue = _shallow ? value : toRaw(value) - this._value = _shallow ? value : toReactive(value) + constructor(value: T, public readonly __v_isShallow: boolean) { + this._rawValue = __v_isShallow ? value : toRaw(value) + this._value = __v_isShallow ? value : toReactive(value) } get value() { @@ -113,10 +109,10 @@ class RefImpl { } set value(newVal) { - newVal = this._shallow ? newVal : toRaw(newVal) + newVal = this.__v_isShallow ? newVal : toRaw(newVal) if (hasChanged(newVal, this._rawValue)) { this._rawValue = newVal - this._value = this._shallow ? newVal : toReactive(newVal) + this._value = this.__v_isShallow ? newVal : toReactive(newVal) triggerRefValue(this, newVal) } } diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index b26c3ee2388..fd09c7434e3 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/packages/runtime-core/src/apiWatch.ts @@ -1,5 +1,6 @@ import { isRef, + isShallow, Ref, ComputedRef, ReactiveEffect, @@ -205,7 +206,7 @@ function doWatch( if (isRef(source)) { getter = () => source.value - forceTrigger = !!source._shallow + forceTrigger = isShallow(source) } else if (isReactive(source)) { getter = () => source deep = true diff --git a/packages/runtime-core/src/customFormatter.ts b/packages/runtime-core/src/customFormatter.ts index e628f75bad4..768240feb62 100644 --- a/packages/runtime-core/src/customFormatter.ts +++ b/packages/runtime-core/src/customFormatter.ts @@ -1,5 +1,6 @@ import { isReactive, isReadonly, isRef, Ref, toRaw } from '@vue/reactivity' import { EMPTY_OBJ, extend, isArray, isFunction, isObject } from '@vue/shared' +import { isShallow } from '../../reactivity/src/reactive' import { ComponentInternalInstance, ComponentOptions } from './component' import { ComponentPublicInstance } from './componentPublicInstance' @@ -38,7 +39,7 @@ export function initCustomFormatter() { return [ 'div', {}, - ['span', vueStyle, 'Reactive'], + ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'], '<', formatValue(obj), `>${isReadonly(obj) ? ` (readonly)` : ``}` @@ -47,7 +48,7 @@ export function initCustomFormatter() { return [ 'div', {}, - ['span', vueStyle, 'Readonly'], + ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'], '<', formatValue(obj), '>' @@ -181,7 +182,7 @@ export function initCustomFormatter() { } function genRefFlag(v: Ref) { - if (v._shallow) { + if (isShallow(v)) { return `ShallowRef` } if ((v as any).effect) { diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 65fc62b3e2f..ad4817d91b9 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -15,6 +15,7 @@ export { isProxy, isReactive, isReadonly, + isShallow, // advanced customRef, triggerRef, From 9c304bfe7942a20264235865b4bb5f6e53fdee0d Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 18 Jan 2022 09:22:03 +0800 Subject: [PATCH 23/23] fix(reactivity): differentiate shallow/deep proxies of same target when nested in reactive fix #5271 --- .../__tests__/shallowReactive.spec.ts | 20 +++++++++++++++++++ packages/reactivity/src/baseHandlers.ts | 9 ++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/packages/reactivity/__tests__/shallowReactive.spec.ts b/packages/reactivity/__tests__/shallowReactive.spec.ts index f7c7e07b055..200aa462496 100644 --- a/packages/reactivity/__tests__/shallowReactive.spec.ts +++ b/packages/reactivity/__tests__/shallowReactive.spec.ts @@ -35,6 +35,26 @@ describe('shallowReactive', () => { expect(isShallow(shallowReadonly({}))).toBe(true) }) + // #5271 + test('should respect shallow reactive nested inside reactive on reset', () => { + const r = reactive({ foo: shallowReactive({ bar: {} }) }) + expect(isShallow(r.foo)).toBe(true) + expect(isReactive(r.foo.bar)).toBe(false) + + r.foo = shallowReactive({ bar: {} }) + expect(isShallow(r.foo)).toBe(true) + expect(isReactive(r.foo.bar)).toBe(false) + }) + + test('should respect shallow/deep versions of same target on access', () => { + const original = {} + const shallow = shallowReactive(original) + const deep = reactive(original) + const r = reactive({ shallow, deep }) + expect(r.shallow).toBe(shallow) + expect(r.deep).toBe(deep) + }) + describe('collections', () => { test('should be reactive', () => { const shallowSet = shallowReactive(new Set()) diff --git a/packages/reactivity/src/baseHandlers.ts b/packages/reactivity/src/baseHandlers.ts index 3d2ba661973..97acf063f67 100644 --- a/packages/reactivity/src/baseHandlers.ts +++ b/packages/reactivity/src/baseHandlers.ts @@ -8,7 +8,8 @@ import { reactiveMap, shallowReactiveMap, shallowReadonlyMap, - isReadonly + isReadonly, + isShallow } from './reactive' import { TrackOpTypes, TriggerOpTypes } from './operations' import { @@ -150,8 +151,10 @@ function createSetter(shallow = false) { ): boolean { let oldValue = (target as any)[key] if (!shallow && !isReadonly(value)) { - value = toRaw(value) - oldValue = toRaw(oldValue) + if (!isShallow(value)) { + value = toRaw(value) + oldValue = toRaw(oldValue) + } if (!isArray(target) && isRef(oldValue) && !isRef(value)) { oldValue.value = value return true