@cedarjs/cli 5.0.0-canary.13889 → 5.0.0-canary.13892
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/dist/commands/build/buildHandler.js +37 -16
- package/dist/lib/exec.js +34 -42
- package/package.json +13 -13
|
@@ -20,6 +20,7 @@ import { loadAndValidateSdls } from "@cedarjs/internal/dist/validateSchema";
|
|
|
20
20
|
import { detectPrerenderRoutes } from "@cedarjs/prerender/detection";
|
|
21
21
|
import {} from "@cedarjs/project-config";
|
|
22
22
|
import { timedTelemetry } from "@cedarjs/telemetry";
|
|
23
|
+
import { buildCedarApp } from "@cedarjs/vite/build";
|
|
23
24
|
import { buildUDApiServer } from "@cedarjs/vite/buildUDApiServer";
|
|
24
25
|
import { generatePrismaCommand } from "../../lib/generatePrismaClient.js";
|
|
25
26
|
import { getPaths, getConfig } from "../../lib/index.js";
|
|
@@ -163,25 +164,23 @@ Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspac
|
|
|
163
164
|
title: "Verifying graphql schema...",
|
|
164
165
|
task: loadAndValidateSdls
|
|
165
166
|
},
|
|
166
|
-
// The API build has two sequential steps:
|
|
167
|
-
// 1. esbuild compiles api/src/** → api/dist/ (functions, services, etc.)
|
|
168
|
-
// 2. Vite wraps api/dist/functions/ into a self-contained UD Node server
|
|
169
|
-
// entry at api/dist/ud/index.js for `cedar serve api`
|
|
170
|
-
// Step 2 depends on step 1 having completed.
|
|
171
|
-
workspace.includes("api") && {
|
|
172
|
-
title: "Building API...",
|
|
173
|
-
task: async () => {
|
|
174
|
-
await cleanApiBuild();
|
|
175
|
-
await buildApiWithVite();
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
167
|
ud && workspace.includes("api") && {
|
|
179
168
|
title: "Bundling API server entry (Universal Deploy)...",
|
|
180
169
|
task: async () => {
|
|
181
170
|
await buildUDApiServer({ verbose });
|
|
182
171
|
}
|
|
183
172
|
},
|
|
184
|
-
|
|
173
|
+
// When streaming SSR is enabled, fall back to the legacy separate build
|
|
174
|
+
// paths because streaming SSR has its own complex build orchestration.
|
|
175
|
+
// Phase 7 (SSR/RSC rebuild) will address unifying this path.
|
|
176
|
+
workspace.includes("api") && getConfig().experimental?.streamingSsr?.enabled && {
|
|
177
|
+
title: "Building API...",
|
|
178
|
+
task: async () => {
|
|
179
|
+
await cleanApiBuild();
|
|
180
|
+
await buildApiWithVite();
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
workspace.includes("web") && getConfig().experimental?.streamingSsr?.enabled && {
|
|
185
184
|
title: "Building Web...",
|
|
186
185
|
task: async () => {
|
|
187
186
|
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
@@ -194,9 +193,6 @@ Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspac
|
|
|
194
193
|
{
|
|
195
194
|
stdio: verbose ? "inherit" : "pipe",
|
|
196
195
|
shell: true,
|
|
197
|
-
// `cwd` is needed for yarn to find the cedar-vite-build binary
|
|
198
|
-
// It won't change process.cwd for anything else here, in this
|
|
199
|
-
// process
|
|
200
196
|
cwd: cedarPaths.web.base
|
|
201
197
|
}
|
|
202
198
|
);
|
|
@@ -209,6 +205,31 @@ Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspac
|
|
|
209
205
|
);
|
|
210
206
|
}
|
|
211
207
|
}
|
|
208
|
+
},
|
|
209
|
+
// Unified build path (default, non-streaming-SSR)
|
|
210
|
+
(workspace.includes("api") || workspace.includes("web")) && !getConfig().experimental?.streamingSsr?.enabled && {
|
|
211
|
+
title: workspace.includes("api") && workspace.includes("web") ? "Building App..." : workspace.includes("api") ? "Building API..." : "Building Web...",
|
|
212
|
+
task: async () => {
|
|
213
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
214
|
+
if (workspace.includes("api")) {
|
|
215
|
+
await cleanApiBuild();
|
|
216
|
+
}
|
|
217
|
+
const originalCwd = process.cwd();
|
|
218
|
+
process.chdir(cedarPaths.web.base);
|
|
219
|
+
try {
|
|
220
|
+
await buildCedarApp({ verbose, workspace });
|
|
221
|
+
} finally {
|
|
222
|
+
process.chdir(originalCwd);
|
|
223
|
+
}
|
|
224
|
+
if (workspace.includes("web")) {
|
|
225
|
+
console.log("Creating 200.html...");
|
|
226
|
+
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
227
|
+
fs.copyFileSync(
|
|
228
|
+
indexHtmlPath,
|
|
229
|
+
path.join(getPaths().web.dist, "200.html")
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
212
233
|
}
|
|
213
234
|
].filter((t) => Boolean(t));
|
|
214
235
|
const triggerPrerender = async () => {
|
package/dist/lib/exec.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import { createServer,
|
|
3
|
-
import { ViteNodeRunner } from "vite-node/client";
|
|
4
|
-
import { ViteNodeServer } from "vite-node/server";
|
|
5
|
-
import { installSourcemapsSupport } from "vite-node/source-map";
|
|
3
|
+
import { createServer, isRunnableDevEnvironment } from "vite";
|
|
6
4
|
import { getPaths, importStatementPath } from "@cedarjs/project-config";
|
|
7
5
|
import {
|
|
8
6
|
cedarCellTransform,
|
|
@@ -10,8 +8,21 @@ import {
|
|
|
10
8
|
cedarjsJobPathInjectorPlugin,
|
|
11
9
|
cedarSwapApolloProvider,
|
|
12
10
|
cedarImportDirPlugin,
|
|
13
|
-
cedarAutoImportsPlugin
|
|
11
|
+
cedarAutoImportsPlugin,
|
|
12
|
+
cedarCjsCompatPlugin
|
|
14
13
|
} from "@cedarjs/vite";
|
|
14
|
+
function resolveExtension(id) {
|
|
15
|
+
if (existsSync(id)) {
|
|
16
|
+
return id;
|
|
17
|
+
}
|
|
18
|
+
const withoutExt = /\.jsx?$/.test(id) ? id.replace(/\.jsx?$/, "") : id;
|
|
19
|
+
for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
|
|
20
|
+
if (existsSync(withoutExt + ext)) {
|
|
21
|
+
return withoutExt + ext;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
15
26
|
async function runScriptFunction({
|
|
16
27
|
path: scriptPath,
|
|
17
28
|
functionName,
|
|
@@ -22,10 +33,16 @@ async function runScriptFunction({
|
|
|
22
33
|
const server = await createServer({
|
|
23
34
|
mode: "production",
|
|
24
35
|
optimizeDeps: {
|
|
25
|
-
// This is recommended in the vite-node readme
|
|
26
36
|
noDiscovery: true,
|
|
27
37
|
include: void 0
|
|
28
38
|
},
|
|
39
|
+
server: {
|
|
40
|
+
hmr: false,
|
|
41
|
+
watch: null
|
|
42
|
+
},
|
|
43
|
+
environments: {
|
|
44
|
+
nodeRunnerEnv: {}
|
|
45
|
+
},
|
|
29
46
|
resolve: {
|
|
30
47
|
alias: [
|
|
31
48
|
{
|
|
@@ -52,18 +69,12 @@ async function runScriptFunction({
|
|
|
52
69
|
const webImportBase = importStatementPath(getPaths().web.base);
|
|
53
70
|
if (importer.startsWith(apiImportBase)) {
|
|
54
71
|
const apiImportSrc = importStatementPath(getPaths().api.src);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
resolvedId = resolvedId.replace(/\.jsx?$/, "");
|
|
58
|
-
}
|
|
59
|
-
return { id: resolvedId };
|
|
72
|
+
const resolvedId = id.replace("src", apiImportSrc);
|
|
73
|
+
return { id: resolveExtension(resolvedId) };
|
|
60
74
|
} else if (importer.startsWith(webImportBase)) {
|
|
61
75
|
const webImportSrc = importStatementPath(getPaths().web.src);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
resolvedId = resolvedId.replace(/\.jsx?$/, "");
|
|
65
|
-
}
|
|
66
|
-
return { id: resolvedId };
|
|
76
|
+
const resolvedId = id.replace("src", webImportSrc);
|
|
77
|
+
return { id: resolveExtension(resolvedId) };
|
|
67
78
|
}
|
|
68
79
|
return null;
|
|
69
80
|
}
|
|
@@ -71,6 +82,7 @@ async function runScriptFunction({
|
|
|
71
82
|
]
|
|
72
83
|
},
|
|
73
84
|
plugins: [
|
|
85
|
+
cedarCjsCompatPlugin(),
|
|
74
86
|
cedarjsResolveCedarStyleImportsPlugin(),
|
|
75
87
|
cedarCellTransform(),
|
|
76
88
|
cedarjsJobPathInjectorPlugin(),
|
|
@@ -79,41 +91,21 @@ async function runScriptFunction({
|
|
|
79
91
|
cedarAutoImportsPlugin()
|
|
80
92
|
]
|
|
81
93
|
});
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
const env = server.environments.nodeRunnerEnv;
|
|
95
|
+
if (!env || !isRunnableDevEnvironment(env)) {
|
|
96
|
+
await server.close();
|
|
97
|
+
throw new Error("Vite environment is not runnable.");
|
|
84
98
|
}
|
|
85
|
-
const node = new ViteNodeServer(server, {
|
|
86
|
-
transformMode: {
|
|
87
|
-
ssr: [/.*/],
|
|
88
|
-
web: [/\/web\//]
|
|
89
|
-
},
|
|
90
|
-
deps: {
|
|
91
|
-
fallbackCJS: true
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
installSourcemapsSupport({
|
|
95
|
-
getSourceMap: (source) => node.getSourceMap(source)
|
|
96
|
-
});
|
|
97
|
-
const runner = new ViteNodeRunner({
|
|
98
|
-
root: server.config.root,
|
|
99
|
-
base: server.config.base,
|
|
100
|
-
fetchModule(id) {
|
|
101
|
-
return node.fetchModule(id);
|
|
102
|
-
},
|
|
103
|
-
resolveId(id, importer) {
|
|
104
|
-
return node.resolveId(id, importer);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
99
|
let returnValue;
|
|
108
100
|
let scriptError = null;
|
|
109
101
|
try {
|
|
110
|
-
const script = await runner.
|
|
102
|
+
const script = await env.runner.import(scriptPath);
|
|
111
103
|
returnValue = await script[functionName](args);
|
|
112
104
|
} catch (error) {
|
|
113
105
|
scriptError = error;
|
|
114
106
|
}
|
|
115
107
|
try {
|
|
116
|
-
const { db } = await runner.
|
|
108
|
+
const { db } = await env.runner.import(path.join(getPaths().api.lib, "db"));
|
|
117
109
|
db.$disconnect();
|
|
118
110
|
} catch (e) {
|
|
119
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.13892+1388c33071",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,16 +33,17 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.2",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
|
-
"@cedarjs/api-server": "5.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "5.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "5.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "5.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "5.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "5.0.0-canary.
|
|
45
|
-
"@cedarjs/
|
|
36
|
+
"@cedarjs/api-server": "5.0.0-canary.13892",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.13892",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.13892",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.13892",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.13892",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.13892",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.13892",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.13892",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.13892",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.13892",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.13892",
|
|
46
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
47
48
|
"@opentelemetry/api": "1.9.0",
|
|
48
49
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -88,7 +89,6 @@
|
|
|
88
89
|
"title-case": "3.0.3",
|
|
89
90
|
"unionfs": "4.6.0",
|
|
90
91
|
"uuid": "11.1.0",
|
|
91
|
-
"vite-node": "3.2.4",
|
|
92
92
|
"yargs": "17.7.2"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "1388c330712767faa318d1af805d49e5151470f5"
|
|
112
112
|
}
|