Skip to content

Commit

Permalink
Fix: minor monorepo improvements (#111)
Browse files Browse the repository at this point in the history
* Moved boilerplate, removed unused line in biome

* Add SSR cmd to boilerplate readme

* Added bin script

* Cleanup biome config

* update lockfile

* Revert "update lockfile"

This reverts commit a875ce7.

* add CLI build script for renderer entrypoint

* Add note about bin script issue resolution

---------

Co-authored-by: Julie Muzina <[email protected]>
  • Loading branch information
advl and jmuzina authored Jan 16, 2025
1 parent 11146c0 commit 7607ee8
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 24 deletions.
8 changes: 0 additions & 8 deletions apps/boilerplate-react-vite/README.md

This file was deleted.

File renamed without changes.
35 changes: 35 additions & 0 deletions apps/react/boilerplate-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## React Vite Boilerplate

This project provides a template that can be used to quickly create a React Vite
application using the standard set of shared Canonical packages.

#### Running the boilerplate

Run `bun run dev` to run a live development server with HMR.

Run `bun run serve` to run a server-side rendered version of the app using the [React SSR](../../../packages/react/ssr) package.

##### Build/Serve commands

Two mechanisms for building/serving the application are supported:
- CLI-based: Invoke `@canonical/react-ssr`'s `serve-express` bin script to create an express server.
- Middleware-based: Call `@canonical/react-ssr`'s `serveStream()` function to create a middleware that can be used with an existing express server.

In both cases, the client is built the same way (`bun run build:client`).
The server is built differently depending on the approach:
- CLI-based: The server's SSR renderercd module is the entry point. Built with `bun run build:server:cli`, served with `bun run serve:cli`.
- Middleware-based: The server's server script is the entry point. Built with `bun run build:server:middleware`, served with `bun run serve:middleware`.

The current default behavior is to use the middleware-based approach.
So, `bun run build:server` and `bun run serve` will use the middleware scripts.

In the future, it is intended that the CLI-based approach will be the default,
and the existing `server.ts` file will be moved to the SSR package as an example.

##### Bin script issues

You may run into an issue where `serve-express` is not linked in `node_modules/.bin` after running `bun i`.
This will result in an error when running `bun run serve:cli`.

To fix this, run `bun i` again.
For more information, see [this documentation](https://github.com/jmuzina/bun-repro/tree/7c9f6eefae2843bc904eabc10db973b56f5e017f/repro/bin-scripts).
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@canonical/boilerplate-react-vite",
"name": "@canonical/react-boilerplate-vite",
"private": true,
"version": "0.7.0-experimental.0",
"type": "module",
Expand All @@ -8,8 +8,12 @@
"dev": "vite",
"build": "bun run build:client && bun run build:server",
"build:client": "vite build --ssrManifest --outDir dist/client",
"build:server": "vite build --ssr src/ssr/server.ts --outDir dist/server",
"serve": "bun run build && node dist/server/server.js",
"build:server": "bun run build:server:middleware",
"build:server:middleware": "vite build --ssr src/ssr/server.ts --outDir dist/server",
"build:server:cli": "vite build --ssr src/ssr/renderer.tsx --outDir dist/server",
"serve": "bun run serve:middleware",
"serve:middleware": "bun run build:client && bun run build:server:middleware && node dist/server/server.js",
"serve:cli": "bun run build:client && bun run build:server:cli && bun run serve-express dist/server/renderer.js",
"check": "bun run check:biome && bun run check:ts",
"check:fix": "bun run check:biome:fix && bun run check:ts",
"check:biome": "biome check src *.json",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified bun.lockb
Binary file not shown.
5 changes: 1 addition & 4 deletions packages/react/ds-app-launchpad/biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"],
"files": {
"ignore": ["src/styles/normalize.css"]
}
"extends": ["@canonical/biome-config"]
}
5 changes: 1 addition & 4 deletions packages/react/ds-core/biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"],
"files": {
"ignore": ["src/styles/normalize.css"]
}
"extends": ["@canonical/biome-config"]
}
2 changes: 1 addition & 1 deletion packages/react/ssr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ The example below uses Vite.
### Server Request Handling

Once your app is built, you can set up an Express server to handle SSR requests.
See [this file](../../../apps/boilerplate-react-vite/src/ssr/server.ts) as an example.
See [this file](../../../apps/react/boilerplate-vite/src/ssr/server.ts) as an example.

### Injecting the Client Application

Expand Down
3 changes: 3 additions & 0 deletions packages/react/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"email": "[email protected]",
"name": "Canonical Webteam"
},
"bin": {
"serve-express": "./dist/esm/server/serve-express.js"
},
"repository": {
"type": "git",
"url": "https://github.com/canonical/ds25"
Expand Down
5 changes: 1 addition & 4 deletions packages/typography/biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"],
"files": {
"ignore": ["src/styles/normalize.css"]
}
"extends": ["@canonical/biome-config"]
}

0 comments on commit 7607ee8

Please sign in to comment.