BuilderIO / mitosis

Write components once, run everywhere. Compiles to React, Vue, Qwik, Solid, Angular, Svelte, and more.
https://mitosis.builder.io
MIT License
12.4k stars 549 forks source link

Component exports not including Functions #483

Open samijaber opened 2 years ago

samijaber commented 2 years ago

https://github.com/BuilderIO/mitosis/blob/7b5d4c9396c975b3af5ab83734622347cd546862/packages/core/src/parsers/jsx.ts#L1009

We are hitting this warning in our snapshot tests for React when running for this snapshot: https://github.com/BuilderIO/mitosis/blob/7b5d4c9396c975b3af5ab83734622347cd546862/packages/core/src/__tests__/data/basic-ref-usePrevious.raw.tsx#L7

Looking at the logic: https://github.com/BuilderIO/mitosis/blob/7b5d4c9396c975b3af5ab83734622347cd546862/packages/core/src/parsers/jsx.ts#L982-L1010

This is not accounting for node.declaration being a FunctionDeclaration

PatrickJS commented 2 years ago

yeah this is needed. the workaround is not using function declareation.

export const usePrevious = () => {};
samijaber commented 2 years ago

We should change the warning to throw an error, or at least improve the warning: "Could not parse export: ignoring..."