@crossworks/app-build 0.230.59 → 0.230.60
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/package.json +3 -3
- package/scripts/build-runtime.ts +38 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossworks/app-build",
|
|
3
|
-
"version": "0.230.
|
|
3
|
+
"version": "0.230.60",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lucide-react": "^1.25.0",
|
|
15
15
|
"react": "^19.2.7",
|
|
16
16
|
"react-dom": "^19.2.7",
|
|
17
|
-
"@mantle/share-ui": "npm:@crossworks/share-ui@0.230.
|
|
17
|
+
"@mantle/share-ui": "npm:@crossworks/share-ui@0.230.60"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^22.20.1",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"typecheck": "tsc --noEmit",
|
|
32
|
-
"build:runtime": "node scripts/build-runtime.ts"
|
|
32
|
+
"build:runtime": "node scripts/build-runtime.ts ../../server/web"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/scripts/build-runtime.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Emits the shared mini-app runtime into
|
|
3
|
-
* Run with: `node packages/app-build/scripts/build-runtime.ts`
|
|
4
|
-
* TS types).
|
|
5
|
-
*
|
|
2
|
+
* Emits the shared mini-app runtime into an app's `public/app-runtime/`.
|
|
3
|
+
* Run with: `node packages/app-build/scripts/build-runtime.ts` from the app
|
|
4
|
+
* directory (Node strips the TS types). Invoked from `predev`/`prebuild` in
|
|
5
|
+
* server/web and in jackdaw's client/web, so the runtime always exists before
|
|
6
|
+
* apps render.
|
|
6
7
|
*/
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
7
9
|
import * as path from 'node:path';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
10
|
import { buildRuntime } from '../src/build-runtime.ts';
|
|
10
11
|
|
|
11
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const repoRoot = path.resolve(here, '../../..');
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* Where to write. Each Next app serves its own copy — the ACAO:* runtime has
|
|
14
|
+
* to exist on every origin that renders sandboxes.
|
|
15
|
+
*
|
|
16
|
+
* Paths resolve from the CALLER'S CWD, never from this script's own location.
|
|
17
|
+
* They used to resolve against `../../..` from here, which is the repo root
|
|
18
|
+
* only while this package sits in the repo being built. Published to npm and
|
|
19
|
+
* installed by the jackdaw repo, that same expression pointed at the
|
|
20
|
+
* consumer's `node_modules/`, so `build-runtime.ts client/web` wrote the
|
|
21
|
+
* runtime to `node_modules/client/web/public/app-runtime` — a real directory
|
|
22
|
+
* nothing serves. The owner UI shipped with NO `/app-runtime/*` at all (its
|
|
23
|
+
* Docker build runs the same prebuild), and nothing failed: the build printed
|
|
24
|
+
* a success line naming the wrong path, and only a sandboxed mini-app trying
|
|
25
|
+
* to boot would notice.
|
|
18
26
|
*
|
|
19
27
|
* An ARGUMENT rather than an environment variable, deliberately. The callers
|
|
20
28
|
* used to set `APP_RUNTIME_OUT="$PWD/…"` inline, which is POSIX shell syntax;
|
|
@@ -24,15 +32,27 @@ const repoRoot = path.resolve(here, '../../..');
|
|
|
24
32
|
* `'APP_RUNTIME_OUT' is not recognized`. An argv entry has no shell semantics
|
|
25
33
|
* to get wrong.
|
|
26
34
|
*
|
|
27
|
-
* `APP_RUNTIME_OUT` still works for a direct absolute-path invocation
|
|
28
|
-
* default remains the server app.
|
|
35
|
+
* `APP_RUNTIME_OUT` still works for a direct absolute-path invocation.
|
|
29
36
|
*/
|
|
30
37
|
const appArg = process.argv[2]?.trim();
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
const appDir = path.resolve(process.cwd(), appArg ?? '.');
|
|
39
|
+
const outDir = process.env.APP_RUNTIME_OUT
|
|
40
|
+
? path.resolve(process.env.APP_RUNTIME_OUT)
|
|
41
|
+
: path.join(appDir, 'public/app-runtime');
|
|
42
|
+
|
|
43
|
+
// Tripwire for the failure above: a Next app always has a `public/`, so its
|
|
44
|
+
// absence means the resolved app directory is not an app and the runtime is
|
|
45
|
+
// about to be written somewhere nothing serves. Fail loudly here rather than
|
|
46
|
+
// print a cheerful success line pointing into node_modules. Skipped when
|
|
47
|
+
// APP_RUNTIME_OUT names the destination outright.
|
|
48
|
+
if (!process.env.APP_RUNTIME_OUT && !existsSync(path.join(appDir, 'public'))) {
|
|
49
|
+
console.error(
|
|
50
|
+
`app-runtime: ${appDir} has no public/ directory, so it is not an app.\n` +
|
|
51
|
+
`Run this from the app directory (paths resolve from the cwd), or pass an ` +
|
|
52
|
+
`absolute destination as APP_RUNTIME_OUT.`,
|
|
53
|
+
);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
36
56
|
|
|
37
57
|
const manifest = await buildRuntime(outDir);
|
|
38
58
|
const n = Object.keys(manifest.imports).length;
|