Skip to content

Commit 82f6ac2

Browse files
moved to using cargo init instead of copying Cargo.toml
1 parent aded15e commit 82f6ac2

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

packages/react-scripts/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scripts-rust",
3-
"version": "2.0.16",
3+
"version": "2.0.17",
44
"description": "Configuration and scripts for using Rust with Create React App",
55
"repository": "thomashorrobin/create-react-app-rust",
66
"license": "MIT",
@@ -65,6 +65,7 @@
6565
"sass-loader": "7.1.0",
6666
"style-loader": "0.23.0",
6767
"terser-webpack-plugin": "1.1.0",
68+
"toml-js": "0.0.8",
6869
"url-loader": "1.1.1",
6970
"wasm-loader": "^1.3.0",
7071
"webpack": "4.19.1",

packages/react-scripts/scripts/utils/rustUtils.js

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const execSync = require('child_process').execSync;
22
const chalk = require('chalk');
33
const commandExistsSync = require('command-exists').sync;
4+
const fs = require('fs');
5+
const toml = require('toml-js');
46

57
module.exports = {
68
build: () => {
@@ -23,6 +25,17 @@ module.exports = {
2325
console.log(`${chalk.bold.red('error installing wasm-gc')} please install manually ${chalk.red('cargo install wasm-gc')}')`);
2426
}
2527
}
28+
execSync(
29+
'cargo init --lib',
30+
{ stdio: 'inherit' }
31+
);
32+
fs.readFile('Cargo.toml', function (err, data) {
33+
var cargo = toml.parse(data);
34+
cargo.lib = {};
35+
cargo.lib['crate-type'] = ['cdylib'];
36+
cargo.lib.path = 'src/App.rs';
37+
fs.writeFile('Cargo.toml', toml.dump(cargo), err => console.log(err));
38+
});
2639
execSync(
2740
'rustup target add wasm32-unknown-unknown --toolchain nightly',
2841
{ stdio: 'inherit' }

packages/react-scripts/template/Cargo.toml

-11
This file was deleted.

0 commit comments

Comments
 (0)