Permalink
Browse files

switch to prettier for formatting render fn code

  • Loading branch information...
yyx990803 committed Sep 18, 2017
1 parent db54537 commit 97bd432bba4350988bfd0db6d7a1a514b66a9826
Showing with 38 additions and 95 deletions.
  1. +8 −4 lib/template-compiler/index.js
  2. +29 −90 package-lock.json
  3. +1 −1 package.json
@@ -1,7 +1,7 @@
var prettier = require('prettier')
var loaderUtils = require('loader-utils')
var normalize = require('../utils/normalize')
var compiler = require('vue-template-compiler')
var beautify = require('js-beautify').js_beautify
var transpile = require('vue-template-es2015-compiler')
var hotReloadAPIPath = normalize.dep('vue-hot-reload-api')
var transformRequire = require('./modules/transform-require')
@@ -56,6 +56,12 @@ module.exports = function (html) {
'var staticRenderFns = [' + compiled.staticRenderFns.map(toFunction).join(',') + ']',
bubleOptions
) + '\n'
// prettify render fn
if (!isProduction) {
code = prettier.format(code, { semi: false })
}
// mark with stripped (this enables Vue to use correct runtime proxy detection)
if (!isProduction && (
!bubleOptions ||
@@ -85,9 +91,7 @@ module.exports = function (html) {
}
function toFunction (code) {
return 'function () {' + beautify(code, {
indent_size: 2 // eslint-disable-line camelcase
}) + '}'
return 'function () {' + code + '}'
}
function pad (html) {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -43,12 +43,12 @@
"dependencies": {
"consolidate": "^0.14.0",
"hash-sum": "^1.0.2",
"js-beautify": "^1.6.14",
"loader-utils": "^1.1.0",
"lru-cache": "^4.1.1",
"postcss": "^6.0.6",
"postcss-load-config": "^1.1.0",
"postcss-selector-parser": "^2.0.0",
"prettier": "^1.7.0",
"resolve": "^1.3.3",
"source-map": "^0.5.6",
"vue-hot-reload-api": "^2.1.0",

2 comments on commit 97bd432

@qm3ster

This comment has been minimized.

Show comment
Hide comment
@qm3ster

qm3ster Sep 18, 2017

Ooooh, someone got angry at js-beautify@1.7.0 😝
(I appreciate not beautifying in prod though)

qm3ster replied Sep 18, 2017

Ooooh, someone got angry at js-beautify@1.7.0 😝
(I appreciate not beautifying in prod though)

@ahadyekta

This comment has been minimized.

Show comment
Hide comment
@ahadyekta

ahadyekta Sep 18, 2017

thank you. beautify made vue loader crashed according to beautify-web/js-beautify#1246

ahadyekta replied Sep 18, 2017

thank you. beautify made vue loader crashed according to beautify-web/js-beautify#1246

Please sign in to comment.