From b12247d638cd95f40eb9ed754beb35323e2fd174 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 25 Sep 2018 17:55:47 -0400 Subject: [PATCH] refactor: layout optional features --- packages/core/src/index.ts | 17 +++++++++-------- packages/core/src/optional/asyncComponent.ts | 0 packages/core/src/optional/await.ts | 0 packages/core/src/{ => optional}/context.ts | 4 ++-- packages/core/src/{ => optional}/directive.ts | 4 ++-- packages/core/src/optional/keepAlive.ts | 0 6 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 packages/core/src/optional/asyncComponent.ts create mode 100644 packages/core/src/optional/await.ts rename packages/core/src/{ => optional}/context.ts (94%) rename packages/core/src/{ => optional}/directive.ts (93%) create mode 100644 packages/core/src/optional/keepAlive.ts diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 5e86a6a8..945bc268 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,21 +1,22 @@ -// render api +// Core API export { h, Fragment, Portal } from './h' +export { Component } from './component' export { cloneVNode, createPortal, createFragment } from './vdom' export { createRenderer } from './createRenderer' -export { Component } from './component' -// observer api +// Observer API export * from '@vue/observer' -// scheduler api +// Scheduler API export { nextTick } from '@vue/scheduler' -// internal api +// Internal API export { createComponentInstance } from './componentUtils' -// import-on-demand apis -export { applyDirective } from './directive' -export { Provide, Inject } from './context' +// Optional APIs +// these are imported on-demand and can be tree-shaken +export { applyDirective } from './optional/directive' +export { Provide, Inject } from './optional/context' // flags & types export { ComponentClass, FunctionalComponent } from './component' diff --git a/packages/core/src/optional/asyncComponent.ts b/packages/core/src/optional/asyncComponent.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/core/src/optional/await.ts b/packages/core/src/optional/await.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/core/src/context.ts b/packages/core/src/optional/context.ts similarity index 94% rename from packages/core/src/context.ts rename to packages/core/src/optional/context.ts index 252e6480..7b742503 100644 --- a/packages/core/src/context.ts +++ b/packages/core/src/optional/context.ts @@ -1,6 +1,6 @@ import { observable } from '@vue/observer' -import { Component } from './component' -import { Slots } from './vdom' +import { Component } from '../component' +import { Slots } from '../vdom' const contextStore = observable() as Record diff --git a/packages/core/src/directive.ts b/packages/core/src/optional/directive.ts similarity index 93% rename from packages/core/src/directive.ts rename to packages/core/src/optional/directive.ts index 5c0cdce6..5e225386 100644 --- a/packages/core/src/directive.ts +++ b/packages/core/src/optional/directive.ts @@ -1,5 +1,5 @@ -import { VNode } from './vdom' -import { MountedComponent } from './component' +import { VNode } from '../vdom' +import { MountedComponent } from '../component' export interface DirectiveBinding { instance: MountedComponent diff --git a/packages/core/src/optional/keepAlive.ts b/packages/core/src/optional/keepAlive.ts new file mode 100644 index 00000000..e69de29b