@cedarjs/vite 5.0.4-next.167 → 5.0.4
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 +0 -4
- package/dist/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +9 -105
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +18 -79
- 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 -18
- package/dist/cedar-unified-dev.d.ts.map +1 -1
- package/dist/cedar-unified-dev.js +5 -39
- 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 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -45
- package/dist/lib/getMergedConfig.d.ts.map +1 -1
- package/dist/lib/getMergedConfig.js +0 -4
- 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 +15 -33
- 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.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 +0 -14
- 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 +52 -42
- 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-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 -93
- 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
|
@@ -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,47 +1,17 @@
|
|
|
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
16
|
let graphqlYoga = null;
|
|
47
17
|
let loadApiFunctionsInFlight = null;
|
|
@@ -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",
|
|
@@ -210,51 +154,11 @@ async function createApiViteServer() {
|
|
|
210
154
|
return null;
|
|
211
155
|
}
|
|
212
156
|
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
|
-
}
|
|
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;
|
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
|
-
applyEsmExtensions,
|
|
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,47 +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
|
-
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
|
-
}
|
|
304
245
|
const transformedCode = await transformWithBabel(
|
|
305
|
-
|
|
246
|
+
code,
|
|
306
247
|
id,
|
|
307
248
|
babelPlugins,
|
|
308
|
-
true
|
|
309
|
-
true,
|
|
310
|
-
inputSourceMap ?? void 0
|
|
249
|
+
true
|
|
311
250
|
);
|
|
312
|
-
if (
|
|
313
|
-
return
|
|
251
|
+
if (transformedCode?.code) {
|
|
252
|
+
return {
|
|
253
|
+
code: transformedCode.code,
|
|
254
|
+
map: transformedCode.map ?? null
|
|
255
|
+
};
|
|
314
256
|
}
|
|
315
|
-
return
|
|
316
|
-
code: applyImportRewrites(transformedCode.code),
|
|
317
|
-
map: transformedCode.map ?? null
|
|
318
|
-
};
|
|
257
|
+
return null;
|
|
319
258
|
}
|
|
320
259
|
});
|
|
321
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 {
|