Support index.jsx entry file
See original GitHub issueWhile 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 pass eslint-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
- Rename
index.js
toindex.jsx
npm start
Expected Behavior
App runs normally, treating index.jsx
as the same as index.js
when it’s not present.
Actual Behavior
> react-scripts start
Could not find a required file.
Name: index.js
Searched in: /Users/nick/Repos/password-entropy/src
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:13 (10 by maintainers)
Top Results From Across the Web
webpack can't find module if file named jsx - Stack Overflow
Webpack doesn't know to resolve .jsx files implicitly. You can specify a file extension in your app ( import App from '.
Read more >Introducing JSX - React
It is called JSX, and it is a syntax extension to JavaScript. We recommend using it with React to describe what the UI...
Read more >How to Structure a React Project? - ReactJS News
The index.js files provide us neat entry points to the files so they are easy to consume from elsewhere. Each component is a...
Read more >Say “Hello World!” with the Create React App - Sweetcode.io
/src/index.js is the entry point of the project that React will be looking into before any other files. (Keep in mind that these...
Read more >API - ESBuild
There you can use regular JavaScript syntax to eliminate cross-platform differences. #Entry points. Supported by: Build. This is an array of files that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@torabian This may be simple for just
create-react-app
alone, but it doesn’t play well with developer tools. It took me at least an hour or two to get this working properly, and this affects a lot of people.Here’s what this change involves for me:
auto-mode-alist
, but for packages likeweb-mode
that handle multiple syntaxes, this quickly becomes complicated and difficult to debug.eslint-config-airbnb
, so I either have to violate its requirement or configure the rule to be disabled for this file. Either way, I should not need to violate linter or style guide rules because of technology choices.index.jsx
isn’t allowed andindex.js
has to be used instead, causing potential confusion and additional style guide violations.That’s a great workaround, but I’m concerned about it creating confusion for contributors. If I haven’t used
create-react-app
before and I only had experience with React and Webpack, I wouldn’t be sure if I should be openingindex.js
orindex.jsx
to change functionality, and it wouldn’t be clear at first glance why both need to exist.