Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 103e15d

Browse files
committed
🚧 Mark transpiled render func
Mark transpiled render functions with `_withStripped` Fixes #44
1 parent abd6f70 commit 103e15d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/vueTransform.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ function injectRender (script, render, lang, options) {
4343
if (['js', 'babel'].indexOf(lang.toLowerCase()) > -1) {
4444
const matches = /(export default[^{]*\{)/g.exec(script)
4545
if (matches) {
46-
const renderScript = transpileVueTemplate('module.exports={' +
46+
let renderScript = 'module.exports={' +
4747
`render: ${wrapRenderFunction(render.render)},` +
4848
'staticRenderFns: [' +
49-
`${render.staticRenderFns.map(wrapRenderFunction).join(',')}],}`, options.vue)
49+
`${render.staticRenderFns.map(wrapRenderFunction).join(',')}],}`
50+
51+
if (options.stripWith !== false) {
52+
renderScript = transpileVueTemplate(renderScript, options.vue)
53+
}
54+
5055
const result = script.split(matches[1])
5156
.join(renderScript.replace('module.exports={', 'export default {').replace(/\}$/, ''))
5257

@@ -168,6 +173,13 @@ export default function vueTransform (code, id, options) {
168173
const js = processScript(nodes.script[0], id, code, options, nodes)
169174
const css = processStyle(nodes.style, id, code, options, nodes)
170175

176+
const isProduction = process.env.NODE_ENV === 'production'
177+
const isWithStripped = options.stripWith !== false
178+
179+
if (!isProduction && !isWithStripped) {
180+
js.code = js.code + '\nmodule.exports.render._withStripped = true'
181+
}
182+
171183
if (options.styleToImports === true) {
172184
const style = css.map((s, i) => 'import '+JSON.stringify(`${id}.${i}.vue.component.${s.lang}`)+';').join(' ')
173185

0 commit comments

Comments
 (0)