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

Bug: Where is react.mjs download for browser? #26728

Closed
manake opened this issue Apr 25, 2023 · 10 comments
Closed

Bug: Where is react.mjs download for browser? #26728

manake opened this issue Apr 25, 2023 · 10 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@manake
Copy link

manake commented Apr 25, 2023

What I want to do is:

  1. Go to https://github.com/facebook/react/ to /dist/ folder and download react.mjs and react-dom.mjs.
  2. Create a *.html file like this:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <link href="style.css" rel="stylesheet">
    </head>
    <body>

        <script type="module">
            import * as React from './react.mjs';

            let element = React.createElement('div');
        </script>
    </body>
</html>

This is ridiculous that I can't just do this because there is no /dist/ folder in this repo nor react.mjs available anywhere.

The npm i react react-dom version doesn't have a JS browser module and the only module I found was on a CDN but it wasn't easily copiable from there because I had to manually fix import paths.

@manake manake added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 25, 2023
@MeastroZI
Copy link

MeastroZI commented Apr 26, 2023

I am the beginner , can anyone tell me how can i run my changes on react source code ?

@markerikson
Copy link
Contributor

Per #11503 , React does not currently ship any ES module builds.

Some CDNs do automatic conversion of React for use as an ESM script tag - you can try using that:

https://esm.sh/#docs

@kushhingol
Copy link

@markerikson that's a great suggestion

@kushhingol
Copy link

Hi @MeastroZI, I found something in the readme file which can help you with further investigation for your usecase

image

https://legacy.reactjs.org/docs/cdn-links.html

@manake
Copy link
Author

manake commented Apr 30, 2023

Thanks, but I can't use a CDN for any libraries because I often work offline.

@Bibooo25730
Copy link

https://github.com/Bibooo25730/Browserify-Gulp-Babelify-React

您可以使用我这个来转换 jsx,不过是手动的

@j4acks0n
Copy link

Thanks, but I can't use a CDN for any libraries because I often work offline.

Well It Depends What Editor/Ide You Use.....
Can I Know What Ide/Editor You Use?
Maybe I Can Help You😊

@gaearon
Copy link
Collaborator

gaearon commented May 16, 2023

We don't currently provide a purely ESM build out of the box, so you will have to build it yourself the same way that these CDNs do. We don't think realistically this is a great way to consume React today anyway, since it's not very usable without import maps, and import maps have barely landed across browsers. We'll revisit this in the future.

@gaearon gaearon closed this as completed May 16, 2023
@manake
Copy link
Author

manake commented May 18, 2023

@Bibooo25730 Thanks.

@j4acks0n Thanks. VSCode. I downloaded mjs version from a CDN and it works fine for me for now.

@gaearon
Import maps are present in all major browsers already and aren't going anywhere so how "barely landed" is a problem in any way?
That's a very weird argument.
Anyway, it's possible to export React as a single react.mjs without using import maps.
IMO, it's better to have /dist/ folder and a installation notice (e.g. "mjs is not recommended but available") than no /dist/ folder.

@xiaoqiang1999
Copy link

根据 #11503 ,React 目前没有发布任何 ES 模块构建。

一些 CDN 会自动转换 React 以用作 ESM 脚本标签 - 您可以尝试使用它:

https://esm.sh/#docs

Thank! It works very well !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

8 participants