Skip to content

Commit 97bd432

Browse files
committed
switch to prettier for formatting render fn code
1 parent db54537 commit 97bd432

File tree

3 files changed

+38
-95
lines changed

3 files changed

+38
-95
lines changed

lib/template-compiler/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
var prettier = require('prettier')
12
var loaderUtils = require('loader-utils')
23
var normalize = require('../utils/normalize')
34
var compiler = require('vue-template-compiler')
4-
var beautify = require('js-beautify').js_beautify
55
var transpile = require('vue-template-es2015-compiler')
66
var hotReloadAPIPath = normalize.dep('vue-hot-reload-api')
77
var transformRequire = require('./modules/transform-require')
@@ -56,6 +56,12 @@ module.exports = function (html) {
5656
'var staticRenderFns = [' + compiled.staticRenderFns.map(toFunction).join(',') + ']',
5757
bubleOptions
5858
) + '\n'
59+
60+
// prettify render fn
61+
if (!isProduction) {
62+
code = prettier.format(code, { semi: false })
63+
}
64+
5965
// mark with stripped (this enables Vue to use correct runtime proxy detection)
6066
if (!isProduction && (
6167
!bubleOptions ||
@@ -85,9 +91,7 @@ module.exports = function (html) {
8591
}
8692

8793
function toFunction (code) {
88-
return 'function () {' + beautify(code, {
89-
indent_size: 2 // eslint-disable-line camelcase
90-
}) + '}'
94+
return 'function () {' + code + '}'
9195
}
9296

9397
function pad (html) {

package-lock.json

Lines changed: 29 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
"dependencies": {
4444
"consolidate": "^0.14.0",
4545
"hash-sum": "^1.0.2",
46-
"js-beautify": "^1.6.14",
4746
"loader-utils": "^1.1.0",
4847
"lru-cache": "^4.1.1",
4948
"postcss": "^6.0.6",
5049
"postcss-load-config": "^1.1.0",
5150
"postcss-selector-parser": "^2.0.0",
51+
"prettier": "^1.7.0",
5252
"resolve": "^1.3.3",
5353
"source-map": "^0.5.6",
5454
"vue-hot-reload-api": "^2.1.0",

0 commit comments

Comments
 (0)