Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
facebook/create-react-app
15268531097/create-react-app
2aces/create-react-app
60noy/create-react-app
Aiooioo/create-react-app-ags4x
Amanchouhan192/create-react-app
Axighi/create-pepper-app
BigSquare/create-react-app
Bogala/create-react-app-awesome-ts
CNXTEoEorg/create-react-app
ChaiXiangguo/create-react-app
ChevTech/create-react-app
CodingZeal/create-react-app
ColDog/create-react-app
Connorelsea/create-react-app
Cordlesswire/create-react-app
Danilo-Araujo-Silva/create-react-app-kotlin
DemianD/create-react-app-tailwindcss
DevAnouar/create-react-app
DomainGroupOSS/create-react-app
Exodia/x-react-scripts
Fabianopb/create-react-app
FormidableLabs/spectacle-scripts
GreenTeak/create-react-app
Guang-yi/Create-React-App
HarrariScript/create-react-app
HelpfulHuman/helpful-react-scripts
IamGiel/create-react-app
IlmastMaksim/create-react-app
JawadNazir/create-react-app
JoeCortopassi/create-react-app
JohannesPatzschke/create-react-app
Khappom/create-react-app
Lapat1560700104/create-react-app
LucyZlu/create-react-app
Marcin-Wiglusz/custom-react-scripts
MarieLynneBlock/create-react-app
MarloneA/create-react-app
NLeSC/create-react-app
SUNNERCMS/create-react-app
ScriptedAlchemy/create-react-app
ServiceMax-Engineering/create-react-app
Sibabalwe-Qamata/create-react-app
Skyscanner/backpack-react-scripts
SupremeMag/create-react-app
Tibdem/create-react-app
Toppole69/create-react-app
Valbrand/create-react-app-ts
Valentin-Seehausen/create-react-app
Windscribe/react-scripts-ws-webextension
Wolox/wolox-react-scripts
YannickDot/create-react-app-mods
akesetta/create-react-app
alanquigley/create-react-app
alexdevero/create-react-app
alexkuz/create-preact-app
amsb/create-react-app-for-react-native-web
andredurao/create-react-app
andrewdushane/create-react-app
andriijas/create-react-app
androidice/create-react-app
appier/create-react-app
artemirq/advanced-react-scripts
asberk/create-react-app
ashfaqrafi/create-react-app
bahkostya/create-react-app
barkinet/create-react-app
bem/create-bem-react-app
bhoomi65/create-react-app
bonett/create-react-app
bradfordlemley/create-react-app
brunolemos/create-react-app
brysgo/create-react-app
cfarinas024/create-react-app
chibicode/create-react-app
chilingirov/create-react-app
chocolatech/create-react-app
clarketm/create-react-app
claudiu04/create-react-app
coplanner/create-typed-react-app
coryhouse/create-react-app
cuongptnk/create-react-app
cyrusbowman/create-react-app
daniel-hallgren-cdab/create-react-app
dayawansha/create-react-app
denisbarriere/create-react-app
dhimasn/create-react-app
diegotony/create-react-app
djekwork/create-react-app
dmodalek/create-react-app
dnsndrvsk/create-react-app
dylan-7/joys-create-react-app
feeblejs/feeble-scripts
fengshow12345/create-react-app
flybayer/create-react-webextension
g3r4n/create-esri-react-app
gaearon/create-react-app
glaucosydow/create-react-app
grammarly/create-react-app
hasueno/create-react-app
hcxiong/create-react-app
hieu-nv/create-react-app
iamdoron/create-react-app
iansu/create-react-app
ibarsi/spectacle-scripts
icarlossz/create-react-app
igodorogea/create-react-app
ijh5005/create-react-app
infernojs/create-inferno-app
ipapoutsidis/create-react-app
iplaydu/create-react-app
jackfranklin/create-react-app
jacklovepdf/create-react-app
jdcrensh/create-react-app
jianghuadongstar/create-react-app
joelcalheiros/create-react-app
jonathantneal/create-react-app
joseroubert08/create-react-app
just-boris/create-preact-app
juwonom/create-react-app
jwbennet/create-react-app-old
k2data/create-react-app
kalininilya/create-react-app
karlhorky/create-react-app
kitze/custom-react-scripts
knowbody/create-react-app
kurenn/create-react-app
lebrande/create-react-app
lexasorokin/create-react-app
lightingbeetle/lighter
luyuanye/create-react-app
marcello3d/create-electron-react-app
marcinczenko/create-react-app
marcopeg/create-react-app
martina6hall/create-react-app
matsad3547/create-rx3-app
mattiamanzati/create-react-app
mdelrossi1/create-react-app
meua/create-react-app
mikechau/create-react-app
mithlesh4257/create-react-app
mornya/create-react-app
mpj/create-react-app
mrk-9/create-react-app
mwxmielke/mwx-react-scripts
netguru/create-react-app
nongrmt/create-react-app
nubank/create-react-app
obsidian-btc/create-react-cordova-app
orionsoft/create-react-app
peshonator/create-react-app
postlight/create-react-app
prichodko/create-react-app
rakesh4ui347/create-react-app
rangle/create-react-app
rasata/create-react-app
rasitozcan/microfrontend-react-scripts
robertnealan/create-react-app
roseroja/create-react-app
ryansully/create-react-app
sanjoggit/create-react-app
sayami007/create-react-app
se7en7x/create-react-app
shiven-nayee/create-react-app
shrynx/react-super-scripts
sipgate/create-react-app
smmoosavi/my-create-react-app
soediro/create-react-app
spring-media/create-react-web-component
strawferry/create-react-app
strvcom/strv-react-scripts
superce/create-react-app
svrcekmichal/configurable-react-scripts
thomashorrobin/create-react-app-rust
tomjal/custom-react-scripts
tomkis/create-react-app
trevordmiller/create-react-app-electron
tripleaceme/create-react-app
tvkhoa/create-react-app
tzapu/create-react-app
ueno-llc/create-react-app
vanhonit/create-react-app
vgmr/create-ts-app
vkalinichev/react-fancy-scripts
vtex/create-react-app
wangkun5911/create-react-app
will168/create-react-app
willCode2Surf/create-react-app
wmonk/create-react-app
xbpxxb/create-react-app
yanglinz/create-react-app-django
ydeshayes/create-react-app
yedehrab/create-react-app
yingray/create-react-app
yixizhang/create-preact-compat-app
yyx990803/create-react-app
zetavg/create-react-app-with-relay
zhenwenc/create-react-app
zpao/create-react-app
zwjjap/create-react-app
Nothing to show
Choose a Head Repository
facebook/create-react-app
15268531097/create-react-app
2aces/create-react-app
60noy/create-react-app
Aiooioo/create-react-app-ags4x
Amanchouhan192/create-react-app
Axighi/create-pepper-app
BigSquare/create-react-app
Bogala/create-react-app-awesome-ts
CNXTEoEorg/create-react-app
ChaiXiangguo/create-react-app
ChevTech/create-react-app
CodingZeal/create-react-app
ColDog/create-react-app
Connorelsea/create-react-app
Cordlesswire/create-react-app
Danilo-Araujo-Silva/create-react-app-kotlin
DemianD/create-react-app-tailwindcss
DevAnouar/create-react-app
DomainGroupOSS/create-react-app
Exodia/x-react-scripts
Fabianopb/create-react-app
FormidableLabs/spectacle-scripts
GreenTeak/create-react-app
Guang-yi/Create-React-App
HarrariScript/create-react-app
HelpfulHuman/helpful-react-scripts
IamGiel/create-react-app
IlmastMaksim/create-react-app
JawadNazir/create-react-app
JoeCortopassi/create-react-app
JohannesPatzschke/create-react-app
Khappom/create-react-app
Lapat1560700104/create-react-app
LucyZlu/create-react-app
Marcin-Wiglusz/custom-react-scripts
MarieLynneBlock/create-react-app
MarloneA/create-react-app
NLeSC/create-react-app
SUNNERCMS/create-react-app
ScriptedAlchemy/create-react-app
ServiceMax-Engineering/create-react-app
Sibabalwe-Qamata/create-react-app
Skyscanner/backpack-react-scripts
SupremeMag/create-react-app
Tibdem/create-react-app
Toppole69/create-react-app
Valbrand/create-react-app-ts
Valentin-Seehausen/create-react-app
Windscribe/react-scripts-ws-webextension
Wolox/wolox-react-scripts
YannickDot/create-react-app-mods
akesetta/create-react-app
alanquigley/create-react-app
alexdevero/create-react-app
alexkuz/create-preact-app
amsb/create-react-app-for-react-native-web
andredurao/create-react-app
andrewdushane/create-react-app
andriijas/create-react-app
androidice/create-react-app
appier/create-react-app
artemirq/advanced-react-scripts
asberk/create-react-app
ashfaqrafi/create-react-app
bahkostya/create-react-app
barkinet/create-react-app
bem/create-bem-react-app
bhoomi65/create-react-app
bonett/create-react-app
bradfordlemley/create-react-app
brunolemos/create-react-app
brysgo/create-react-app
cfarinas024/create-react-app
chibicode/create-react-app
chilingirov/create-react-app
chocolatech/create-react-app
clarketm/create-react-app
claudiu04/create-react-app
coplanner/create-typed-react-app
coryhouse/create-react-app
cuongptnk/create-react-app
cyrusbowman/create-react-app
daniel-hallgren-cdab/create-react-app
dayawansha/create-react-app
denisbarriere/create-react-app
dhimasn/create-react-app
diegotony/create-react-app
djekwork/create-react-app
dmodalek/create-react-app
dnsndrvsk/create-react-app
dylan-7/joys-create-react-app
feeblejs/feeble-scripts
fengshow12345/create-react-app
flybayer/create-react-webextension
g3r4n/create-esri-react-app
gaearon/create-react-app
glaucosydow/create-react-app
grammarly/create-react-app
hasueno/create-react-app
hcxiong/create-react-app
hieu-nv/create-react-app
iamdoron/create-react-app
iansu/create-react-app
ibarsi/spectacle-scripts
icarlossz/create-react-app
igodorogea/create-react-app
ijh5005/create-react-app
infernojs/create-inferno-app
ipapoutsidis/create-react-app
iplaydu/create-react-app
jackfranklin/create-react-app
jacklovepdf/create-react-app
jdcrensh/create-react-app
jianghuadongstar/create-react-app
joelcalheiros/create-react-app
jonathantneal/create-react-app
joseroubert08/create-react-app
just-boris/create-preact-app
juwonom/create-react-app
jwbennet/create-react-app-old
k2data/create-react-app
kalininilya/create-react-app
karlhorky/create-react-app
kitze/custom-react-scripts
knowbody/create-react-app
kurenn/create-react-app
lebrande/create-react-app
lexasorokin/create-react-app
lightingbeetle/lighter
luyuanye/create-react-app
marcello3d/create-electron-react-app
marcinczenko/create-react-app
marcopeg/create-react-app
martina6hall/create-react-app
matsad3547/create-rx3-app
mattiamanzati/create-react-app
mdelrossi1/create-react-app
meua/create-react-app
mikechau/create-react-app
mithlesh4257/create-react-app
mornya/create-react-app
mpj/create-react-app
mrk-9/create-react-app
mwxmielke/mwx-react-scripts
netguru/create-react-app
nongrmt/create-react-app
nubank/create-react-app
obsidian-btc/create-react-cordova-app
orionsoft/create-react-app
peshonator/create-react-app
postlight/create-react-app
prichodko/create-react-app
rakesh4ui347/create-react-app
rangle/create-react-app
rasata/create-react-app
rasitozcan/microfrontend-react-scripts
robertnealan/create-react-app
roseroja/create-react-app
ryansully/create-react-app
sanjoggit/create-react-app
sayami007/create-react-app
se7en7x/create-react-app
shiven-nayee/create-react-app
shrynx/react-super-scripts
sipgate/create-react-app
smmoosavi/my-create-react-app
soediro/create-react-app
spring-media/create-react-web-component
strawferry/create-react-app
strvcom/strv-react-scripts
superce/create-react-app
svrcekmichal/configurable-react-scripts
thomashorrobin/create-react-app-rust
tomjal/custom-react-scripts
tomkis/create-react-app
trevordmiller/create-react-app-electron
tripleaceme/create-react-app
tvkhoa/create-react-app
tzapu/create-react-app
ueno-llc/create-react-app
vanhonit/create-react-app
vgmr/create-ts-app
vkalinichev/react-fancy-scripts
vtex/create-react-app
wangkun5911/create-react-app
will168/create-react-app
willCode2Surf/create-react-app
wmonk/create-react-app
xbpxxb/create-react-app
yanglinz/create-react-app-django
ydeshayes/create-react-app
yedehrab/create-react-app
yingray/create-react-app
yixizhang/create-preact-compat-app
yyx990803/create-react-app
zetavg/create-react-app-with-relay
zhenwenc/create-react-app
zpao/create-react-app
zwjjap/create-react-app
Nothing to show
Choose a head branch
Checking mergeability… Don’t worry, you can still create the pull request.
Commits on Oct 15, 2018
Commits on Oct 16, 2018
Commits on Oct 17, 2018
Commits on Oct 18, 2018
Commits on Oct 19, 2018
Commits on Oct 21, 2018
Commits on Oct 22, 2018
Commits on Oct 23, 2018
Commits on Oct 24, 2018
Commits on Oct 27, 2018
improved info on the splash page in the template
added explicit note in app template reminding users they can save src/App.rs and have the app update automatically in the browser
use command-exists instead of manually checking if cmd is avalible
this commit replaces old code that was designed to determine if things like rustup or wasm-gc were installed
the new implementation uses the npm package command-exists, which gives us better async, errs, etc
Commits on Dec 13, 2018
Commits on Dec 15, 2018
@@ -1,17 +1,24 @@
# Create React App [![Build Status](https://travis-ci.org/facebook/create-react-app.svg?branch=master)](https://travis-ci.org/facebook/create-react-app) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/pulls)
# Create React App (Rust) [![Build Status](https://travis-ci.org/facebook/create-react-app.svg?branch=master)](https://travis-ci.org/facebook/create-react-app) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/pulls)

