{"id":13529663,"url":"https://github.com/lukejacksonn/es-react","last_synced_at":"2025-04-04T19:15:09.272Z","repository":{"id":34487822,"uuid":"172551991","full_name":"lukejacksonn/es-react","owner":"lukejacksonn","description":"ES6 module exposing the latest version of react and react-dom","archived":false,"fork":false,"pushed_at":"2023-01-04T13:04:25.000Z","size":493,"stargazers_count":232,"open_issues_count":9,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-01T18:58:04.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codepen.io/lukejacksonn/pen/EMxVWM","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukejacksonn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-25T17:27:27.000Z","updated_at":"2025-01-13T03:59:50.000Z","dependencies_parsed_at":"2023-01-15T07:23:53.696Z","dependency_job_id":null,"html_url":"https://github.com/lukejacksonn/es-react","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukejacksonn%2Fes-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukejacksonn%2Fes-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukejacksonn%2Fes-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukejacksonn%2Fes-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukejacksonn","download_url":"https://codeload.github.com/lukejacksonn/es-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:00:38.365Z","updated_at":"2025-04-04T19:15:09.254Z","avatar_url":"https://github.com/lukejacksonn.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# es-react\n\n\u003e An ES6 module exposing the latest version of react, react-dom, react-is, and prop-types\n\nEver wanted to just import react into your project as a module **without** a build step or even script tags? Native browser support for module [imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) is [pretty good](https://caniuse.com/#feat=es6-module) so this should be an option for react developers now! Alas, there has not been an ES6 module compatible build released yet.\n\nThis package allows you import `react` and `react-dom` as ES6 modules from a CDN like [`unpkg`](https://unpkg.com):\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { React, ReactDOM, PropTypes } from 'https://unpkg.com/es-react';\n\n  ReactDOM.render(\n    React.createElement('h1', {}, 'Hello from es-react'),\n    document.body\n  );\n\u003c/script\u003e\n```\n\nBy default es-react exports the **production build** of react. For the **development build** use the `/dev` subfolder:\n\n```js\nimport { React, ReactDOM } from 'https://unpkg.com/es-react/dev';\n```\n\nYou may also import any members of the React package directly:\n\n```js\nimport React, {\n  Component,\n  useState /* ... */,\n} from 'https://unpkg.com/es-react';\n```\n\nAnd every package is also being provided as a separate file:\n\n- `es-react/index.js`: Exports all of `React` and exports `{ React, ReactDOM, ReactIs, PropTypes }`\n- `es-react/react.js`: Exports all of `React` plus a default export\n- `es-react/react-dom.js`: Exports all of `ReactDOM` plus a default export (but not `react-dom/server`)\n- `es-react/react-is.js`: Exports all of `ReactIs` plus a default export\n- `es-react/prop-types.js`: Exports all of `PropTypes` plus a default export\n- `es-react/react-dom-server.js`: Exports all of `ReactDOMServerBrowser` plus a default export\n\nAll development-versions of these packages are also available under `es-react/dev/`.\n\n## Features\n\n- All the latest React features (hooks, suspense, lazy, memo etc.)\n- Use React directly from any javascript file (no build step required)\n- Compatible with [`htm`](https://github.com/developit/htm) (for JSX compilation at runtime)\n\n## Usage\n\nImport `React` and `ReactDOM` directly from any script with `type=\"module\"`. The package is intended to be available from [`unpkg`](https://unpkg.com) (without having to append `?module` to the package name).\n\n```js\nimport { React, ReactDOM } from 'https://unpkg.com/es-react@16.13.1';\n```\n\nIt is strongly advised that you specify a version when requesting the module – this speeds up the request time and helps with caching. If you don't specify a number then unpkg will redirect and serve up the latest available version.\n\n## Example\n\nCreate a new file, copy the code below into it and then open the file in a browser – or [try online](https://codepen.io/lukejacksonn/pen/EMxVWM).\n\n\u003e If you would like the browser to reload when you update the code, then you can use a dev server like [servor](https://github.com/lukejacksonn/servor) dependency free by running `npx servor --reload --browse`.\n\n```js\n\u003cscript type=\"module\"\u003e\n  import { React, ReactDOM } from 'https://unpkg.com/es-react@16.13.1';\n\n  import htm from 'https://unpkg.com/htm?module'\n  const html = htm.bind(React.createElement)\n\n  const Counter = props =\u003e {\n    const [count, setCount] = React.useState(parseInt(props.count))\n    return html`\n      \u003cdiv\u003e\n        \u003ch1\u003e${count}\u003c/h1\u003e\n        \u003cbutton onClick=${e =\u003e setCount(count - 1)}\u003eDecrement\u003c/button\u003e\n        \u003cbutton onClick=${e =\u003e setCount(count + 1)}\u003eIncrement\u003c/button\u003e\n      \u003c/div\u003e\n    `\n  }\n\n  ReactDOM.render(\n    html`\n      \u003ch1\u003eLook Ma! No script tags, no build step\u003c/h1\u003e\n      \u003c${Counter} count=0 /\u003e\n    `,\n    document.body\n  )\n\n\u003c/script\u003e\n```\n\n## Implementation\n\nThe latest versions of all packages are installed via (pinned) entries in `package.json` and built and bundled using Rollup with automatic code splitting.\n\nThe exports of each package are automatically expanded and `object-assign` is stripped from the output, since all browsers that support ESM will also support `Object.assign`\n(See `scripts/expand-exports-plugin.js` and `scripts/replace-object-assign.js` for the Babel plugins that do this)\n\n## Acknowledgements\n\nBarely any of the code in this repo is written by myself. It is just a wrapper for React that is written and maintained by the team at Facebook. Thanks to my employer [Formidable](https://github.com/formidablelabs) for allowing me the time to think about and work on fun and experimental projects like this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukejacksonn%2Fes-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukejacksonn%2Fes-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukejacksonn%2Fes-react/lists"}