Browse Source

update build setup for flow

dev
Evan You 9 years ago
parent
commit
328bc28482
  1. 1
      .eslintrc
  2. 9
      build/karma.dev.config.js
  3. 2
      build/webpack.dist.dev.config.js
  4. 2
      build/webpack.ssr.dev.config.js
  5. 18
      build/webpack.ssr.test.config.js
  6. 5
      package.json
  7. 18
      src/entries/web-compiler.js

1
.eslintrc

@ -1,4 +1,5 @@
{
"root": true,
"parser": "babel-eslint",
"extends": "vue"
}

9
build/karma.dev.config.js

@ -1,15 +1,6 @@
var base = require('./karma.base.config.js')
module.exports = function (config) {
// enable linting during dev
base.webpack.module.preLoaders = [
{
test: /\.js$/,
loader: 'eslint',
exclude: /node_modules/
}
]
config.set(Object.assign(base, {
browsers: ['Chrome'],
reporters: ['progress']

2
build/webpack.dist.dev.config.js

@ -17,7 +17,7 @@ module.exports = {
},
module: {
loaders: [
{ test: /\.js/, loader: 'babel!eslint', exclude: /node_modules/ }
{ test: /\.js/, loader: 'babel', exclude: /node_modules/ }
]
},
plugins: [

2
build/webpack.ssr.dev.config.js

@ -13,7 +13,7 @@ module.exports = {
},
module: {
loaders: [
{ test: /\.js/, loader: 'babel!eslint', exclude: /node_modules/ }
{ test: /\.js/, loader: 'babel', exclude: /node_modules/ }
]
}
}

18
build/webpack.ssr.test.config.js

@ -1,18 +0,0 @@
var path = require('path')
var alias = require('./alias')
module.exports = {
entry: path.resolve(__dirname, '../test/ssr/ssr.spec.js'),
output: {
path: path.resolve(__dirname, '../test/ssr'),
filename: 'ssr.spec.bundle.js'
},
resolve: {
alias: alias
},
module: {
loaders: [
{ test: /\.js/, loader: 'babel', exclude: /node_modules/ }
]
}
}

5
package.json

@ -38,7 +38,10 @@
"homepage": "https://github.com/vuejs/vue#readme",
"devDependencies": {
"babel-core": "6.8.x",
"babel-eslint": "^6.0.4",
"babel-loader": "6.2.x",
"babel-plugin-syntax-flow": "^6.8.0",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"babel-preset-es2015": "6.6.x",
"babel-preset-es2015-rollup-vue": "1.1.x",
"chromedriver": "2.21.x",
@ -46,7 +49,7 @@
"entities": "1.1.x",
"eslint": "2.9.x",
"eslint-config-vue": "1.0.x",
"eslint-loader": "1.3.x",
"flow-bin": "^0.24.2",
"http-server": "0.9.x",
"isparta-loader": "2.0.x",
"jasmine": "2.4.x",

18
src/entries/web-compiler.js

@ -17,14 +17,20 @@ const baseOptions = {
getTagNamespace
}
export function compile (template: string, options: Object): Object {
export function compile (
template: string,
options: Object
): { render: string, staticRenderFns: Array<string> } {
options = options
? extend(extend({}, baseOptions), options)
: baseOptions
return baseCompile(template, options)
}
export function compileToFunctions (template: string, options: Object = {}): Object {
export function compileToFunctions (
template: string,
options: Object = {}
): { render: Function, staticRenderFns: Array<Function> } {
options.preserveWhitespace = options.preserveWhitespace !== false
const cache = options.preserveWhitespace ? cache1 : cache2
if (cache[template]) {
@ -34,11 +40,9 @@ export function compileToFunctions (template: string, options: Object = {}): Obj
const compiled = compile(template, options)
res.render = new Function(compiled.render)
const l: number = compiled.staticRenderFns.length
if (l) {
res.staticRenderFns = new Array(l)
for (let i = 0; i < l; i++) {
res.staticRenderFns[i] = new Function(compiled.staticRenderFns[i])
}
res.staticRenderFns = new Array(l)
for (let i = 0; i < l; i++) {
res.staticRenderFns[i] = new Function(compiled.staticRenderFns[i])
}
return (cache[template] = res)
}

Loading…
Cancel
Save