From a117dbf3f78f21e71776d36dc63b1295ac4a7130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 17 Nov 2023 17:35:49 +0800 Subject: [PATCH] feat: build --- packages/compiler-vapor/src/generate.ts | 6 +++--- packages/compiler-vapor/src/transform.ts | 9 +++++++-- playground/package.json | 3 ++- playground/src/App.vue | 2 +- playground/vite.config.ts | 3 +++ 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/compiler-vapor/src/generate.ts b/packages/compiler-vapor/src/generate.ts index 5763d4f7a..9a22ad031 100644 --- a/packages/compiler-vapor/src/generate.ts +++ b/packages/compiler-vapor/src/generate.ts @@ -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 { diff --git a/packages/compiler-vapor/src/transform.ts b/packages/compiler-vapor/src/transform.ts index 598e274b3..5624b2de3 100644 --- a/packages/compiler-vapor/src/transform.ts +++ b/packages/compiler-vapor/src/transform.ts @@ -65,11 +65,16 @@ function transformChildren(children: TemplateChildNode[]) { case 2 satisfies NodeTypes.TEXT: template += node.content break + case 3 satisfies NodeTypes.COMMENT: + template += `` + 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}]` } } } diff --git a/playground/package.json b/playground/package.json index 94f095cfa..c920827d5 100644 --- a/playground/package.json +++ b/playground/package.json @@ -3,7 +3,8 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite" + "dev": "vite", + "build": "vite build" }, "dependencies": { "vue": "workspace:*" diff --git a/playground/src/App.vue b/playground/src/App.vue index 2794cc64f..cb9bd26c9 100644 --- a/playground/src/App.vue +++ b/playground/src/App.vue @@ -7,7 +7,7 @@ const count = ref(0) diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 61c419fae..bbd8c6cd8 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -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: {