From 328bc28482bed5eb3977bec0cdf1a9868f8f8c39 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 11 May 2016 20:03:18 -0400 Subject: [PATCH] update build setup for flow --- .eslintrc | 1 + build/karma.dev.config.js | 9 --------- build/webpack.dist.dev.config.js | 2 +- build/webpack.ssr.dev.config.js | 2 +- build/webpack.ssr.test.config.js | 18 ------------------ package.json | 5 ++++- src/entries/web-compiler.js | 18 +++++++++++------- 7 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 build/webpack.ssr.test.config.js diff --git a/.eslintrc b/.eslintrc index d0dd64cb..81d1af35 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,5 @@ { "root": true, + "parser": "babel-eslint", "extends": "vue" } diff --git a/build/karma.dev.config.js b/build/karma.dev.config.js index 6d6b6315..756ca1d7 100644 --- a/build/karma.dev.config.js +++ b/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'] diff --git a/build/webpack.dist.dev.config.js b/build/webpack.dist.dev.config.js index 9706575d..61184c14 100644 --- a/build/webpack.dist.dev.config.js +++ b/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: [ diff --git a/build/webpack.ssr.dev.config.js b/build/webpack.ssr.dev.config.js index a8de2550..5ca32a4a 100644 --- a/build/webpack.ssr.dev.config.js +++ b/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/ } ] } } diff --git a/build/webpack.ssr.test.config.js b/build/webpack.ssr.test.config.js deleted file mode 100644 index f1117652..00000000 --- a/build/webpack.ssr.test.config.js +++ /dev/null @@ -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/ } - ] - } -} diff --git a/package.json b/package.json index 2874d36c..035c4e7d 100644 --- a/package.json +++ b/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", diff --git a/src/entries/web-compiler.js b/src/entries/web-compiler.js index e0547b8c..2b3664d3 100644 --- a/src/entries/web-compiler.js +++ b/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 } { 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 } { 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) }