@rust-js/create 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -53,11 +53,6 @@ for (const field of ["dependencies", "devDependencies"]) {
53
53
  if (spec.startsWith("workspace:")) manifest[field][name] = dist ? archive(name) : self.version;
54
54
  }
55
55
  }
56
- // The app's own, so every package manager has it at node_modules/@rust-js/resources,
57
- // where its Cargo.toml has the crates the app uses.
58
- manifest.devDependencies["@rust-js/resources"] = dist ? archive("@rust-js/resources") : self.version;
59
- const cargo = join(app, "Cargo.toml");
60
- writeFileSync(cargo, readFileSync(cargo, "utf8").replaceAll('path = "../../', 'path = "node_modules/@rust-js/resources/'));
61
56
  // The compiler is the app's own, as the plugin finds it, from the app: a
62
57
  // release's or a distribution's. A distribution's `@rust-js/build` is the
63
58
  // app's too, and the plugin's, where a release's is the registry's.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rust-js/create",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "description": "`bun create @rust-js my-app`: a Vite and React app written in Rust. See docs/decisions/0105-create.md.",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
- # src/App.rs as a crate, for an editor's rust-analyzer and a `cargo check`,
2
- # which check it with a plain rustc (ADR 0114). rust-js's build of it is the
3
- # Vite plugin's. `bun create @rust-js` has the crates where the app installs
4
- # them, in @rust-js/resources.
1
+ # The app's crate, src/App.rs, which the Vite plugin builds with Cargo, and
2
+ # an editor's rust-analyzer checks (ADR 0114). Its crates are npm packages,
3
+ # named by version, which rust-js-patch, the app's `postinstall`, tells
4
+ # Cargo are in node_modules; rust-js's own example has them by path.
5
5
  [package]
6
6
  name = "app"
7
7
  version = "0.0.0"
@@ -12,9 +12,9 @@ publish = false
12
12
  path = "src/App.rs"
13
13
 
14
14
  [dependencies]
15
- js = { package = "rust-js-builtins", path = "../../builtins" }
16
- react = { package = "rust-js-react", path = "../../react" }
17
- webapi = { package = "rust-js-webapi", path = "../../webapi" }
15
+ js = { package = "rust-js-builtins", version = "~0.0.1" }
16
+ react = { package = "rust-js-react", version = "~0.0.2" }
17
+ webapi = { package = "rust-js-webapi", version = "~0.0.2" }
18
18
 
19
19
  # rust-js compiles with `--cfg=rust_js` (ADR 0113): a `cfg` Cargo checks for,
20
20
  # here too, in what `js::import!` expands to.
@@ -38,10 +38,14 @@ version that compiled. The browser's source map points at `App.rs`.
38
38
  else { "text-sky-500" }`, not a string built from pieces.
39
39
  - `rustJs()` comes first in `vite.config.js`, before `tailwindcss()`, so that
40
40
  a save refreshes the page instead of reloading it.
41
- - **`Cargo.toml` is for your editor** and `cargo check`: rust-analyzer finds
42
- `react`, `webapi` and `js` in `node_modules/@rust-js/resources`, once the
43
- app is installed. It doesn't look inside `jsx!`, so a variable used only in
44
- JSX shows as unused there.
41
+ - **The app is a Cargo package**, `Cargo.toml`, which the Vite plugin builds
42
+ with Cargo, and your editor's rust-analyzer checks. Its crates, `react`,
43
+ `webapi` and `js`, are npm packages, `@rust-js/react` and the others, named
44
+ in `Cargo.toml` by version: `rust-js-patch`, the app's `postinstall`, tells
45
+ Cargo they're in `node_modules`, in `.cargo/config.toml`. A binding of another
46
+ library, `@rust-js-bindings/canvas-confetti`, is added the same way: its npm
47
+ package, and a line in `Cargo.toml`. rust-analyzer doesn't look inside
48
+ `jsx!`, so a variable used only in JSX shows as unused there.
45
49
  - **`Cargo.toml` also sets how the JS is laid out**, by oxfmt's options,
46
50
  `[package.metadata.rust-js.format]` with `printWidth = 120`, say, and can run
47
51
  your own tools on it, a formatter or a linter, in
@@ -27,7 +27,9 @@ dist-ssr
27
27
  # ReScript recommends for its JS. Its source map isn't.
28
28
  /src/App.jsx.map
29
29
 
30
- # What an editor's `cargo check` of Cargo.toml writes. Its crates are paths,
31
- # which a lockfile pins nothing of.
30
+ # What Cargo writes, and the patch rust-js-patch writes, of what's
31
+ # installed: its crates are npm packages, which the lockfile of the app's
32
+ # package manager pins.
32
33
  /target
33
34
  /Cargo.lock
35
+ /.cargo
@@ -7,14 +7,18 @@
7
7
  "dev": "vite",
8
8
  "build": "vite build",
9
9
  "lint": "oxlint",
10
- "preview": "vite preview"
10
+ "preview": "vite preview",
11
+ "postinstall": "rust-js-patch"
11
12
  },
12
13
  "dependencies": {
13
14
  "@rust-js/runtime": "workspace:*",
14
15
  "@tailwindcss/vite": "^4.3.3",
15
16
  "react": "^19.2.8",
16
17
  "react-dom": "^19.2.8",
17
- "tailwindcss": "^4.3.3"
18
+ "tailwindcss": "^4.3.3",
19
+ "@rust-js/builtins": "0.0.1",
20
+ "@rust-js/webapi": "0.0.2",
21
+ "@rust-js/react": "0.0.2"
18
22
  },
19
23
  "devDependencies": {
20
24
  "@babel/core": "^7.29.7",
@@ -25,6 +29,7 @@
25
29
  "babel-plugin-react-compiler": "^1.0.0",
26
30
  "oxlint": "^1.81.0",
27
31
  "vite": "^8.3.0",
28
- "@rust-js/vite-plugin": "workspace:*"
32
+ "@rust-js/vite-plugin": "workspace:*",
33
+ "@rust-js/build": "workspace:*"
29
34
  }
30
35
  }
@@ -7,9 +7,10 @@ import rustJs from '@rust-js/vite-plugin'
7
7
  // https://vite.dev/config/
8
8
  export default defineConfig({
9
9
  plugins: [
10
- // rust-js compiles src/App.rs to src/App.jsx, which plugin-react serves
11
- // with Fast Refresh, and React Compiler memoizes.
12
- rustJs(),
10
+ // rust-js compiles the app's crate, src/App.rs, with Cargo (ADR 0101),
11
+ // to src/App.jsx, which plugin-react serves with Fast Refresh, and React
12
+ // Compiler memoizes.
13
+ rustJs({ cargo: { package: 'app' } }),
13
14
  react(),
14
15
  babel({ presets: [reactCompilerPreset()] }),
15
16
  tailwindcss(),