-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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 index.jsx entry file #3052
Comments
Please see #290; we do not recommend using the If you feel strongly about this, we can petition it but it would considered a breaking change and have to be released in a major version change. |
Thanks, I know it's not recommended, though it seems well supported enough that I would expect the I would be fine with dropping this if it's too complicated. However, couldn't we keep this back compatible by only searching for an |
For what it's worth, Webpack uses node's module resolution for entries, which means you can use a directory or an extensionless file as an entry point. Directories resolve to an index file inside that directory. File extensions are given priority based on their order in resolve.extensions.
So supporting this should be as simple removing the hard coded '.js' in the config. The extensionless file might be a better bet since just using This would also allow for using .mjs files as entry points too. (If those were to be added to the extensions list) But that should probably be a separate discussion. |
Hmm, yes -- it should be as simple as removing |
@variadicintegrity Thanks that's a good point, didn't know about that. So we would want |
Yes, extension order would matter. It's true that this would rely on webpack specific module resolution, but only for the entry file. I personally don't think that's too much of a concern, but you guys may think differently. I also agree that it's a bit surprising for .jsx files to work everywhere except the entry file. It seems that if they're going to be reluctantly supported, they may as well be reluctantly supported everywhere. One other tiny benefit might be that this is one less thing for a hypothetical plugin system to have to worry about. A typescript (or other compile-to-js language) plugin would need to allow .ts files as entry points anyway. Which could simply be done by adding .ts to the |
Totally agree. @Timer Would you like a PR for this? If so I would prioritize |
We prioritize It seems we only use the path entry in webpack and the I'd like to see a PR implementing this where we wouldn't have to duplicate logic (like the extensions) and still retain the error message in the |
Change your file name to |
@torabian This may be simple for just Here's what this change involves for me:
|
A temporary solution would probably be to just defer
require('./index.jsx') |
That's a great workaround, but I'm concerned about it creating confusion for contributors. If I haven't used |
Meh. If it's easy to fix, happy to take a PR, but I wouldn't lose sleep over this. |
related issues: 1. facebook#1084 2. facebook#3941 3. facebook#3052
While I understand that the jsx extension is supported but not recommended, I was surprised that my
index.jsx
file isn't being recognized after renaming it to passeslint-config-airbnb
's jsx extension requirement.Is this a bug report?
Sort of, I was surprised this wasn't supported but it may be an intentionally missing feature.
Which terms did you search for in User Guide?
index.js
, it's clear that it's currently expected for the filename to be an exact match.Steps to Reproduce
index.js
toindex.jsx
npm start
Expected Behavior
App runs normally, treating
index.jsx
as the same asindex.js
when it's not present.Actual Behavior
The text was updated successfully, but these errors were encountered: