create-backtick-app 0.2.1 → 0.2.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/README.md +2 -2
- package/dist/index.js +0 -4
- package/package.json +1 -1
- package/templates/react/package.json +6 -6
- package/templates/react-native/app.json +2 -1
- package/templates/react-native/client/App.tsx +4 -5
- package/templates/react-native/package.json +8 -10
- package/templates/react-native/server/index.tsx +3 -0
- package/templates/react-native/tsconfig.json +2 -2
- package/templates/solid-js/package.json +6 -6
- package/templates/react-native/app.config.ts +0 -12
- package/templates/react-native/scripts/reload-expo.mjs +0 -37
package/README.md
CHANGED
|
@@ -52,14 +52,14 @@ Every template has:
|
|
|
52
52
|
|
|
53
53
|
An Expo app (SDK 57) with the Backtick server beside it in `server/`. `client/App.tsx` fetches the screen at `/` and runs it with `execRoot` from [`@backtickjs/core/cjs`](https://github.com/backtickjs/backtick/tree/main/packages/core), offering screens what `client/moduleMap.ts` lists.
|
|
54
54
|
|
|
55
|
-
Each build of the app sends the modules it carries: those `client/moduleMap.ts` offers, at the versions `app.
|
|
55
|
+
Each build of the app sends the modules it carries: those `client/moduleMap.ts` offers, at the versions the `@backtickjs/expo` plugin in `app.json` records. The server bundles each screen for those modules ([more](https://github.com/backtickjs/backtick/tree/main/packages/core#every-build-in-users-hands)), so a build in users' hands keeps working as the app moves on, with nothing to record before it ships.
|
|
56
56
|
|
|
57
57
|
```sh
|
|
58
58
|
npm start # then scan the QR code with your phone, in Expo Go
|
|
59
59
|
npm run ios # or android, or web: a simulator, an emulator or a browser
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Each starts your Backtick server alongside Expo, in one terminal. Edit `server/Home.tsx` and save: the server restarts, and
|
|
62
|
+
Each starts your Backtick server alongside Expo, in one terminal. Edit `server/Home.tsx` and save: the server restarts, and once it listens, `reloadExpo()` in `server/index.tsx` reloads the app. The app fetches the new screen without rebuilding.
|
|
63
63
|
|
|
64
64
|
`npm test` draws `server/Home.tsx` as the app would, in `server/Home.test.tsx`; [Testing screens](https://backtickjs.com/docs/testing/) explains the test.
|
|
65
65
|
|
package/dist/index.js
CHANGED
|
@@ -155,10 +155,6 @@ rewriteJson(path.join(target, "package.json"), (json) => {
|
|
|
155
155
|
for (const [name, command] of Object.entries(json.scripts)) {
|
|
156
156
|
json.scripts[name] = bun(command);
|
|
157
157
|
}
|
|
158
|
-
const events = json.nodemonConfig.events ?? {};
|
|
159
|
-
for (const [name, command] of Object.entries(events)) {
|
|
160
|
-
events[name] = bun(command);
|
|
161
|
-
}
|
|
162
158
|
// What still runs on Node, as the tests do, keeps Node's loader.
|
|
163
159
|
if (Object.values(json.scripts).some((command) => command.includes("@backtickjs/node-plugin"))) {
|
|
164
160
|
json.devDependencies = Object.fromEntries(Object.entries({
|
package/package.json
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"format:check": "prettier --check --ignore-unknown ."
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@backtickjs/bundler": "^0.2.
|
|
15
|
-
"@backtickjs/core": "^0.2.
|
|
16
|
-
"@backtickjs/node-plugin": "^0.2.
|
|
17
|
-
"@backtickjs/jsx-react": "^0.2.
|
|
14
|
+
"@backtickjs/bundler": "^0.2.2",
|
|
15
|
+
"@backtickjs/core": "^0.2.2",
|
|
16
|
+
"@backtickjs/node-plugin": "^0.2.2",
|
|
17
|
+
"@backtickjs/jsx-react": "^0.2.2",
|
|
18
18
|
"@hono/node-server": "^2.1.4",
|
|
19
19
|
"hono": "^4.13.13",
|
|
20
20
|
"react": "19.2.3",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"typescript": "^6.0.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@backtickjs/prettier-plugin": "^0.2.
|
|
26
|
-
"@backtickjs/tsc": "^0.2.
|
|
25
|
+
"@backtickjs/prettier-plugin": "^0.2.2",
|
|
26
|
+
"@backtickjs/tsc": "^0.2.2",
|
|
27
27
|
"@types/node": "^25.9.1",
|
|
28
28
|
"@types/react": "19.2.18",
|
|
29
29
|
"@types/react-dom": "19.2.7",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Bundle, modulesOf } from "@backtickjs/core";
|
|
2
2
|
import { execRoot } from "@backtickjs/core/cjs";
|
|
3
|
+
import { getBacktickExtra } from "@backtickjs/expo";
|
|
3
4
|
import Constants from "expo-constants";
|
|
4
5
|
import { StatusBar } from "expo-status-bar";
|
|
5
6
|
import { type ReactNode, Suspense, use, useState } from "react";
|
|
@@ -15,11 +16,9 @@ import { moduleMap } from "./moduleMap";
|
|
|
15
16
|
const host = Constants.expoConfig?.hostUri?.split(":")[0] ?? "localhost";
|
|
16
17
|
const server = `http://${host}:3000`;
|
|
17
18
|
|
|
18
|
-
// The modules this build carries,
|
|
19
|
-
|
|
20
|
-
const modules = JSON.stringify(
|
|
21
|
-
modulesOf(moduleMap, Constants.expoConfig?.extra?.backtick?.packages),
|
|
22
|
-
);
|
|
19
|
+
// The modules this build carries, at the versions app.json's plugin records.
|
|
20
|
+
const { installedPackages } = getBacktickExtra(Constants.expoConfig);
|
|
21
|
+
const modules = JSON.stringify(modulesOf(moduleMap, installedPackages));
|
|
23
22
|
|
|
24
23
|
// The screen at `path` on your server: its bundle, fetched and run with the
|
|
25
24
|
// app's modules. Your fetch to shape: headers, auth, caching.
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
"format:check": "prettier --check --ignore-unknown ."
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@backtickjs/bundler": "^0.2.
|
|
20
|
-
"@backtickjs/core": "^0.2.
|
|
21
|
-
"@backtickjs/
|
|
22
|
-
"@backtickjs/
|
|
19
|
+
"@backtickjs/bundler": "^0.2.2",
|
|
20
|
+
"@backtickjs/core": "^0.2.2",
|
|
21
|
+
"@backtickjs/expo": "^0.2.2",
|
|
22
|
+
"@backtickjs/node-plugin": "^0.2.2",
|
|
23
|
+
"@backtickjs/jsx-react": "^0.2.2",
|
|
23
24
|
"@hono/node-server": "^2.1.4",
|
|
24
25
|
"expo": "~57.0.26",
|
|
25
26
|
"expo-constants": "~57.0.20",
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
"typescript": "^6.0.3"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@backtickjs/prettier-plugin": "^0.2.
|
|
37
|
-
"@backtickjs/tsc": "^0.2.
|
|
37
|
+
"@backtickjs/prettier-plugin": "^0.2.2",
|
|
38
|
+
"@backtickjs/tsc": "^0.2.2",
|
|
38
39
|
"@testing-library/react": "^16.3.3",
|
|
39
40
|
"@testing-library/user-event": "^14.6.7",
|
|
40
41
|
"@types/node": "^25.9.1",
|
|
@@ -50,10 +51,7 @@
|
|
|
50
51
|
"watch": [
|
|
51
52
|
"server"
|
|
52
53
|
],
|
|
53
|
-
"ext": "ts,tsx"
|
|
54
|
-
"events": {
|
|
55
|
-
"start": "node scripts/reload-expo.mjs"
|
|
56
|
-
}
|
|
54
|
+
"ext": "ts,tsx"
|
|
57
55
|
},
|
|
58
56
|
"backtick": {
|
|
59
57
|
"plugins": [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reloadExpo } from "@backtickjs/expo/server";
|
|
1
2
|
import { serve } from "@hono/node-server";
|
|
2
3
|
import { Hono } from "hono";
|
|
3
4
|
import { cors } from "hono/cors";
|
|
@@ -19,6 +20,8 @@ app.onError((error, context) => {
|
|
|
19
20
|
return context.text(String(error), 500);
|
|
20
21
|
});
|
|
21
22
|
|
|
23
|
+
// Once it listens, the app Expo serves reloads to show this server's screens.
|
|
22
24
|
serve({ fetch: app.fetch, port: 3000 }, () => {
|
|
23
25
|
console.log("Backtick server on http://localhost:3000");
|
|
26
|
+
reloadExpo();
|
|
24
27
|
});
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
"format:check": "prettier --check --ignore-unknown ."
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@backtickjs/bundler": "^0.2.
|
|
15
|
-
"@backtickjs/core": "^0.2.
|
|
16
|
-
"@backtickjs/node-plugin": "^0.2.
|
|
17
|
-
"@backtickjs/jsx-solid": "^0.2.
|
|
14
|
+
"@backtickjs/bundler": "^0.2.2",
|
|
15
|
+
"@backtickjs/core": "^0.2.2",
|
|
16
|
+
"@backtickjs/node-plugin": "^0.2.2",
|
|
17
|
+
"@backtickjs/jsx-solid": "^0.2.2",
|
|
18
18
|
"@hono/node-server": "^2.1.4",
|
|
19
19
|
"hono": "^4.13.13",
|
|
20
20
|
"solid-js": "1.9.17",
|
|
21
21
|
"typescript": "^6.0.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@backtickjs/prettier-plugin": "^0.2.
|
|
25
|
-
"@backtickjs/tsc": "^0.2.
|
|
24
|
+
"@backtickjs/prettier-plugin": "^0.2.2",
|
|
25
|
+
"@backtickjs/tsc": "^0.2.2",
|
|
26
26
|
"@types/node": "^25.9.1",
|
|
27
27
|
"agent-device": "^0.21.27",
|
|
28
28
|
"nodemon": "^3.1.14",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { installedPackages } from "@backtickjs/core/node";
|
|
2
|
-
import type { ConfigContext, ExpoConfig } from "expo/config";
|
|
3
|
-
|
|
4
|
-
// app.json, with the installed version of each of the app's dependencies,
|
|
5
|
-
// which the app reads to tell its server the modules it carries.
|
|
6
|
-
export default ({ config, projectRoot }: ConfigContext): ExpoConfig => ({
|
|
7
|
-
...(config as ExpoConfig),
|
|
8
|
-
extra: {
|
|
9
|
-
...config.extra,
|
|
10
|
-
backtick: { packages: installedPackages(projectRoot) },
|
|
11
|
-
},
|
|
12
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Run by nodemon each time it starts your server: once the server listens,
|
|
2
|
-
// the apps Expo serves reload, as pressing `r` in Expo's terminal does: a
|
|
3
|
-
// `reload` on its message socket, which it accepts from this computer.
|
|
4
|
-
// Nothing happens without Expo running.
|
|
5
|
-
import { connect } from "node:net";
|
|
6
|
-
import { setTimeout as sleep } from "node:timers/promises";
|
|
7
|
-
|
|
8
|
-
// Your server's port, and Expo's: React Native's variable for it.
|
|
9
|
-
const port = 3000;
|
|
10
|
-
const metro = `ws://127.0.0.1:${process.env.RCT_METRO_PORT ?? 8081}/message`;
|
|
11
|
-
|
|
12
|
-
// A connection, not a request, so the server has nothing to answer or log.
|
|
13
|
-
const listening = () =>
|
|
14
|
-
new Promise((resolve) => {
|
|
15
|
-
const socket = connect(port, "localhost");
|
|
16
|
-
socket.on("connect", () => {
|
|
17
|
-
socket.end();
|
|
18
|
-
resolve(true);
|
|
19
|
-
});
|
|
20
|
-
socket.on("error", () => resolve(false));
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Waited for, so the app doesn't fetch from a server still starting; given up
|
|
24
|
-
// on when it crashed instead.
|
|
25
|
-
for (let tries = 0; tries < 120; tries++) {
|
|
26
|
-
if (await listening()) {
|
|
27
|
-
const socket = new WebSocket(metro);
|
|
28
|
-
socket.onopen = () => {
|
|
29
|
-
socket.send(JSON.stringify({ version: 2, method: "reload" }));
|
|
30
|
-
socket.close();
|
|
31
|
-
};
|
|
32
|
-
// Expo isn't running: there's no app to reload.
|
|
33
|
-
socket.onerror = () => {};
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
await sleep(250);
|
|
37
|
-
}
|