This is similar to "Support index.jsx entry file #3052".
I'm playing around with react-primitives and naturally I have multiple entry points into my app. After reading the reasons why #3052 was closed, I still think that index.web.js is a valid use case. Thank you for consideration.
https://github.com/facebook/create-react-app/issues/3052#issuecomment-356114916 suggest that if it's easy, they are happy to take a PR.
I think the one way to do it without fiddling with webpack config is to let node's own module resolution takes care of this.
https://github.com/facebook/create-react-app/blob/next/packages/react-scripts/config/paths.js#L56 -> instead of hard-coding src/index.js we can move it to just src, and the user can create a package.json there with main property pointed to any file the user like.
IIRC node's module resolution does not handle index.web.js. And I don't think package.json main would work either, because the use case is when you have multiple main entry points for different platforms such as index.web.js, index.ios.js, index.android.js and so on.
I think the most reasonable solution is to modify the line that you referenced, check if src/index.web.js exists, and otherwise proceed with src/index.js
Truth be told I'm surprised that package.json main is not supported, so maybe check that too.
that would also work. and we can just use paths.appSrc variable in the webpack configs. I think there's a bigger reason why they don't go supporting node resolution though I'm not sure.
I'm curious about how you set up your multi-platform app with CRA though, do you have an example of how you do that?
Sorry for the delay. Here is my setup.
As for supporting node resolution, I think it's because there was no need to support index.json and index.node extensions.
This is on master since #4837.
These are now accepted as an entry point:
You can close this issue. :)
Most helpful comment
https://github.com/facebook/create-react-app/issues/3052#issuecomment-356114916 suggest that if it's easy, they are happy to take a PR.
I think the one way to do it without fiddling with webpack config is to let node's own module resolution takes care of this.
https://github.com/facebook/create-react-app/blob/next/packages/react-scripts/config/paths.js#L56 -> instead of hard-coding src/index.js we can move it to just src, and the user can create a
package.jsonthere withmainproperty pointed to any file the user like.