@cedarjs/vite 5.0.7-next.336 → 5.0.7-rc.3
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/bins/cedar-vite-dev.mjs +1 -14
- package/dist/api/vite-plugin-cedar-vitest-api-preset.d.ts.map +1 -1
- package/dist/api/vite-plugin-cedar-vitest-api-preset.js +0 -4
- package/dist/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +15 -117
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +18 -77
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +4 -36
- package/dist/bundled/react-server-dom-webpack.server.js +99 -192
- package/dist/cedar-unified-dev.d.ts +0 -19
- package/dist/cedar-unified-dev.d.ts.map +1 -1
- package/dist/cedar-unified-dev.js +9 -74
- package/dist/cjs/ClientRouter.d.ts +1 -0
- package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +37 -0
- package/dist/cjs/apiDevMiddleware.js +371 -0
- package/dist/cjs/build/build.d.ts +1 -0
- package/dist/cjs/build/build.js +58 -0
- package/dist/cjs/buildApp.js +306 -0
- package/dist/cjs/buildFeServer.d.ts +1 -0
- package/dist/cjs/buildFeServer.js +63 -0
- package/dist/cjs/buildRouteHooks.js +80 -0
- package/dist/cjs/buildRouteManifest.js +92 -0
- package/dist/cjs/buildRscClientAndServer.js +54 -0
- package/dist/cjs/cedar-unified-dev.js +310 -0
- package/dist/cjs/client.d.ts +1 -0
- package/dist/cjs/clientSsr.d.ts +1 -0
- package/dist/cjs/devFeServer.js +157 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +141 -0
- package/dist/cjs/lib/StatusError.js +37 -0
- package/dist/cjs/lib/entries.js +52 -0
- package/dist/cjs/lib/getMergedConfig.js +185 -0
- package/dist/cjs/lib/onWarn.js +36 -0
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +102 -0
- package/dist/cjs/lib/workspacePackageAliases.js +107 -0
- package/dist/cjs/middleware/index.js +22 -0
- package/dist/cjs/middleware/invokeMiddleware.js +52 -0
- package/dist/cjs/middleware/register.js +105 -0
- package/dist/cjs/middleware/types.js +16 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/vite-plugin-cedar-auto-import.js +107 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cell.js +183 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +341 -0
- package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +95 -0
- package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +107 -0
- package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +67 -0
- package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +118 -0
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +43 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +61 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +76 -0
- package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +126 -0
- package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +346 -0
- package/dist/cjs/plugins/vite-plugin-cedar-wait-for-api-server.js +134 -0
- package/dist/cjs/plugins/vite-plugin-cedarjs-job-path-injector.js +134 -0
- package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +106 -0
- package/dist/cjs/plugins/vite-plugin-jsx-loader.js +42 -0
- package/dist/cjs/plugins/vite-plugin-merged-config.js +39 -0
- package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +104 -0
- package/dist/cjs/plugins/vite-plugin-rsc-reload.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +159 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +125 -0
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +228 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +398 -0
- package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +46 -0
- package/dist/cjs/rsc/rscBuildAnalyze.js +126 -0
- package/dist/cjs/rsc/rscBuildClient.js +91 -0
- package/dist/cjs/rsc/rscBuildCopyCssAssets.js +56 -0
- package/dist/cjs/rsc/rscBuildEntriesFile.js +115 -0
- package/dist/cjs/rsc/rscBuildForServer.js +168 -0
- package/dist/cjs/rsc/rscBuildForSsr.js +173 -0
- package/dist/cjs/rsc/rscBuildRwEnvVars.js +56 -0
- package/dist/cjs/rsc/rscRenderer.js +165 -0
- package/dist/cjs/rsc/rscRequestHandler.js +162 -0
- package/dist/cjs/rsc/rscStudioHandlers.js +156 -0
- package/dist/cjs/runFeServer.js +165 -0
- package/dist/cjs/streaming/buildForStreamingServer.js +65 -0
- package/dist/cjs/streaming/collectCss.js +52 -0
- package/dist/cjs/streaming/createReactStreamingHandler.js +173 -0
- package/dist/cjs/streaming/streamHelpers.js +230 -0
- package/dist/cjs/streaming/transforms/bufferedTransform.js +61 -0
- package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +34 -0
- package/dist/cjs/streaming/transforms/encode-decode.js +36 -0
- package/dist/cjs/streaming/transforms/serverInjectionTransform.js +84 -0
- package/dist/cjs/streaming/triggerRouteHooks.js +96 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/utils.js +92 -0
- package/dist/devFeServer.js +8 -3
- package/dist/index.d.ts +4 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -51
- package/dist/lib/getMergedConfig.d.ts.map +1 -1
- package/dist/lib/getMergedConfig.js +6 -16
- package/dist/lib/registerFwGlobalsAndShims.d.ts.map +1 -1
- package/dist/lib/registerFwGlobalsAndShims.js +4 -14
- package/dist/package.json +1 -0
- package/dist/plugins/vite-plugin-cedar-auto-import.d.ts +1 -1
- package/dist/plugins/vite-plugin-cedar-auto-import.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-auto-import.js +1 -8
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.js +1 -2
- package/dist/plugins/{vite-plugin-handler-als-wrapping.d.ts → vite-plugin-cedar-context-wrapping.d.ts} +12 -12
- package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/plugins/{vite-plugin-handler-als-wrapping.js → vite-plugin-cedar-context-wrapping.js} +16 -16
- package/dist/plugins/vite-plugin-cedar-import-dir.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-import-dir.js +31 -44
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +19 -0
- package/dist/plugins/vite-plugin-cedar-universal-deploy.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +90 -92
- package/dist/plugins/vite-plugin-cedarjs-job-path-injector.d.ts +0 -29
- package/dist/plugins/vite-plugin-cedarjs-job-path-injector.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedarjs-job-path-injector.js +81 -63
- package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +0 -14
- package/dist/plugins/vite-plugin-rsc-analyze.js +1 -2
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +0 -3
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-swap-apollo-provider.js +2 -2
- package/dist/rsc/rscBuildForSsr.d.ts.map +1 -1
- package/dist/rsc/rscBuildForSsr.js +5 -3
- package/dist/streaming/buildForStreamingServer.d.ts.map +1 -1
- package/dist/streaming/buildForStreamingServer.js +5 -3
- package/package.json +57 -47
- package/dist/jobsDevMiddleware.d.ts +0 -17
- package/dist/jobsDevMiddleware.d.ts.map +0 -1
- package/dist/jobsDevMiddleware.js +0 -106
- package/dist/lib/generateDiffSourceMap.d.ts +0 -18
- package/dist/lib/generateDiffSourceMap.d.ts.map +0 -1
- package/dist/lib/generateDiffSourceMap.js +0 -151
- package/dist/plugins/vite-plugin-cedar-api-import-guard.d.ts +0 -13
- package/dist/plugins/vite-plugin-cedar-api-import-guard.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-api-import-guard.js +0 -17
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +0 -3
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +0 -43
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +0 -12
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-directory-named-import.js +0 -35
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +0 -29
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +0 -76
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +0 -42
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +0 -103
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts +0 -28
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.js +0 -67
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts +0 -28
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.js +0 -247
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +0 -39
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +0 -200
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +0 -1
package/bins/cedar-vite-dev.mjs
CHANGED
|
@@ -16,28 +16,15 @@ const startDevServer = async () => {
|
|
|
16
16
|
// Tries to maintain the same options as vite's dev cli
|
|
17
17
|
// See here: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/cli.ts#L103
|
|
18
18
|
// e.g. yarn cedar dev web --fwd="--force"
|
|
19
|
-
//
|
|
20
|
-
// `force` and `debug` aren't Vite server options, so pull those out.
|
|
21
|
-
// Everything else yargs-parser picks out of argv (e.g. `open`, `port`,
|
|
22
|
-
// `https`, `strictPort`, `cors`) is a forwarded server option and gets
|
|
23
|
-
// passed straight through to Vite's `server` config.
|
|
24
19
|
const {
|
|
25
20
|
force: forceOptimize,
|
|
21
|
+
forwardedServerArgs,
|
|
26
22
|
debug,
|
|
27
|
-
_: _positional,
|
|
28
|
-
...forwardedServerArgs
|
|
29
23
|
} = yargsParser(process.argv.slice(2), {
|
|
30
24
|
boolean: ['https', 'open', 'strictPort', 'force', 'cors', 'debug'],
|
|
31
25
|
number: ['port'],
|
|
32
26
|
})
|
|
33
27
|
|
|
34
|
-
// Default to not auto-opening a browser when there's no interactive
|
|
35
|
-
// terminal attached (CI, AI coding agents, etc.), unless the user
|
|
36
|
-
// explicitly forwarded --open.
|
|
37
|
-
if (forwardedServerArgs.open === undefined && !process.stdout.isTTY) {
|
|
38
|
-
forwardedServerArgs.open = false
|
|
39
|
-
}
|
|
40
|
-
|
|
41
28
|
const devServer = await createServer({
|
|
42
29
|
configFile,
|
|
43
30
|
envFile: false, // env file is handled by plugins in the redwood-vite plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-vitest-api-preset.d.ts","sourceRoot":"","sources":["../../src/api/vite-plugin-cedar-vitest-api-preset.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-vitest-api-preset.d.ts","sourceRoot":"","sources":["../../src/api/vite-plugin-cedar-vitest-api-preset.ts"],"names":[],"mappings":"AAQA,wBAAgB,iBAAiB,kEAOhC"}
|
|
@@ -3,13 +3,9 @@ import {
|
|
|
3
3
|
cedarVitestApiConfigPlugin,
|
|
4
4
|
trackDbImportsPlugin
|
|
5
5
|
} from "@cedarjs/testing/api/vitest";
|
|
6
|
-
import { cedarImportDirPlugin } from "../plugins/vite-plugin-cedar-import-dir.js";
|
|
7
|
-
import { cedarjsJobPathInjectorPlugin } from "../plugins/vite-plugin-cedarjs-job-path-injector.js";
|
|
8
6
|
import { cedarjsResolveCedarStyleImportsPlugin } from "../plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js";
|
|
9
7
|
function cedarVitestPreset() {
|
|
10
8
|
return [
|
|
11
|
-
cedarImportDirPlugin(),
|
|
12
|
-
cedarjsJobPathInjectorPlugin(),
|
|
13
9
|
cedarVitestApiConfigPlugin(),
|
|
14
10
|
autoImportsPlugin(),
|
|
15
11
|
cedarjsResolveCedarStyleImportsPlugin(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,MAAM,CAAA;AA2BrD,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA+GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CAgFlE;AA0BD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CA0EhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,KAIrB,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAoFnD;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC;IACrD,UAAU,EAAE,aAAa,CAAA;IACzB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CACjD,CAAC,CAcD"}
|
package/dist/apiDevMiddleware.js
CHANGED
|
@@ -1,49 +1,19 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import { glob } from "node:fs/promises";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { pathToFileURL } from "node:url";
|
|
5
4
|
import ansis from "ansis";
|
|
6
5
|
import { normalizePath } from "vite";
|
|
7
|
-
import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
|
|
8
|
-
import tsPathsMod from "vite-tsconfig-paths";
|
|
9
|
-
const tsconfigPaths = (
|
|
10
|
-
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
11
|
-
// interop
|
|
12
|
-
tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
|
|
13
|
-
);
|
|
14
6
|
import { buildCedarContext, wrapLegacyHandler } from "@cedarjs/api/runtime";
|
|
15
7
|
import {
|
|
16
|
-
|
|
17
|
-
getApiSideBabelPluginsForVite,
|
|
8
|
+
getApiSideBabelPlugins,
|
|
18
9
|
transformWithBabel
|
|
19
10
|
} from "@cedarjs/babel-config";
|
|
20
11
|
import { getAsyncStoreInstance } from "@cedarjs/context/dist/store";
|
|
21
12
|
import { createGraphQLYoga } from "@cedarjs/graphql-server";
|
|
22
|
-
import {
|
|
23
|
-
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
24
|
-
import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
|
|
13
|
+
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
25
14
|
import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
|
|
26
|
-
import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
|
|
27
|
-
import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
|
|
28
|
-
import { applyGraphqlOptionsExtract } from "./plugins/vite-plugin-cedar-graphql-options-extract.js";
|
|
29
|
-
import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
|
|
30
|
-
import { cedarApiLogFormatterDevPlugin } from "./plugins/vite-plugin-cedar-log-formatter-dev.js";
|
|
31
|
-
import { applyOtelWrapping } from "./plugins/vite-plugin-cedar-otel-wrapping.js";
|
|
32
|
-
import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-path-injector.js";
|
|
33
|
-
function resolveWithExtensions(id) {
|
|
34
|
-
if (fs.existsSync(id) && fs.statSync(id).isFile()) {
|
|
35
|
-
return id;
|
|
36
|
-
}
|
|
37
|
-
for (const ext of [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"]) {
|
|
38
|
-
const withExt = id + ext;
|
|
39
|
-
if (fs.existsSync(withExt)) {
|
|
40
|
-
return withExt;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return id;
|
|
44
|
-
}
|
|
45
15
|
const LAMBDA_FUNCTIONS = {};
|
|
46
|
-
let
|
|
16
|
+
let graphqlYoga = null;
|
|
47
17
|
let loadApiFunctionsInFlight = null;
|
|
48
18
|
let needsReloadAfterInFlight = false;
|
|
49
19
|
async function loadApiFunctions(viteServer) {
|
|
@@ -134,9 +104,9 @@ async function internalLoadApiFunctions(viteServer) {
|
|
|
134
104
|
await Promise.all(imports);
|
|
135
105
|
if (extractedGraphqlOptions) {
|
|
136
106
|
const { yoga } = await createGraphQLYoga(extractedGraphqlOptions);
|
|
137
|
-
|
|
107
|
+
graphqlYoga = yoga;
|
|
138
108
|
} else {
|
|
139
|
-
|
|
109
|
+
graphqlYoga = null;
|
|
140
110
|
}
|
|
141
111
|
console.log(
|
|
142
112
|
ansis.dim.italic("...Done importing in " + (Date.now() - tsImport) + " ms")
|
|
@@ -145,8 +115,12 @@ async function internalLoadApiFunctions(viteServer) {
|
|
|
145
115
|
async function createApiViteServer() {
|
|
146
116
|
const cedarPaths = getPaths();
|
|
147
117
|
const cedarConfig = getConfig();
|
|
118
|
+
const isEsm = projectSideIsEsm("api");
|
|
148
119
|
const normalizedBase = normalizePath(cedarPaths.base);
|
|
149
|
-
const babelPlugins =
|
|
120
|
+
const babelPlugins = getApiSideBabelPlugins({
|
|
121
|
+
openTelemetry: (cedarConfig.experimental?.opentelemetry?.enabled ?? false) && (cedarConfig.experimental?.opentelemetry?.wrapApi ?? false),
|
|
122
|
+
projectIsEsm: isEsm
|
|
123
|
+
});
|
|
150
124
|
const workspacePkgSourceMap = Object.fromEntries(
|
|
151
125
|
Object.entries(getWorkspacePackageAliases(cedarPaths, cedarConfig)).map(
|
|
152
126
|
([name, sourceFile]) => [name, normalizePath(sourceFile)]
|
|
@@ -166,36 +140,6 @@ async function createApiViteServer() {
|
|
|
166
140
|
alias: workspacePkgSourceMap
|
|
167
141
|
},
|
|
168
142
|
plugins: [
|
|
169
|
-
// tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
|
|
170
|
-
// replaces the Babel module-resolver's tsconfig-paths handling for dev.
|
|
171
|
-
tsconfigPaths(),
|
|
172
|
-
cedarApiLogFormatterDevPlugin(),
|
|
173
|
-
{
|
|
174
|
-
name: "cedar-api-src-redirect",
|
|
175
|
-
enforce: "pre",
|
|
176
|
-
resolveId(id, importer) {
|
|
177
|
-
const normalizedImporter = importer && normalizePath(importer);
|
|
178
|
-
const normalizedApiSrc = normalizePath(cedarPaths.api.src);
|
|
179
|
-
if (!normalizedImporter?.startsWith(`${normalizedApiSrc}/`)) {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
if (id.startsWith("src/")) {
|
|
183
|
-
return resolveWithExtensions(
|
|
184
|
-
path.join(cedarPaths.api.src, id.slice(4))
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
cedarImportDirPlugin(),
|
|
191
|
-
cedarDirectoryNamedImportPlugin(),
|
|
192
|
-
cedarAutoImportsPlugin(),
|
|
193
|
-
cedarjsJobPathInjectorPlugin(),
|
|
194
|
-
(() => {
|
|
195
|
-
const p = gqlTagPlugin();
|
|
196
|
-
p.enforce = "post";
|
|
197
|
-
return p;
|
|
198
|
-
})(),
|
|
199
143
|
{
|
|
200
144
|
name: "cedar-api-babel-transform",
|
|
201
145
|
enforce: "pre",
|
|
@@ -209,52 +153,12 @@ async function createApiViteServer() {
|
|
|
209
153
|
if (!id.startsWith(normalizedBase)) {
|
|
210
154
|
return null;
|
|
211
155
|
}
|
|
212
|
-
let sourceCode = code;
|
|
213
|
-
let sourceMap = null;
|
|
214
|
-
if (normalizePath(id).endsWith("/graphql.ts") || normalizePath(id).endsWith("/graphql.js")) {
|
|
215
|
-
const extracted = applyGraphqlOptionsExtract(sourceCode);
|
|
216
|
-
if (extracted) {
|
|
217
|
-
sourceCode = extracted.code;
|
|
218
|
-
sourceMap = extracted.map;
|
|
219
|
-
}
|
|
220
|
-
const injected = applyGqlormInject(sourceCode, id);
|
|
221
|
-
if (injected) {
|
|
222
|
-
sourceCode = injected;
|
|
223
|
-
sourceMap = null;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
156
|
try {
|
|
227
|
-
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
228
|
-
const relativePath = normalizePath(id).slice(
|
|
229
|
-
normalizedBase.length + "/api/src/".length
|
|
230
|
-
);
|
|
231
|
-
const apiFolder = relativePath.split("/")[0] ?? "?";
|
|
232
|
-
const wrapped = applyOtelWrapping(sourceCode, id, apiFolder);
|
|
233
|
-
if (wrapped) {
|
|
234
|
-
sourceCode = wrapped;
|
|
235
|
-
sourceMap = null;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (!babelPlugins) {
|
|
239
|
-
if (sourceCode === code) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
code: sourceCode,
|
|
244
|
-
map: sourceMap ?? generateDiffSourceMap(code, sourceCode)
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
const inputSourceMap = sourceCode === code ? null : sourceMap ?? generateDiffSourceMap(code, sourceCode);
|
|
248
|
-
if (inputSourceMap) {
|
|
249
|
-
inputSourceMap.sources = [id];
|
|
250
|
-
}
|
|
251
157
|
const result = await transformWithBabel(
|
|
252
|
-
|
|
158
|
+
code,
|
|
253
159
|
id,
|
|
254
160
|
babelPlugins,
|
|
255
|
-
true
|
|
256
|
-
true,
|
|
257
|
-
inputSourceMap ?? void 0
|
|
161
|
+
true
|
|
258
162
|
);
|
|
259
163
|
if (!result?.code) {
|
|
260
164
|
return null;
|
|
@@ -360,22 +264,16 @@ function createApiFetchHandler() {
|
|
|
360
264
|
pathname = "/";
|
|
361
265
|
}
|
|
362
266
|
if (pathname === "/graphql" || pathname.startsWith("/graphql/")) {
|
|
363
|
-
|
|
364
|
-
if (!graphqlServer) {
|
|
267
|
+
if (!graphqlYoga) {
|
|
365
268
|
return new Response(
|
|
366
269
|
JSON.stringify({ error: "GraphQL Yoga instance not initialized" }),
|
|
367
270
|
{ status: 503, headers: { "Content-Type": "application/json" } }
|
|
368
271
|
);
|
|
369
272
|
}
|
|
273
|
+
const yoga = graphqlYoga;
|
|
370
274
|
return getAsyncStoreInstance().run(/* @__PURE__ */ new Map(), async () => {
|
|
371
275
|
try {
|
|
372
|
-
|
|
373
|
-
authDecoder: graphqlServer.options.authDecoder
|
|
374
|
-
});
|
|
375
|
-
return await graphqlServer.yoga.handle(request, {
|
|
376
|
-
request,
|
|
377
|
-
cedarContext
|
|
378
|
-
});
|
|
276
|
+
return await yoga.handle(request, { request });
|
|
379
277
|
} catch (e) {
|
|
380
278
|
if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
381
279
|
return new Response(null, { status: 499 });
|
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":"AA+BA,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,iBA8U3B"}
|
package/dist/buildApp.js
CHANGED
|
@@ -3,37 +3,16 @@ import path from "node:path";
|
|
|
3
3
|
import { catchAllEntry, getAllEntries } from "@universal-deploy/store";
|
|
4
4
|
import { catchAll } from "@universal-deploy/vite";
|
|
5
5
|
import { createBuilder, normalizePath } from "vite";
|
|
6
|
-
import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
|
|
7
|
-
import tsPathsMod from "vite-tsconfig-paths";
|
|
8
|
-
const tsconfigPaths = (
|
|
9
|
-
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
10
|
-
// interop
|
|
11
|
-
tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
|
|
12
|
-
);
|
|
13
6
|
import {
|
|
14
|
-
|
|
15
|
-
getApiSideBabelPluginsForVite,
|
|
7
|
+
getApiSideBabelPlugins,
|
|
16
8
|
transformWithBabel
|
|
17
9
|
} from "@cedarjs/babel-config";
|
|
18
|
-
import {
|
|
19
|
-
applyImportExtensions,
|
|
20
|
-
applySrcAlias
|
|
21
|
-
} from "@cedarjs/internal/dist/build/api.js";
|
|
22
10
|
import { findApiFiles } from "@cedarjs/internal/dist/files.js";
|
|
23
11
|
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
24
|
-
import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
|
|
25
12
|
import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
|
|
26
|
-
import {
|
|
27
|
-
import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
|
|
28
|
-
import { cedarGqlormInjectPlugin } from "./plugins/vite-plugin-cedar-gqlorm-inject.js";
|
|
29
|
-
import { cedarGraphqlOptionsExtractPlugin } from "./plugins/vite-plugin-cedar-graphql-options-extract.js";
|
|
30
|
-
import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
|
|
31
|
-
import { cedarMockCellDataPlugin } from "./plugins/vite-plugin-cedar-mock-cell-data.js";
|
|
32
|
-
import { cedarOtelWrappingPlugin } from "./plugins/vite-plugin-cedar-otel-wrapping.js";
|
|
33
|
-
import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-path-injector.js";
|
|
34
|
-
import { handlerAlsWrappingPlugin } from "./plugins/vite-plugin-handler-als-wrapping.js";
|
|
13
|
+
import { cedarContextWrappingPlugin } from "./plugins/vite-plugin-cedar-context-wrapping.js";
|
|
35
14
|
function resolveWithExtensions(id) {
|
|
36
|
-
if (fs.existsSync(id)
|
|
15
|
+
if (fs.existsSync(id)) {
|
|
37
16
|
return id;
|
|
38
17
|
}
|
|
39
18
|
for (const ext of [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"]) {
|
|
@@ -120,19 +99,16 @@ async function buildCedarApp({
|
|
|
120
99
|
};
|
|
121
100
|
}
|
|
122
101
|
}
|
|
102
|
+
const babelPlugins = workspace.includes("api") ? getApiSideBabelPlugins({
|
|
103
|
+
openTelemetry: (cedarConfig.experimental?.opentelemetry?.enabled ?? false) && (cedarConfig.experimental?.opentelemetry?.wrapApi ?? false),
|
|
104
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
105
|
+
}) : null;
|
|
123
106
|
const workspacePkgSourceMap = workspace.includes("api") ? Object.fromEntries(
|
|
124
107
|
Object.entries(getWorkspacePackageAliases(cedarPaths, cedarConfig)).map(
|
|
125
108
|
([name, sourceFile]) => [name, normalizePath(sourceFile)]
|
|
126
109
|
)
|
|
127
110
|
) : {};
|
|
128
111
|
const plugins = [
|
|
129
|
-
tsconfigPaths(),
|
|
130
|
-
cedarAutoImportsPlugin(),
|
|
131
|
-
(() => {
|
|
132
|
-
const p = gqlTagPlugin();
|
|
133
|
-
p.enforce = "post";
|
|
134
|
-
return p;
|
|
135
|
-
})(),
|
|
136
112
|
// Suppress noisy warnings from third-party dependencies across all
|
|
137
113
|
// environments by injecting onwarn into every environment's rollupOptions.
|
|
138
114
|
{
|
|
@@ -235,9 +211,7 @@ async function buildCedarApp({
|
|
|
235
211
|
name: "cedar-api-src-redirect",
|
|
236
212
|
enforce: "pre",
|
|
237
213
|
resolveId(id, importer) {
|
|
238
|
-
|
|
239
|
-
const normalizedApiSrc = normalizePath(cedarPaths.api.src);
|
|
240
|
-
if (!normalizedImporter?.startsWith(`${normalizedApiSrc}/`)) {
|
|
214
|
+
if (!importer?.startsWith(cedarPaths.api.src)) {
|
|
241
215
|
return null;
|
|
242
216
|
}
|
|
243
217
|
if (id.startsWith("src/")) {
|
|
@@ -250,18 +224,11 @@ async function buildCedarApp({
|
|
|
250
224
|
});
|
|
251
225
|
}
|
|
252
226
|
if (workspace.includes("api")) {
|
|
253
|
-
plugins.push(cedarGraphqlOptionsExtractPlugin());
|
|
254
|
-
plugins.push(cedarGqlormInjectPlugin());
|
|
255
|
-
plugins.push(cedarImportDirPlugin());
|
|
256
|
-
plugins.push(cedarDirectoryNamedImportPlugin());
|
|
257
|
-
plugins.push(cedarOtelWrappingPlugin());
|
|
258
|
-
plugins.push(cedarjsJobPathInjectorPlugin());
|
|
259
227
|
plugins.push(
|
|
260
|
-
|
|
228
|
+
cedarContextWrappingPlugin({ projectIsEsm: projectSideIsEsm("api") })
|
|
261
229
|
);
|
|
262
230
|
}
|
|
263
|
-
|
|
264
|
-
if (workspace.includes("api")) {
|
|
231
|
+
if (babelPlugins) {
|
|
265
232
|
plugins.push({
|
|
266
233
|
name: "cedar-vite-api-babel-transform",
|
|
267
234
|
enforce: "pre",
|
|
@@ -275,45 +242,19 @@ async function buildCedarApp({
|
|
|
275
242
|
if (!normalizePath(id).startsWith(normalizePath(cedarPaths.api.base))) {
|
|
276
243
|
return null;
|
|
277
244
|
}
|
|
278
|
-
const babelPlugins = getApiSideBabelConfigPath() ? getApiSideBabelPluginsForVite() : null;
|
|
279
|
-
const fromDirRelativeToApiSrc = path.relative(
|
|
280
|
-
cedarPaths.api.src,
|
|
281
|
-
path.dirname(id)
|
|
282
|
-
);
|
|
283
|
-
const applyImportRewrites = (source) => {
|
|
284
|
-
let rewritten = applySrcAlias(source, fromDirRelativeToApiSrc);
|
|
285
|
-
rewritten = applyImportExtensions(rewritten, id);
|
|
286
|
-
return rewritten;
|
|
287
|
-
};
|
|
288
|
-
const rewrittenCode = applyImportRewrites(code);
|
|
289
|
-
if (!babelPlugins) {
|
|
290
|
-
if (rewrittenCode === code) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
return {
|
|
294
|
-
code: rewrittenCode,
|
|
295
|
-
map: generateDiffSourceMap(code, rewrittenCode)
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
const inputSourceMap = rewrittenCode === code ? null : generateDiffSourceMap(code, rewrittenCode);
|
|
299
|
-
if (inputSourceMap) {
|
|
300
|
-
inputSourceMap.sources = [id];
|
|
301
|
-
}
|
|
302
245
|
const transformedCode = await transformWithBabel(
|
|
303
|
-
|
|
246
|
+
code,
|
|
304
247
|
id,
|
|
305
248
|
babelPlugins,
|
|
306
|
-
true
|
|
307
|
-
true,
|
|
308
|
-
inputSourceMap ?? void 0
|
|
249
|
+
true
|
|
309
250
|
);
|
|
310
|
-
if (
|
|
311
|
-
return
|
|
251
|
+
if (transformedCode?.code) {
|
|
252
|
+
return {
|
|
253
|
+
code: transformedCode.code,
|
|
254
|
+
map: transformedCode.map ?? null
|
|
255
|
+
};
|
|
312
256
|
}
|
|
313
|
-
return
|
|
314
|
-
code: applyImportRewrites(transformedCode.code),
|
|
315
|
-
map: transformedCode.map ?? null
|
|
316
|
-
};
|
|
257
|
+
return null;
|
|
317
258
|
}
|
|
318
259
|
});
|
|
319
260
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGpD,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBA0Cf"}
|
package/dist/buildRouteHooks.js
CHANGED
|
@@ -1,55 +1,26 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
2
|
import { build as esbuildBuild } from "esbuild";
|
|
4
|
-
import { gqlPlugin } from "vite-plugin-graphql-tag";
|
|
5
3
|
import {
|
|
6
4
|
getRouteHookBabelPlugins,
|
|
7
5
|
transformWithBabel
|
|
8
6
|
} from "@cedarjs/babel-config";
|
|
9
7
|
import { findRouteHooksSrc } from "@cedarjs/internal/dist/files.js";
|
|
10
8
|
import { getPaths } from "@cedarjs/project-config";
|
|
11
|
-
const GQL_TAG_PLUGIN_NAME = "rwjs-babel-graphql-tag";
|
|
12
|
-
const gqlPluginResult = gqlPlugin();
|
|
13
|
-
if (!gqlPluginResult || Array.isArray(gqlPluginResult) || !("transform" in gqlPluginResult) || !gqlPluginResult.transform) {
|
|
14
|
-
throw new Error("vite-plugin-graphql-tag did not return the expected shape");
|
|
15
|
-
}
|
|
16
|
-
const transform = gqlPluginResult.transform;
|
|
17
|
-
if (typeof transform !== "object" || !("handler" in transform)) {
|
|
18
|
-
throw new Error("vite-plugin-graphql-tag did not return the expected shape");
|
|
19
|
-
}
|
|
20
|
-
const gqlTransform = transform.handler;
|
|
21
9
|
async function buildRouteHooks(verbose, rwPaths) {
|
|
22
10
|
const allRouteHooks = findRouteHooksSrc();
|
|
23
11
|
const runRwBabelTransformsPlugin = {
|
|
24
|
-
name: "
|
|
12
|
+
name: "rw-esbuild-babel-transform",
|
|
25
13
|
setup(build) {
|
|
26
14
|
build.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
27
15
|
const fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
28
|
-
const babelPlugins = getRouteHookBabelPlugins().filter(
|
|
29
|
-
(p) => !(Array.isArray(p) && p[2] === GQL_TAG_PLUGIN_NAME)
|
|
30
|
-
);
|
|
31
16
|
const transformedCode = await transformWithBabel(
|
|
32
17
|
fileContents,
|
|
33
18
|
args.path,
|
|
34
|
-
|
|
19
|
+
[...getRouteHookBabelPlugins()]
|
|
35
20
|
);
|
|
36
21
|
if (transformedCode?.code) {
|
|
37
|
-
const mockCtx = {
|
|
38
|
-
warn(msg) {
|
|
39
|
-
console.warn(`[gql-plugin] ${msg}`);
|
|
40
|
-
},
|
|
41
|
-
error(err) {
|
|
42
|
-
throw new Error(String(err));
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const gqlResult = await gqlTransform.call(
|
|
46
|
-
mockCtx,
|
|
47
|
-
transformedCode.code,
|
|
48
|
-
args.path
|
|
49
|
-
);
|
|
50
|
-
const gqlCode = gqlResult && typeof gqlResult === "object" && "code" in gqlResult ? gqlResult.code : void 0;
|
|
51
22
|
return {
|
|
52
|
-
contents:
|
|
23
|
+
contents: transformedCode.code,
|
|
53
24
|
loader: "js"
|
|
54
25
|
};
|
|
55
26
|
}
|
|
@@ -70,10 +41,7 @@ async function buildRouteHooks(verbose, rwPaths) {
|
|
|
70
41
|
plugins: [runRwBabelTransformsPlugin],
|
|
71
42
|
packages: "external",
|
|
72
43
|
logLevel: verbose ? "info" : "error",
|
|
73
|
-
outdir: rwPaths.web.distRouteHooks
|
|
74
|
-
alias: {
|
|
75
|
-
"api/src": path.join(getPaths().api.base, "src")
|
|
76
|
-
}
|
|
44
|
+
outdir: rwPaths.web.distRouteHooks
|
|
77
45
|
});
|
|
78
46
|
}
|
|
79
47
|
export {
|