From d29e375adc145f9af0310eb46a8afc24382192ef Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 1 Jan 2019 21:28:03 +0800 Subject: [PATCH 1/2] feat: add `formatCompiled` option --- README.md | 4 ++++ lib/compileTemplate.ts | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be3c45e..6b4b215 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,10 @@ interface TemplateCompileOptions { isProduction?: boolean // default: false isFunctional?: boolean // default: false optimizeSSR?: boolean // default: false + + // Whether prettifiy compiled render function or not (development only) + // default: true + formatCompiled?: boolean } interface TemplateCompileResult { diff --git a/lib/compileTemplate.ts b/lib/compileTemplate.ts index 13bb3c8..8703ac5 100644 --- a/lib/compileTemplate.ts +++ b/lib/compileTemplate.ts @@ -5,7 +5,6 @@ import assetUrlsModule, { } from './templateCompilerModules/assetUrl' import srcsetModule from './templateCompilerModules/srcset' -const prettier = require('prettier') const consolidate = require('consolidate') const transpile = require('vue-template-es2015-compiler') @@ -21,6 +20,7 @@ export interface TemplateCompileOptions { isProduction?: boolean isFunctional?: boolean optimizeSSR?: boolean + formatCompiled?: boolean } export interface TemplateCompileResult { @@ -103,7 +103,8 @@ function actuallyCompile( transformAssetUrls, isProduction = process.env.NODE_ENV === 'production', isFunctional = false, - optimizeSSR = false + optimizeSSR = false, + formatCompiled = true } = options const compile = @@ -163,7 +164,13 @@ function actuallyCompile( // mark with stripped (this enables Vue to use correct runtime proxy // detection) code += `render._withStripped = true` - code = prettier.format(code, { semi: false, parser: 'babylon' }) + + if (formatCompiled) { + code = require('prettier').format(code, { + semi: false, + parser: 'babylon' + }) + } } return { From 2fe5cfd45533cd31ce2795d462348e33be099815 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 2 Jan 2019 11:30:58 +0800 Subject: [PATCH 2/2] chore: formatCompiled => prettify --- README.md | 4 ++-- lib/compileTemplate.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6b4b215..55ad357 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,9 @@ interface TemplateCompileOptions { isFunctional?: boolean // default: false optimizeSSR?: boolean // default: false - // Whether prettifiy compiled render function or not (development only) + // Whether prettify compiled render function or not (development only) // default: true - formatCompiled?: boolean + prettify?: boolean } interface TemplateCompileResult { diff --git a/lib/compileTemplate.ts b/lib/compileTemplate.ts index 8703ac5..7d65f28 100644 --- a/lib/compileTemplate.ts +++ b/lib/compileTemplate.ts @@ -20,7 +20,7 @@ export interface TemplateCompileOptions { isProduction?: boolean isFunctional?: boolean optimizeSSR?: boolean - formatCompiled?: boolean + prettify?: boolean } export interface TemplateCompileResult { @@ -104,7 +104,7 @@ function actuallyCompile( isProduction = process.env.NODE_ENV === 'production', isFunctional = false, optimizeSSR = false, - formatCompiled = true + prettify = true } = options const compile = @@ -165,7 +165,7 @@ function actuallyCompile( // detection) code += `render._withStripped = true` - if (formatCompiled) { + if (prettify) { code = require('prettier').format(code, { semi: false, parser: 'babylon' pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy