Skip to content

[pull] master from vuejs:master #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2b506d7
chore: fix template exploerer boot with no storage
yyx990803 Jan 4, 2022
eb721d4
workflow: improve template explorer hash persistence
yyx990803 Jan 4, 2022
92f11d6
fix(types): fix shallowReadonly type
yyx990803 Jan 10, 2022
3007d5b
fix(types): KeepAlive match pattern should allow mixed array
yyx990803 Jan 12, 2022
ce49fdf
refactor: more readable type names for watch cleanup function
yyx990803 Jan 12, 2022
ff2d6d1
chore: comment usage of short property name
yyx990803 Jan 12, 2022
77283f4
test(types): test ComponentCustomProps
yyx990803 Jan 14, 2022
92fcb9d
workflow: use esbuild for dev scripts
yyx990803 Jan 14, 2022
4dd0f34
workflow: bump vite
yyx990803 Jan 14, 2022
55cc4af
fix(ssr): remove missing ssr directive transform error
yyx990803 Jan 16, 2022
2e3e183
fix(KeepAlive): remove cached VNode properly (#5260)
edison1105 Jan 16, 2022
6cfd72e
refactor: move type utils to shared
yyx990803 Jan 16, 2022
5ac7030
fix(types): handle ToRef<any>
yyx990803 Jan 16, 2022
78df8c7
fix(types/tsx): allow ref_for type on tsx elements
yyx990803 Jan 16, 2022
bc170e6
build: downgrade vite
yyx990803 Jan 16, 2022
4d07ed8
test: remove module augmentation test which does not work in the setup
yyx990803 Jan 16, 2022
f4f0966
fix(ssr): make computed inactive during ssr, fix memory leak
yyx990803 Jan 16, 2022
ed9eb62
perf: improve memory usage for static vnodes
yyx990803 Jan 16, 2022
3adfc0f
release: v3.2.27
yyx990803 Jan 16, 2022
8cbfe09
docs(contributing): missing structure info for compiler-sfc (#3559) […
JayFate Jan 17, 2022
0c06c74
chore: bump marked
yyx990803 Jan 17, 2022
9fda941
feat(reactivity): add isShallow api
yyx990803 Jan 18, 2022
9c304bf
fix(reactivity): differentiate shallow/deep proxies of same target wh…
yyx990803 Jan 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -175,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.
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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<any> ([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)


Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -66,13 +67,14 @@
"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",
"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",
Expand All @@ -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",
"vite": "^2.7.12",
"vue": "workspace:*",
"vite": "^2.7.1",
"yorkie": "^2.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/compiler-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.2.26",
"version": "3.2.27",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.2.26",
"version": "3.2.27",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/vuejs/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"
}
}
12 changes: 6 additions & 6 deletions packages/compiler-sfc/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-ssr/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
4 changes: 1 addition & 3 deletions packages/compiler-ssr/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
Expand Down
12 changes: 2 additions & 10 deletions packages/compiler-ssr/src/transforms/ssrTransformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/reactivity-transform/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/reactivity/__tests__/ref.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 32 additions & 1 deletion packages/reactivity/__tests__/shallowReactive.spec.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -24,6 +30,31 @@ describe('shallowReactive', () => {
expect(isReactive(reactiveProxy.foo)).toBe(true)
})

test('isShallow', () => {
expect(isShallow(shallowReactive({}))).toBe(true)
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())
Expand Down
4 changes: 2 additions & 2 deletions packages/reactivity/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
11 changes: 8 additions & 3 deletions packages/reactivity/src/baseHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
reactiveMap,
shallowReactiveMap,
shallowReadonlyMap,
isReadonly
isReadonly,
isShallow
} from './reactive'
import { TrackOpTypes, TriggerOpTypes } from './operations'
import {
Expand Down Expand Up @@ -84,6 +85,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 ===
Expand Down Expand Up @@ -148,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
Expand Down
Loading