mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
separate builds with/without compiler
This commit is contained in:
parent
7a4d30f62b
commit
1c8afd26a9
@ -34,6 +34,8 @@ var plugins = [
|
||||
// CommonJS build.
|
||||
// this is used as the "main" field in package.json
|
||||
// and used by bundlers like Webpack and Browserify.
|
||||
// doesn't come with the compiler because it's meant to be
|
||||
// used with vue-loader which pre-compiles the template.
|
||||
rollup.rollup({
|
||||
entry: 'src/index.js',
|
||||
plugins: plugins
|
||||
@ -47,7 +49,7 @@ rollup.rollup({
|
||||
// Standalone Dev Build
|
||||
.then(function () {
|
||||
return rollup.rollup({
|
||||
entry: 'src/index.js',
|
||||
entry: 'src/with-compiler.js',
|
||||
plugins: [
|
||||
replace({
|
||||
'process.env.NODE_ENV': "'development'"
|
||||
@ -65,7 +67,7 @@ rollup.rollup({
|
||||
.then(function () {
|
||||
// Standalone Production Build
|
||||
return rollup.rollup({
|
||||
entry: 'src/index.js',
|
||||
entry: 'src/with-compiler.js',
|
||||
plugins: [
|
||||
replace({
|
||||
'process.env.NODE_ENV': "'production'"
|
||||
|
1
build/dev-entry.js
Normal file
1
build/dev-entry.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('../src/with-compiler')['default']
|
@ -1 +0,0 @@
|
||||
module.exports = require('./index')['default']
|
@ -1,14 +1,12 @@
|
||||
import { compile } from '../compiler/index'
|
||||
import { observe } from '../observer/index'
|
||||
import Watcher from '../observer/watcher'
|
||||
import { h, patch } from '../vdom/index'
|
||||
import { nextTick, isReserved, getOuterHTML } from '../util/index'
|
||||
import { nextTick, isReserved } from '../util/index'
|
||||
|
||||
export default function Component (options) {
|
||||
this.$options = options
|
||||
this._data = options.data
|
||||
const el = this._el = document.querySelector(options.el)
|
||||
const render = compile(getOuterHTML(el))
|
||||
this._el.innerHTML = ''
|
||||
Object.keys(options.data).forEach(key => proxy(this, key))
|
||||
if (options.methods) {
|
||||
@ -18,7 +16,7 @@ export default function Component (options) {
|
||||
}
|
||||
this._ob = observe(options.data)
|
||||
this._watchers = []
|
||||
this._watcher = new Watcher(this, render, this._update)
|
||||
this._watcher = new Watcher(this, options.render, this._update)
|
||||
this._update(this._watcher.value)
|
||||
}
|
||||
|
||||
|
14
src/with-compiler.js
Normal file
14
src/with-compiler.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { compile } from './compiler/index'
|
||||
import { getOuterHTML, query } from './util/index'
|
||||
import Component from './instance/index'
|
||||
|
||||
export default function Vue (options) {
|
||||
if (!options.render) {
|
||||
if (options.template) {
|
||||
options.render = compile(options.template)
|
||||
} else if (options.el) {
|
||||
options.render = compile(getOuterHTML(query(options.el)))
|
||||
}
|
||||
}
|
||||
return new Component(options)
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
var path = require('path')
|
||||
|
||||
module.exports = {
|
||||
entry: path.resolve(__dirname, 'src/index.umd.js'),
|
||||
entry: path.resolve(__dirname, 'build/dev-entry.js'),
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'vue.js',
|
||||
|
Loading…
Reference in New Issue
Block a user