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