@cedarjs/vite 5.0.7-next.186 → 5.0.7-next.219

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.
@@ -1 +1 @@
1
- {"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAA;AA4E7D,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA+GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CAoMlE;AA0BD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CA0EhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,KAIrB,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAmGnD;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"}
1
+ {"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAA;AA4E7D,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA+GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CAyMlE;AA0BD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CA0EhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,KAIrB,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAmGnD;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"}
@@ -209,21 +209,21 @@ async function createApiViteServer() {
209
209
  if (!id.startsWith(normalizedBase)) {
210
210
  return null;
211
211
  }
212
- try {
213
- let sourceCode = code;
214
- let sourceMap = null;
215
- if (normalizePath(id).endsWith("/graphql.ts") || normalizePath(id).endsWith("/graphql.js")) {
216
- const extracted = applyGraphqlOptionsExtract(sourceCode);
217
- if (extracted) {
218
- sourceCode = extracted.code;
219
- sourceMap = extracted.map;
220
- }
221
- const injected = applyGqlormInject(sourceCode, id);
222
- if (injected) {
223
- sourceCode = injected;
224
- sourceMap = null;
225
- }
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;
226
219
  }
220
+ const injected = applyGqlormInject(sourceCode, id);
221
+ if (injected) {
222
+ sourceCode = injected;
223
+ sourceMap = null;
224
+ }
225
+ }
226
+ try {
227
227
  if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
228
228
  const relativePath = normalizePath(id).slice(
229
229
  normalizedBase.length + "/api/src/".length
@@ -1 +1 @@
1
- {"version":3,"file":"getMergedConfig.d.ts","sourceRoot":"","sources":["../../src/lib/getMergedConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAS5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,IAC5D,YAAY,cAAc,EAAE,KAAK,SAAS,KAAG,cAAc,CAgIpE"}
1
+ {"version":3,"file":"getMergedConfig.d.ts","sourceRoot":"","sources":["../../src/lib/getMergedConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAW5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,IAC5D,YAAY,cAAc,EAAE,KAAK,SAAS,KAAG,cAAc,CAyIpE"}
@@ -3,20 +3,26 @@ import { mergeConfig } from "vite";
3
3
  import {
4
4
  getConfig,
5
5
  getEnvVarDefinitions,
6
- getPaths
6
+ getPaths,
7
+ parsePort,
8
+ readEnvVar
7
9
  } from "@cedarjs/project-config";
8
10
  import { getWorkspacePackageAliases } from "./workspacePackageAliases.js";
9
11
  function getMergedConfig(cedarConfig, cedarPaths) {
10
12
  return (userConfig, env) => {
11
13
  const workspaceAliases = env.command === "serve" ? getWorkspacePackageAliases(cedarPaths, cedarConfig) : {};
12
- let apiHost = process.env.REDWOOD_API_HOST;
13
- apiHost ??= cedarConfig.api.host;
14
- apiHost ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "127.0.0.1";
14
+ const hostEnv = readEnvVar("CEDAR_API_HOST", {
15
+ deprecatedAlias: "REDWOOD_API_HOST"
16
+ });
17
+ const apiHost = hostEnv ?? cedarConfig.api.host ?? "127.0.0.1";
15
18
  const streamingSsrEnabled = cedarConfig.experimental.streamingSsr?.enabled;
16
19
  const rscEnabled = cedarConfig.experimental.rsc?.enabled;
20
+ const apiPortEnvVar = readEnvVar("CEDAR_API_PORT", {
21
+ deprecatedAlias: "REDWOOD_API_PORT"
22
+ });
17
23
  let apiPort;
18
- if (process.env.REDWOOD_API_PORT) {
19
- apiPort = parseInt(process.env.REDWOOD_API_PORT);
24
+ if (apiPortEnvVar) {
25
+ apiPort = parsePort(apiPortEnvVar, "CEDAR_API_PORT");
20
26
  } else {
21
27
  apiPort = cedarConfig.api.port;
22
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"registerFwGlobalsAndShims.d.ts","sourceRoot":"","sources":["../../src/lib/registerFwGlobalsAndShims.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,YAGrC,CAAA"}
1
+ {"version":3,"file":"registerFwGlobalsAndShims.d.ts","sourceRoot":"","sources":["../../src/lib/registerFwGlobalsAndShims.ts"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,YAGrC,CAAA"}
@@ -1,5 +1,10 @@
1
1
  import { createRequire } from "node:module";
2
- import { getConfig, getEnvVarDefinitions } from "@cedarjs/project-config";
2
+ import {
3
+ getConfig,
4
+ getEnvVarDefinitions,
5
+ parsePort,
6
+ readEnvVar
7
+ } from "@cedarjs/project-config";
3
8
  const registerFwGlobalsAndShims = () => {
4
9
  registerFwGlobals();
5
10
  registerFwShims();
@@ -14,12 +19,17 @@ function registerFwGlobals() {
14
19
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(apiPath)) {
15
20
  return apiPath;
16
21
  } else {
17
- let webHost = process.env.REDWOOD_WEB_HOST;
22
+ let webHost = readEnvVar("CEDAR_WEB_HOST", {
23
+ deprecatedAlias: "REDWOOD_WEB_HOST"
24
+ });
18
25
  webHost ??= rwConfig.web.host;
19
26
  webHost ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "[::]";
27
+ const webPortEnvVar = readEnvVar("CEDAR_WEB_PORT", {
28
+ deprecatedAlias: "REDWOOD_WEB_PORT"
29
+ });
20
30
  let webPort;
21
- if (process.env.REDWOOD_WEB_PORT) {
22
- webPort = parseInt(process.env.REDWOOD_WEB_PORT);
31
+ if (webPortEnvVar) {
32
+ webPort = parsePort(webPortEnvVar, "CEDAR_WEB_PORT");
23
33
  } else {
24
34
  webPort = rwConfig.web.port;
25
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CA2BzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAgGzC"}
1
+ {"version":3,"file":"vite-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CA2BzD;AAQD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAiHzC"}
@@ -21,6 +21,8 @@ function cedarGraphqlOptionsExtractPlugin() {
21
21
  }
22
22
  };
23
23
  }
24
+ const GRAPHQL_OPTIONS_ERROR_PREFIX = "Could not read the GraphQL options in api/src/functions/graphql. Cedar needs to statically extract them so the api server can serve /graphql and its health endpoint. ";
25
+ const GRAPHQL_OPTIONS_ERROR_SUFFIX = " Expected a single `createGraphQLHandler({ ... })` call with the options passed directly as an object, an identifier, a call, or a ternary.";
24
26
  function applyGraphqlOptionsExtract(code) {
25
27
  if (code.includes("__cedar_graphqlOptions")) {
26
28
  return null;
@@ -56,18 +58,26 @@ function applyGraphqlOptionsExtract(code) {
56
58
  }
57
59
  }).visit(program);
58
60
  if (callExpressionPaths.length > 1) {
59
- return null;
61
+ throw new Error(
62
+ GRAPHQL_OPTIONS_ERROR_PREFIX + "Found more than one call to createGraphQLHandler." + GRAPHQL_OPTIONS_ERROR_SUFFIX
63
+ );
60
64
  }
61
65
  const callExpression = callExpressionPaths[0];
62
66
  if (!callExpression) {
63
- return null;
67
+ throw new Error(
68
+ GRAPHQL_OPTIONS_ERROR_PREFIX + "createGraphQLHandler is imported but never called." + GRAPHQL_OPTIONS_ERROR_SUFFIX
69
+ );
64
70
  }
65
71
  const options = callExpression.arguments[0];
66
72
  if (!options) {
67
- return null;
73
+ throw new Error(
74
+ GRAPHQL_OPTIONS_ERROR_PREFIX + "createGraphQLHandler was called without any options." + GRAPHQL_OPTIONS_ERROR_SUFFIX
75
+ );
68
76
  }
69
77
  if (options.type !== "Identifier" && options.type !== "ObjectExpression" && options.type !== "CallExpression" && options.type !== "ConditionalExpression") {
70
- return null;
78
+ throw new Error(
79
+ GRAPHQL_OPTIONS_ERROR_PREFIX + `The options argument is a ${options.type}, which can't be read statically.` + GRAPHQL_OPTIONS_ERROR_SUFFIX
80
+ );
71
81
  }
72
82
  const optionsStart = options.start;
73
83
  const optionsEnd = options.end;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "5.0.7-next.186",
3
+ "version": "5.0.7-next.219",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -52,16 +52,16 @@
52
52
  "@babel/parser": "7.29.7",
53
53
  "@babel/traverse": "7.29.7",
54
54
  "@babel/types": "7.29.7",
55
- "@cedarjs/api": "5.0.7-next.186",
56
- "@cedarjs/api-server": "5.0.7-next.186",
57
- "@cedarjs/babel-config": "5.0.7-next.186",
58
- "@cedarjs/context": "5.0.7-next.186",
59
- "@cedarjs/graphql-server": "5.0.7-next.186",
60
- "@cedarjs/internal": "5.0.7-next.186",
61
- "@cedarjs/project-config": "5.0.7-next.186",
62
- "@cedarjs/server-store": "5.0.7-next.186",
63
- "@cedarjs/structure": "5.0.7-next.186",
64
- "@cedarjs/testing": "5.0.7-next.186",
55
+ "@cedarjs/api": "5.0.7-next.219",
56
+ "@cedarjs/api-server": "5.0.7-next.219",
57
+ "@cedarjs/babel-config": "5.0.7-next.219",
58
+ "@cedarjs/context": "5.0.7-next.219",
59
+ "@cedarjs/graphql-server": "5.0.7-next.219",
60
+ "@cedarjs/internal": "5.0.7-next.219",
61
+ "@cedarjs/project-config": "5.0.7-next.219",
62
+ "@cedarjs/server-store": "5.0.7-next.219",
63
+ "@cedarjs/structure": "5.0.7-next.219",
64
+ "@cedarjs/testing": "5.0.7-next.219",
65
65
  "@swc/core": "1.15.46",
66
66
  "@universal-deploy/store": "^0.2.1",
67
67
  "@universal-deploy/vite": "^0.1.9",
@@ -92,10 +92,10 @@
92
92
  "yargs-parser": "21.1.1"
93
93
  },
94
94
  "devDependencies": {
95
- "@cedarjs/auth": "5.0.7-next.186",
96
- "@cedarjs/framework-tools": "5.0.7-next.186",
97
- "@cedarjs/router": "5.0.7-next.186",
98
- "@cedarjs/web": "5.0.7-next.186",
95
+ "@cedarjs/auth": "5.0.7-next.219",
96
+ "@cedarjs/framework-tools": "5.0.7-next.219",
97
+ "@cedarjs/router": "5.0.7-next.219",
98
+ "@cedarjs/web": "5.0.7-next.219",
99
99
  "@dr.pogodin/react-helmet": "2.0.4",
100
100
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",
101
101
  "@jridgewell/trace-mapping": "0.3.31",
@@ -115,9 +115,9 @@
115
115
  "vitest": "4.1.10"
116
116
  },
117
117
  "peerDependencies": {
118
- "@cedarjs/auth": "5.0.7-next.186",
119
- "@cedarjs/router": "5.0.7-next.186",
120
- "@cedarjs/web": "5.0.7-next.186"
118
+ "@cedarjs/auth": "5.0.7-next.219",
119
+ "@cedarjs/router": "5.0.7-next.219",
120
+ "@cedarjs/web": "5.0.7-next.219"
121
121
  },
122
122
  "engines": {
123
123
  "node": ">=24"