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 index.web.js entry file #3941

Closed
Hermanya opened this issue Jan 30, 2018 · 5 comments
Closed

Support index.web.js entry file #3941

Hermanya opened this issue Jan 30, 2018 · 5 comments
Milestone

Comments

@Hermanya
Copy link

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.

@viankakrisna
Copy link
Contributor

#3052 (comment) 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.

@Hermanya
Copy link
Author

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.

@viankakrisna
Copy link
Contributor

viankakrisna commented Jan 31, 2018

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?

@Hermanya
Copy link
Author

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.

@brunolemos
Copy link
Contributor

This is on master since #4837.

These are now accepted as an entry point:

  • index.js
  • index.jsx
  • index.mjs
  • index.ts
  • index.tsx
  • index.web.js
  • index.web.jsx
  • index.web.mjs
  • index.web.ts
  • index.web.tsx

You can close this issue. :)

@Timer Timer closed this as completed Oct 23, 2018
@Timer Timer added this to the 2.1 milestone Oct 23, 2018
lepture added a commit to lepture/create-react-app that referenced this issue Nov 1, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants