Skip to content

Commit e69e300

Browse files
committed
chore: update example
1 parent ec80938 commit e69e300

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

examples/vite/src/App.vue

+8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ const msg = ref("");
55

66
<template>
77
<div>
8+
123
89
<h1>Hello world</h1>
10+
3123132ww
911
<h2>{{ msg }}</h2>
1012
12313211231222146521312wwwwww321
1113
<input v-model="msg" type="text" />
1214
</div>
1315
</template>
16+
17+
<style>
18+
body {
19+
background-color: #fba;
20+
}
21+
</style>

src/core/index.ts

+36-35
Original file line numberDiff line numberDiff line change
@@ -372,42 +372,42 @@ export const plugin = createUnplugin<Options | undefined, false>(
372372
return fs.readFileSync(filename, "utf-8");
373373
}
374374

375-
// const descriptor = getDescriptor(filename, options.value)!;
376-
// let block: SFCBlock | null | undefined;
377-
// if (query.type === "script") {
378-
// // handle <script> + <script setup> merge via compileScript()
379-
// block = resolveScript(
380-
// meta.framework,
381-
// descriptor,
382-
// options.value,
383-
// ssr,
384-
// customElementFilter.value(filename),
385-
// );
386-
// } else if (query.type === "template") {
387-
// block = descriptor.template!;
388-
// } else if (query.type === "style") {
389-
// block = descriptor.styles[query.index!];
390-
// } else if (query.index != null) {
391-
// block = descriptor.customBlocks[query.index];
392-
// }
393-
394-
// if (block) {
395-
396-
const res = fervidCompiler.compileSync(
397-
fs.readFileSync(filename, "utf-8"),
398-
{
399-
id,
400-
filename: id,
401-
},
402-
);
375+
const descriptor = getDescriptor(filename, options.value)!;
376+
let block: SFCBlock | null | undefined;
377+
if (query.type === "script") {
378+
// handle <script> + <script setup> merge via compileScript()
379+
block = resolveScript(
380+
meta.framework,
381+
descriptor,
382+
options.value,
383+
ssr,
384+
customElementFilter.value(filename),
385+
);
386+
} else if (query.type === "template") {
387+
block = descriptor.template!;
388+
} else if (query.type === "style") {
389+
block = descriptor.styles[query.index!];
390+
} else if (query.index != null) {
391+
block = descriptor.customBlocks[query.index];
392+
}
403393

404-
return {
405-
code: res.code,
406-
// code: block.content,
407-
// map:
408-
map: "",
409-
};
410-
// }
394+
if (block) {
395+
// const res = fervidCompiler.compileSync(
396+
// fs.readFileSync(filename, "utf-8"),
397+
// {
398+
// id,
399+
// filename: id,
400+
// },
401+
// );
402+
console.log(block.content);
403+
404+
return {
405+
// code: res.code,
406+
code: block.content,
407+
// map:
408+
map: "",
409+
};
410+
}
411411
}
412412
},
413413

@@ -437,6 +437,7 @@ export const plugin = createUnplugin<Options | undefined, false>(
437437
fervidCompiler,
438438
);
439439
} else {
440+
console.log(query);
440441
// sub block request
441442
const descriptor = query.src
442443
? getSrcDescriptor(filename, query) ||

src/core/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export async function transformMain(
254254

255255
// handle TS transpilation
256256
let resolvedCode = output.join("\n");
257-
console.log(resolvedCode);
257+
// console.log(resolvedCode);
258258

259259
const lang = descriptor.scriptSetup?.lang || descriptor.script?.lang;
260260

0 commit comments

Comments
 (0)