@cedarjs/vite 5.0.0-canary.2555 → 5.0.0-canary.2559
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/buildApp.d.ts +2 -1
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +65 -1
- package/dist/cjs/buildApp.js +69 -5
- package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +1 -17
- package/dist/plugins/vite-plugin-cedar-universal-deploy.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +1 -17
- package/package.json +12 -15
- package/dist/buildUDApiServer.d.ts +0 -29
- package/dist/buildUDApiServer.d.ts.map +0 -1
- package/dist/buildUDApiServer.js +0 -93
- package/dist/cjs/buildUDApiServer.js +0 -127
package/dist/buildApp.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface BuildCedarAppOptions {
|
|
2
2
|
verbose?: boolean;
|
|
3
3
|
workspace?: string[];
|
|
4
|
+
ud?: boolean;
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* Unified build for Cedar apps using Vite's builder API.
|
|
@@ -11,5 +12,5 @@ export interface BuildCedarAppOptions {
|
|
|
11
12
|
* `src/` import redirection so it resolves correctly even though the builder
|
|
12
13
|
* root is the web source directory.
|
|
13
14
|
*/
|
|
14
|
-
export declare function buildCedarApp({ verbose, workspace, }?: BuildCedarAppOptions): Promise<void>;
|
|
15
|
+
export declare function buildCedarApp({ verbose, workspace, ud, }?: BuildCedarAppOptions): Promise<void>;
|
|
15
16
|
//# sourceMappingURL=buildApp.d.ts.map
|
package/dist/buildApp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,iBAoU3B"}
|
package/dist/buildApp.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { catchAllEntry, getAllEntries } from "@universal-deploy/store";
|
|
4
|
+
import { catchAll } from "@universal-deploy/vite";
|
|
3
5
|
import { createBuilder, normalizePath } from "vite";
|
|
4
6
|
import {
|
|
5
7
|
getApiSideBabelPlugins,
|
|
@@ -22,7 +24,8 @@ function resolveWithExtensions(id) {
|
|
|
22
24
|
}
|
|
23
25
|
async function buildCedarApp({
|
|
24
26
|
verbose = false,
|
|
25
|
-
workspace = ["api", "web"]
|
|
27
|
+
workspace = ["api", "web"],
|
|
28
|
+
ud = false
|
|
26
29
|
} = {}) {
|
|
27
30
|
const cedarPaths = getPaths();
|
|
28
31
|
const cedarConfig = getConfig();
|
|
@@ -69,6 +72,31 @@ async function buildCedarApp({
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
};
|
|
75
|
+
if (ud) {
|
|
76
|
+
environments["ssr"] = {
|
|
77
|
+
build: {
|
|
78
|
+
ssr: true,
|
|
79
|
+
outDir: path.join(cedarPaths.api.dist, "ud"),
|
|
80
|
+
emptyOutDir: true,
|
|
81
|
+
rollupOptions: {
|
|
82
|
+
input: catchAllEntry,
|
|
83
|
+
output: {
|
|
84
|
+
entryFileNames: "index.js"
|
|
85
|
+
},
|
|
86
|
+
external: (id) => {
|
|
87
|
+
if (id.startsWith("virtual:")) {
|
|
88
|
+
return false;
|
|
89
|
+
} else if (id.startsWith("node:")) {
|
|
90
|
+
return true;
|
|
91
|
+
} else if (!id.startsWith(".") && !path.isAbsolute(id)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
72
100
|
}
|
|
73
101
|
const babelPlugins = workspace.includes("api") ? getApiSideBabelPlugins({
|
|
74
102
|
openTelemetry: (cedarConfig.experimental?.opentelemetry?.enabled ?? false) && (cedarConfig.experimental?.opentelemetry?.wrapApi ?? false),
|
|
@@ -137,10 +165,46 @@ async function buildCedarApp({
|
|
|
137
165
|
if (workspace.includes("api") && builder2.environments.api && !builder2.environments.api.isBuilt) {
|
|
138
166
|
await builder2.build(builder2.environments.api);
|
|
139
167
|
}
|
|
168
|
+
if (workspace.includes("api") && builder2.environments["ssr"] && !builder2.environments["ssr"].isBuilt) {
|
|
169
|
+
await builder2.build(builder2.environments["ssr"]);
|
|
170
|
+
}
|
|
140
171
|
}
|
|
141
172
|
}
|
|
142
173
|
}
|
|
143
174
|
];
|
|
175
|
+
if (ud) {
|
|
176
|
+
plugins.push(catchAll());
|
|
177
|
+
plugins.push({
|
|
178
|
+
name: "cedar-ud-verify-routes",
|
|
179
|
+
configResolved() {
|
|
180
|
+
const entries = getAllEntries();
|
|
181
|
+
if (entries.length === 0) {
|
|
182
|
+
console.warn(
|
|
183
|
+
"\n",
|
|
184
|
+
" Warning: No Universal Deploy API routes were registered.\n",
|
|
185
|
+
" The built server entry will be an empty router (404 for all\n",
|
|
186
|
+
" requests). Check that you have API functions under\n",
|
|
187
|
+
" `api/src/functions/` and that your vite config includes\n",
|
|
188
|
+
" `cedarUniversalDeployPlugin()`.\n"
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
plugins.push({
|
|
194
|
+
name: "cedar-ud-write-package-json",
|
|
195
|
+
applyToEnvironment(env) {
|
|
196
|
+
return env.name === "ssr";
|
|
197
|
+
},
|
|
198
|
+
closeBundle() {
|
|
199
|
+
const dir = path.join(cedarPaths.api.dist, "ud");
|
|
200
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
201
|
+
fs.writeFileSync(
|
|
202
|
+
path.join(dir, "package.json"),
|
|
203
|
+
JSON.stringify({ type: "module" }, null, 2)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
144
208
|
if (workspace.includes("api")) {
|
|
145
209
|
plugins.push({
|
|
146
210
|
name: "cedar-api-src-redirect",
|
package/dist/cjs/buildApp.js
CHANGED
|
@@ -33,7 +33,9 @@ __export(buildApp_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(buildApp_exports);
|
|
34
34
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
35
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
var
|
|
36
|
+
var import_store = require("@universal-deploy/store");
|
|
37
|
+
var import_vite = require("@universal-deploy/vite");
|
|
38
|
+
var import_vite2 = require("vite");
|
|
37
39
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
38
40
|
var import_files = require("@cedarjs/internal/dist/files.js");
|
|
39
41
|
var import_project_config = require("@cedarjs/project-config");
|
|
@@ -52,7 +54,8 @@ function resolveWithExtensions(id) {
|
|
|
52
54
|
}
|
|
53
55
|
async function buildCedarApp({
|
|
54
56
|
verbose = false,
|
|
55
|
-
workspace = ["api", "web"]
|
|
57
|
+
workspace = ["api", "web"],
|
|
58
|
+
ud = false
|
|
56
59
|
} = {}) {
|
|
57
60
|
const cedarPaths = (0, import_project_config.getPaths)();
|
|
58
61
|
const cedarConfig = (0, import_project_config.getConfig)();
|
|
@@ -99,6 +102,31 @@ async function buildCedarApp({
|
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
};
|
|
105
|
+
if (ud) {
|
|
106
|
+
environments["ssr"] = {
|
|
107
|
+
build: {
|
|
108
|
+
ssr: true,
|
|
109
|
+
outDir: import_node_path.default.join(cedarPaths.api.dist, "ud"),
|
|
110
|
+
emptyOutDir: true,
|
|
111
|
+
rollupOptions: {
|
|
112
|
+
input: import_store.catchAllEntry,
|
|
113
|
+
output: {
|
|
114
|
+
entryFileNames: "index.js"
|
|
115
|
+
},
|
|
116
|
+
external: (id) => {
|
|
117
|
+
if (id.startsWith("virtual:")) {
|
|
118
|
+
return false;
|
|
119
|
+
} else if (id.startsWith("node:")) {
|
|
120
|
+
return true;
|
|
121
|
+
} else if (!id.startsWith(".") && !import_node_path.default.isAbsolute(id)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
102
130
|
}
|
|
103
131
|
const babelPlugins = workspace.includes("api") ? (0, import_babel_config.getApiSideBabelPlugins)({
|
|
104
132
|
openTelemetry: (cedarConfig.experimental?.opentelemetry?.enabled ?? false) && (cedarConfig.experimental?.opentelemetry?.wrapApi ?? false),
|
|
@@ -106,7 +134,7 @@ async function buildCedarApp({
|
|
|
106
134
|
}) : null;
|
|
107
135
|
const workspacePkgSourceMap = workspace.includes("api") ? Object.fromEntries(
|
|
108
136
|
Object.entries((0, import_workspacePackageAliases.getWorkspacePackageAliases)(cedarPaths, cedarConfig)).map(
|
|
109
|
-
([name, sourceFile]) => [name, (0,
|
|
137
|
+
([name, sourceFile]) => [name, (0, import_vite2.normalizePath)(sourceFile)]
|
|
110
138
|
)
|
|
111
139
|
) : {};
|
|
112
140
|
const plugins = [
|
|
@@ -167,10 +195,46 @@ async function buildCedarApp({
|
|
|
167
195
|
if (workspace.includes("api") && builder2.environments.api && !builder2.environments.api.isBuilt) {
|
|
168
196
|
await builder2.build(builder2.environments.api);
|
|
169
197
|
}
|
|
198
|
+
if (workspace.includes("api") && builder2.environments["ssr"] && !builder2.environments["ssr"].isBuilt) {
|
|
199
|
+
await builder2.build(builder2.environments["ssr"]);
|
|
200
|
+
}
|
|
170
201
|
}
|
|
171
202
|
}
|
|
172
203
|
}
|
|
173
204
|
];
|
|
205
|
+
if (ud) {
|
|
206
|
+
plugins.push((0, import_vite.catchAll)());
|
|
207
|
+
plugins.push({
|
|
208
|
+
name: "cedar-ud-verify-routes",
|
|
209
|
+
configResolved() {
|
|
210
|
+
const entries = (0, import_store.getAllEntries)();
|
|
211
|
+
if (entries.length === 0) {
|
|
212
|
+
console.warn(
|
|
213
|
+
"\n",
|
|
214
|
+
" Warning: No Universal Deploy API routes were registered.\n",
|
|
215
|
+
" The built server entry will be an empty router (404 for all\n",
|
|
216
|
+
" requests). Check that you have API functions under\n",
|
|
217
|
+
" `api/src/functions/` and that your vite config includes\n",
|
|
218
|
+
" `cedarUniversalDeployPlugin()`.\n"
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
plugins.push({
|
|
224
|
+
name: "cedar-ud-write-package-json",
|
|
225
|
+
applyToEnvironment(env) {
|
|
226
|
+
return env.name === "ssr";
|
|
227
|
+
},
|
|
228
|
+
closeBundle() {
|
|
229
|
+
const dir = import_node_path.default.join(cedarPaths.api.dist, "ud");
|
|
230
|
+
import_node_fs.default.mkdirSync(dir, { recursive: true });
|
|
231
|
+
import_node_fs.default.writeFileSync(
|
|
232
|
+
import_node_path.default.join(dir, "package.json"),
|
|
233
|
+
JSON.stringify({ type: "module" }, null, 2)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
174
238
|
if (workspace.includes("api")) {
|
|
175
239
|
plugins.push({
|
|
176
240
|
name: "cedar-api-src-redirect",
|
|
@@ -197,7 +261,7 @@ async function buildCedarApp({
|
|
|
197
261
|
if (id.includes("node_modules")) {
|
|
198
262
|
return null;
|
|
199
263
|
}
|
|
200
|
-
if (!(0,
|
|
264
|
+
if (!(0, import_vite2.normalizePath)(id).startsWith((0, import_vite2.normalizePath)(cedarPaths.api.base))) {
|
|
201
265
|
return null;
|
|
202
266
|
}
|
|
203
267
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(id, babelPlugins);
|
|
@@ -212,7 +276,7 @@ async function buildCedarApp({
|
|
|
212
276
|
});
|
|
213
277
|
}
|
|
214
278
|
}
|
|
215
|
-
const builder = await (0,
|
|
279
|
+
const builder = await (0, import_vite2.createBuilder)({
|
|
216
280
|
configFile: cedarPaths.web.viteConfig,
|
|
217
281
|
envFile: false,
|
|
218
282
|
logLevel: verbose ? "info" : "warn",
|
|
@@ -37,7 +37,6 @@ var import_files = require("@cedarjs/internal/dist/files.js");
|
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
38
|
const VIRTUAL_CEDAR_FN_PREFIX = "virtual:cedar-api:fn:";
|
|
39
39
|
const RESOLVED_CEDAR_FN_PREFIX = "\0virtual:cedar-api:fn:";
|
|
40
|
-
const UD_STORE_SYMBOL = /* @__PURE__ */ Symbol.for("ud:store");
|
|
41
40
|
const GRAPHQL_METHODS = ["GET", "POST", "OPTIONS"];
|
|
42
41
|
function normaliseApiPrefix(apiPrefix) {
|
|
43
42
|
apiPrefix = apiPrefix.trim();
|
|
@@ -97,30 +96,15 @@ function toEntryMeta(route) {
|
|
|
97
96
|
}
|
|
98
97
|
};
|
|
99
98
|
}
|
|
100
|
-
function clearCedarEntries() {
|
|
101
|
-
const store = globalThis[UD_STORE_SYMBOL];
|
|
102
|
-
if (!store) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
store.entries = store.entries.filter(
|
|
106
|
-
(entry) => !entry.id?.startsWith(VIRTUAL_CEDAR_FN_PREFIX)
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
99
|
function cedarUniversalDeployPlugin(options = {}) {
|
|
110
100
|
const effectiveApiRootPath = process.env.CEDAR_API_ROOT_PATH ?? options.apiRootPath;
|
|
111
101
|
const routes = discoverCedarRoutes(effectiveApiRootPath ?? "/");
|
|
112
|
-
let entriesInjected = false;
|
|
113
102
|
return {
|
|
114
103
|
name: "cedar-universal-deploy",
|
|
115
104
|
apply: "build",
|
|
116
105
|
config: {
|
|
117
106
|
order: "pre",
|
|
118
107
|
handler() {
|
|
119
|
-
if (entriesInjected) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
entriesInjected = true;
|
|
123
|
-
clearCedarEntries();
|
|
124
108
|
for (const route of routes) {
|
|
125
109
|
(0, import_store.addEntry)(toEntryMeta(route));
|
|
126
110
|
}
|
|
@@ -187,7 +171,7 @@ async function bundleDistFile(distPath, options = {}) {
|
|
|
187
171
|
name: "ud-external",
|
|
188
172
|
setup(build2) {
|
|
189
173
|
build2.onResolve({ filter: /^[^.]/ }, (args) => {
|
|
190
|
-
if (args.path
|
|
174
|
+
if (import_node_path.default.isAbsolute(args.path)) {
|
|
191
175
|
return;
|
|
192
176
|
}
|
|
193
177
|
if (args.path.startsWith("api/")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AA6GD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,iCAAsC,GAC9C,MAAM,CA0GR"}
|
|
@@ -4,7 +4,6 @@ import { findApiServerFunctions } from "@cedarjs/internal/dist/files.js";
|
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
5
|
const VIRTUAL_CEDAR_FN_PREFIX = "virtual:cedar-api:fn:";
|
|
6
6
|
const RESOLVED_CEDAR_FN_PREFIX = "\0virtual:cedar-api:fn:";
|
|
7
|
-
const UD_STORE_SYMBOL = /* @__PURE__ */ Symbol.for("ud:store");
|
|
8
7
|
const GRAPHQL_METHODS = ["GET", "POST", "OPTIONS"];
|
|
9
8
|
function normaliseApiPrefix(apiPrefix) {
|
|
10
9
|
apiPrefix = apiPrefix.trim();
|
|
@@ -64,30 +63,15 @@ function toEntryMeta(route) {
|
|
|
64
63
|
}
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
|
-
function clearCedarEntries() {
|
|
68
|
-
const store = globalThis[UD_STORE_SYMBOL];
|
|
69
|
-
if (!store) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
store.entries = store.entries.filter(
|
|
73
|
-
(entry) => !entry.id?.startsWith(VIRTUAL_CEDAR_FN_PREFIX)
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
66
|
function cedarUniversalDeployPlugin(options = {}) {
|
|
77
67
|
const effectiveApiRootPath = process.env.CEDAR_API_ROOT_PATH ?? options.apiRootPath;
|
|
78
68
|
const routes = discoverCedarRoutes(effectiveApiRootPath ?? "/");
|
|
79
|
-
let entriesInjected = false;
|
|
80
69
|
return {
|
|
81
70
|
name: "cedar-universal-deploy",
|
|
82
71
|
apply: "build",
|
|
83
72
|
config: {
|
|
84
73
|
order: "pre",
|
|
85
74
|
handler() {
|
|
86
|
-
if (entriesInjected) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
entriesInjected = true;
|
|
90
|
-
clearCedarEntries();
|
|
91
75
|
for (const route of routes) {
|
|
92
76
|
addEntry(toEntryMeta(route));
|
|
93
77
|
}
|
|
@@ -154,7 +138,7 @@ async function bundleDistFile(distPath, options = {}) {
|
|
|
154
138
|
name: "ud-external",
|
|
155
139
|
setup(build2) {
|
|
156
140
|
build2.onResolve({ filter: /^[^.]/ }, (args) => {
|
|
157
|
-
if (args.path
|
|
141
|
+
if (path.isAbsolute(args.path)) {
|
|
158
142
|
return;
|
|
159
143
|
}
|
|
160
144
|
if (args.path.startsWith("api/")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2559",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,9 +33,6 @@
|
|
|
33
33
|
"require": "./dist/cjs/buildFeServer.js",
|
|
34
34
|
"import": "./dist/buildFeServer.js"
|
|
35
35
|
},
|
|
36
|
-
"./buildUDApiServer": {
|
|
37
|
-
"import": "./dist/buildUDApiServer.js"
|
|
38
|
-
},
|
|
39
36
|
"./build": {
|
|
40
37
|
"import": "./dist/build/build.js",
|
|
41
38
|
"default": "./dist/cjs/build/build.js"
|
|
@@ -70,17 +67,17 @@
|
|
|
70
67
|
"@babel/parser": "7.29.7",
|
|
71
68
|
"@babel/traverse": "7.29.7",
|
|
72
69
|
"@babel/types": "7.29.7",
|
|
73
|
-
"@cedarjs/api": "5.0.0-canary.
|
|
74
|
-
"@cedarjs/auth": "5.0.0-canary.
|
|
75
|
-
"@cedarjs/babel-config": "5.0.0-canary.
|
|
76
|
-
"@cedarjs/context": "5.0.0-canary.
|
|
77
|
-
"@cedarjs/cookie-jar": "5.0.0-canary.
|
|
78
|
-
"@cedarjs/graphql-server": "5.0.0-canary.
|
|
79
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
80
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
81
|
-
"@cedarjs/server-store": "5.0.0-canary.
|
|
82
|
-
"@cedarjs/testing": "5.0.0-canary.
|
|
83
|
-
"@cedarjs/web": "5.0.0-canary.
|
|
70
|
+
"@cedarjs/api": "5.0.0-canary.2559",
|
|
71
|
+
"@cedarjs/auth": "5.0.0-canary.2559",
|
|
72
|
+
"@cedarjs/babel-config": "5.0.0-canary.2559",
|
|
73
|
+
"@cedarjs/context": "5.0.0-canary.2559",
|
|
74
|
+
"@cedarjs/cookie-jar": "5.0.0-canary.2559",
|
|
75
|
+
"@cedarjs/graphql-server": "5.0.0-canary.2559",
|
|
76
|
+
"@cedarjs/internal": "5.0.0-canary.2559",
|
|
77
|
+
"@cedarjs/project-config": "5.0.0-canary.2559",
|
|
78
|
+
"@cedarjs/server-store": "5.0.0-canary.2559",
|
|
79
|
+
"@cedarjs/testing": "5.0.0-canary.2559",
|
|
80
|
+
"@cedarjs/web": "5.0.0-canary.2559",
|
|
84
81
|
"@fastify/url-data": "6.0.3",
|
|
85
82
|
"@swc/core": "1.15.41",
|
|
86
83
|
"@universal-deploy/store": "^0.2.1",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface BuildUDApiServerOptions {
|
|
2
|
-
verbose?: boolean;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Builds the API server Universal Deploy server entry using Vite.
|
|
6
|
-
*
|
|
7
|
-
* Runs a Vite SSR build that produces a pure WinterTC-compatible Fetchable
|
|
8
|
-
* (`export default { fetch }`) at `api/dist/ud/index.js`. The output
|
|
9
|
-
* contains NO HTTP server startup code — the Fetchable is wrapped by
|
|
10
|
-
* `cedar serve` at runtime.
|
|
11
|
-
*
|
|
12
|
-
* Loads the user's Vite config (`web/vite.config.ts`) so both provider
|
|
13
|
-
* plugins (Netlify, Vercel, etc.) and Cedar's own UD plugin
|
|
14
|
-
* (`cedarUniversalDeployPlugin`) run during the build.
|
|
15
|
-
* Provider plugins produce their own deployment artifacts alongside Cedar's UD
|
|
16
|
-
* output.
|
|
17
|
-
* The user must include `cedarUniversalDeployPlugin()` in their Vite config to
|
|
18
|
-
* register API routes.
|
|
19
|
-
*
|
|
20
|
-
* The emitted server entry is placed under `api/dist/ud/` so it does not
|
|
21
|
-
* collide with the existing esbuild output under `api/dist/`.
|
|
22
|
-
*
|
|
23
|
-
* NOTE: The Vite "ssr" build target used here is a server-side module build
|
|
24
|
-
* concern — it is NOT related to Cedar HTML SSR / streaming / RSC. "ssr"
|
|
25
|
-
* simply means Vite produces a Node-compatible bundle rather than a browser
|
|
26
|
-
* bundle.
|
|
27
|
-
*/
|
|
28
|
-
export declare function buildUDApiServer({ verbose, }?: BuildUDApiServerOptions): Promise<void>;
|
|
29
|
-
//# sourceMappingURL=buildUDApiServer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildUDApiServer.d.ts","sourceRoot":"","sources":["../src/buildUDApiServer.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,OAAe,GAChB,GAAE,uBAA4B,iBAyG9B"}
|
package/dist/buildUDApiServer.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
-
async function buildUDApiServer({
|
|
5
|
-
verbose = false
|
|
6
|
-
} = {}) {
|
|
7
|
-
const { build } = await import("vite");
|
|
8
|
-
const { catchAll, devServer } = await import("@universal-deploy/vite");
|
|
9
|
-
const { catchAllEntry, getAllEntries } = await import("@universal-deploy/store");
|
|
10
|
-
const cedarPaths = getPaths();
|
|
11
|
-
const outDir = path.join(cedarPaths.api.dist, "ud");
|
|
12
|
-
const providerOutputDirs = [path.join(cedarPaths.base, ".vercel", "output")];
|
|
13
|
-
const savedDirs = /* @__PURE__ */ new Map();
|
|
14
|
-
for (const dir of providerOutputDirs) {
|
|
15
|
-
if (fs.existsSync(dir)) {
|
|
16
|
-
const tmpDir = dir + ".cedar-ud-backup";
|
|
17
|
-
await fs.promises.cp(dir, tmpDir, { recursive: true, force: true });
|
|
18
|
-
savedDirs.set(dir, tmpDir);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
await build({
|
|
23
|
-
// Load the user's Vite config so all plugins (Cedar's UD plugin,
|
|
24
|
-
// provider plugins, etc.) run during the build.
|
|
25
|
-
configFile: cedarPaths.web.viteConfig,
|
|
26
|
-
logLevel: verbose ? "info" : "warn",
|
|
27
|
-
plugins: [
|
|
28
|
-
// catchAll() generates the rou3-based route dispatcher
|
|
29
|
-
// (virtual:ud:catch-all). devServer() provides Vite dev support for
|
|
30
|
-
// cedar dev --ud.
|
|
31
|
-
//
|
|
32
|
-
// NOTE: We intentionally do NOT use universalDeploy() here — that
|
|
33
|
-
// plugin auto-detects deployment targets and would embed the Node
|
|
34
|
-
// HTTP server startup code into the output. Our plugin list is
|
|
35
|
-
// adapter-free: the output is a pure Fetchable export, and cedar
|
|
36
|
-
// serve wraps it in srvx at runtime.
|
|
37
|
-
catchAll(),
|
|
38
|
-
devServer(),
|
|
39
|
-
// Warn if no Cedar API routes were registered — likely means the
|
|
40
|
-
// user's vite config is missing cedarUniversalDeployPlugin or there
|
|
41
|
-
// are no API functions to serve.
|
|
42
|
-
{
|
|
43
|
-
name: "cedar-ud-verify-routes",
|
|
44
|
-
configResolved() {
|
|
45
|
-
const entries = getAllEntries();
|
|
46
|
-
if (entries.length === 0) {
|
|
47
|
-
console.warn(
|
|
48
|
-
"\n Warning: No Universal Deploy API routes were registered.",
|
|
49
|
-
"\n The built server entry will be an empty router (404 for all",
|
|
50
|
-
"\n requests). Check that you have API functions under",
|
|
51
|
-
"\n `api/src/functions/` and that your vite config includes",
|
|
52
|
-
"\n `cedarUniversalDeployPlugin()`.\n"
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
// Legacy ssr flag approach. The explicit rollupOptions.input prevents the
|
|
59
|
-
// "index.html as SSR entry" error. Vite will also build a 'client'
|
|
60
|
-
// environment from the user's config file (wasteful but harmless), and
|
|
61
|
-
// the 'ssr' environment produces our canonical Fetchable artifact at
|
|
62
|
-
// api/dist/ud/index.js.
|
|
63
|
-
build: {
|
|
64
|
-
ssr: true,
|
|
65
|
-
outDir,
|
|
66
|
-
rollupOptions: {
|
|
67
|
-
input: catchAllEntry,
|
|
68
|
-
output: {
|
|
69
|
-
entryFileNames: "index.js"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
fs.writeFileSync(
|
|
75
|
-
path.join(outDir, "package.json"),
|
|
76
|
-
JSON.stringify({ type: "module" }, null, 2)
|
|
77
|
-
);
|
|
78
|
-
} finally {
|
|
79
|
-
for (const [dir, tmpDir] of savedDirs) {
|
|
80
|
-
if (fs.existsSync(tmpDir)) {
|
|
81
|
-
const opts = { recursive: true, force: true };
|
|
82
|
-
await fs.promises.rm(dir, opts).catch(() => {
|
|
83
|
-
});
|
|
84
|
-
await fs.promises.cp(tmpDir, dir, opts);
|
|
85
|
-
await fs.promises.rm(tmpDir, opts).catch(() => {
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
buildUDApiServer
|
|
93
|
-
};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var buildUDApiServer_exports = {};
|
|
30
|
-
__export(buildUDApiServer_exports, {
|
|
31
|
-
buildUDApiServer: () => buildUDApiServer
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(buildUDApiServer_exports);
|
|
34
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
-
async function buildUDApiServer({
|
|
38
|
-
verbose = false
|
|
39
|
-
} = {}) {
|
|
40
|
-
const { build } = await import("vite");
|
|
41
|
-
const { catchAll, devServer } = await import("@universal-deploy/vite");
|
|
42
|
-
const { catchAllEntry, getAllEntries } = await import("@universal-deploy/store");
|
|
43
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
44
|
-
const outDir = import_node_path.default.join(cedarPaths.api.dist, "ud");
|
|
45
|
-
const providerOutputDirs = [import_node_path.default.join(cedarPaths.base, ".vercel", "output")];
|
|
46
|
-
const savedDirs = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const dir of providerOutputDirs) {
|
|
48
|
-
if (import_node_fs.default.existsSync(dir)) {
|
|
49
|
-
const tmpDir = dir + ".cedar-ud-backup";
|
|
50
|
-
await import_node_fs.default.promises.cp(dir, tmpDir, { recursive: true, force: true });
|
|
51
|
-
savedDirs.set(dir, tmpDir);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
await build({
|
|
56
|
-
// Load the user's Vite config so all plugins (Cedar's UD plugin,
|
|
57
|
-
// provider plugins, etc.) run during the build.
|
|
58
|
-
configFile: cedarPaths.web.viteConfig,
|
|
59
|
-
logLevel: verbose ? "info" : "warn",
|
|
60
|
-
plugins: [
|
|
61
|
-
// catchAll() generates the rou3-based route dispatcher
|
|
62
|
-
// (virtual:ud:catch-all). devServer() provides Vite dev support for
|
|
63
|
-
// cedar dev --ud.
|
|
64
|
-
//
|
|
65
|
-
// NOTE: We intentionally do NOT use universalDeploy() here — that
|
|
66
|
-
// plugin auto-detects deployment targets and would embed the Node
|
|
67
|
-
// HTTP server startup code into the output. Our plugin list is
|
|
68
|
-
// adapter-free: the output is a pure Fetchable export, and cedar
|
|
69
|
-
// serve wraps it in srvx at runtime.
|
|
70
|
-
catchAll(),
|
|
71
|
-
devServer(),
|
|
72
|
-
// Warn if no Cedar API routes were registered — likely means the
|
|
73
|
-
// user's vite config is missing cedarUniversalDeployPlugin or there
|
|
74
|
-
// are no API functions to serve.
|
|
75
|
-
{
|
|
76
|
-
name: "cedar-ud-verify-routes",
|
|
77
|
-
configResolved() {
|
|
78
|
-
const entries = getAllEntries();
|
|
79
|
-
if (entries.length === 0) {
|
|
80
|
-
console.warn(
|
|
81
|
-
"\n Warning: No Universal Deploy API routes were registered.",
|
|
82
|
-
"\n The built server entry will be an empty router (404 for all",
|
|
83
|
-
"\n requests). Check that you have API functions under",
|
|
84
|
-
"\n `api/src/functions/` and that your vite config includes",
|
|
85
|
-
"\n `cedarUniversalDeployPlugin()`.\n"
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
],
|
|
91
|
-
// Legacy ssr flag approach. The explicit rollupOptions.input prevents the
|
|
92
|
-
// "index.html as SSR entry" error. Vite will also build a 'client'
|
|
93
|
-
// environment from the user's config file (wasteful but harmless), and
|
|
94
|
-
// the 'ssr' environment produces our canonical Fetchable artifact at
|
|
95
|
-
// api/dist/ud/index.js.
|
|
96
|
-
build: {
|
|
97
|
-
ssr: true,
|
|
98
|
-
outDir,
|
|
99
|
-
rollupOptions: {
|
|
100
|
-
input: catchAllEntry,
|
|
101
|
-
output: {
|
|
102
|
-
entryFileNames: "index.js"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
import_node_fs.default.writeFileSync(
|
|
108
|
-
import_node_path.default.join(outDir, "package.json"),
|
|
109
|
-
JSON.stringify({ type: "module" }, null, 2)
|
|
110
|
-
);
|
|
111
|
-
} finally {
|
|
112
|
-
for (const [dir, tmpDir] of savedDirs) {
|
|
113
|
-
if (import_node_fs.default.existsSync(tmpDir)) {
|
|
114
|
-
const opts = { recursive: true, force: true };
|
|
115
|
-
await import_node_fs.default.promises.rm(dir, opts).catch(() => {
|
|
116
|
-
});
|
|
117
|
-
await import_node_fs.default.promises.cp(tmpDir, dir, opts);
|
|
118
|
-
await import_node_fs.default.promises.rm(tmpDir, opts).catch(() => {
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
-
0 && (module.exports = {
|
|
126
|
-
buildUDApiServer
|
|
127
|
-
});
|