You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The plugin doesn't inject the __collectModule hook.
This is because the ExportDefaultDeclaration ast traverse has a small missing step for arrowFunctionExpressions.
I've provided some code that I think can resolve the issue. Let me know if you want me to make a forkPR.
ExportDefaultDeclaration(path){constdeclaration=path.node.declaration;// Insert hook in `export default function() { ... }`if(isReactFunctionComponent(declaration)){injectImport(ast,__internal_importHelperModuleName);injectHook(path.get('declaration'),relative);injected=true;}elseif(t.isIdentifier(declaration)){// Insert hook in `function Component() { ... }; export default Component;`constbinding=path.scope.getBinding(declaration.name);if(binding){// Right here we need to check if the binding is a declarator for the ArrowFunctionExpression. // This code creates the correct NodePath for the if statement and the injectHook function.constexpressionPath=t.isVariableDeclarator(binding.path.node) ? binding.path.get('init') : binding.path;if(isReactFunctionComponent(expressionPath.node)){injectImport(ast,__internal_importHelperModuleName);injectHook(expressionPath,relative);injected=true;}}}},
Let me know if I can help resolve this or if more information is required.
The text was updated successfully, but these errors were encountered:
If a component is defined like so:
The plugin doesn't inject the
__collectModule
hook.This is because the
ExportDefaultDeclaration
ast traverse has a small missing step for arrowFunctionExpressions.I've provided some code that I think can resolve the issue. Let me know if you want me to make a forkPR.
Let me know if I can help resolve this or if more information is required.
The text was updated successfully, but these errors were encountered: