Skip to content

Commit 2105a3c

Browse files
authored
Merge branch 'master' into fix/444/reused-instances
2 parents c518750 + e47c84c commit 2105a3c

File tree

10 files changed

+516
-274
lines changed

10 files changed

+516
-274
lines changed

__tests__/mount.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
Component,
32
createApp,
43
defineComponent,
54
h,
@@ -62,12 +61,15 @@ export function mount(
6261
targetComponent: Parameters<typeof createApp>[0],
6362
options: Partial<MountOptions> = {}
6463
): Promise<Wrapper> {
65-
const TargetComponent = targetComponent as Component
64+
const TargetComponent = targetComponent
6665
return new Promise(resolve => {
6766
// NOTE: only supports props as an object
6867
const propsData = reactive(
6968
Object.assign(
70-
initialProps(TargetComponent.props || {}),
69+
initialProps(
70+
// @ts-ignore
71+
TargetComponent.props || {}
72+
),
7173
options.propsData
7274
)
7375
)
@@ -85,7 +87,7 @@ export function mount(
8587

8688
return () => {
8789
return h(
88-
TargetComponent,
90+
TargetComponent as any,
8991
{
9092
ref: componentInstanceRef,
9193
onVnodeMounted() {

__tests__/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export function createDom(options?: ConstructorOptions) {
103103
}
104104
)
105105

106+
// @ts-ignore: TODO: remove this line then?
106107
global.window = dom.window
107108
global.location = dom.window.location
108109
global.history = dom.window.history

docs/guide/advanced/transitions.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Transitions
22

3-
TODO: redo this page once it's good to use in Vue router
4-
53
Since the `<router-view>` is essentially a dynamic component, we can apply transition effects to it the same way using the `<transition>` component:
64

75
```html
8-
<transition>
9-
<router-view></router-view>
10-
</transition>
6+
<router-view v-slot="{ Component }">
7+
<transition>
8+
<component :is="Component" />
9+
</transition>
10+
</router-view>
1111
```
1212

1313
[All transition APIs](https://vuejs.org/guide/transitions.html) work the same here.

netlify.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[build]
2+
ignore = "./scripts/docs-check.sh"
3+
publish = "docs/.vitepress/dist"
4+
command = "yarn run docs:build"

package.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"test:e2e": "yarn run test:e2e:headless && yarn run test:e2e:native",
3838
"test:e2e:headless": "node e2e/runner.js -e chrome-headless --skiptags no-headless",
3939
"test:e2e:native": "node e2e/runner.js -e chrome --tag no-headless",
40-
"test:e2e:ci": "node e2e/runner.js -e firefox --retries 2"
40+
"test:e2e:ci": "node e2e/runner.js -e firefox --retries 2",
41+
"postinstall": "patch-package"
4142
},
4243
"gitHooks": {
4344
"pre-commit": "lint-staged",
@@ -60,7 +61,7 @@
6061
}
6162
],
6263
"peerDependencies": {
63-
"vue": "^3.0.0-rc.5"
64+
"vue": "^3.0.0-rc.9"
6465
},
6566
"vetur": {
6667
"tags": "vetur/tags.json",
@@ -70,45 +71,47 @@
7071
"@microsoft/api-documenter": "^7.8.33",
7172
"@microsoft/api-extractor": "^7.8.1",
7273
"@rollup/plugin-alias": "^3.1.1",
73-
"@rollup/plugin-commonjs": "^14.0.0",
74-
"@rollup/plugin-node-resolve": "^8.4.0",
74+
"@rollup/plugin-commonjs": "^15.0.0",
75+
"@rollup/plugin-node-resolve": "^9.0.0",
7576
"@rollup/plugin-replace": "^2.3.3",
7677
"@size-limit/preset-small-lib": "^4.5.7",
7778
"@types/jest": "^26.0.10",
7879
"@types/jsdom": "^16.2.3",
7980
"@types/webpack": "^4.41.21",
8081
"@types/webpack-env": "^1.15.2",
81-
"@vue/compiler-sfc": "3.0.0-rc.5",
82+
"@vue/compiler-sfc": "3.0.0-rc.9",
8283
"@vue/server-renderer": "^3.0.0-rc.5",
83-
"axios": "^0.19.2",
84+
"axios": "^0.20.0",
8485
"browserstack-local": "^1.4.5",
8586
"chalk": "^4.1.0",
86-
"chromedriver": "^84.0.1",
87+
"chromedriver": "^85.0.0",
8788
"codecov": "^3.7.2",
8889
"conventional-changelog-cli": "^2.1.0",
8990
"css-loader": "^4.2.1",
9091
"dotenv": "^8.2.0",
9192
"faked-promise": "^2.2.2",
92-
"html-webpack-plugin": "^4.3.0",
93+
"html-webpack-plugin": "^4.4.1",
9394
"jest": "^26.4.2",
9495
"jest-mock-warn": "^1.1.0",
9596
"lint-staged": "^10.2.11",
9697
"nightwatch": "^1.3.7",
9798
"nightwatch-helpers": "^1.2.0",
99+
"patch-package": "^6.2.2",
100+
"postinstall-postinstall": "^2.1.0",
98101
"prettier": "^2.0.5",
99-
"rollup": "^2.26.5",
100-
"rollup-plugin-terser": "^6.1.0",
102+
"rollup": "^2.26.8",
103+
"rollup-plugin-terser": "^7.0.1",
101104
"rollup-plugin-typescript2": "^0.27.2",
102105
"selenium-server": "^3.141.59",
103106
"serve-handler": "^6.1.3",
104107
"size-limit": "^4.5.7",
105108
"style-loader": "^1.2.1",
106109
"ts-jest": "^26.2.0",
107110
"ts-loader": "^8.0.2",
108-
"ts-node": "^8.10.2",
111+
"ts-node": "^9.0.0",
109112
"typescript": "^3.9.7",
110113
"vitepress": "^0.5.0",
111-
"vue": "^3.0.0-rc.5",
114+
"vue": "^3.0.0-rc.9",
112115
"vue-loader": "^16.0.0-beta.5",
113116
"webpack": "^4.44.1",
114117
"webpack-bundle-analyzer": "^3.8.0",

patches/vite+1.0.0-rc.4.patch

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff --git a/node_modules/vite/dist/node/build/index.js b/node_modules/vite/dist/node/build/index.js
2+
index 923d0ea..7155e48 100644
3+
--- a/node_modules/vite/dist/node/build/index.js
4+
+++ b/node_modules/vite/dist/node/build/index.js
5+
@@ -351,7 +351,7 @@ async function build(options) {
6+
console.log(`Build completed in ${((Date.now() - start) / 1000).toFixed(2)}s.\n`);
7+
}
8+
// stop the esbuild service after each build
9+
- esbuildService_1.stopService();
10+
+ await esbuildService_1.stopService();
11+
return {
12+
assets: output,
13+
html: indexHtml
14+
diff --git a/node_modules/vite/dist/node/esbuildService.js b/node_modules/vite/dist/node/esbuildService.js
15+
index 0d5d11b..2caf9e3 100644
16+
--- a/node_modules/vite/dist/node/esbuildService.js
17+
+++ b/node_modules/vite/dist/node/esbuildService.js
18+
@@ -33,16 +33,19 @@ function resolveJsxOptions(options = 'vue') {
19+
}
20+
exports.resolveJsxOptions = resolveJsxOptions;
21+
// lazy start the service
22+
-let _service;
23+
-const ensureService = async () => {
24+
- if (!_service) {
25+
- _service = await esbuild_1.startService();
26+
+let _servicePromise;
27+
+const ensureService = () => {
28+
+ if (!_servicePromise) {
29+
+ _servicePromise = esbuild_1.startService();
30+
}
31+
- return _service;
32+
+ return _servicePromise;
33+
};
34+
-exports.stopService = () => {
35+
- _service && _service.stop();
36+
- _service = undefined;
37+
+exports.stopService = async () => {
38+
+ if (_servicePromise) {
39+
+ const service = await _servicePromise
40+
+ service.stop();
41+
+ _servicePromise = undefined;
42+
+ }
43+
};
44+
// transform used in server plugins with a more friendly API
45+
exports.transform = async (src, request, options = {}, jsxOption) => {

scripts/docs-check.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# check if doc files changes for netlify
4+
# needed because we cannot use && in netlify.toml
5+
6+
git diff --quiet 'HEAD^' HEAD ./docs/ && ! git diff 'HEAD^' HEAD ./yarn.lock | grep --quiet vite

src/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LocationQuery, LocationQueryRaw } from '../query'
22
import { PathParserOptions } from '../matcher'
3-
import { Ref, ComputedRef, Component, ComponentPublicInstance } from 'vue'
3+
import { Ref, ComputedRef, ComponentPublicInstance, Component } from 'vue'
44
import { RouteRecord, RouteRecordNormalized } from '../matcher/types'
55
import { HistoryState } from '../history/common'
66
import { NavigationFailure } from '../errors'

test-dts/createRouter.test-d.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,40 @@ import {
55
NavigationGuardNext,
66
RouteLocationNormalized,
77
} from './index'
8-
import { createApp, defineComponent } from 'vue'
8+
import { createApp, defineComponent, h } from 'vue'
99

1010
const component = defineComponent({})
1111

12+
const WithProps = defineComponent({
13+
props: {
14+
id: {
15+
type: String,
16+
required: true,
17+
},
18+
},
19+
})
20+
21+
const Foo = defineComponent({
22+
props: {
23+
test: String,
24+
},
25+
setup() {
26+
return {
27+
title: 'homepage',
28+
}
29+
},
30+
render() {
31+
return h('div', `${this.title}: ${this.test}`)
32+
},
33+
})
34+
1235
const router = createRouter({
1336
history: createWebHistory(),
14-
routes: [{ path: '/', component }],
37+
routes: [
38+
{ path: '/', component },
39+
{ path: '/foo', component: Foo },
40+
{ path: '/', component: WithProps },
41+
],
1542
parseQuery: search => ({}),
1643
stringifyQuery: query => '',
1744
strict: true,

0 commit comments

Comments
 (0)