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

When to use file extension on imports and when to use .jsx extension #220

Closed
MarceloPrado opened this issue Jan 3, 2017 · 1 comment
Closed

Comments

@MarceloPrado
Copy link

Hello, how are you doing today?

I'm developing a medium-large application and I've bootstrapped it with Base. I noticed that sometimes you've imported a file using its extension and sometimes you didn't. For example:
import Component from '../components/Component and import Component from '../components/Component.js

What would be the appropriate way of doing this? I noticed that in some cases, React can't find the module without the extension.

Also, I noticed you're not using .jsx extension, but somehow it knows we're using React. How's that possible? I couldn't find any configuration file that setups this.

Thanks!

@themeteorchef
Copy link
Owner

Hi, Marcelo! I'm well; hope you are, too.

Re: .js vs .jsx, this is handled automatically via the Babel transpiler that Meteor uses behind the scenes as part of its build system. You can use either .jsx or .js for files containing JSX code and it will parse them properly either way (it can detect the JSX syntax).

In Base/my own projects, I prefer .js to keep all of my files consistent.

Going to close this out but feel free to add more questions/notes here :)

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

No branches or pull requests

2 participants