Skip to content

Commit 01746ca

Browse files
authored
Push page module item later (#21)
* Modify test case * Push page later
1 parent b138019 commit 01746ca

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/lib.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@ impl VisitMut for NextSuperJsonTransformer {
327327
ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultExpr(
328328
ExportDefaultExpr { expr, .. },
329329
)) => {
330-
keep_page = self.use_init_props;
330+
keep_page = true;
331331
*expr = expr.take().wrap_page();
332332
}
333333
ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultDecl(
334334
ExportDefaultDecl { decl, .. },
335335
)) => {
336-
keep_page = self.use_init_props;
336+
keep_page = true;
337337
// TODO: remove duplicate code
338338
match decl {
339339
DefaultDecl::Class(class_expr) => {
@@ -421,11 +421,7 @@ impl VisitMut for NextSuperJsonTransformer {
421421
span: DUMMY_SP,
422422
}),
423423
);
424-
if !self.use_init_props {
425-
new_items.push(new_page);
426-
} else {
427-
temp_page = Some(new_page);
428-
}
424+
temp_page = Some(new_page);
429425

430426
// export { Page as default }
431427
// =>
@@ -438,11 +434,7 @@ impl VisitMut for NextSuperJsonTransformer {
438434
span: DUMMY_SP,
439435
}),
440436
);
441-
if !self.use_init_props {
442-
new_items.push(new_page);
443-
} else {
444-
temp_page = Some(new_page);
445-
}
437+
temp_page = Some(new_page);
446438
}
447439
}
448440

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { withSuperJSONPage as _withSuperJSONPage } from "next-superjson-plugin/tools";
22
import { foo as _NEXT_SUPERJSON_IMPORTED_PAGE } from 'source';
3-
export default _withSuperJSONPage(_NEXT_SUPERJSON_IMPORTED_PAGE);
4-
export { getServerSideProps } from 'source';
3+
export { getServerSideProps } from 'source';
4+
export default _withSuperJSONPage(_NEXT_SUPERJSON_IMPORTED_PAGE);

0 commit comments

Comments
 (0)