From f94f0645531baba98072cd660066a451dd947c8b Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 30 Aug 2017 00:54:48 +0200 Subject: [PATCH 1/6] trim trailing whitespace --- test/unit/features/component/component-slot.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/features/component/component-slot.spec.js b/test/unit/features/component/component-slot.spec.js index 894dc9f7ed0..95a771e286c 100644 --- a/test/unit/features/component/component-slot.spec.js +++ b/test/unit/features/component/component-slot.spec.js @@ -709,7 +709,7 @@ describe('Component slot', () => { - `, + `, components: { TestComponent, foo: { From 095595f46401d479a6c12c5bf1a4983666ae82c2 Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 30 Aug 2017 13:08:23 +0800 Subject: [PATCH 2/6] add EsModuleComponent definition --- types/options.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index b1ab1256659..94dc1dfc730 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -5,7 +5,12 @@ type Constructor = { new (...args: any[]): any; } -export type Component = typeof Vue | ComponentOptions | FunctionalComponentOptions; +type NormalComponent = typeof Vue | ComponentOptions | FunctionalComponentOptions; +type EsModuleComponent = { + default: NormalComponent +} + +export type Component = NormalComponent | EsModuleComponent; export type AsyncComponent = ( resolve: (component: Component) => void, reject: (reason?: any) => void From 30db09a4e8e4ab6df1fd5749ce95e0602899e47e Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 30 Aug 2017 13:38:48 +0800 Subject: [PATCH 3/6] Component should not be overridden --- types/options.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index 94dc1dfc730..554e84eb30e 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -5,16 +5,16 @@ type Constructor = { new (...args: any[]): any; } -type NormalComponent = typeof Vue | ComponentOptions | FunctionalComponentOptions; +export type Component = typeof Vue | ComponentOptions | FunctionalComponentOptions; + type EsModuleComponent = { - default: NormalComponent + default: Component } -export type Component = NormalComponent | EsModuleComponent; export type AsyncComponent = ( resolve: (component: Component) => void, reject: (reason?: any) => void -) => Promise | Component | void; +) => Promise | Component | void; export interface ComponentOptions { data?: Object | ((this: V) => Object); From 61f31cbb81172b1a3e7bd642184adf39bda10b00 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 31 Aug 2017 15:19:52 +0800 Subject: [PATCH 4/6] add es-module AsyncComponent type test --- types/test/es-module.ts | 5 +++++ types/test/options-test.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 types/test/es-module.ts diff --git a/types/test/es-module.ts b/types/test/es-module.ts new file mode 100644 index 00000000000..f124374df4f --- /dev/null +++ b/types/test/es-module.ts @@ -0,0 +1,5 @@ +export default { + data() { + return {} + } +} diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 28ce077e988..3f17b071a33 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -1,5 +1,5 @@ import Vue = require("../index"); -import { ComponentOptions, FunctionalComponentOptions } from "../index"; +import { AsyncComponent, ComponentOptions, FunctionalComponentOptions } from "../index"; interface Component extends Vue { a: number; @@ -206,11 +206,13 @@ Vue.component('functional-component', { } } as FunctionalComponentOptions); -Vue.component("async-component", (resolve, reject) => { +Vue.component("async-component", ((resolve, reject) => { setTimeout(() => { resolve(Vue.component("component")); }, 0); return new Promise((resolve) => { resolve({ functional: true } as FunctionalComponentOptions); }) -}); +}) as AsyncComponent); + +Vue.component('async-es-module-component', (() => import('./es-module')) as AsyncComponent) From ea8e07f89304ba9a3cce4ea7d2e683a729be1d5d Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 31 Aug 2017 18:26:27 +0800 Subject: [PATCH 5/6] change EsModuleComponent to be interface https://github.com/vuejs/vue/pull/6477#discussion_r136283098 --- types/options.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/options.d.ts b/types/options.d.ts index 554e84eb30e..0de8e8f7de5 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -7,7 +7,7 @@ type Constructor = { export type Component = typeof Vue | ComponentOptions | FunctionalComponentOptions; -type EsModuleComponent = { +interface EsModuleComponent { default: Component } From 702671510f2948a2b5d82e89c267a25712cad9b8 Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 6 Sep 2017 10:51:38 +0800 Subject: [PATCH 6/6] try to fix #6353 defineProperty `styles` in `vue-server-renderer` --- src/server/bundle-renderer/create-bundle-runner.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/bundle-renderer/create-bundle-runner.js b/src/server/bundle-renderer/create-bundle-runner.js index b0cec881965..4c011dee86f 100644 --- a/src/server/bundle-renderer/create-bundle-runner.js +++ b/src/server/bundle-renderer/create-bundle-runner.js @@ -129,6 +129,10 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) { // vue-style-loader styles imported outside of component lifecycle hooks if (initialContext._styles) { userContext._styles = deepClone(initialContext._styles) + Object.defineProperty(userContext, 'styles', { + enumerable: true, + get: () => initialContext._renderStyles(userContext._styles) + }) } resolve(runner(userContext)) })