@cedarjs/vite 5.0.3 → 5.0.4-next.167
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/api/vite-plugin-cedar-vitest-api-preset.d.ts.map +1 -1
- package/dist/api/vite-plugin-cedar-vitest-api-preset.js +4 -0
- package/dist/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +105 -9
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +79 -18
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +36 -4
- package/dist/bundled/react-server-dom-webpack.server.js +192 -99
- package/dist/cedar-unified-dev.d.ts +18 -0
- package/dist/cedar-unified-dev.d.ts.map +1 -1
- package/dist/cedar-unified-dev.js +39 -5
- package/dist/devFeServer.js +3 -8
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -19
- package/dist/lib/generateDiffSourceMap.d.ts +18 -0
- package/dist/lib/generateDiffSourceMap.d.ts.map +1 -0
- package/dist/lib/generateDiffSourceMap.js +151 -0
- package/dist/lib/getMergedConfig.d.ts.map +1 -1
- package/dist/lib/getMergedConfig.js +4 -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 +8 -1
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.js +2 -1
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +43 -0
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +12 -0
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-directory-named-import.js +35 -0
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +29 -0
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +76 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +42 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +93 -0
- package/dist/plugins/vite-plugin-cedar-import-dir.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-import-dir.js +33 -15
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts +28 -0
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.js +67 -0
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts +28 -0
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.js +247 -0
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +39 -0
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +200 -0
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +1 -1
- 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 +14 -0
- package/dist/plugins/{vite-plugin-cedar-context-wrapping.d.ts → vite-plugin-handler-als-wrapping.d.ts} +12 -12
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -0
- package/dist/plugins/{vite-plugin-cedar-context-wrapping.js → vite-plugin-handler-als-wrapping.js} +16 -16
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +3 -0
- 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 +3 -5
- package/dist/streaming/buildForStreamingServer.d.ts.map +1 -1
- package/dist/streaming/buildForStreamingServer.js +3 -5
- package/package.json +42 -52
- package/dist/cjs/ClientRouter.d.ts +0 -1
- package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +0 -37
- package/dist/cjs/apiDevMiddleware.js +0 -371
- package/dist/cjs/build/build.d.ts +0 -1
- package/dist/cjs/build/build.js +0 -58
- package/dist/cjs/buildApp.js +0 -306
- package/dist/cjs/buildFeServer.d.ts +0 -1
- package/dist/cjs/buildFeServer.js +0 -63
- package/dist/cjs/buildRouteHooks.js +0 -80
- package/dist/cjs/buildRouteManifest.js +0 -92
- package/dist/cjs/buildRscClientAndServer.js +0 -54
- package/dist/cjs/cedar-unified-dev.js +0 -310
- package/dist/cjs/client.d.ts +0 -1
- package/dist/cjs/clientSsr.d.ts +0 -1
- package/dist/cjs/devFeServer.js +0 -157
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -141
- package/dist/cjs/lib/StatusError.js +0 -37
- package/dist/cjs/lib/entries.js +0 -52
- package/dist/cjs/lib/getMergedConfig.js +0 -185
- package/dist/cjs/lib/onWarn.js +0 -36
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +0 -102
- 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 -107
- package/dist/cjs/plugins/vite-plugin-cedar-cell.js +0 -183
- package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +0 -341
- package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +0 -95
- package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +0 -107
- package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +0 -67
- package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +0 -118
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +0 -43
- 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 -106
- 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 -398
- 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 -173
- package/dist/cjs/rsc/rscBuildRwEnvVars.js +0 -56
- package/dist/cjs/rsc/rscRenderer.js +0 -165
- package/dist/cjs/rsc/rscRequestHandler.js +0 -162
- package/dist/cjs/rsc/rscStudioHandlers.js +0 -156
- package/dist/cjs/runFeServer.js +0 -165
- package/dist/cjs/streaming/buildForStreamingServer.js +0 -65
- package/dist/cjs/streaming/collectCss.js +0 -52
- package/dist/cjs/streaming/createReactStreamingHandler.js +0 -173
- package/dist/cjs/streaming/streamHelpers.js +0 -230
- 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/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +0 -3
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +0 -19
|
@@ -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":"AAUA,wBAAgB,iBAAiB,kEAShC"}
|
|
@@ -3,9 +3,13 @@ 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";
|
|
6
8
|
import { cedarjsResolveCedarStyleImportsPlugin } from "../plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js";
|
|
7
9
|
function cedarVitestPreset() {
|
|
8
10
|
return [
|
|
11
|
+
cedarImportDirPlugin(),
|
|
12
|
+
cedarjsJobPathInjectorPlugin(),
|
|
9
13
|
cedarVitestApiConfigPlugin(),
|
|
10
14
|
autoImportsPlugin(),
|
|
11
15
|
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":"AASA,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAA;AAkE7D,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,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,17 +1,47 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import { glob } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
5
|
import ansis from "ansis";
|
|
5
6
|
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
|
+
);
|
|
6
14
|
import { buildCedarContext, wrapLegacyHandler } from "@cedarjs/api/runtime";
|
|
7
15
|
import {
|
|
8
|
-
|
|
16
|
+
getApiSideBabelConfigPath,
|
|
17
|
+
getApiSideBabelPluginsForVite,
|
|
9
18
|
transformWithBabel
|
|
10
19
|
} from "@cedarjs/babel-config";
|
|
11
20
|
import { getAsyncStoreInstance } from "@cedarjs/context/dist/store";
|
|
12
21
|
import { createGraphQLYoga } from "@cedarjs/graphql-server";
|
|
13
|
-
import {
|
|
22
|
+
import { applyGqlormInject } from "@cedarjs/internal/dist/build/api-graphql-transforms.js";
|
|
23
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
24
|
+
import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
|
|
14
25
|
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
|
+
}
|
|
15
45
|
const LAMBDA_FUNCTIONS = {};
|
|
16
46
|
let graphqlYoga = null;
|
|
17
47
|
let loadApiFunctionsInFlight = null;
|
|
@@ -115,12 +145,8 @@ async function internalLoadApiFunctions(viteServer) {
|
|
|
115
145
|
async function createApiViteServer() {
|
|
116
146
|
const cedarPaths = getPaths();
|
|
117
147
|
const cedarConfig = getConfig();
|
|
118
|
-
const isEsm = projectSideIsEsm("api");
|
|
119
148
|
const normalizedBase = normalizePath(cedarPaths.base);
|
|
120
|
-
const babelPlugins =
|
|
121
|
-
openTelemetry: (cedarConfig.experimental?.opentelemetry?.enabled ?? false) && (cedarConfig.experimental?.opentelemetry?.wrapApi ?? false),
|
|
122
|
-
projectIsEsm: isEsm
|
|
123
|
-
});
|
|
149
|
+
const babelPlugins = getApiSideBabelConfigPath() ? getApiSideBabelPluginsForVite() : null;
|
|
124
150
|
const workspacePkgSourceMap = Object.fromEntries(
|
|
125
151
|
Object.entries(getWorkspacePackageAliases(cedarPaths, cedarConfig)).map(
|
|
126
152
|
([name, sourceFile]) => [name, normalizePath(sourceFile)]
|
|
@@ -140,6 +166,36 @@ async function createApiViteServer() {
|
|
|
140
166
|
alias: workspacePkgSourceMap
|
|
141
167
|
},
|
|
142
168
|
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
|
+
})(),
|
|
143
199
|
{
|
|
144
200
|
name: "cedar-api-babel-transform",
|
|
145
201
|
enforce: "pre",
|
|
@@ -154,11 +210,51 @@ async function createApiViteServer() {
|
|
|
154
210
|
return null;
|
|
155
211
|
}
|
|
156
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
|
+
}
|
|
226
|
+
}
|
|
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
|
+
}
|
|
157
251
|
const result = await transformWithBabel(
|
|
158
|
-
|
|
252
|
+
sourceCode,
|
|
159
253
|
id,
|
|
160
254
|
babelPlugins,
|
|
161
|
-
true
|
|
255
|
+
true,
|
|
256
|
+
true,
|
|
257
|
+
inputSourceMap ?? void 0
|
|
162
258
|
);
|
|
163
259
|
if (!result?.code) {
|
|
164
260
|
return null;
|
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":"AA6DA,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,iBAya3B"}
|
package/dist/buildApp.js
CHANGED
|
@@ -3,16 +3,37 @@ 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
|
+
);
|
|
6
13
|
import {
|
|
7
|
-
|
|
14
|
+
getApiSideBabelConfigPath,
|
|
15
|
+
getApiSideBabelPluginsForVite,
|
|
8
16
|
transformWithBabel
|
|
9
17
|
} from "@cedarjs/babel-config";
|
|
18
|
+
import {
|
|
19
|
+
applyEsmExtensions,
|
|
20
|
+
applySrcAlias
|
|
21
|
+
} from "@cedarjs/internal/dist/build/api.js";
|
|
10
22
|
import { findApiFiles } from "@cedarjs/internal/dist/files.js";
|
|
11
23
|
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
24
|
+
import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
|
|
12
25
|
import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
|
|
13
|
-
import {
|
|
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 { 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";
|
|
14
35
|
function resolveWithExtensions(id) {
|
|
15
|
-
if (fs.existsSync(id)) {
|
|
36
|
+
if (fs.existsSync(id) && fs.statSync(id).isFile()) {
|
|
16
37
|
return id;
|
|
17
38
|
}
|
|
18
39
|
for (const ext of [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"]) {
|
|
@@ -99,16 +120,19 @@ async function buildCedarApp({
|
|
|
99
120
|
};
|
|
100
121
|
}
|
|
101
122
|
}
|
|
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;
|
|
106
123
|
const workspacePkgSourceMap = workspace.includes("api") ? Object.fromEntries(
|
|
107
124
|
Object.entries(getWorkspacePackageAliases(cedarPaths, cedarConfig)).map(
|
|
108
125
|
([name, sourceFile]) => [name, normalizePath(sourceFile)]
|
|
109
126
|
)
|
|
110
127
|
) : {};
|
|
111
128
|
const plugins = [
|
|
129
|
+
tsconfigPaths(),
|
|
130
|
+
cedarAutoImportsPlugin(),
|
|
131
|
+
(() => {
|
|
132
|
+
const p = gqlTagPlugin();
|
|
133
|
+
p.enforce = "post";
|
|
134
|
+
return p;
|
|
135
|
+
})(),
|
|
112
136
|
// Suppress noisy warnings from third-party dependencies across all
|
|
113
137
|
// environments by injecting onwarn into every environment's rollupOptions.
|
|
114
138
|
{
|
|
@@ -211,7 +235,9 @@ async function buildCedarApp({
|
|
|
211
235
|
name: "cedar-api-src-redirect",
|
|
212
236
|
enforce: "pre",
|
|
213
237
|
resolveId(id, importer) {
|
|
214
|
-
|
|
238
|
+
const normalizedImporter = importer && normalizePath(importer);
|
|
239
|
+
const normalizedApiSrc = normalizePath(cedarPaths.api.src);
|
|
240
|
+
if (!normalizedImporter?.startsWith(`${normalizedApiSrc}/`)) {
|
|
215
241
|
return null;
|
|
216
242
|
}
|
|
217
243
|
if (id.startsWith("src/")) {
|
|
@@ -224,11 +250,18 @@ async function buildCedarApp({
|
|
|
224
250
|
});
|
|
225
251
|
}
|
|
226
252
|
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());
|
|
227
259
|
plugins.push(
|
|
228
|
-
|
|
260
|
+
handlerAlsWrappingPlugin({ projectIsEsm: projectSideIsEsm("api") })
|
|
229
261
|
);
|
|
230
262
|
}
|
|
231
|
-
|
|
263
|
+
plugins.push(cedarMockCellDataPlugin());
|
|
264
|
+
if (workspace.includes("api")) {
|
|
232
265
|
plugins.push({
|
|
233
266
|
name: "cedar-vite-api-babel-transform",
|
|
234
267
|
enforce: "pre",
|
|
@@ -242,19 +275,47 @@ async function buildCedarApp({
|
|
|
242
275
|
if (!normalizePath(id).startsWith(normalizePath(cedarPaths.api.base))) {
|
|
243
276
|
return null;
|
|
244
277
|
}
|
|
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
|
+
if (projectSideIsEsm("api")) {
|
|
286
|
+
rewritten = applyEsmExtensions(rewritten, id);
|
|
287
|
+
}
|
|
288
|
+
return rewritten;
|
|
289
|
+
};
|
|
290
|
+
const rewrittenCode = applyImportRewrites(code);
|
|
291
|
+
if (!babelPlugins) {
|
|
292
|
+
if (rewrittenCode === code) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
code: rewrittenCode,
|
|
297
|
+
map: generateDiffSourceMap(code, rewrittenCode)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
const inputSourceMap = rewrittenCode === code ? null : generateDiffSourceMap(code, rewrittenCode);
|
|
301
|
+
if (inputSourceMap) {
|
|
302
|
+
inputSourceMap.sources = [id];
|
|
303
|
+
}
|
|
245
304
|
const transformedCode = await transformWithBabel(
|
|
246
|
-
|
|
305
|
+
rewrittenCode,
|
|
247
306
|
id,
|
|
248
307
|
babelPlugins,
|
|
249
|
-
true
|
|
308
|
+
true,
|
|
309
|
+
true,
|
|
310
|
+
inputSourceMap ?? void 0
|
|
250
311
|
);
|
|
251
|
-
if (transformedCode?.code) {
|
|
252
|
-
return
|
|
253
|
-
code: transformedCode.code,
|
|
254
|
-
map: transformedCode.map ?? null
|
|
255
|
-
};
|
|
312
|
+
if (!transformedCode?.code) {
|
|
313
|
+
return null;
|
|
256
314
|
}
|
|
257
|
-
return
|
|
315
|
+
return {
|
|
316
|
+
code: applyImportRewrites(transformedCode.code),
|
|
317
|
+
map: transformedCode.map ?? null
|
|
318
|
+
};
|
|
258
319
|
}
|
|
259
320
|
});
|
|
260
321
|
}
|
|
@@ -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,26 +1,55 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { build as esbuildBuild } from "esbuild";
|
|
4
|
+
import { gqlPlugin } from "vite-plugin-graphql-tag";
|
|
3
5
|
import {
|
|
4
6
|
getRouteHookBabelPlugins,
|
|
5
7
|
transformWithBabel
|
|
6
8
|
} from "@cedarjs/babel-config";
|
|
7
9
|
import { findRouteHooksSrc } from "@cedarjs/internal/dist/files.js";
|
|
8
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;
|
|
9
21
|
async function buildRouteHooks(verbose, rwPaths) {
|
|
10
22
|
const allRouteHooks = findRouteHooksSrc();
|
|
11
23
|
const runRwBabelTransformsPlugin = {
|
|
12
|
-
name: "
|
|
24
|
+
name: "cedar-esbuild-babel-transform",
|
|
13
25
|
setup(build) {
|
|
14
26
|
build.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
15
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
|
+
);
|
|
16
31
|
const transformedCode = await transformWithBabel(
|
|
17
32
|
fileContents,
|
|
18
33
|
args.path,
|
|
19
|
-
|
|
34
|
+
babelPlugins
|
|
20
35
|
);
|
|
21
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;
|
|
22
51
|
return {
|
|
23
|
-
contents: transformedCode.code,
|
|
52
|
+
contents: gqlCode ?? transformedCode.code,
|
|
24
53
|
loader: "js"
|
|
25
54
|
};
|
|
26
55
|
}
|
|
@@ -41,7 +70,10 @@ async function buildRouteHooks(verbose, rwPaths) {
|
|
|
41
70
|
plugins: [runRwBabelTransformsPlugin],
|
|
42
71
|
packages: "external",
|
|
43
72
|
logLevel: verbose ? "info" : "error",
|
|
44
|
-
outdir: rwPaths.web.distRouteHooks
|
|
73
|
+
outdir: rwPaths.web.distRouteHooks,
|
|
74
|
+
alias: {
|
|
75
|
+
"api/src": path.join(getPaths().api.base, "src")
|
|
76
|
+
}
|
|
45
77
|
});
|
|
46
78
|
}
|
|
47
79
|
export {
|