Skip to content

Commit 496fb0f

Browse files
committed
if program has one node in it, and that node is a function declaration, automatically export default it
1 parent fd66650 commit 496fb0f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/processScript/preprocess.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ export function preprocess(code: string, { uniqueID = `00000000000` }: Partial<P
153153
], t.stringLiteral(`proxy-polyfill/src/proxy.js`)))
154154
}
155155

156+
if (program.node.body.length == 1 && program.node.body[0]!.type == `FunctionDeclaration`) {
157+
return {
158+
code: `export default ${generate(file).code}`,
159+
seclevel
160+
}
161+
}
162+
156163
return {
157164
code: generate(file).code,
158165
seclevel

0 commit comments

Comments
 (0)