Skip to content

Commit 2c7ee0f

Browse files
committed
Update index.ts
1 parent 6c9d851 commit 2c7ee0f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/babel/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ function bubbleFunctionDeclaration(
309309
// have zero or one parameter
310310
decl.params.length < 2
311311
) {
312-
const first = program.get('body')[0];
313-
const [tmp] = first.insertBefore(decl);
314-
program.scope.registerDeclaration(tmp);
315-
tmp.skip();
316312
if (path.parentPath.isExportNamedDeclaration()) {
317313
path.parentPath.replaceWith(
318314
t.exportNamedDeclaration(undefined, [
@@ -324,6 +320,9 @@ function bubbleFunctionDeclaration(
324320
} else {
325321
path.remove();
326322
}
323+
const [tmp] = program.unshiftContainer('body', [decl]);
324+
program.scope.registerDeclaration(tmp);
325+
tmp.skip();
327326
}
328327
}
329328
}
@@ -361,6 +360,7 @@ export default function solidRefreshPlugin(): babel.PluginObj<State> {
361360
bubbleFunctionDeclaration(programPath, path);
362361
},
363362
});
363+
programPath.scope.crawl();
364364
if (state.jsx) {
365365
programPath.traverse({
366366
JSXElement(path) {
@@ -370,6 +370,7 @@ export default function solidRefreshPlugin(): babel.PluginObj<State> {
370370
transformJSX(path);
371371
},
372372
});
373+
programPath.scope.crawl();
373374
}
374375
programPath.traverse({
375376
VariableDeclarator(path) {

0 commit comments

Comments
 (0)