@cedarjs/vite 6.0.0-canary.2632 → 6.0.0-canary.2635
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/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +11 -1
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +9 -0
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +31 -6
- package/dist/cjs/apiDevMiddleware.js +11 -1
- package/dist/cjs/buildApp.js +9 -0
- package/dist/cjs/buildRouteHooks.js +31 -6
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/plugins/vite-plugin-cedar-graphql-options-extract.js +22 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +7 -3
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +12 -7
- package/dist/rsc/rscBuildClient.d.ts +1 -1
- package/dist/rsc/rscBuildForServer.d.ts +1 -1
- package/dist/rsc/rscBuildForSsr.d.ts +1 -1
- package/package.json +15 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAA;AAgC7D,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA+GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CA8GlE;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
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import ansis from "ansis";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
|
+
import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
|
|
6
7
|
import { buildCedarContext, wrapLegacyHandler } from "@cedarjs/api/runtime";
|
|
7
8
|
import {
|
|
8
9
|
getApiSideBabelPlugins,
|
|
@@ -13,6 +14,7 @@ import { createGraphQLYoga } from "@cedarjs/graphql-server";
|
|
|
13
14
|
import { applyGqlormInject } from "@cedarjs/internal/dist/build/api-graphql-transforms.js";
|
|
14
15
|
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
15
16
|
import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
|
|
17
|
+
import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
|
|
16
18
|
import { applyGraphqlOptionsExtract } from "./plugins/vite-plugin-cedar-graphql-options-extract.js";
|
|
17
19
|
import { applyOtelWrapping } from "./plugins/vite-plugin-cedar-otel-wrapping.js";
|
|
18
20
|
const LAMBDA_FUNCTIONS = {};
|
|
@@ -121,6 +123,7 @@ async function createApiViteServer() {
|
|
|
121
123
|
const isEsm = projectSideIsEsm("api");
|
|
122
124
|
const normalizedBase = normalizePath(cedarPaths.base);
|
|
123
125
|
const babelPlugins = getApiSideBabelPlugins({
|
|
126
|
+
forVite: true,
|
|
124
127
|
projectIsEsm: isEsm
|
|
125
128
|
});
|
|
126
129
|
const workspacePkgSourceMap = Object.fromEntries(
|
|
@@ -142,6 +145,12 @@ async function createApiViteServer() {
|
|
|
142
145
|
alias: workspacePkgSourceMap
|
|
143
146
|
},
|
|
144
147
|
plugins: [
|
|
148
|
+
cedarAutoImportsPlugin(),
|
|
149
|
+
(() => {
|
|
150
|
+
const p = gqlTagPlugin();
|
|
151
|
+
p.enforce = "post";
|
|
152
|
+
return p;
|
|
153
|
+
})(),
|
|
145
154
|
{
|
|
146
155
|
name: "cedar-api-babel-transform",
|
|
147
156
|
enforce: "pre",
|
|
@@ -158,7 +167,8 @@ async function createApiViteServer() {
|
|
|
158
167
|
try {
|
|
159
168
|
let sourceCode = code;
|
|
160
169
|
if (normalizePath(id).endsWith("/graphql.ts") || normalizePath(id).endsWith("/graphql.js")) {
|
|
161
|
-
|
|
170
|
+
const extracted = applyGraphqlOptionsExtract(sourceCode);
|
|
171
|
+
sourceCode = extracted?.code ?? sourceCode;
|
|
162
172
|
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
163
173
|
}
|
|
164
174
|
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
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+CA,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,iBAwV3B"}
|
package/dist/buildApp.js
CHANGED
|
@@ -3,6 +3,7 @@ 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";
|
|
6
7
|
import tsPathsMod from "vite-tsconfig-paths";
|
|
7
8
|
const tsconfigPaths = (
|
|
8
9
|
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
import { findApiFiles } from "@cedarjs/internal/dist/files.js";
|
|
17
18
|
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
18
19
|
import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
|
|
20
|
+
import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
|
|
19
21
|
import { cedarGqlormInjectPlugin } from "./plugins/vite-plugin-cedar-gqlorm-inject.js";
|
|
20
22
|
import { cedarGraphqlOptionsExtractPlugin } from "./plugins/vite-plugin-cedar-graphql-options-extract.js";
|
|
21
23
|
import { cedarMockCellDataPlugin } from "./plugins/vite-plugin-cedar-mock-cell-data.js";
|
|
@@ -110,6 +112,7 @@ async function buildCedarApp({
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
const babelPlugins = workspace.includes("api") ? getApiSideBabelPlugins({
|
|
115
|
+
forVite: true,
|
|
113
116
|
projectIsEsm: projectSideIsEsm("api")
|
|
114
117
|
}) : null;
|
|
115
118
|
const workspacePkgSourceMap = workspace.includes("api") ? Object.fromEntries(
|
|
@@ -119,6 +122,12 @@ async function buildCedarApp({
|
|
|
119
122
|
) : {};
|
|
120
123
|
const plugins = [
|
|
121
124
|
tsconfigPaths(),
|
|
125
|
+
cedarAutoImportsPlugin(),
|
|
126
|
+
(() => {
|
|
127
|
+
const p = gqlTagPlugin();
|
|
128
|
+
p.enforce = "post";
|
|
129
|
+
return p;
|
|
130
|
+
})(),
|
|
122
131
|
// Suppress noisy warnings from third-party dependencies across all
|
|
123
132
|
// environments by injecting onwarn into every environment's rollupOptions.
|
|
124
133
|
{
|
|
@@ -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":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AA2BpD,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBA+Ef"}
|
package/dist/buildRouteHooks.js
CHANGED
|
@@ -1,27 +1,55 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { build as esbuildBuild } from "esbuild";
|
|
4
|
+
import { gqlPlugin } from "vite-plugin-graphql-tag";
|
|
4
5
|
import {
|
|
5
6
|
getRouteHookBabelPlugins,
|
|
6
7
|
transformWithBabel
|
|
7
8
|
} from "@cedarjs/babel-config";
|
|
8
9
|
import { findRouteHooksSrc } from "@cedarjs/internal/dist/files.js";
|
|
9
10
|
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;
|
|
10
21
|
async function buildRouteHooks(verbose, rwPaths) {
|
|
11
22
|
const allRouteHooks = findRouteHooksSrc();
|
|
12
23
|
const runRwBabelTransformsPlugin = {
|
|
13
|
-
name: "
|
|
24
|
+
name: "cedar-esbuild-babel-transform",
|
|
14
25
|
setup(build) {
|
|
15
26
|
build.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
16
27
|
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
|
+
);
|
|
17
31
|
const transformedCode = await transformWithBabel(
|
|
18
32
|
fileContents,
|
|
19
33
|
args.path,
|
|
20
|
-
|
|
34
|
+
babelPlugins
|
|
21
35
|
);
|
|
22
36
|
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;
|
|
23
51
|
return {
|
|
24
|
-
contents: transformedCode.code,
|
|
52
|
+
contents: gqlCode ?? transformedCode.code,
|
|
25
53
|
loader: "js"
|
|
26
54
|
};
|
|
27
55
|
}
|
|
@@ -44,9 +72,6 @@ async function buildRouteHooks(verbose, rwPaths) {
|
|
|
44
72
|
logLevel: verbose ? "info" : "error",
|
|
45
73
|
outdir: rwPaths.web.distRouteHooks,
|
|
46
74
|
alias: {
|
|
47
|
-
// Lift the `api/src` → real api src resolution that was previously
|
|
48
|
-
// handled by `babel-plugin-module-resolver`. The Babel plugin has been
|
|
49
|
-
// removed from `getRouteHookBabelPlugins`; esbuild handles this now.
|
|
50
75
|
"api/src": path.join(getPaths().api.base, "src")
|
|
51
76
|
}
|
|
52
77
|
});
|
|
@@ -40,6 +40,7 @@ var import_node_path = __toESM(require("node:path"), 1);
|
|
|
40
40
|
var import_node_url = require("node:url");
|
|
41
41
|
var import_ansis = __toESM(require("ansis"), 1);
|
|
42
42
|
var import_vite = require("vite");
|
|
43
|
+
var import_vite_plugin_graphql_tag = require("vite-plugin-graphql-tag");
|
|
43
44
|
var import_runtime = require("@cedarjs/api/runtime");
|
|
44
45
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
45
46
|
var import_store = require("@cedarjs/context/dist/store");
|
|
@@ -47,6 +48,7 @@ var import_graphql_server = require("@cedarjs/graphql-server");
|
|
|
47
48
|
var import_api_graphql_transforms = require("@cedarjs/internal/dist/build/api-graphql-transforms.js");
|
|
48
49
|
var import_project_config = require("@cedarjs/project-config");
|
|
49
50
|
var import_workspacePackageAliases = require("./lib/workspacePackageAliases.js");
|
|
51
|
+
var import_vite_plugin_cedar_auto_import = require("./plugins/vite-plugin-cedar-auto-import.js");
|
|
50
52
|
var import_vite_plugin_cedar_graphql_options_extract = require("./plugins/vite-plugin-cedar-graphql-options-extract.js");
|
|
51
53
|
var import_vite_plugin_cedar_otel_wrapping = require("./plugins/vite-plugin-cedar-otel-wrapping.js");
|
|
52
54
|
const LAMBDA_FUNCTIONS = {};
|
|
@@ -155,6 +157,7 @@ async function createApiViteServer() {
|
|
|
155
157
|
const isEsm = (0, import_project_config.projectSideIsEsm)("api");
|
|
156
158
|
const normalizedBase = (0, import_vite.normalizePath)(cedarPaths.base);
|
|
157
159
|
const babelPlugins = (0, import_babel_config.getApiSideBabelPlugins)({
|
|
160
|
+
forVite: true,
|
|
158
161
|
projectIsEsm: isEsm
|
|
159
162
|
});
|
|
160
163
|
const workspacePkgSourceMap = Object.fromEntries(
|
|
@@ -176,6 +179,12 @@ async function createApiViteServer() {
|
|
|
176
179
|
alias: workspacePkgSourceMap
|
|
177
180
|
},
|
|
178
181
|
plugins: [
|
|
182
|
+
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
183
|
+
(() => {
|
|
184
|
+
const p = (0, import_vite_plugin_graphql_tag.gqlPlugin)();
|
|
185
|
+
p.enforce = "post";
|
|
186
|
+
return p;
|
|
187
|
+
})(),
|
|
179
188
|
{
|
|
180
189
|
name: "cedar-api-babel-transform",
|
|
181
190
|
enforce: "pre",
|
|
@@ -192,7 +201,8 @@ async function createApiViteServer() {
|
|
|
192
201
|
try {
|
|
193
202
|
let sourceCode = code;
|
|
194
203
|
if ((0, import_vite.normalizePath)(id).endsWith("/graphql.ts") || (0, import_vite.normalizePath)(id).endsWith("/graphql.js")) {
|
|
195
|
-
|
|
204
|
+
const extracted = (0, import_vite_plugin_cedar_graphql_options_extract.applyGraphqlOptionsExtract)(sourceCode);
|
|
205
|
+
sourceCode = extracted?.code ?? sourceCode;
|
|
196
206
|
sourceCode = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id) ?? sourceCode;
|
|
197
207
|
}
|
|
198
208
|
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
package/dist/cjs/buildApp.js
CHANGED
|
@@ -36,11 +36,13 @@ var import_node_path = __toESM(require("node:path"), 1);
|
|
|
36
36
|
var import_store = require("@universal-deploy/store");
|
|
37
37
|
var import_vite = require("@universal-deploy/vite");
|
|
38
38
|
var import_vite2 = require("vite");
|
|
39
|
+
var import_vite_plugin_graphql_tag = require("vite-plugin-graphql-tag");
|
|
39
40
|
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
40
41
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
41
42
|
var import_files = require("@cedarjs/internal/dist/files.js");
|
|
42
43
|
var import_project_config = require("@cedarjs/project-config");
|
|
43
44
|
var import_workspacePackageAliases = require("./lib/workspacePackageAliases.js");
|
|
45
|
+
var import_vite_plugin_cedar_auto_import = require("./plugins/vite-plugin-cedar-auto-import.js");
|
|
44
46
|
var import_vite_plugin_cedar_gqlorm_inject = require("./plugins/vite-plugin-cedar-gqlorm-inject.js");
|
|
45
47
|
var import_vite_plugin_cedar_graphql_options_extract = require("./plugins/vite-plugin-cedar-graphql-options-extract.js");
|
|
46
48
|
var import_vite_plugin_cedar_mock_cell_data = require("./plugins/vite-plugin-cedar-mock-cell-data.js");
|
|
@@ -140,6 +142,7 @@ async function buildCedarApp({
|
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
const babelPlugins = workspace.includes("api") ? (0, import_babel_config.getApiSideBabelPlugins)({
|
|
145
|
+
forVite: true,
|
|
143
146
|
projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
|
|
144
147
|
}) : null;
|
|
145
148
|
const workspacePkgSourceMap = workspace.includes("api") ? Object.fromEntries(
|
|
@@ -149,6 +152,12 @@ async function buildCedarApp({
|
|
|
149
152
|
) : {};
|
|
150
153
|
const plugins = [
|
|
151
154
|
tsconfigPaths(),
|
|
155
|
+
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
156
|
+
(() => {
|
|
157
|
+
const p = (0, import_vite_plugin_graphql_tag.gqlPlugin)();
|
|
158
|
+
p.enforce = "post";
|
|
159
|
+
return p;
|
|
160
|
+
})(),
|
|
152
161
|
// Suppress noisy warnings from third-party dependencies across all
|
|
153
162
|
// environments by injecting onwarn into every environment's rollupOptions.
|
|
154
163
|
{
|
|
@@ -34,24 +34,52 @@ module.exports = __toCommonJS(buildRouteHooks_exports);
|
|
|
34
34
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
35
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
36
|
var import_esbuild = require("esbuild");
|
|
37
|
+
var import_vite_plugin_graphql_tag = require("vite-plugin-graphql-tag");
|
|
37
38
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
38
39
|
var import_files = require("@cedarjs/internal/dist/files.js");
|
|
39
40
|
var import_project_config = require("@cedarjs/project-config");
|
|
41
|
+
const GQL_TAG_PLUGIN_NAME = "rwjs-babel-graphql-tag";
|
|
42
|
+
const gqlPluginResult = (0, import_vite_plugin_graphql_tag.gqlPlugin)();
|
|
43
|
+
if (!gqlPluginResult || Array.isArray(gqlPluginResult) || !("transform" in gqlPluginResult) || !gqlPluginResult.transform) {
|
|
44
|
+
throw new Error("vite-plugin-graphql-tag did not return the expected shape");
|
|
45
|
+
}
|
|
46
|
+
const transform = gqlPluginResult.transform;
|
|
47
|
+
if (typeof transform !== "object" || !("handler" in transform)) {
|
|
48
|
+
throw new Error("vite-plugin-graphql-tag did not return the expected shape");
|
|
49
|
+
}
|
|
50
|
+
const gqlTransform = transform.handler;
|
|
40
51
|
async function buildRouteHooks(verbose, rwPaths) {
|
|
41
52
|
const allRouteHooks = (0, import_files.findRouteHooksSrc)();
|
|
42
53
|
const runRwBabelTransformsPlugin = {
|
|
43
|
-
name: "
|
|
54
|
+
name: "cedar-esbuild-babel-transform",
|
|
44
55
|
setup(build) {
|
|
45
56
|
build.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
46
57
|
const fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
|
|
58
|
+
const babelPlugins = (0, import_babel_config.getRouteHookBabelPlugins)().filter(
|
|
59
|
+
(p) => !(Array.isArray(p) && p[2] === GQL_TAG_PLUGIN_NAME)
|
|
60
|
+
);
|
|
47
61
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
48
62
|
fileContents,
|
|
49
63
|
args.path,
|
|
50
|
-
|
|
64
|
+
babelPlugins
|
|
51
65
|
);
|
|
52
66
|
if (transformedCode?.code) {
|
|
67
|
+
const mockCtx = {
|
|
68
|
+
warn(msg) {
|
|
69
|
+
console.warn(`[gql-plugin] ${msg}`);
|
|
70
|
+
},
|
|
71
|
+
error(err) {
|
|
72
|
+
throw new Error(String(err));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const gqlResult = await gqlTransform.call(
|
|
76
|
+
mockCtx,
|
|
77
|
+
transformedCode.code,
|
|
78
|
+
args.path
|
|
79
|
+
);
|
|
80
|
+
const gqlCode = gqlResult && typeof gqlResult === "object" && "code" in gqlResult ? gqlResult.code : void 0;
|
|
53
81
|
return {
|
|
54
|
-
contents: transformedCode.code,
|
|
82
|
+
contents: gqlCode ?? transformedCode.code,
|
|
55
83
|
loader: "js"
|
|
56
84
|
};
|
|
57
85
|
}
|
|
@@ -74,9 +102,6 @@ async function buildRouteHooks(verbose, rwPaths) {
|
|
|
74
102
|
logLevel: verbose ? "info" : "error",
|
|
75
103
|
outdir: rwPaths.web.distRouteHooks,
|
|
76
104
|
alias: {
|
|
77
|
-
// Lift the `api/src` → real api src resolution that was previously
|
|
78
|
-
// handled by `babel-plugin-module-resolver`. The Babel plugin has been
|
|
79
|
-
// removed from `getRouteHookBabelPlugins`; esbuild handles this now.
|
|
80
105
|
"api/src": import_node_path.default.join((0, import_project_config.getPaths)().api.base, "src")
|
|
81
106
|
}
|
|
82
107
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
});
|
|
57
57
|
module.exports = __toCommonJS(index_exports);
|
|
58
58
|
var import_plugin_react = __toESM(require("@vitejs/plugin-react"), 1);
|
|
59
|
+
var import_vite_plugin_graphql_tag = require("vite-plugin-graphql-tag");
|
|
59
60
|
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
60
61
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
61
62
|
var import_project_config = require("@cedarjs/project-config");
|
|
@@ -112,6 +113,7 @@ function cedar({ mode } = {}) {
|
|
|
112
113
|
};
|
|
113
114
|
return [
|
|
114
115
|
tsconfigPaths(),
|
|
116
|
+
(0, import_vite_plugin_graphql_tag.gqlPlugin)(),
|
|
115
117
|
mode === "test" && (0, import_vitest.cedarJsRouterImportTransformPlugin)(),
|
|
116
118
|
mode === "test" && (0, import_vitest.createAuthImportTransformPlugin)(),
|
|
117
119
|
mode === "test" && (0, import_vitest.autoImportsPlugin)(),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var vite_plugin_cedar_graphql_options_extract_exports = {};
|
|
20
30
|
__export(vite_plugin_cedar_graphql_options_extract_exports, {
|
|
@@ -22,6 +32,7 @@ __export(vite_plugin_cedar_graphql_options_extract_exports, {
|
|
|
22
32
|
cedarGraphqlOptionsExtractPlugin: () => cedarGraphqlOptionsExtractPlugin
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(vite_plugin_cedar_graphql_options_extract_exports);
|
|
35
|
+
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
25
36
|
var import_oxc_parser = require("oxc-parser");
|
|
26
37
|
function cedarGraphqlOptionsExtractPlugin() {
|
|
27
38
|
return {
|
|
@@ -33,12 +44,13 @@ function cedarGraphqlOptionsExtractPlugin() {
|
|
|
33
44
|
if (!code.includes("createGraphQLHandler")) {
|
|
34
45
|
return null;
|
|
35
46
|
}
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
47
|
+
const result = applyGraphqlOptionsExtract(code);
|
|
48
|
+
if (!result) {
|
|
38
49
|
return null;
|
|
39
50
|
}
|
|
40
51
|
return {
|
|
41
|
-
code:
|
|
52
|
+
code: result.code,
|
|
53
|
+
map: result.map
|
|
42
54
|
};
|
|
43
55
|
}
|
|
44
56
|
};
|
|
@@ -101,10 +113,13 @@ function applyGraphqlOptionsExtract(code) {
|
|
|
101
113
|
optionsEnd
|
|
102
114
|
)}
|
|
103
115
|
`;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
116
|
+
const s = new import_magic_string.default(code);
|
|
117
|
+
s.prependLeft(lineStart, optionsConst);
|
|
118
|
+
s.overwrite(optionsStart, optionsEnd, "__cedar_graphqlOptions");
|
|
119
|
+
return {
|
|
120
|
+
code: s.toString(),
|
|
121
|
+
map: s.generateMap({ hires: true })
|
|
122
|
+
};
|
|
108
123
|
}
|
|
109
124
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
125
|
0 && (module.exports = {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAoCxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAA;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAA;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,8DAA8D,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAE1F,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAoClE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import react from "@vitejs/plugin-react";
|
|
2
|
+
import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
|
|
2
3
|
import tsPathsMod from "vite-tsconfig-paths";
|
|
3
4
|
const tsconfigPaths = (
|
|
4
5
|
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
@@ -62,6 +63,7 @@ function cedar({ mode } = {}) {
|
|
|
62
63
|
};
|
|
63
64
|
return [
|
|
64
65
|
tsconfigPaths(),
|
|
66
|
+
gqlTagPlugin(),
|
|
65
67
|
mode === "test" && cedarJsRouterImportTransformPlugin(),
|
|
66
68
|
mode === "test" && createAuthImportTransformPlugin(),
|
|
67
69
|
mode === "test" && autoImportsPlugin(),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SourceMap } from 'magic-string';
|
|
1
2
|
import type { Plugin } from 'vite';
|
|
2
3
|
/**
|
|
3
4
|
* Vite plugin that extracts options passed to createGraphQLHandler into an
|
|
@@ -21,8 +22,8 @@ import type { Plugin } from 'vite';
|
|
|
21
22
|
export declare function cedarGraphqlOptionsExtractPlugin(): Plugin;
|
|
22
23
|
/**
|
|
23
24
|
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
24
|
-
* them in an exported variable. Returns the transformed code
|
|
25
|
-
* transformation was needed.
|
|
25
|
+
* them in an exported variable. Returns the transformed code with a sourcemap,
|
|
26
|
+
* or null if no transformation was needed.
|
|
26
27
|
*
|
|
27
28
|
* Transforms:
|
|
28
29
|
* export const handler = createGraphQLHandler({ options })
|
|
@@ -34,5 +35,8 @@ export declare function cedarGraphqlOptionsExtractPlugin(): Plugin;
|
|
|
34
35
|
* logic can run inside the Vite plugin pipeline without depending on internal's
|
|
35
36
|
* build output.
|
|
36
37
|
*/
|
|
37
|
-
export declare function applyGraphqlOptionsExtract(code: string):
|
|
38
|
+
export declare function applyGraphqlOptionsExtract(code: string): {
|
|
39
|
+
code: string;
|
|
40
|
+
map: SourceMap;
|
|
41
|
+
} | null;
|
|
38
42
|
//# sourceMappingURL=vite-plugin-cedar-graphql-options-extract.d.ts.map
|
|
@@ -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":"
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
1
2
|
import { parseSync, Visitor } from "oxc-parser";
|
|
2
3
|
function cedarGraphqlOptionsExtractPlugin() {
|
|
3
4
|
return {
|
|
@@ -9,12 +10,13 @@ function cedarGraphqlOptionsExtractPlugin() {
|
|
|
9
10
|
if (!code.includes("createGraphQLHandler")) {
|
|
10
11
|
return null;
|
|
11
12
|
}
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
13
|
+
const result = applyGraphqlOptionsExtract(code);
|
|
14
|
+
if (!result) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
return {
|
|
17
|
-
code:
|
|
18
|
+
code: result.code,
|
|
19
|
+
map: result.map
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
};
|
|
@@ -77,10 +79,13 @@ function applyGraphqlOptionsExtract(code) {
|
|
|
77
79
|
optionsEnd
|
|
78
80
|
)}
|
|
79
81
|
`;
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
82
|
+
const s = new MagicString(code);
|
|
83
|
+
s.prependLeft(lineStart, optionsConst);
|
|
84
|
+
s.overwrite(optionsStart, optionsEnd, "__cedar_graphqlOptions");
|
|
85
|
+
return {
|
|
86
|
+
code: s.toString(),
|
|
87
|
+
map: s.generateMap({ hires: true })
|
|
88
|
+
};
|
|
84
89
|
}
|
|
85
90
|
export {
|
|
86
91
|
applyGraphqlOptionsExtract,
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* buildFeServer -> buildRscFeServer -> rscBuildClient
|
|
4
4
|
* Generate the client bundle
|
|
5
5
|
*/
|
|
6
|
-
export declare function rscBuildClient(clientEntryFiles: Record<string, string>): Promise<[import("rollup").OutputChunk, ...(import("rollup").
|
|
6
|
+
export declare function rscBuildClient(clientEntryFiles: Record<string, string>): Promise<[import("rollup").OutputChunk, ...(import("rollup").OutputAsset | import("rollup").OutputChunk)[]]>;
|
|
7
7
|
//# sourceMappingURL=rscBuildClient.d.ts.map
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* buildFeServer -> buildRscFeServer -> rscBuildForServer
|
|
4
4
|
* Generate the output to be used by the rsc worker (not the actual server!)
|
|
5
5
|
*/
|
|
6
|
-
export declare function rscBuildForServer(clientEntryFiles: Record<string, string>, serverEntryFiles: Record<string, string>, customModules: Record<string, string>): Promise<[import("rollup").OutputChunk, ...(import("rollup").
|
|
6
|
+
export declare function rscBuildForServer(clientEntryFiles: Record<string, string>, serverEntryFiles: Record<string, string>, customModules: Record<string, string>): Promise<[import("rollup").OutputChunk, ...(import("rollup").OutputAsset | import("rollup").OutputChunk)[]]>;
|
|
7
7
|
//# sourceMappingURL=rscBuildForServer.d.ts.map
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
export declare function rscBuildForSsr({ clientEntryFiles, verbose, }: {
|
|
6
6
|
clientEntryFiles: Record<string, string>;
|
|
7
7
|
verbose?: boolean;
|
|
8
|
-
}): Promise<[import("rollup").OutputChunk, ...(import("rollup").
|
|
8
|
+
}): Promise<[import("rollup").OutputChunk, ...(import("rollup").OutputAsset | import("rollup").OutputChunk)[]]>;
|
|
9
9
|
//# sourceMappingURL=rscBuildForSsr.d.ts.map
|
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.2635",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"@babel/parser": "7.29.7",
|
|
64
64
|
"@babel/traverse": "7.29.7",
|
|
65
65
|
"@babel/types": "7.29.7",
|
|
66
|
-
"@cedarjs/api": "6.0.0-canary.
|
|
67
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
68
|
-
"@cedarjs/context": "6.0.0-canary.
|
|
69
|
-
"@cedarjs/cookie-jar": "6.0.0-canary.
|
|
70
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
71
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
72
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
73
|
-
"@cedarjs/server-store": "6.0.0-canary.
|
|
74
|
-
"@cedarjs/testing": "6.0.0-canary.
|
|
66
|
+
"@cedarjs/api": "6.0.0-canary.2635",
|
|
67
|
+
"@cedarjs/babel-config": "6.0.0-canary.2635",
|
|
68
|
+
"@cedarjs/context": "6.0.0-canary.2635",
|
|
69
|
+
"@cedarjs/cookie-jar": "6.0.0-canary.2635",
|
|
70
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2635",
|
|
71
|
+
"@cedarjs/internal": "6.0.0-canary.2635",
|
|
72
|
+
"@cedarjs/project-config": "6.0.0-canary.2635",
|
|
73
|
+
"@cedarjs/server-store": "6.0.0-canary.2635",
|
|
74
|
+
"@cedarjs/testing": "6.0.0-canary.2635",
|
|
75
75
|
"@fastify/url-data": "6.0.3",
|
|
76
76
|
"@swc/core": "1.15.41",
|
|
77
77
|
"@universal-deploy/store": "^0.2.1",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"find-my-way": "8.2.2",
|
|
93
93
|
"http-proxy-middleware": "3.0.7",
|
|
94
94
|
"isbot": "5.1.43",
|
|
95
|
+
"magic-string": "0.30.21",
|
|
95
96
|
"oxc-parser": "0.137.0",
|
|
96
97
|
"react": "19.2.3",
|
|
97
98
|
"react-server-dom-webpack": "19.2.4",
|
|
@@ -99,15 +100,16 @@
|
|
|
99
100
|
"rou3": "^0.8.1",
|
|
100
101
|
"vite": "7.3.5",
|
|
101
102
|
"vite-plugin-cjs-interop": "2.4.4",
|
|
103
|
+
"vite-plugin-graphql-tag": "0.1.1",
|
|
102
104
|
"vite-tsconfig-paths": "^6.1.1",
|
|
103
105
|
"ws": "8.20.0",
|
|
104
106
|
"yargs-parser": "21.1.1"
|
|
105
107
|
},
|
|
106
108
|
"devDependencies": {
|
|
107
109
|
"@arethetypeswrong/cli": "0.18.5",
|
|
108
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
109
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
110
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
110
|
+
"@cedarjs/auth": "6.0.0-canary.2635",
|
|
111
|
+
"@cedarjs/router": "6.0.0-canary.2635",
|
|
112
|
+
"@cedarjs/web": "6.0.0-canary.2635",
|
|
111
113
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
112
114
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
113
115
|
"@types/aws-lambda": "8.10.162",
|