From f00097127a31d1d8d9a2a9cf8e5be5c7a2f7201b Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 1 Mar 2019 13:58:08 -0500 Subject: [PATCH] refactor: move decorators into their own package --- packages/decorators/.npmignore | 3 +++ packages/decorators/README.md | 1 + .../__tests__/prop.spec.ts} | 2 +- packages/decorators/index.js | 7 +++++++ packages/decorators/package.json | 21 +++++++++++++++++++ packages/decorators/src/index.ts | 2 ++ packages/decorators/src/inject.ts | 1 + .../src/prop.ts} | 3 +-- packages/runtime-core/src/index.ts | 3 +-- 9 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 packages/decorators/.npmignore create mode 100644 packages/decorators/README.md rename packages/{runtime-core/__tests__/propDecorator.spec.ts => decorators/__tests__/prop.spec.ts} (96%) create mode 100644 packages/decorators/index.js create mode 100644 packages/decorators/package.json create mode 100644 packages/decorators/src/index.ts create mode 100644 packages/decorators/src/inject.ts rename packages/{runtime-core/src/optional/propDecorator.ts => decorators/src/prop.ts} (85%) diff --git a/packages/decorators/.npmignore b/packages/decorators/.npmignore new file mode 100644 index 00000000..bb5c8a54 --- /dev/null +++ b/packages/decorators/.npmignore @@ -0,0 +1,3 @@ +__tests__/ +__mocks__/ +dist/packages \ No newline at end of file diff --git a/packages/decorators/README.md b/packages/decorators/README.md new file mode 100644 index 00000000..d06feabb --- /dev/null +++ b/packages/decorators/README.md @@ -0,0 +1 @@ +# @vue/decorators \ No newline at end of file diff --git a/packages/runtime-core/__tests__/propDecorator.spec.ts b/packages/decorators/__tests__/prop.spec.ts similarity index 96% rename from packages/runtime-core/__tests__/propDecorator.spec.ts rename to packages/decorators/__tests__/prop.spec.ts index 1ea33c60..0bcfc806 100644 --- a/packages/runtime-core/__tests__/propDecorator.spec.ts +++ b/packages/decorators/__tests__/prop.spec.ts @@ -1,4 +1,4 @@ -import { prop } from '../src/optional/propDecorator' +import { prop } from '../src/prop' import { Component, createInstance } from '@vue/runtime-test' test('without options', () => { diff --git a/packages/decorators/index.js b/packages/decorators/index.js new file mode 100644 index 00000000..6817e443 --- /dev/null +++ b/packages/decorators/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/decorators.cjs.prod.js') +} else { + module.exports = require('./dist/decorators.cjs.js') +} diff --git a/packages/decorators/package.json b/packages/decorators/package.json new file mode 100644 index 00000000..e88e438a --- /dev/null +++ b/packages/decorators/package.json @@ -0,0 +1,21 @@ +{ + "name": "@vue/decorators", + "version": "3.0.0-alpha.1", + "description": "@vue/decorators", + "main": "index.js", + "module": "dist/decorators.esm-bundler.js", + "types": "dist/index.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/vuejs/vue.git" + }, + "keywords": [ + "vue" + ], + "author": "Evan You", + "license": "MIT", + "bugs": { + "url": "https://github.com/vuejs/vue/issues" + }, + "homepage": "https://github.com/vuejs/vue/tree/dev/packages/decorators#readme" +} \ No newline at end of file diff --git a/packages/decorators/src/index.ts b/packages/decorators/src/index.ts new file mode 100644 index 00000000..969bdd1d --- /dev/null +++ b/packages/decorators/src/index.ts @@ -0,0 +1,2 @@ +export { prop } from './prop' +export { inject } from './inject' diff --git a/packages/decorators/src/inject.ts b/packages/decorators/src/inject.ts new file mode 100644 index 00000000..daaf965b --- /dev/null +++ b/packages/decorators/src/inject.ts @@ -0,0 +1 @@ +export function inject() {} diff --git a/packages/runtime-core/src/optional/propDecorator.ts b/packages/decorators/src/prop.ts similarity index 85% rename from packages/runtime-core/src/optional/propDecorator.ts rename to packages/decorators/src/prop.ts index 8cdb088f..5b310937 100644 --- a/packages/runtime-core/src/optional/propDecorator.ts +++ b/packages/decorators/src/prop.ts @@ -1,5 +1,4 @@ -import { Component } from '../component' -import { PropValidator } from '../componentOptions' +import { Component, PropValidator } from '@vue/runtime-core' import { camelize } from '@vue/shared' export function prop( diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 34e689ac..be2cb6cc 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -24,13 +24,12 @@ export { nextTick } from '@vue/scheduler' // Optional APIs // these are imported on-demand and can be tree-shaken -export { applyDirectives } from './optional/directives' export { createAsyncComponent } from './optional/asyncComponent' export { KeepAlive } from './optional/keepAlive' +export { applyDirectives } from './optional/directives' export { mixins } from './optional/mixins' export { EventEmitter } from './optional/eventEmitter' export { memoize } from './optional/memoize' -export { prop } from './optional/propDecorator' // flags & types export { ComponentType, ComponentClass, FunctionalComponent } from './component'