mirror of https://github.com/vuejs/core.git
feat: build
This commit is contained in:
parent
0de56b5a3c
commit
a117dbf3f7
|
@ -18,8 +18,8 @@ export function generate(
|
|||
const isSetupInlined = !!options.inline
|
||||
|
||||
preamble += ast.template
|
||||
.map((template, i) => `const t${i} = template(\`${template.template}\`)`)
|
||||
.join('\n')
|
||||
.map((template, i) => `const t${i} = template(\`${template.template}\`)\n`)
|
||||
.join('')
|
||||
|
||||
code += 'const root = t0()\n'
|
||||
code += 'return root'
|
||||
|
@ -28,7 +28,7 @@ export function generate(
|
|||
if (isSetupInlined) {
|
||||
code = `(() => {\n${code}\n})();`
|
||||
} else {
|
||||
code = `${preamble}\nexport function ${functionName}() {\n${code}\n}`
|
||||
code = `${preamble}export function ${functionName}() {\n${code}\n}`
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -65,11 +65,16 @@ function transformChildren(children: TemplateChildNode[]) {
|
|||
case 2 satisfies NodeTypes.TEXT:
|
||||
template += node.content
|
||||
break
|
||||
case 3 satisfies NodeTypes.COMMENT:
|
||||
template += `<!--${node.content}-->`
|
||||
break
|
||||
case 5 satisfies NodeTypes.INTERPOLATION:
|
||||
template += transformInterpolation(node)
|
||||
break
|
||||
case 12 satisfies NodeTypes.TEXT_CALL:
|
||||
template += node.content
|
||||
// case 12 satisfies NodeTypes.TEXT_CALL:
|
||||
// template += node.content
|
||||
default:
|
||||
template += `[${node.type}]`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite"
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "workspace:*"
|
||||
|
|
|
@ -7,7 +7,7 @@ const count = ref(0)
|
|||
<template>
|
||||
<div>
|
||||
<h1 class="red">Hello world</h1>
|
||||
{{ count }}
|
||||
<!-- {{ count }} -->
|
||||
<button style="font-weight: bold">Inc</button>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -4,6 +4,9 @@ import Inspect from 'vite-plugin-inspect'
|
|||
import * as CompilerVapor from '../packages/compiler-vapor/src'
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
target: 'esnext'
|
||||
},
|
||||
plugins: [
|
||||
Vue({
|
||||
template: {
|
||||
|
|
Loading…
Reference in New Issue