@cedarjs/vite 6.0.0-canary.2771 → 6.0.0-canary.2772
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 +21 -31
- package/dist/cjs/ClientRouter.d.ts +0 -1
- package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +0 -41
- package/dist/cjs/apiDevMiddleware.js +0 -466
- package/dist/cjs/build/build.d.ts +0 -1
- package/dist/cjs/build/build.js +0 -58
- package/dist/cjs/buildApp.js +0 -363
- package/dist/cjs/buildFeServer.d.ts +0 -1
- package/dist/cjs/buildFeServer.js +0 -63
- package/dist/cjs/buildRouteHooks.js +0 -112
- package/dist/cjs/buildRouteManifest.js +0 -92
- package/dist/cjs/buildRscClientAndServer.js +0 -54
- package/dist/cjs/cedar-unified-dev.js +0 -345
- package/dist/cjs/client.d.ts +0 -1
- package/dist/cjs/clientSsr.d.ts +0 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -168
- package/dist/cjs/lib/StatusError.js +0 -37
- package/dist/cjs/lib/entries.js +0 -52
- package/dist/cjs/lib/generateDiffSourceMap.js +0 -185
- package/dist/cjs/lib/getMergedConfig.js +0 -189
- package/dist/cjs/lib/onWarn.js +0 -36
- package/dist/cjs/lib/workspacePackageAliases.js +0 -107
- package/dist/cjs/middleware/index.js +0 -22
- package/dist/cjs/middleware/invokeMiddleware.js +0 -52
- package/dist/cjs/middleware/register.js +0 -105
- package/dist/cjs/middleware/types.js +0 -16
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/plugins/vite-plugin-cedar-auto-import.js +0 -114
- package/dist/cjs/plugins/vite-plugin-cedar-cell.js +0 -184
- package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +0 -341
- package/dist/cjs/plugins/vite-plugin-cedar-data-uri-shim.js +0 -67
- package/dist/cjs/plugins/vite-plugin-cedar-directory-named-import.js +0 -69
- package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +0 -107
- package/dist/cjs/plugins/vite-plugin-cedar-gqlorm-inject.js +0 -106
- package/dist/cjs/plugins/vite-plugin-cedar-graphql-options-extract.js +0 -128
- package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +0 -67
- package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +0 -136
- package/dist/cjs/plugins/vite-plugin-cedar-log-formatter-dev.js +0 -93
- package/dist/cjs/plugins/vite-plugin-cedar-mock-cell-data.js +0 -282
- package/dist/cjs/plugins/vite-plugin-cedar-otel-wrapping.js +0 -225
- package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +0 -61
- package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +0 -76
- package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +0 -126
- package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +0 -346
- package/dist/cjs/plugins/vite-plugin-cedar-wait-for-api-server.js +0 -134
- package/dist/cjs/plugins/vite-plugin-cedarjs-job-path-injector.js +0 -134
- package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +0 -120
- package/dist/cjs/plugins/vite-plugin-handler-als-wrapping.js +0 -95
- package/dist/cjs/plugins/vite-plugin-jsx-loader.js +0 -42
- package/dist/cjs/plugins/vite-plugin-merged-config.js +0 -39
- package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +0 -104
- package/dist/cjs/plugins/vite-plugin-rsc-reload.js +0 -75
- package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +0 -159
- package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +0 -125
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +0 -75
- package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +0 -228
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +0 -402
- package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +0 -46
- package/dist/cjs/rsc/rscBuildAnalyze.js +0 -126
- package/dist/cjs/rsc/rscBuildClient.js +0 -91
- package/dist/cjs/rsc/rscBuildCopyCssAssets.js +0 -56
- package/dist/cjs/rsc/rscBuildEntriesFile.js +0 -115
- package/dist/cjs/rsc/rscBuildForServer.js +0 -168
- package/dist/cjs/rsc/rscBuildForSsr.js +0 -172
- package/dist/cjs/rsc/rscBuildRwEnvVars.js +0 -56
- package/dist/cjs/rsc/rscRenderer.js +0 -179
- package/dist/cjs/rsc/rscRequestHandler.js +0 -162
- package/dist/cjs/rsc/rscStudioHandlers.js +0 -156
- package/dist/cjs/rsc/rscWebSocketServer.js +0 -56
- package/dist/cjs/rsc/utils.js +0 -56
- package/dist/cjs/streaming/buildForStreamingServer.js +0 -64
- package/dist/cjs/streaming/collectCss.js +0 -52
- package/dist/cjs/streaming/transforms/bufferedTransform.js +0 -61
- package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +0 -34
- package/dist/cjs/streaming/transforms/encode-decode.js +0 -36
- package/dist/cjs/streaming/transforms/serverInjectionTransform.js +0 -84
- package/dist/cjs/streaming/triggerRouteHooks.js +0 -96
- package/dist/cjs/types.js +0 -16
- package/dist/cjs/utils.js +0 -92
- package/dist/package.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2772",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,27 +12,17 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
"./package.json": "./package.json",
|
|
14
14
|
".": {
|
|
15
|
-
"
|
|
15
|
+
"default": {
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
|
-
},
|
|
19
|
-
"require": {
|
|
20
|
-
"types": "./dist/cjs/index.d.ts",
|
|
21
|
-
"default": "./dist/cjs/index.js"
|
|
22
18
|
}
|
|
23
19
|
},
|
|
24
20
|
"./api": {
|
|
25
21
|
"types": "./dist/api/vite-plugin-cedar-vitest-api-preset.d.ts",
|
|
26
22
|
"default": "./dist/api/vite-plugin-cedar-vitest-api-preset.js"
|
|
27
23
|
},
|
|
28
|
-
"./buildFeServer":
|
|
29
|
-
|
|
30
|
-
"import": "./dist/buildFeServer.js"
|
|
31
|
-
},
|
|
32
|
-
"./build": {
|
|
33
|
-
"import": "./dist/build/build.js",
|
|
34
|
-
"default": "./dist/cjs/build/build.js"
|
|
35
|
-
},
|
|
24
|
+
"./buildFeServer": "./dist/buildFeServer.js",
|
|
25
|
+
"./build": "./dist/build/build.js",
|
|
36
26
|
"./bins/cedar-vite-build.mjs": "./bins/cedar-vite-build.mjs"
|
|
37
27
|
},
|
|
38
28
|
"bin": {
|
|
@@ -49,7 +39,7 @@
|
|
|
49
39
|
"inject"
|
|
50
40
|
],
|
|
51
41
|
"scripts": {
|
|
52
|
-
"build": "node ./build.ts
|
|
42
|
+
"build": "node ./build.ts",
|
|
53
43
|
"build:pack": "yarn pack -o cedarjs-vite.tgz",
|
|
54
44
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
55
45
|
"check:attw": "node ./attw.ts",
|
|
@@ -63,16 +53,16 @@
|
|
|
63
53
|
"@babel/parser": "7.29.7",
|
|
64
54
|
"@babel/traverse": "7.29.7",
|
|
65
55
|
"@babel/types": "7.29.7",
|
|
66
|
-
"@cedarjs/api": "6.0.0-canary.
|
|
67
|
-
"@cedarjs/api-server": "6.0.0-canary.
|
|
68
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
69
|
-
"@cedarjs/context": "6.0.0-canary.
|
|
70
|
-
"@cedarjs/cookie-jar": "6.0.0-canary.
|
|
71
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
72
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
73
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
74
|
-
"@cedarjs/server-store": "6.0.0-canary.
|
|
75
|
-
"@cedarjs/testing": "6.0.0-canary.
|
|
56
|
+
"@cedarjs/api": "6.0.0-canary.2772",
|
|
57
|
+
"@cedarjs/api-server": "6.0.0-canary.2772",
|
|
58
|
+
"@cedarjs/babel-config": "6.0.0-canary.2772",
|
|
59
|
+
"@cedarjs/context": "6.0.0-canary.2772",
|
|
60
|
+
"@cedarjs/cookie-jar": "6.0.0-canary.2772",
|
|
61
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2772",
|
|
62
|
+
"@cedarjs/internal": "6.0.0-canary.2772",
|
|
63
|
+
"@cedarjs/project-config": "6.0.0-canary.2772",
|
|
64
|
+
"@cedarjs/server-store": "6.0.0-canary.2772",
|
|
65
|
+
"@cedarjs/testing": "6.0.0-canary.2772",
|
|
76
66
|
"@fastify/url-data": "6.0.3",
|
|
77
67
|
"@swc/core": "1.15.46",
|
|
78
68
|
"@universal-deploy/store": "^0.2.1",
|
|
@@ -109,9 +99,9 @@
|
|
|
109
99
|
},
|
|
110
100
|
"devDependencies": {
|
|
111
101
|
"@arethetypeswrong/cli": "0.18.5",
|
|
112
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
113
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
114
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
102
|
+
"@cedarjs/auth": "6.0.0-canary.2772",
|
|
103
|
+
"@cedarjs/router": "6.0.0-canary.2772",
|
|
104
|
+
"@cedarjs/web": "6.0.0-canary.2772",
|
|
115
105
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
116
106
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
117
107
|
"@types/aws-lambda": "8.10.162",
|
|
@@ -130,9 +120,9 @@
|
|
|
130
120
|
"vitest": "4.1.10"
|
|
131
121
|
},
|
|
132
122
|
"peerDependencies": {
|
|
133
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
134
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
135
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
123
|
+
"@cedarjs/auth": "6.0.0-canary.2772",
|
|
124
|
+
"@cedarjs/router": "6.0.0-canary.2772",
|
|
125
|
+
"@cedarjs/web": "6.0.0-canary.2772"
|
|
136
126
|
},
|
|
137
127
|
"engines": {
|
|
138
128
|
"node": ">=24"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type * from "../ClientRouter.d.ts"
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var vite_plugin_cedar_vitest_api_preset_exports = {};
|
|
20
|
-
__export(vite_plugin_cedar_vitest_api_preset_exports, {
|
|
21
|
-
cedarVitestPreset: () => cedarVitestPreset
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(vite_plugin_cedar_vitest_api_preset_exports);
|
|
24
|
-
var import_vitest = require("@cedarjs/testing/api/vitest");
|
|
25
|
-
var import_vite_plugin_cedar_import_dir = require("../plugins/vite-plugin-cedar-import-dir.js");
|
|
26
|
-
var import_vite_plugin_cedarjs_job_path_injector = require("../plugins/vite-plugin-cedarjs-job-path-injector.js");
|
|
27
|
-
var import_vite_plugin_cedarjs_resolve_cedar_style_imports = require("../plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js");
|
|
28
|
-
function cedarVitestPreset() {
|
|
29
|
-
return [
|
|
30
|
-
(0, import_vite_plugin_cedar_import_dir.cedarImportDirPlugin)(),
|
|
31
|
-
(0, import_vite_plugin_cedarjs_job_path_injector.cedarjsJobPathInjectorPlugin)(),
|
|
32
|
-
(0, import_vitest.cedarVitestApiConfigPlugin)(),
|
|
33
|
-
(0, import_vitest.autoImportsPlugin)(),
|
|
34
|
-
(0, import_vite_plugin_cedarjs_resolve_cedar_style_imports.cedarjsResolveCedarStyleImportsPlugin)(),
|
|
35
|
-
(0, import_vitest.trackDbImportsPlugin)()
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
cedarVitestPreset
|
|
41
|
-
});
|
|
@@ -1,466 +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 apiDevMiddleware_exports = {};
|
|
30
|
-
__export(apiDevMiddleware_exports, {
|
|
31
|
-
createApiFetchHandler: () => createApiFetchHandler,
|
|
32
|
-
createApiViteServer: () => createApiViteServer,
|
|
33
|
-
loadApiFunctions: () => loadApiFunctions,
|
|
34
|
-
setupHmrHandlers: () => setupHmrHandlers,
|
|
35
|
-
startApiDevMiddleware: () => startApiDevMiddleware
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(apiDevMiddleware_exports);
|
|
38
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
39
|
-
var import_promises = require("node:fs/promises");
|
|
40
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
41
|
-
var import_node_url = require("node:url");
|
|
42
|
-
var import_ansis = __toESM(require("ansis"), 1);
|
|
43
|
-
var import_vite = require("vite");
|
|
44
|
-
var import_vite_plugin_graphql_tag = require("vite-plugin-graphql-tag");
|
|
45
|
-
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
46
|
-
var import_runtime = require("@cedarjs/api/runtime");
|
|
47
|
-
var import_babel_config = require("@cedarjs/babel-config");
|
|
48
|
-
var import_store = require("@cedarjs/context/dist/store");
|
|
49
|
-
var import_graphql_server = require("@cedarjs/graphql-server");
|
|
50
|
-
var import_api_graphql_transforms = require("@cedarjs/internal/dist/build/api-graphql-transforms.js");
|
|
51
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
52
|
-
var import_generateDiffSourceMap = require("./lib/generateDiffSourceMap.js");
|
|
53
|
-
var import_workspacePackageAliases = require("./lib/workspacePackageAliases.js");
|
|
54
|
-
var import_vite_plugin_cedar_auto_import = require("./plugins/vite-plugin-cedar-auto-import.js");
|
|
55
|
-
var import_vite_plugin_cedar_directory_named_import = require("./plugins/vite-plugin-cedar-directory-named-import.js");
|
|
56
|
-
var import_vite_plugin_cedar_graphql_options_extract = require("./plugins/vite-plugin-cedar-graphql-options-extract.js");
|
|
57
|
-
var import_vite_plugin_cedar_import_dir = require("./plugins/vite-plugin-cedar-import-dir.js");
|
|
58
|
-
var import_vite_plugin_cedar_log_formatter_dev = require("./plugins/vite-plugin-cedar-log-formatter-dev.js");
|
|
59
|
-
var import_vite_plugin_cedar_otel_wrapping = require("./plugins/vite-plugin-cedar-otel-wrapping.js");
|
|
60
|
-
var import_vite_plugin_cedarjs_job_path_injector = require("./plugins/vite-plugin-cedarjs-job-path-injector.js");
|
|
61
|
-
const tsconfigPaths = (
|
|
62
|
-
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
63
|
-
// interop
|
|
64
|
-
import_vite_tsconfig_paths.default.default?.default || import_vite_tsconfig_paths.default.default || import_vite_tsconfig_paths.default
|
|
65
|
-
);
|
|
66
|
-
function resolveWithExtensions(id) {
|
|
67
|
-
if (import_node_fs.default.existsSync(id) && import_node_fs.default.statSync(id).isFile()) {
|
|
68
|
-
return id;
|
|
69
|
-
}
|
|
70
|
-
for (const ext of [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"]) {
|
|
71
|
-
const withExt = id + ext;
|
|
72
|
-
if (import_node_fs.default.existsSync(withExt)) {
|
|
73
|
-
return withExt;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return id;
|
|
77
|
-
}
|
|
78
|
-
const LAMBDA_FUNCTIONS = {};
|
|
79
|
-
let graphqlYoga = null;
|
|
80
|
-
let loadApiFunctionsInFlight = null;
|
|
81
|
-
let needsReloadAfterInFlight = false;
|
|
82
|
-
async function loadApiFunctions(viteServer) {
|
|
83
|
-
if (loadApiFunctionsInFlight) {
|
|
84
|
-
needsReloadAfterInFlight = true;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
do {
|
|
88
|
-
needsReloadAfterInFlight = false;
|
|
89
|
-
loadApiFunctionsInFlight = internalLoadApiFunctions(viteServer);
|
|
90
|
-
try {
|
|
91
|
-
await loadApiFunctionsInFlight;
|
|
92
|
-
} finally {
|
|
93
|
-
loadApiFunctionsInFlight = null;
|
|
94
|
-
}
|
|
95
|
-
} while (needsReloadAfterInFlight);
|
|
96
|
-
}
|
|
97
|
-
async function internalLoadApiFunctions(viteServer) {
|
|
98
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
99
|
-
for (const key of Object.keys(LAMBDA_FUNCTIONS)) {
|
|
100
|
-
delete LAMBDA_FUNCTIONS[key];
|
|
101
|
-
}
|
|
102
|
-
let srcFunctions = [];
|
|
103
|
-
try {
|
|
104
|
-
srcFunctions = await Array.fromAsync(
|
|
105
|
-
(0, import_promises.glob)("**/*.{ts,tsx,js,jsx}", {
|
|
106
|
-
cwd: cedarPaths.api.functions,
|
|
107
|
-
exclude: [
|
|
108
|
-
"**/*.test.{ts,tsx,js,jsx}",
|
|
109
|
-
"**/*.scenarios.{ts,tsx,js,jsx}",
|
|
110
|
-
"**/*.fixtures.{ts,tsx,js,jsx}",
|
|
111
|
-
"**/*.d.ts"
|
|
112
|
-
]
|
|
113
|
-
}),
|
|
114
|
-
(entry) => import_node_path.default.join(cedarPaths.api.functions, entry)
|
|
115
|
-
);
|
|
116
|
-
} catch {
|
|
117
|
-
srcFunctions = [];
|
|
118
|
-
}
|
|
119
|
-
console.log(import_ansis.default.dim.italic("Importing Server Functions... "));
|
|
120
|
-
const tsImport = Date.now();
|
|
121
|
-
let extractedGraphqlOptions = null;
|
|
122
|
-
const imports = srcFunctions.map(async (fnPath) => {
|
|
123
|
-
const ts = Date.now();
|
|
124
|
-
const routeName = import_node_path.default.basename(fnPath).replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
125
|
-
try {
|
|
126
|
-
const mod = await viteServer.ssrLoadModule((0, import_node_url.pathToFileURL)(fnPath).href);
|
|
127
|
-
const cedarHandler = (() => {
|
|
128
|
-
if ("handleRequest" in mod) {
|
|
129
|
-
return mod.handleRequest;
|
|
130
|
-
}
|
|
131
|
-
if ("default" in mod && mod.default && "handleRequest" in mod.default) {
|
|
132
|
-
return mod.default.handleRequest;
|
|
133
|
-
}
|
|
134
|
-
let legacyHandler;
|
|
135
|
-
if ("handler" in mod) {
|
|
136
|
-
legacyHandler = mod.handler;
|
|
137
|
-
} else if ("default" in mod && mod.default && "handler" in mod.default) {
|
|
138
|
-
legacyHandler = mod.default.handler;
|
|
139
|
-
}
|
|
140
|
-
if (legacyHandler) {
|
|
141
|
-
return (0, import_runtime.wrapLegacyHandler)(legacyHandler);
|
|
142
|
-
}
|
|
143
|
-
return void 0;
|
|
144
|
-
})();
|
|
145
|
-
if (cedarHandler) {
|
|
146
|
-
LAMBDA_FUNCTIONS[routeName] = cedarHandler;
|
|
147
|
-
console.log(
|
|
148
|
-
import_ansis.default.magenta("/" + routeName),
|
|
149
|
-
import_ansis.default.dim.italic(Date.now() - ts + " ms")
|
|
150
|
-
);
|
|
151
|
-
} else {
|
|
152
|
-
console.warn(
|
|
153
|
-
`[apiDevMiddleware] No handler or handleRequest export found in function: ${fnPath}`
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
if (routeName === "graphql" && "__cedar_graphqlOptions" in mod) {
|
|
157
|
-
extractedGraphqlOptions = mod.__cedar_graphqlOptions;
|
|
158
|
-
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
viteServer.ssrFixStacktrace(err);
|
|
161
|
-
console.error(
|
|
162
|
-
`[apiDevMiddleware] Failed to load function "${routeName}" from ${fnPath}:`,
|
|
163
|
-
err
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
await Promise.all(imports);
|
|
168
|
-
if (extractedGraphqlOptions) {
|
|
169
|
-
const { yoga } = await (0, import_graphql_server.createGraphQLYoga)(extractedGraphqlOptions);
|
|
170
|
-
graphqlYoga = yoga;
|
|
171
|
-
} else {
|
|
172
|
-
graphqlYoga = null;
|
|
173
|
-
}
|
|
174
|
-
console.log(
|
|
175
|
-
import_ansis.default.dim.italic("...Done importing in " + (Date.now() - tsImport) + " ms")
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
async function createApiViteServer() {
|
|
179
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
180
|
-
const cedarConfig = (0, import_project_config.getConfig)();
|
|
181
|
-
const normalizedBase = (0, import_vite.normalizePath)(cedarPaths.base);
|
|
182
|
-
const babelPlugins = (0, import_babel_config.getApiSideBabelConfigPath)() ? (0, import_babel_config.getApiSideBabelPluginsForVite)() : null;
|
|
183
|
-
const workspacePkgSourceMap = Object.fromEntries(
|
|
184
|
-
Object.entries((0, import_workspacePackageAliases.getWorkspacePackageAliases)(cedarPaths, cedarConfig)).map(
|
|
185
|
-
([name, sourceFile]) => [name, (0, import_vite.normalizePath)(sourceFile)]
|
|
186
|
-
)
|
|
187
|
-
);
|
|
188
|
-
const { createServer: createViteServer } = await import("vite");
|
|
189
|
-
return createViteServer({
|
|
190
|
-
configFile: false,
|
|
191
|
-
root: cedarPaths.api.base,
|
|
192
|
-
appType: "custom",
|
|
193
|
-
clearScreen: false,
|
|
194
|
-
logLevel: "warn",
|
|
195
|
-
server: {
|
|
196
|
-
middlewareMode: true
|
|
197
|
-
},
|
|
198
|
-
resolve: {
|
|
199
|
-
alias: workspacePkgSourceMap
|
|
200
|
-
},
|
|
201
|
-
plugins: [
|
|
202
|
-
// tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
|
|
203
|
-
// replaces the Babel module-resolver's tsconfig-paths handling for dev.
|
|
204
|
-
tsconfigPaths(),
|
|
205
|
-
(0, import_vite_plugin_cedar_log_formatter_dev.cedarApiLogFormatterDevPlugin)(),
|
|
206
|
-
{
|
|
207
|
-
name: "cedar-api-src-redirect",
|
|
208
|
-
enforce: "pre",
|
|
209
|
-
resolveId(id, importer) {
|
|
210
|
-
const normalizedImporter = importer && (0, import_vite.normalizePath)(importer);
|
|
211
|
-
const normalizedApiSrc = (0, import_vite.normalizePath)(cedarPaths.api.src);
|
|
212
|
-
if (!normalizedImporter?.startsWith(`${normalizedApiSrc}/`)) {
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
if (id.startsWith("src/")) {
|
|
216
|
-
return resolveWithExtensions(
|
|
217
|
-
import_node_path.default.join(cedarPaths.api.src, id.slice(4))
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
(0, import_vite_plugin_cedar_import_dir.cedarImportDirPlugin)(),
|
|
224
|
-
(0, import_vite_plugin_cedar_directory_named_import.cedarDirectoryNamedImportPlugin)(),
|
|
225
|
-
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
226
|
-
(0, import_vite_plugin_cedarjs_job_path_injector.cedarjsJobPathInjectorPlugin)(),
|
|
227
|
-
(() => {
|
|
228
|
-
const p = (0, import_vite_plugin_graphql_tag.gqlPlugin)();
|
|
229
|
-
p.enforce = "post";
|
|
230
|
-
return p;
|
|
231
|
-
})(),
|
|
232
|
-
{
|
|
233
|
-
name: "cedar-api-babel-transform",
|
|
234
|
-
enforce: "pre",
|
|
235
|
-
async transform(code, id) {
|
|
236
|
-
if (!/\.(ts|tsx|js|jsx)$/.test(id)) {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
if (id.includes("node_modules")) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
if (!id.startsWith(normalizedBase)) {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
try {
|
|
246
|
-
let sourceCode = code;
|
|
247
|
-
let sourceMap = null;
|
|
248
|
-
if ((0, import_vite.normalizePath)(id).endsWith("/graphql.ts") || (0, import_vite.normalizePath)(id).endsWith("/graphql.js")) {
|
|
249
|
-
const extracted = (0, import_vite_plugin_cedar_graphql_options_extract.applyGraphqlOptionsExtract)(sourceCode);
|
|
250
|
-
if (extracted) {
|
|
251
|
-
sourceCode = extracted.code;
|
|
252
|
-
sourceMap = extracted.map;
|
|
253
|
-
}
|
|
254
|
-
const injected = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id);
|
|
255
|
-
if (injected) {
|
|
256
|
-
sourceCode = injected;
|
|
257
|
-
sourceMap = null;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
261
|
-
const relativePath = (0, import_vite.normalizePath)(id).slice(
|
|
262
|
-
normalizedBase.length + "/api/src/".length
|
|
263
|
-
);
|
|
264
|
-
const apiFolder = relativePath.split("/")[0] ?? "?";
|
|
265
|
-
const wrapped = (0, import_vite_plugin_cedar_otel_wrapping.applyOtelWrapping)(sourceCode, id, apiFolder);
|
|
266
|
-
if (wrapped) {
|
|
267
|
-
sourceCode = wrapped;
|
|
268
|
-
sourceMap = null;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (!babelPlugins) {
|
|
272
|
-
if (sourceCode === code) {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
code: sourceCode,
|
|
277
|
-
map: sourceMap ?? (0, import_generateDiffSourceMap.generateDiffSourceMap)(code, sourceCode)
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
const inputSourceMap = sourceCode === code ? null : sourceMap ?? (0, import_generateDiffSourceMap.generateDiffSourceMap)(code, sourceCode);
|
|
281
|
-
if (inputSourceMap) {
|
|
282
|
-
inputSourceMap.sources = [id];
|
|
283
|
-
}
|
|
284
|
-
const result = await (0, import_babel_config.transformWithBabel)(
|
|
285
|
-
sourceCode,
|
|
286
|
-
id,
|
|
287
|
-
babelPlugins,
|
|
288
|
-
true,
|
|
289
|
-
true,
|
|
290
|
-
inputSourceMap ?? void 0
|
|
291
|
-
);
|
|
292
|
-
if (!result?.code) {
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
code: result.code,
|
|
297
|
-
map: result.map ?? null
|
|
298
|
-
};
|
|
299
|
-
} catch (err) {
|
|
300
|
-
this.warn(
|
|
301
|
-
`[cedar-api-babel-transform] Failed to transform ${id}: ${String(err)}`
|
|
302
|
-
);
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
]
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
function invalidateApiModules(viteServer, normalizedApiSrc) {
|
|
311
|
-
const invalidated = /* @__PURE__ */ new Set();
|
|
312
|
-
const invalidateWithImporters = (mod) => {
|
|
313
|
-
if (!mod || invalidated.has(mod.id ?? mod.url)) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
invalidated.add(mod.id ?? mod.url);
|
|
317
|
-
viteServer.moduleGraph.invalidateModule(mod);
|
|
318
|
-
for (const importer of mod.importers) {
|
|
319
|
-
invalidateWithImporters(importer);
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
for (const mod of viteServer.moduleGraph.idToModuleMap.values()) {
|
|
323
|
-
if (mod.id?.startsWith(normalizedApiSrc)) {
|
|
324
|
-
invalidateWithImporters(mod);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function setupHmrHandlers(viteServer) {
|
|
329
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
330
|
-
const normalizedApiSrc = (0, import_vite.normalizePath)(cedarPaths.api.src);
|
|
331
|
-
const normalizedApiBase = (0, import_vite.normalizePath)(cedarPaths.api.base);
|
|
332
|
-
viteServer.watcher.on("change", async (filePath) => {
|
|
333
|
-
const normalizedFilePath = (0, import_vite.normalizePath)(filePath);
|
|
334
|
-
if (!normalizedFilePath.startsWith(normalizedApiSrc)) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
const displayPath = import_node_path.default.relative(normalizedApiBase, normalizedFilePath);
|
|
338
|
-
console.log(import_ansis.default.dim(`[change] ${displayPath}`));
|
|
339
|
-
const fileUrl = (0, import_node_url.pathToFileURL)(normalizedFilePath).href;
|
|
340
|
-
const mod = viteServer.moduleGraph.getModuleById(normalizedFilePath) ?? viteServer.moduleGraph.getModuleById(fileUrl);
|
|
341
|
-
if (mod) {
|
|
342
|
-
const invalidated = /* @__PURE__ */ new Set();
|
|
343
|
-
const invalidateWithImporters = (m) => {
|
|
344
|
-
if (!m || invalidated.has(m.id ?? m.url)) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
invalidated.add(m.id ?? m.url);
|
|
348
|
-
viteServer.moduleGraph.invalidateModule(m);
|
|
349
|
-
for (const importer of m.importers) {
|
|
350
|
-
invalidateWithImporters(importer);
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
invalidateWithImporters(mod);
|
|
354
|
-
}
|
|
355
|
-
await loadApiFunctions(viteServer);
|
|
356
|
-
});
|
|
357
|
-
viteServer.watcher.on("add", async (filePath) => {
|
|
358
|
-
const normalizedFilePath = (0, import_vite.normalizePath)(filePath);
|
|
359
|
-
if (!normalizedFilePath.startsWith(normalizedApiSrc)) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
console.log(
|
|
363
|
-
import_ansis.default.dim(
|
|
364
|
-
`[add] ${import_node_path.default.relative(normalizedApiBase, normalizedFilePath)}`
|
|
365
|
-
)
|
|
366
|
-
);
|
|
367
|
-
invalidateApiModules(viteServer, normalizedApiSrc);
|
|
368
|
-
await loadApiFunctions(viteServer);
|
|
369
|
-
});
|
|
370
|
-
viteServer.watcher.on("unlink", async (filePath) => {
|
|
371
|
-
const normalizedFilePath = (0, import_vite.normalizePath)(filePath);
|
|
372
|
-
if (!normalizedFilePath.startsWith(normalizedApiSrc)) {
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
console.log(
|
|
376
|
-
import_ansis.default.dim(
|
|
377
|
-
`[unlink] ${import_node_path.default.relative(normalizedApiBase, normalizedFilePath)}`
|
|
378
|
-
)
|
|
379
|
-
);
|
|
380
|
-
invalidateApiModules(viteServer, normalizedApiSrc);
|
|
381
|
-
await loadApiFunctions(viteServer);
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
function createApiFetchHandler() {
|
|
385
|
-
const cedarConfig = (0, import_project_config.getConfig)();
|
|
386
|
-
const apiUrlPrefix = cedarConfig.web.apiUrl.replace(/\/$/, "");
|
|
387
|
-
return async (request) => {
|
|
388
|
-
const url = new URL(request.url);
|
|
389
|
-
let pathname = url.pathname;
|
|
390
|
-
if (pathname.startsWith(apiUrlPrefix + "/")) {
|
|
391
|
-
pathname = pathname.slice(apiUrlPrefix.length);
|
|
392
|
-
} else if (pathname === apiUrlPrefix) {
|
|
393
|
-
pathname = "/";
|
|
394
|
-
}
|
|
395
|
-
if (pathname === "/graphql" || pathname.startsWith("/graphql/")) {
|
|
396
|
-
if (!graphqlYoga) {
|
|
397
|
-
return new Response(
|
|
398
|
-
JSON.stringify({ error: "GraphQL Yoga instance not initialized" }),
|
|
399
|
-
{ status: 503, headers: { "Content-Type": "application/json" } }
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
const yoga = graphqlYoga;
|
|
403
|
-
return (0, import_store.getAsyncStoreInstance)().run(/* @__PURE__ */ new Map(), async () => {
|
|
404
|
-
try {
|
|
405
|
-
return await yoga.handle(request, { request });
|
|
406
|
-
} catch (e) {
|
|
407
|
-
if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
408
|
-
return new Response(null, { status: 499 });
|
|
409
|
-
}
|
|
410
|
-
throw e;
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
const match = pathname.match(/^\/([^/]+)(?:\/.*)?$/);
|
|
415
|
-
if (!match) {
|
|
416
|
-
return new Response("Not Found", { status: 404 });
|
|
417
|
-
}
|
|
418
|
-
const routeName = match[1];
|
|
419
|
-
const handler = LAMBDA_FUNCTIONS[routeName];
|
|
420
|
-
if (!handler) {
|
|
421
|
-
return new Response(
|
|
422
|
-
JSON.stringify({
|
|
423
|
-
error: `Function "${routeName}" was not found.`,
|
|
424
|
-
availableFunctions: Object.keys(LAMBDA_FUNCTIONS)
|
|
425
|
-
}),
|
|
426
|
-
{ status: 404, headers: { "Content-Type": "application/json" } }
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
try {
|
|
430
|
-
const ctx = await (0, import_runtime.buildCedarContext)(request, {
|
|
431
|
-
params: { routeName }
|
|
432
|
-
});
|
|
433
|
-
return await handler(request, ctx);
|
|
434
|
-
} catch (err) {
|
|
435
|
-
console.error(
|
|
436
|
-
`[apiDevMiddleware] Error handling function "${routeName}":`,
|
|
437
|
-
err
|
|
438
|
-
);
|
|
439
|
-
return new Response(
|
|
440
|
-
JSON.stringify({
|
|
441
|
-
error: err instanceof Error ? err.message : "Internal Server Error"
|
|
442
|
-
}),
|
|
443
|
-
{ status: 500, headers: { "Content-Type": "application/json" } }
|
|
444
|
-
);
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
async function startApiDevMiddleware() {
|
|
449
|
-
const viteServer = await createApiViteServer();
|
|
450
|
-
console.log(import_ansis.default.dim.italic("Starting API dev server..."));
|
|
451
|
-
await loadApiFunctions(viteServer);
|
|
452
|
-
setupHmrHandlers(viteServer);
|
|
453
|
-
const close = async () => {
|
|
454
|
-
await viteServer.close();
|
|
455
|
-
};
|
|
456
|
-
const handler = createApiFetchHandler();
|
|
457
|
-
return { viteServer, close, handler };
|
|
458
|
-
}
|
|
459
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
460
|
-
0 && (module.exports = {
|
|
461
|
-
createApiFetchHandler,
|
|
462
|
-
createApiViteServer,
|
|
463
|
-
loadApiFunctions,
|
|
464
|
-
setupHmrHandlers,
|
|
465
|
-
startApiDevMiddleware
|
|
466
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type * from "../../build/build.d.ts"
|
package/dist/cjs/build/build.js
DELETED
|
@@ -1,58 +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 build_exports = {};
|
|
30
|
-
__export(build_exports, {
|
|
31
|
-
buildCedarApp: () => import_buildApp.buildCedarApp,
|
|
32
|
-
buildWeb: () => buildWeb
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(build_exports);
|
|
35
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
-
var import_buildApp = require("../buildApp.js");
|
|
37
|
-
const buildWeb = async ({ verbose }) => {
|
|
38
|
-
const { build } = await import("vite");
|
|
39
|
-
const viteConfig = (0, import_project_config.getPaths)().web.viteConfig;
|
|
40
|
-
if (process.cwd() !== (0, import_project_config.getPaths)().web.base) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
"Looks like you are running the command from the wrong dir, this can lead to unintended consequences on CSS processing"
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (!viteConfig) {
|
|
46
|
-
throw new Error("Could not locate your web/vite.config.{js,ts} file");
|
|
47
|
-
}
|
|
48
|
-
return build({
|
|
49
|
-
configFile: viteConfig,
|
|
50
|
-
envFile: false,
|
|
51
|
-
logLevel: verbose ? "info" : "warn"
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
buildCedarApp,
|
|
57
|
-
buildWeb
|
|
58
|
-
});
|