Skip to content

Commit

Permalink
Merge pull request #97 from blitz-js/fix-96
Browse files Browse the repository at this point in the history
Fix #96
  • Loading branch information
Skn0tt authored Sep 20, 2021
2 parents ca77f5a + 82b944e commit f8f5b2b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
isClassDeclaration,
isExportDefaultDeclaration,
isFunctionDeclaration,
isFunctionExpression,
isIdentifier,
isVariableDeclaration,
stringLiteral,
Expand Down Expand Up @@ -119,14 +118,6 @@ function wrapExportDefaultDeclaration(path: NodePath<any>) {

const { node } = path;

if (isIdentifier(node.declaration)) {
node.declaration = wrapInHOC(node.declaration);
}

if (isFunctionExpression(node.declaration)) {
node.declaration = wrapInHOC(node.declaration);
}

if (
isFunctionDeclaration(node.declaration) ||
isClassDeclaration(node.declaration)
Expand All @@ -145,6 +136,8 @@ function wrapExportDefaultDeclaration(path: NodePath<any>) {
);
}
}
} else {
node.declaration = wrapInHOC(node.declaration);
}
}

Expand Down
10 changes: 10 additions & 0 deletions test/pages/already wrapped gSSP and component/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const getServerSideProps = withAuthUserTokenSSR({
whenUnauthed: AuthAction.REDIRECT_TO_LOGIN,
})(async ({ AuthUser }) => {
// ...
return {
props,
};
});

export default withAuthUser()(Component);
14 changes: 14 additions & 0 deletions test/pages/already wrapped gSSP and component/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools';
import { withSuperJSONProps as _withSuperJSONProps } from 'babel-plugin-superjson-next/tools';
export const getServerSideProps = _withSuperJSONProps(
withAuthUserTokenSSR({
whenUnauthed: AuthAction.REDIRECT_TO_LOGIN,
})(async ({ AuthUser }) => {
// ...
return {
props,
};
}),
['smth']
);
export default _withSuperJSONPage(withAuthUser()(Component));

0 comments on commit f8f5b2b

Please sign in to comment.