Create React apps with no build configuration.
Create React apps with support for WebAssembly/Rust with no build configuration.

- [Creating an App](#creating-an-app) – How to create a new app.
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.

Create React App works on macOS, Windows, and Linux.<br>
Create React App works on macOS, Windows, and Linux. However Rust tools may behave diferently on Windows in certain cercumstances.<br>
If something doesn’t work, please [file an issue](https://github.com/facebook/create-react-app/issues/new).

## Quick Overview

If you haven't already you'll need to install Rust and source it into your current context
```sh
npx create-react-app my-app
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
```

Then you can run the tool with `npx`
```sh
npx create-react-app my-app --scripts-version react-scripts-rust
cd my-app
npm start
```
@@ -79,6 +86,7 @@ my-app
├── App.css
├── App.js
├── App.test.js
├── App.rs
├── index.css
├── index.js
├── logo.svg
@@ -1,7 +1,24 @@
# react-scripts
# react-scripts-rust

This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
This package includes scripts and configuration used by [Create React App (Rust)](https://github.com/thomashorrobin/create-react-app-rust).<br>
Please refer to its documentation:

- [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.


## Quick Overview

First install Rust if you haven't already
```sh
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
```
Then you can run the tool with `npx`
```sh
npx create-react-app my-app --scripts-version react-scripts-rust
cd my-app
npm start
```

After the project has loaded in Chrome any changes in `src/lib.rs` should result in an instant update in the browser.
@@ -325,6 +325,21 @@ module.exports = function(webpackEnv) {
],
include: paths.appSrc,
},
{
test: /\.rs$/,
use: [
{
loader: 'wasm-loader',
},
{
loader: 'rust-native-wasm-loader',
options: {
release: true,
gc: true,
},
},
],
},
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
@@ -1,14 +1,14 @@
{
"name": "react-scripts",
"version": "2.1.1",
"description": "Configuration and scripts for Create React App.",
"repository": "facebook/create-react-app",
"name": "react-scripts-rust",
"version": "2.0.17",
"description": "Configuration and scripts for using Rust with Create React App",
"repository": "thomashorrobin/create-react-app-rust",
"license": "MIT",
"engines": {
"node": ">=6"
},
"bugs": {
"url": "https://github.com/facebook/create-react-app/issues"
"url": "https://github.com/thomashorrobin/create-react-app-rust/issues"
},
"files": [
"bin",
@@ -35,6 +35,7 @@
"bfj": "6.1.1",
"case-sensitive-paths-webpack-plugin": "2.1.2",
"chalk": "2.4.1",
"command-exists": "^1.2.8",
"css-loader": "1.0.0",
"dotenv": "6.0.0",
"dotenv-expand": "4.2.0",
@@ -63,10 +64,13 @@
"react-app-polyfill": "^0.1.3",
"react-dev-utils": "^6.1.1",
"resolve": "1.8.1",
"rust-native-wasm-loader": "^0.8.1",
"sass-loader": "7.1.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "1.1.0",
"toml-js": "0.0.8",
"url-loader": "1.1.1",
"wasm-loader": "^1.3.0",
"webpack": "4.19.1",
"webpack-dev-server": "3.1.9",
"webpack-manifest-plugin": "2.0.4",
@@ -43,6 +43,7 @@ const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
const printBuildError = require('react-dev-utils/printBuildError');
const rustUtils = require('./utils/rustUtils');

const measureFileSizesBeforeBuild =
FileSizeReporter.measureFileSizesBeforeBuild;
@@ -82,6 +83,8 @@ checkBrowsers(paths.appPath, isInteractive)
fs.emptyDirSync(paths.appBuild);
// Merge with the public folder
copyPublicFolder();
// compile Rust to wasm
rustUtils.build();
// Start the webpack build
return build(previousFileSizes);
})
@@ -204,6 +204,22 @@ module.exports = function(
console.log('Initialized a git repository.');
}

const rustUtils = require('./utils/rustUtils');

if (rustUtils.isRustInstalled()) {
console.log('rust installed 👍');
} else {
console.log(
chalk.bold.red('rust not installed')
);
console.log(
'install rust from here https://www.rust-lang.org/en-US/install.html'
);
return;
}

rustUtils.installRustWebAssemblyTools();

// Display the most elegant way to cd.
// This needs to handle an undefined originalDirectory for
// backward compatibility with old global-cli's.
@@ -0,0 +1,45 @@
const execSync = require('child_process').execSync;
const chalk = require('chalk');
const commandExistsSync = require('command-exists').sync;
const fs = require('fs');
const toml = require('toml-js');

module.exports = {
build: () => {
try {
// first build app.wasm and then optimize with wasm-gc
execSync(
'rustc +nightly --target wasm32-unknown-unknown -O --crate-type=cdylib src/App.rs -o build/app.wasm && wasm-gc build/app.wasm',
{ stdio: 'inherit' }
);
} catch (error) {
console.log(chalk.bold.red('error compiling rust'));
}
},
isRustInstalled: () => commandExistsSync('rustup'),
installRustWebAssemblyTools: () => {
if (!commandExistsSync('wasm-gc')) {
try {
execSync('cargo install wasm-gc', { stdio: 'inherit' });
} catch (e) {
console.log(e);
console.log(`${chalk.bold.red('error installing wasm-gc')} please install manually ${chalk.red('cargo install wasm-gc')}')`);
}
}
execSync(
'cargo init --lib',
{ stdio: 'inherit' }
);
fs.readFile('Cargo.toml', function (err, data) {
var cargo = toml.parse(data);
cargo.lib = {};
cargo.lib['crate-type'] = ['cdylib'];
cargo.lib.path = 'src/App.rs';
fs.writeFile('Cargo.toml', toml.dump(cargo), err => console.log(err));
});
execSync(
'rustup target add wasm32-unknown-unknown --toolchain nightly',
{ stdio: 'inherit' }
);
},
};
@@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

/target
**/*.rs.bk
@@ -0,0 +1 @@
nightly
@@ -1,15 +1,24 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { loadWasm } from "./wasmLoader";

class App extends Component {
constructor() {
super();
loadWasm(result => {
const calculateFactorial = result.instance.exports['fact'];
const x = 5;
alert(`the factorial of ${ x } is ${ calculateFactorial(x) }`);
});
}
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
Edit <code>src/App.js</code> or <code>src/App.rs</code> and save to reload.
</p>
<a
className="App-link"
@@ -0,0 +1,9 @@
#[no_mangle]
pub extern "C" fn fact(mut n: u32) -> u32 {
let mut result = 1;
while n > 0 {
result = result * n;
n = n - 1;
}
result
}
@@ -0,0 +1,17 @@
import rustFile from './App.rs';

export function loadWasm(handleResultObjectPromise) {
switch (process.env.NODE_ENV) {
case 'production':
fetch('app.wasm')
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, {}))
.then(handleResultObjectPromise);
break;
case 'development':
rustFile().then(handleResultObjectPromise);
break;
default:
break;
}
}

No commit comments for this range