Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSX file extension #491

Closed
mathisonian opened this issue May 11, 2019 · 5 comments · Fixed by #603
Closed

Support JSX file extension #491

mathisonian opened this issue May 11, 2019 · 5 comments · Fixed by #603

Comments

@mathisonian
Copy link
Member

Describe the solution you'd like
Given that many Idyll components use JSX syntax, it would be nice to support files named with the .jsx file extension in addition to the standard .js.

@amitbadala
Copy link
Member

amitbadala commented Jul 7, 2019

@mathisonian could you provide more details?

@mathisonian
Copy link
Member Author

So some people prefer to name their components like my-component.jsx rather than my-component.js if they are using React's JSX syntax in those component files, however if you try to do this now, you'll get a "component not found error" when trying to use that my-component.jsx file.

To fix, we'll have to update the component resolver to be able to handle .jsx files. I believe the culprit for the error comes from this line. The problem could likely be solved by checking if the import worked as expected, and trying to import the .jsx version if the first attempt fails (although I haven't tested this logic yet!)

@amitbadala amitbadala self-assigned this Jul 11, 2019
@amitbadala
Copy link
Member

amitbadala commented Jul 11, 2019

@mathisonian I tried reproducing.

  1. Added my-component.jsx file
  2. Exported as MyComponent
  3. Accessed that particular component in Idyll project using [MyComponent/]
  4. Also imported my-component into another component.

Didn't receive an error. Am I doing something wrong here?

@mathisonian
Copy link
Member Author

mathisonian commented Jul 11, 2019

Do you possibly have a copy of the file still saved as my-component.js? What OS/node version are you using?

I wouldn't expect that to work! 👻

@amitbadala
Copy link
Member

amitbadala commented Jul 12, 2019

Just to be sure I had tried it with three different component names. 🤹‍♂️
OS / node = Linux / 12.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants