Skip to content

Commit

Permalink
Merge branch 'master' into fix/444/reused-instances
Browse files Browse the repository at this point in the history
  • Loading branch information
posva authored Aug 31, 2020
2 parents c518750 + e47c84c commit 2105a3c
Show file tree
Hide file tree
Showing 10 changed files with 516 additions and 274 deletions.
10 changes: 6 additions & 4 deletions __tests__/mount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Component,
createApp,
defineComponent,
h,
Expand Down Expand Up @@ -62,12 +61,15 @@ export function mount(
targetComponent: Parameters<typeof createApp>[0],
options: Partial<MountOptions> = {}
): Promise<Wrapper> {
const TargetComponent = targetComponent as Component
const TargetComponent = targetComponent
return new Promise(resolve => {
// NOTE: only supports props as an object
const propsData = reactive(
Object.assign(
initialProps(TargetComponent.props || {}),
initialProps(
// @ts-ignore
TargetComponent.props || {}
),
options.propsData
)
)
Expand All @@ -85,7 +87,7 @@ export function mount(

return () => {
return h(
TargetComponent,
TargetComponent as any,
{
ref: componentInstanceRef,
onVnodeMounted() {
Expand Down
1 change: 1 addition & 0 deletions __tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function createDom(options?: ConstructorOptions) {
}
)

// @ts-ignore: TODO: remove this line then?
global.window = dom.window
global.location = dom.window.location
global.history = dom.window.history
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/advanced/transitions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Transitions

TODO: redo this page once it's good to use in Vue router

Since the `<router-view>` is essentially a dynamic component, we can apply transition effects to it the same way using the `<transition>` component:

```html
<transition>
<router-view></router-view>
</transition>
<router-view v-slot="{ Component }">
<transition>
<component :is="Component" />
</transition>
</router-view>
```

[All transition APIs](https://vuejs.org/guide/transitions.html) work the same here.
Expand Down
4 changes: 4 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build]
ignore = "./scripts/docs-check.sh"
publish = "docs/.vitepress/dist"
command = "yarn run docs:build"
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"test:e2e": "yarn run test:e2e:headless && yarn run test:e2e:native",
"test:e2e:headless": "node e2e/runner.js -e chrome-headless --skiptags no-headless",
"test:e2e:native": "node e2e/runner.js -e chrome --tag no-headless",
"test:e2e:ci": "node e2e/runner.js -e firefox --retries 2"
"test:e2e:ci": "node e2e/runner.js -e firefox --retries 2",
"postinstall": "patch-package"
},
"gitHooks": {
"pre-commit": "lint-staged",
Expand All @@ -60,7 +61,7 @@
}
],
"peerDependencies": {
"vue": "^3.0.0-rc.5"
"vue": "^3.0.0-rc.9"
},
"vetur": {
"tags": "vetur/tags.json",
Expand All @@ -70,45 +71,47 @@
"@microsoft/api-documenter": "^7.8.33",
"@microsoft/api-extractor": "^7.8.1",
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3",
"@size-limit/preset-small-lib": "^4.5.7",
"@types/jest": "^26.0.10",
"@types/jsdom": "^16.2.3",
"@types/webpack": "^4.41.21",
"@types/webpack-env": "^1.15.2",
"@vue/compiler-sfc": "3.0.0-rc.5",
"@vue/compiler-sfc": "3.0.0-rc.9",
"@vue/server-renderer": "^3.0.0-rc.5",
"axios": "^0.19.2",
"axios": "^0.20.0",
"browserstack-local": "^1.4.5",
"chalk": "^4.1.0",
"chromedriver": "^84.0.1",
"chromedriver": "^85.0.0",
"codecov": "^3.7.2",
"conventional-changelog-cli": "^2.1.0",
"css-loader": "^4.2.1",
"dotenv": "^8.2.0",
"faked-promise": "^2.2.2",
"html-webpack-plugin": "^4.3.0",
"html-webpack-plugin": "^4.4.1",
"jest": "^26.4.2",
"jest-mock-warn": "^1.1.0",
"lint-staged": "^10.2.11",
"nightwatch": "^1.3.7",
"nightwatch-helpers": "^1.2.0",
"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.0.5",
"rollup": "^2.26.5",
"rollup-plugin-terser": "^6.1.0",
"rollup": "^2.26.8",
"rollup-plugin-terser": "^7.0.1",
"rollup-plugin-typescript2": "^0.27.2",
"selenium-server": "^3.141.59",
"serve-handler": "^6.1.3",
"size-limit": "^4.5.7",
"style-loader": "^1.2.1",
"ts-jest": "^26.2.0",
"ts-loader": "^8.0.2",
"ts-node": "^8.10.2",
"ts-node": "^9.0.0",
"typescript": "^3.9.7",
"vitepress": "^0.5.0",
"vue": "^3.0.0-rc.5",
"vue": "^3.0.0-rc.9",
"vue-loader": "^16.0.0-beta.5",
"webpack": "^4.44.1",
"webpack-bundle-analyzer": "^3.8.0",
Expand Down
45 changes: 45 additions & 0 deletions patches/vite+1.0.0-rc.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/node_modules/vite/dist/node/build/index.js b/node_modules/vite/dist/node/build/index.js
index 923d0ea..7155e48 100644
--- a/node_modules/vite/dist/node/build/index.js
+++ b/node_modules/vite/dist/node/build/index.js
@@ -351,7 +351,7 @@ async function build(options) {
console.log(`Build completed in ${((Date.now() - start) / 1000).toFixed(2)}s.\n`);
}
// stop the esbuild service after each build
- esbuildService_1.stopService();
+ await esbuildService_1.stopService();
return {
assets: output,
html: indexHtml
diff --git a/node_modules/vite/dist/node/esbuildService.js b/node_modules/vite/dist/node/esbuildService.js
index 0d5d11b..2caf9e3 100644
--- a/node_modules/vite/dist/node/esbuildService.js
+++ b/node_modules/vite/dist/node/esbuildService.js
@@ -33,16 +33,19 @@ function resolveJsxOptions(options = 'vue') {
}
exports.resolveJsxOptions = resolveJsxOptions;
// lazy start the service
-let _service;
-const ensureService = async () => {
- if (!_service) {
- _service = await esbuild_1.startService();
+let _servicePromise;
+const ensureService = () => {
+ if (!_servicePromise) {
+ _servicePromise = esbuild_1.startService();
}
- return _service;
+ return _servicePromise;
};
-exports.stopService = () => {
- _service && _service.stop();
- _service = undefined;
+exports.stopService = async () => {
+ if (_servicePromise) {
+ const service = await _servicePromise
+ service.stop();
+ _servicePromise = undefined;
+ }
};
// transform used in server plugins with a more friendly API
exports.transform = async (src, request, options = {}, jsxOption) => {
6 changes: 6 additions & 0 deletions scripts/docs-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# check if doc files changes for netlify
# needed because we cannot use && in netlify.toml

git diff --quiet 'HEAD^' HEAD ./docs/ && ! git diff 'HEAD^' HEAD ./yarn.lock | grep --quiet vite
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LocationQuery, LocationQueryRaw } from '../query'
import { PathParserOptions } from '../matcher'
import { Ref, ComputedRef, Component, ComponentPublicInstance } from 'vue'
import { Ref, ComputedRef, ComponentPublicInstance, Component } from 'vue'
import { RouteRecord, RouteRecordNormalized } from '../matcher/types'
import { HistoryState } from '../history/common'
import { NavigationFailure } from '../errors'
Expand Down
31 changes: 29 additions & 2 deletions test-dts/createRouter.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,40 @@ import {
NavigationGuardNext,
RouteLocationNormalized,
} from './index'
import { createApp, defineComponent } from 'vue'
import { createApp, defineComponent, h } from 'vue'

const component = defineComponent({})

const WithProps = defineComponent({
props: {
id: {
type: String,
required: true,
},
},
})

const Foo = defineComponent({
props: {
test: String,
},
setup() {
return {
title: 'homepage',
}
},
render() {
return h('div', `${this.title}: ${this.test}`)
},
})

const router = createRouter({
history: createWebHistory(),
routes: [{ path: '/', component }],
routes: [
{ path: '/', component },
{ path: '/foo', component: Foo },
{ path: '/', component: WithProps },
],
parseQuery: search => ({}),
stringifyQuery: query => '',
strict: true,
Expand Down
Loading

0 comments on commit 2105a3c

Please sign in to comment.