add build aliases for easier importing

This commit is contained in:
Evan You 2016-04-23 16:57:44 -04:00
parent cf8253cdd9
commit e7f021fc9b
24 changed files with 52 additions and 40 deletions

8
build/alias.js Normal file
View File

@ -0,0 +1,8 @@
var path = require('path')
module.exports = {
compiler: path.resolve(__dirname, '../src/compiler'),
core: path.resolve(__dirname, '../src/core'),
shared: path.resolve(__dirname, '../src/shared'),
web: path.resolve(__dirname, '../src/platforms/web')
}

View File

@ -4,7 +4,8 @@ var rollup = require('rollup')
var uglify = require('uglify-js')
var babel = require('rollup-plugin-babel')
var replace = require('rollup-plugin-replace')
var alias = require('rollup-plugin-alias')
var aliasPlugin = require('rollup-plugin-alias')
var baseAlias = require('./alias')
var version = process.env.VERSION || require('../package.json').version
var banner =
@ -86,9 +87,11 @@ function buildEntry (opts) {
'process.env.NODE_ENV': JSON.stringify(opts.env)
}))
}
var alias = baseAlias
if (opts.alias) {
plugins.push(alias(opts.alias))
alias = Object.assign({}, baseAlias, opts.alias)
}
plugins.push(aliasPlugin(alias))
return rollup.rollup({
entry: opts.entry,
plugins: plugins,

View File

@ -1,4 +1,5 @@
var path = require('path')
var alias = require('./alias')
module.exports = {
entry: path.resolve(__dirname, 'dev-entry.js'),
@ -9,9 +10,9 @@ module.exports = {
libraryTarget: 'umd'
},
resolve: {
alias: {
alias: Object.assign({}, alias, {
entities: './entity-decoder'
}
})
},
module: {
loaders: [

View File

@ -1,4 +1,4 @@
import { isArray } from '../shared/util'
import { isArray } from 'shared/util'
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/
// keyCode aliases

View File

@ -1,4 +1,4 @@
import { isArray } from '../shared/util'
import { isArray } from 'shared/util'
export function addProp (el, name, value) {
(el.props || (el.props = [])).push({ name, value })

View File

@ -1,4 +1,4 @@
import { makeMap, isBuiltInTag } from '../shared/util'
import { makeMap, isBuiltInTag } from 'shared/util'
let isPlatformReservedTag

View File

@ -6,7 +6,7 @@
*/
import { decodeHTML } from 'entities'
import { makeMap } from '../../shared/util'
import { makeMap } from 'shared/util'
// Regular Expressions for parsing tags and attributes
const singleAttrIdentifier = /([^\s"'<>\/=]+)/

View File

@ -1,7 +1,7 @@
import { decodeHTML } from 'entities'
import { parseHTML } from './html-parser'
import { parseText } from './text-parser'
import { hyphenate, cached } from '../../shared/util'
import { hyphenate, cached } from 'shared/util'
import {
getAndRemoveAttr,
addProp,

View File

@ -1,5 +1,5 @@
import config from '../config'
import { hyphenate } from '../../shared/util'
import { hyphenate } from 'shared/util'
let warn
let formatComponentName

View File

@ -1,4 +1,4 @@
export * from '../../shared/util'
export * from 'shared/util'
export * from './lang'
export * from './env'
export * from './options'

View File

@ -10,7 +10,7 @@ import {
hasOwn,
camelize,
isBuiltInTag
} from '../../shared/util'
} from 'shared/util'
/**
* Option overwriting strategies are functions that handle

View File

@ -1,4 +1,4 @@
import { hasOwn, isArray, isObject, isPlainObject } from '../../shared/util'
import { hasOwn, isArray, isObject, isPlainObject } from 'shared/util'
import { observe, observerState } from '../observer/index'
import { warn } from './debug'

View File

@ -1,7 +1,7 @@
import { extend } from '../shared/util'
import { compile as baseCompile } from '../compiler/index'
import directives from '../platforms/web/compiler/directives/index'
import { isReservedTag, mustUseProp, getTagNamespace } from '../platforms/web/util'
import { extend } from 'shared/util'
import { compile as baseCompile } from 'compiler/index'
import directives from 'web/compiler/directives/index'
import { isReservedTag, mustUseProp, getTagNamespace } from 'web/util'
const baseOptions = {
directives,

View File

@ -1,6 +1,6 @@
import config from '../core/config'
import { warn, cached } from '../core/util/index'
import { query } from '../platforms/web/util'
import config from 'core/config'
import { warn, cached } from 'core/util/index'
import { query } from 'web/util'
import Vue from './web-runtime'
import { compile } from './web-compiler'

View File

@ -1,10 +1,10 @@
import Vue from '../core/index'
import { createPatchFunction } from '../core/vdom/patch'
import * as nodeOps from '../platforms/web/runtime/node-ops'
import platformDirectives from '../platforms/web/runtime/directives/index'
import baseModules from '../core/vdom/modules/index'
import platformModules from '../platforms/web/runtime/modules/index'
import { query, isUnknownElement, isReservedTag } from '../platforms/web/util'
import Vue from 'core/index'
import { createPatchFunction } from 'core/vdom/patch'
import * as nodeOps from 'web/runtime/node-ops'
import platformDirectives from 'web/runtime/directives/index'
import baseModules from 'core/vdom/modules/index'
import platformModules from 'web/runtime/modules/index'
import { query, isUnknownElement, isReservedTag } from 'web/util'
// install platform specific utils
Vue.config.isUnknownElement = isUnknownElement

View File

@ -1,4 +1,4 @@
import { addProp } from '../../../../compiler/helpers'
import { addProp } from 'compiler/helpers'
export default function html (el, dir) {
if (!dir.value) return

View File

@ -1,4 +1,4 @@
import { addHandler, addProp, getBindingAttr } from '../../../../compiler/helpers'
import { addHandler, addProp, getBindingAttr } from 'compiler/helpers'
export default function model (el, dir) {
const value = dir.value

View File

@ -1,4 +1,4 @@
import { addProp } from '../../../../compiler/helpers'
import { addProp } from 'compiler/helpers'
export default function text (el, dir) {
if (!dir.value) return

View File

@ -1,4 +1,4 @@
import { makeMap } from '../../../../shared/util'
import { makeMap } from 'shared/util'
const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck')
const isBooleanAttr = makeMap(

View File

@ -1,4 +1,4 @@
import { extend, isArray, isObject } from '../../../../shared/util'
import { extend, isArray, isObject } from 'shared/util'
import { setClass } from '../class-util'
function updateClass (oldVnode, vnode) {

View File

@ -1,4 +1,4 @@
import { updateListeners } from '../../../../core/vdom/helpers'
import { updateListeners } from 'core/vdom/helpers'
function updateDOMListeners (oldVnode, vnode) {
if (!oldVnode.data.on && !vnode.data.on) {

View File

@ -1,5 +1,5 @@
import { extend, isArray, cached, camelize } from '../../../../shared/util'
import { inBrowser } from '../../../../core/util/env'
import { extend, isArray, cached, camelize } from 'shared/util'
import { inBrowser } from 'core/util/env'
const prefixes = ['Webkit', 'Moz', 'ms']
const testEl = inBrowser && document.createElement('div')

View File

@ -1,6 +1,6 @@
import { addClass, removeClass } from '../class-util'
import { inBrowser } from '../../../../core/util/index'
import { cached, remove } from '../../../../shared/util'
import { inBrowser } from 'core/util/index'
import { cached, remove } from 'shared/util'
import { isIE9 } from '../../util'
const TRANSITION = 'transition'

View File

@ -1,6 +1,6 @@
import { inBrowser } from '../../core/util/env'
import { warn } from '../../core/util/debug'
import { makeMap } from '../../shared/util'
import { inBrowser } from 'core/util/env'
import { warn } from 'core/util/debug'
import { makeMap } from 'shared/util'
const UA = inBrowser && window.navigator.userAgent.toLowerCase()
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0