Skip to content

Commit

Permalink
fix: component export default jsdoc loss when use <script setup>
Browse files Browse the repository at this point in the history
close #1327
  • Loading branch information
johnsoncodehk committed May 30, 2022
1 parent 71f8837 commit cc5e752
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/vue-code-gen/src/generators/script.ts
Expand Up @@ -39,6 +39,7 @@ export function generate(
}

writeScriptSrc();
writeScriptSetupImports();
writeScriptBeforeExportDefault();
writeScriptSetup();
writeScriptSetupTypes();
Expand Down Expand Up @@ -167,7 +168,7 @@ export function generate(
return;

if (!!scriptSetup && scriptRanges?.exportDefault) {
addVirtualCode('script', 0, scriptRanges.exportDefault.start);
addVirtualCode('script', 0, scriptRanges.exportDefault.expression.start);
}
else {
let isExportRawObject = false;
Expand Down Expand Up @@ -228,7 +229,7 @@ export function generate(
},
);
}
function writeScriptSetup() {
function writeScriptSetupImports() {

if (!scriptSetup)
return;
Expand Down Expand Up @@ -256,8 +257,22 @@ export function generate(
},
},
);
}
function writeScriptSetup() {

if (!scriptSetup)
return;

if (!scriptSetupRanges)
return;

if (scriptRanges?.exportDefault) {
codeGen.addText('await (async () => {\n');
}
else {
codeGen.addText('export default await (async () => {\n');
}

codeGen.addText('export default await (async () => {\n');
codeGen.addCode(
scriptSetup.content.substring(scriptSetupRanges.importSectionEndOffset),
{
Expand Down

0 comments on commit cc5e752

Please sign in to comment.