vue-inbrowser-compiler-utils
Advanced tools
Comparing version 4.62.0 to 4.62.1
# Change Log | ||
## 4.62.1 | ||
### Patch Changes | ||
- [#1500](https://github.com/vue-styleguidist/vue-styleguidist/pull/1500) [`6027b18c`](https://github.com/vue-styleguidist/vue-styleguidist/commit/6027b18cbfd75dda9f7bc5eb934b5a2482f86dba) Thanks [@elevatebart](https://github.com/elevatebart)! - fix script setup template compilation | ||
## 4.62.0 | ||
@@ -4,0 +10,0 @@ |
@@ -195,13 +195,15 @@ 'use strict'; | ||
const { bindings } = vueInbrowserCompilerDemi.compileScript(descriptor, { id: '-' }); | ||
const renderObject = vueInbrowserCompilerDemi.compileTemplate({ | ||
source: code, | ||
filename: EXAMPLE_FILENAME, | ||
id: '-', | ||
compilerOptions: { | ||
bindingMetadata: bindings, | ||
prefixIdentifiers: true, | ||
mode: 'function' | ||
}, | ||
}); | ||
setFinalRender(compiledComponent, renderObject); | ||
if (compiledComponent.template) { | ||
const renderObject = vueInbrowserCompilerDemi.compileTemplate({ | ||
source: compiledComponent.template, | ||
filename: EXAMPLE_FILENAME, | ||
id: '-', | ||
compilerOptions: { | ||
bindingMetadata: bindings, | ||
prefixIdentifiers: true, | ||
mode: 'function' | ||
} | ||
}); | ||
setFinalRender(compiledComponent, renderObject); | ||
} | ||
} | ||
@@ -212,9 +214,10 @@ function setFinalRender(sfc, renderObject) { | ||
${vueInbrowserCompilerDemi.isVue3 ? 'const Vue = require("vue")' : ''} | ||
const comp = (function() {${sfc.script}})()${((_a = renderObject.staticRenderFns) === null || _a === void 0 ? void 0 : _a.length) ? ` | ||
const comp = (function() {${sfc.script}})()${((_a = renderObject.staticRenderFns) === null || _a === void 0 ? void 0 : _a.length) | ||
? ` | ||
comp.staticRenderFns = [${(_b = renderObject.staticRenderFns) === null || _b === void 0 ? void 0 : _b.map((fn) => { | ||
return `function(){${fn}}`; | ||
}).join(',')}]` : ''} | ||
return `function(){${fn}}`; | ||
}).join(',')}]` | ||
: ''} | ||
comp.render = function() {${renderObject.code}} | ||
${vueInbrowserCompilerDemi.isVue3 | ||
? `comp.render = comp.render()` : ''} | ||
${vueInbrowserCompilerDemi.isVue3 ? `comp.render = comp.render()` : ''} | ||
return comp`; | ||
@@ -221,0 +224,0 @@ delete sfc.template; |
@@ -188,13 +188,15 @@ import { isVue3, parseComponent, compileScript, compileTemplate } from 'vue-inbrowser-compiler-demi'; | ||
const { bindings } = compileScript(descriptor, { id: '-' }); | ||
const renderObject = compileTemplate({ | ||
source: code, | ||
filename: EXAMPLE_FILENAME, | ||
id: '-', | ||
compilerOptions: { | ||
bindingMetadata: bindings, | ||
prefixIdentifiers: true, | ||
mode: 'function' | ||
}, | ||
}); | ||
setFinalRender(compiledComponent, renderObject); | ||
if (compiledComponent.template) { | ||
const renderObject = compileTemplate({ | ||
source: compiledComponent.template, | ||
filename: EXAMPLE_FILENAME, | ||
id: '-', | ||
compilerOptions: { | ||
bindingMetadata: bindings, | ||
prefixIdentifiers: true, | ||
mode: 'function' | ||
} | ||
}); | ||
setFinalRender(compiledComponent, renderObject); | ||
} | ||
} | ||
@@ -205,9 +207,10 @@ function setFinalRender(sfc, renderObject) { | ||
${isVue3 ? 'const Vue = require("vue")' : ''} | ||
const comp = (function() {${sfc.script}})()${((_a = renderObject.staticRenderFns) === null || _a === void 0 ? void 0 : _a.length) ? ` | ||
const comp = (function() {${sfc.script}})()${((_a = renderObject.staticRenderFns) === null || _a === void 0 ? void 0 : _a.length) | ||
? ` | ||
comp.staticRenderFns = [${(_b = renderObject.staticRenderFns) === null || _b === void 0 ? void 0 : _b.map((fn) => { | ||
return `function(){${fn}}`; | ||
}).join(',')}]` : ''} | ||
return `function(){${fn}}`; | ||
}).join(',')}]` | ||
: ''} | ||
comp.render = function() {${renderObject.code}} | ||
${isVue3 | ||
? `comp.render = comp.render()` : ''} | ||
${isVue3 ? `comp.render = comp.render()` : ''} | ||
return comp`; | ||
@@ -214,0 +217,0 @@ delete sfc.template; |
{ | ||
"name": "vue-inbrowser-compiler-utils", | ||
"version": "4.62.0", | ||
"version": "4.62.1", | ||
"description": "use this with vue-inbrowser-compiler to allow jsx compilation", | ||
@@ -5,0 +5,0 @@ "module": "lib/vue-inbrowser-compiler-utils.esm.js", |
@@ -6,3 +6,3 @@ import { compileScript, compileTemplate, isVue3, parseComponent } from 'vue-inbrowser-compiler-demi' | ||
export function compileTemplateForEval(compiledComponent: EvaluableComponent):void { | ||
export function compileTemplateForEval(compiledComponent: EvaluableComponent): void { | ||
if (compiledComponent.template) { | ||
@@ -30,3 +30,2 @@ const { bindings } = compileScript( | ||
mode: 'function' | ||
} | ||
@@ -38,35 +37,40 @@ }) | ||
export function compileTemplateForEvalSetup(compiledComponent: EvaluableComponent, code:string):void{ | ||
export function compileTemplateForEvalSetup( | ||
compiledComponent: EvaluableComponent, | ||
code: string | ||
): void { | ||
const descriptor = parseComponent(code) | ||
const { bindings } = compileScript(descriptor as any, { id: '-' }) | ||
const renderObject = compileTemplate({ | ||
source: code, | ||
filename: EXAMPLE_FILENAME, | ||
id: '-', | ||
compilerOptions: { | ||
bindingMetadata: bindings, | ||
prefixIdentifiers: true, | ||
mode: 'function' | ||
}, | ||
}) | ||
setFinalRender(compiledComponent, renderObject) | ||
if (compiledComponent.template) { | ||
const renderObject = compileTemplate({ | ||
source: compiledComponent.template, | ||
filename: EXAMPLE_FILENAME, | ||
id: '-', | ||
compilerOptions: { | ||
bindingMetadata: bindings, | ||
prefixIdentifiers: true, | ||
mode: 'function' | ||
} | ||
}) | ||
setFinalRender(compiledComponent, renderObject) | ||
} | ||
} | ||
function setFinalRender(sfc: EvaluableComponent, renderObject:any):void { | ||
function setFinalRender(sfc: EvaluableComponent, renderObject: any): void { | ||
sfc.script = ` | ||
${isVue3 ? 'const Vue = require("vue")' : ''} | ||
const comp = (function() {${sfc.script}})()${ | ||
renderObject.staticRenderFns?.length ? ` | ||
renderObject.staticRenderFns?.length | ||
? ` | ||
comp.staticRenderFns = [${renderObject.staticRenderFns | ||
?.map((fn:string) => { | ||
return `function(){${fn}}` | ||
}) | ||
.join(',')}]` : ''} | ||
?.map((fn: string) => { | ||
return `function(){${fn}}` | ||
}) | ||
.join(',')}]` | ||
: '' | ||
} | ||
comp.render = function() {${renderObject.code}} | ||
${ | ||
isVue3 | ||
? `comp.render = comp.render()`:'' | ||
} | ||
${isVue3 ? `comp.render = comp.render()` : ''} | ||
return comp` | ||
delete sfc.template | ||
delete sfc.template | ||
} |
@@ -10,3 +10,3 @@ { | ||
"include": ["src/**/*.ts", "../../@types/**/*"], | ||
"exclude": ["node_modules", "src/**/*.spec.ts"] | ||
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/test.vue3.ts"] | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52111
21
913