Skip to content

Commit

Permalink
fix: make export default order unimportant
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Aug 6, 2022
1 parent f326626 commit d7af2ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vue-code-gen/src/generators/script.ts
Expand Up @@ -312,6 +312,8 @@ export function generate(
codeGen.addText('export default await (async () => {\n');
}

codeGen.addText('const __VLS_setup = async () => {\n');

codeGen.addCode(
scriptSetup.content.substring(scriptSetupRanges.importSectionEndOffset),
{
Expand Down Expand Up @@ -535,6 +537,8 @@ export function generate(
codeGen.addText(`const __VLS_slots = (await import('./${path.basename(fileName)}.__VLS_template.jsx')).default;\n`)
codeGen.addText(`return {} as typeof __VLS_Component & (new () => { ${getSlotsPropertyName(vueVersion)}: typeof __VLS_slots });\n`);
}
codeGen.addText(`};\n`);
codeGen.addText(`return await __VLS_setup();\n`);
codeGen.addText(`})();`);
exportdefaultEnd = codeGen.getText().length;

Expand Down
@@ -0,0 +1,14 @@
<script lang="ts">
export const useOne = async () => {
return { one: 'one' }
}
export default {}
export const useTwo = async () => ({ two: 'two' })
</script>

<script lang="ts" setup>
useOne()
useTwo()
</script>

0 comments on commit d7af2ee

Please sign in to comment.