@cedarjs/vite 8.0.0-canary.3489 → 8.0.0-canary.3493

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":"vite-plugin-cedar-mock-cell-data.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-mock-cell-data.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAyKhD;AAcD,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM;;;;;;CAoFxC,CAAA;AAgCD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;CACtD"}
1
+ {"version":3,"file":"vite-plugin-cedar-mock-cell-data.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-mock-cell-data.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAQlC;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAyKhD;AAgDD,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM;;;;;;CAuGxC,CAAA;AAgCD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;CACtD"}
@@ -8,6 +8,7 @@ import fg from "fast-glob";
8
8
  import { parse as graphqlParse, Kind } from "graphql";
9
9
  const traverse = babelTraverse.default ?? babelTraverse;
10
10
  const generate = babelGenerator.default ?? babelGenerator;
11
+ const QUERY_EXPORT_NAME = "QUERY";
11
12
  function cedarMockCellDataPlugin() {
12
13
  return {
13
14
  name: "cedar-mock-cell-data",
@@ -143,6 +144,23 @@ function createExportStandard(babelTypes, ex) {
143
144
  ])
144
145
  );
145
146
  }
147
+ const getQueryCallSource = (init) => {
148
+ let expression = init;
149
+ while (expression?.type === "TSAsExpression" || expression?.type === "TSSatisfiesExpression" || expression?.type === "TSNonNullExpression") {
150
+ expression = expression.expression;
151
+ }
152
+ if (expression?.type !== "CallExpression") {
153
+ return void 0;
154
+ }
155
+ const [source] = expression.arguments;
156
+ if (source?.type === "StringLiteral") {
157
+ return source.value;
158
+ }
159
+ if (source?.type === "TemplateLiteral" && source.expressions.length === 0) {
160
+ return source.quasis[0].value.raw;
161
+ }
162
+ return void 0;
163
+ };
146
164
  const getCellMetadata = (p) => {
147
165
  const ast = getCellAst(p);
148
166
  let hasDefaultExport = false;
@@ -169,6 +187,13 @@ const getCellMetadata = (p) => {
169
187
  return;
170
188
  }
171
189
  if (declaration.type === "VariableDeclaration") {
190
+ const queryDeclarator = declaration.declarations.find(
191
+ (declarator) => declarator.id.type === "Identifier" && declarator.id.name === QUERY_EXPORT_NAME
192
+ );
193
+ const querySource = getQueryCallSource(queryDeclarator?.init);
194
+ if (querySource !== void 0) {
195
+ operation = querySource;
196
+ }
172
197
  const id = declaration.declarations[0].id;
173
198
  namedExports.push({
174
199
  name: id.name,
@@ -187,23 +212,28 @@ const getCellMetadata = (p) => {
187
212
  }
188
213
  },
189
214
  TaggedTemplateExpression(path2) {
190
- if (path2.parent?.id?.name !== "QUERY") {
215
+ if (path2.parent?.id?.name !== QUERY_EXPORT_NAME) {
191
216
  return;
192
217
  }
193
218
  operation = path2.node.quasi.quasis[0].value.raw;
194
219
  }
195
220
  });
196
- const hasQueryExport = namedExports.find(({ name }) => name === "QUERY");
221
+ const hasQueryExport = namedExports.find(
222
+ ({ name }) => name === QUERY_EXPORT_NAME
223
+ );
197
224
  const hasAfterQueryExport = namedExports.find(
198
225
  ({ name }) => name === "afterQuery"
199
226
  );
200
227
  let operationName = "";
201
228
  if (operation) {
202
- const document = graphqlParse(operation);
203
- for (const definition of document.definitions) {
204
- if (definition.kind === Kind.OPERATION_DEFINITION && definition.name?.value) {
205
- operationName = definition.name.value;
229
+ try {
230
+ const document = graphqlParse(operation);
231
+ for (const definition of document.definitions) {
232
+ if (definition.kind === Kind.OPERATION_DEFINITION && definition.name?.value) {
233
+ operationName = definition.name.value;
234
+ }
206
235
  }
236
+ } catch {
207
237
  }
208
238
  }
209
239
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "8.0.0-canary.3489",
3
+ "version": "8.0.0-canary.3493",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -54,17 +54,17 @@
54
54
  "@babel/preset-typescript": "7.29.7",
55
55
  "@babel/traverse": "7.29.10",
56
56
  "@babel/types": "7.29.8",
57
- "@cedarjs/api": "8.0.0-canary.3489",
58
- "@cedarjs/api-server": "8.0.0-canary.3489",
59
- "@cedarjs/babel-config": "8.0.0-canary.3489",
60
- "@cedarjs/context": "8.0.0-canary.3489",
61
- "@cedarjs/graphql-server": "8.0.0-canary.3489",
62
- "@cedarjs/internal": "8.0.0-canary.3489",
63
- "@cedarjs/jobs": "8.0.0-canary.3489",
64
- "@cedarjs/project-config": "8.0.0-canary.3489",
65
- "@cedarjs/server-store": "8.0.0-canary.3489",
66
- "@cedarjs/structure": "8.0.0-canary.3489",
67
- "@cedarjs/testing": "8.0.0-canary.3489",
57
+ "@cedarjs/api": "8.0.0-canary.3493",
58
+ "@cedarjs/api-server": "8.0.0-canary.3493",
59
+ "@cedarjs/babel-config": "8.0.0-canary.3493",
60
+ "@cedarjs/context": "8.0.0-canary.3493",
61
+ "@cedarjs/graphql-server": "8.0.0-canary.3493",
62
+ "@cedarjs/internal": "8.0.0-canary.3493",
63
+ "@cedarjs/jobs": "8.0.0-canary.3493",
64
+ "@cedarjs/project-config": "8.0.0-canary.3493",
65
+ "@cedarjs/server-store": "8.0.0-canary.3493",
66
+ "@cedarjs/structure": "8.0.0-canary.3493",
67
+ "@cedarjs/testing": "8.0.0-canary.3493",
68
68
  "@swc/core": "1.16.18",
69
69
  "@universal-deploy/store": "^0.3.0",
70
70
  "@universal-deploy/vite": "^0.2.0",
@@ -94,10 +94,10 @@
94
94
  "yargs-parser": "21.1.1"
95
95
  },
96
96
  "devDependencies": {
97
- "@cedarjs/auth": "8.0.0-canary.3489",
98
- "@cedarjs/framework-tools": "8.0.0-canary.3489",
99
- "@cedarjs/router": "8.0.0-canary.3489",
100
- "@cedarjs/web": "8.0.0-canary.3489",
97
+ "@cedarjs/auth": "8.0.0-canary.3493",
98
+ "@cedarjs/framework-tools": "8.0.0-canary.3493",
99
+ "@cedarjs/router": "8.0.0-canary.3493",
100
+ "@cedarjs/web": "8.0.0-canary.3493",
101
101
  "@dr.pogodin/react-helmet": "2.0.4",
102
102
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",
103
103
  "@jridgewell/trace-mapping": "0.3.31",
@@ -119,9 +119,9 @@
119
119
  "vitest": "4.1.12"
120
120
  },
121
121
  "peerDependencies": {
122
- "@cedarjs/auth": "8.0.0-canary.3489",
123
- "@cedarjs/router": "8.0.0-canary.3489",
124
- "@cedarjs/web": "8.0.0-canary.3489",
122
+ "@cedarjs/auth": "8.0.0-canary.3493",
123
+ "@cedarjs/router": "8.0.0-canary.3493",
124
+ "@cedarjs/web": "8.0.0-canary.3493",
125
125
  "react": "19.3.1",
126
126
  "react-dom": "19.3.1"
127
127
  },