@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.
Files changed (143) hide show
  1. package/dist/api/vite-plugin-cedar-vitest-api-preset.d.ts.map +1 -1
  2. package/dist/api/vite-plugin-cedar-vitest-api-preset.js +4 -0
  3. package/dist/apiDevMiddleware.d.ts.map +1 -1
  4. package/dist/apiDevMiddleware.js +105 -9
  5. package/dist/buildApp.d.ts.map +1 -1
  6. package/dist/buildApp.js +79 -18
  7. package/dist/buildRouteHooks.d.ts.map +1 -1
  8. package/dist/buildRouteHooks.js +36 -4
  9. package/dist/bundled/react-server-dom-webpack.server.js +192 -99
  10. package/dist/cedar-unified-dev.d.ts +18 -0
  11. package/dist/cedar-unified-dev.d.ts.map +1 -1
  12. package/dist/cedar-unified-dev.js +39 -5
  13. package/dist/devFeServer.js +3 -8
  14. package/dist/index.d.ts +10 -4
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +45 -19
  17. package/dist/lib/generateDiffSourceMap.d.ts +18 -0
  18. package/dist/lib/generateDiffSourceMap.d.ts.map +1 -0
  19. package/dist/lib/generateDiffSourceMap.js +151 -0
  20. package/dist/lib/getMergedConfig.d.ts.map +1 -1
  21. package/dist/lib/getMergedConfig.js +4 -0
  22. package/dist/plugins/vite-plugin-cedar-auto-import.d.ts +1 -1
  23. package/dist/plugins/vite-plugin-cedar-auto-import.d.ts.map +1 -1
  24. package/dist/plugins/vite-plugin-cedar-auto-import.js +8 -1
  25. package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
  26. package/dist/plugins/vite-plugin-cedar-cell.js +2 -1
  27. package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +3 -0
  28. package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +1 -0
  29. package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +43 -0
  30. package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +12 -0
  31. package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +1 -0
  32. package/dist/plugins/vite-plugin-cedar-directory-named-import.js +35 -0
  33. package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +29 -0
  34. package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +1 -0
  35. package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +76 -0
  36. package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +42 -0
  37. package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +1 -0
  38. package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +93 -0
  39. package/dist/plugins/vite-plugin-cedar-import-dir.d.ts.map +1 -1
  40. package/dist/plugins/vite-plugin-cedar-import-dir.js +33 -15
  41. package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts +28 -0
  42. package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts.map +1 -0
  43. package/dist/plugins/vite-plugin-cedar-log-formatter-dev.js +67 -0
  44. package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts +28 -0
  45. package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +1 -0
  46. package/dist/plugins/vite-plugin-cedar-mock-cell-data.js +247 -0
  47. package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +39 -0
  48. package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +1 -0
  49. package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +200 -0
  50. package/dist/plugins/vite-plugin-cedar-universal-deploy.js +1 -1
  51. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map +1 -1
  52. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +14 -0
  53. package/dist/plugins/{vite-plugin-cedar-context-wrapping.d.ts → vite-plugin-handler-als-wrapping.d.ts} +12 -12
  54. package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -0
  55. package/dist/plugins/{vite-plugin-cedar-context-wrapping.js → vite-plugin-handler-als-wrapping.js} +16 -16
  56. package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +3 -0
  57. package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
  58. package/dist/plugins/vite-plugin-swap-apollo-provider.js +2 -2
  59. package/dist/rsc/rscBuildForSsr.d.ts.map +1 -1
  60. package/dist/rsc/rscBuildForSsr.js +3 -5
  61. package/dist/streaming/buildForStreamingServer.d.ts.map +1 -1
  62. package/dist/streaming/buildForStreamingServer.js +3 -5
  63. package/package.json +42 -52
  64. package/dist/cjs/ClientRouter.d.ts +0 -1
  65. package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +0 -37
  66. package/dist/cjs/apiDevMiddleware.js +0 -371
  67. package/dist/cjs/build/build.d.ts +0 -1
  68. package/dist/cjs/build/build.js +0 -58
  69. package/dist/cjs/buildApp.js +0 -306
  70. package/dist/cjs/buildFeServer.d.ts +0 -1
  71. package/dist/cjs/buildFeServer.js +0 -63
  72. package/dist/cjs/buildRouteHooks.js +0 -80
  73. package/dist/cjs/buildRouteManifest.js +0 -92
  74. package/dist/cjs/buildRscClientAndServer.js +0 -54
  75. package/dist/cjs/cedar-unified-dev.js +0 -310
  76. package/dist/cjs/client.d.ts +0 -1
  77. package/dist/cjs/clientSsr.d.ts +0 -1
  78. package/dist/cjs/devFeServer.js +0 -157
  79. package/dist/cjs/index.d.ts +0 -1
  80. package/dist/cjs/index.js +0 -141
  81. package/dist/cjs/lib/StatusError.js +0 -37
  82. package/dist/cjs/lib/entries.js +0 -52
  83. package/dist/cjs/lib/getMergedConfig.js +0 -185
  84. package/dist/cjs/lib/onWarn.js +0 -36
  85. package/dist/cjs/lib/registerFwGlobalsAndShims.js +0 -102
  86. package/dist/cjs/lib/workspacePackageAliases.js +0 -107
  87. package/dist/cjs/middleware/index.js +0 -22
  88. package/dist/cjs/middleware/invokeMiddleware.js +0 -52
  89. package/dist/cjs/middleware/register.js +0 -105
  90. package/dist/cjs/middleware/types.js +0 -16
  91. package/dist/cjs/package.json +0 -1
  92. package/dist/cjs/plugins/vite-plugin-cedar-auto-import.js +0 -107
  93. package/dist/cjs/plugins/vite-plugin-cedar-cell.js +0 -183
  94. package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +0 -341
  95. package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +0 -95
  96. package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +0 -107
  97. package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +0 -67
  98. package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +0 -118
  99. package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +0 -43
  100. package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +0 -61
  101. package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +0 -76
  102. package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +0 -126
  103. package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +0 -346
  104. package/dist/cjs/plugins/vite-plugin-cedar-wait-for-api-server.js +0 -134
  105. package/dist/cjs/plugins/vite-plugin-cedarjs-job-path-injector.js +0 -134
  106. package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +0 -106
  107. package/dist/cjs/plugins/vite-plugin-jsx-loader.js +0 -42
  108. package/dist/cjs/plugins/vite-plugin-merged-config.js +0 -39
  109. package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +0 -104
  110. package/dist/cjs/plugins/vite-plugin-rsc-reload.js +0 -75
  111. package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +0 -159
  112. package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +0 -125
  113. package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +0 -75
  114. package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +0 -228
  115. package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +0 -398
  116. package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +0 -46
  117. package/dist/cjs/rsc/rscBuildAnalyze.js +0 -126
  118. package/dist/cjs/rsc/rscBuildClient.js +0 -91
  119. package/dist/cjs/rsc/rscBuildCopyCssAssets.js +0 -56
  120. package/dist/cjs/rsc/rscBuildEntriesFile.js +0 -115
  121. package/dist/cjs/rsc/rscBuildForServer.js +0 -168
  122. package/dist/cjs/rsc/rscBuildForSsr.js +0 -173
  123. package/dist/cjs/rsc/rscBuildRwEnvVars.js +0 -56
  124. package/dist/cjs/rsc/rscRenderer.js +0 -165
  125. package/dist/cjs/rsc/rscRequestHandler.js +0 -162
  126. package/dist/cjs/rsc/rscStudioHandlers.js +0 -156
  127. package/dist/cjs/runFeServer.js +0 -165
  128. package/dist/cjs/streaming/buildForStreamingServer.js +0 -65
  129. package/dist/cjs/streaming/collectCss.js +0 -52
  130. package/dist/cjs/streaming/createReactStreamingHandler.js +0 -173
  131. package/dist/cjs/streaming/streamHelpers.js +0 -230
  132. package/dist/cjs/streaming/transforms/bufferedTransform.js +0 -61
  133. package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +0 -34
  134. package/dist/cjs/streaming/transforms/encode-decode.js +0 -36
  135. package/dist/cjs/streaming/transforms/serverInjectionTransform.js +0 -84
  136. package/dist/cjs/streaming/triggerRouteHooks.js +0 -96
  137. package/dist/cjs/types.js +0 -16
  138. package/dist/cjs/utils.js +0 -92
  139. package/dist/package.json +0 -1
  140. package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +0 -1
  141. package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +0 -3
  142. package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +0 -1
  143. package/dist/plugins/vite-plugin-cedar-node-polyfills.js +0 -19
@@ -1,306 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var buildApp_exports = {};
30
- __export(buildApp_exports, {
31
- buildCedarApp: () => buildCedarApp
32
- });
33
- module.exports = __toCommonJS(buildApp_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_node_path = __toESM(require("node:path"), 1);
36
- var import_store = require("@universal-deploy/store");
37
- var import_vite = require("@universal-deploy/vite");
38
- var import_vite2 = require("vite");
39
- var import_babel_config = require("@cedarjs/babel-config");
40
- var import_files = require("@cedarjs/internal/dist/files.js");
41
- var import_project_config = require("@cedarjs/project-config");
42
- var import_workspacePackageAliases = require("./lib/workspacePackageAliases.js");
43
- var import_vite_plugin_cedar_context_wrapping = require("./plugins/vite-plugin-cedar-context-wrapping.js");
44
- function resolveWithExtensions(id) {
45
- if (import_node_fs.default.existsSync(id)) {
46
- return id;
47
- }
48
- for (const ext of [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"]) {
49
- const withExt = id + ext;
50
- if (import_node_fs.default.existsSync(withExt)) {
51
- return withExt;
52
- }
53
- }
54
- return id;
55
- }
56
- async function buildCedarApp({
57
- verbose = false,
58
- workspace = ["api", "web"],
59
- ud = false
60
- } = {}) {
61
- const cedarPaths = (0, import_project_config.getPaths)();
62
- const cedarConfig = (0, import_project_config.getConfig)();
63
- const environments = {};
64
- if (workspace.includes("web")) {
65
- environments.client = {
66
- build: {
67
- outDir: cedarPaths.web.dist
68
- }
69
- };
70
- }
71
- if (workspace.includes("api")) {
72
- const isEsm = (0, import_project_config.projectSideIsEsm)("api");
73
- const format = isEsm ? "es" : "cjs";
74
- const apiFiles = (0, import_files.findApiFiles)();
75
- const input = {};
76
- for (const f of apiFiles) {
77
- const key = import_node_path.default.relative(cedarPaths.api.src, f).replace(/\.(ts|tsx|mts|js|jsx|mjs)$/, "");
78
- input[key] = f;
79
- }
80
- environments.api = {
81
- build: {
82
- ssr: true,
83
- sourcemap: true,
84
- outDir: cedarPaths.api.dist,
85
- emptyOutDir: true,
86
- rollupOptions: {
87
- input,
88
- output: {
89
- format,
90
- preserveModules: true,
91
- preserveModulesRoot: cedarPaths.api.src,
92
- entryFileNames: "[name].js",
93
- exports: "named"
94
- },
95
- external: (id) => {
96
- if (id.startsWith("node:")) {
97
- return true;
98
- } else if (!id.startsWith(".") && !import_node_path.default.isAbsolute(id)) {
99
- return true;
100
- }
101
- return false;
102
- }
103
- }
104
- }
105
- };
106
- if (ud) {
107
- environments["ssr"] = {
108
- build: {
109
- ssr: true,
110
- outDir: import_node_path.default.join(cedarPaths.api.dist, "ud"),
111
- emptyOutDir: true,
112
- rollupOptions: {
113
- input: import_store.catchAllEntry,
114
- output: {
115
- entryFileNames: "index.js"
116
- },
117
- external: (id) => {
118
- if (id.startsWith("virtual:")) {
119
- return false;
120
- } else if (id.startsWith("node:")) {
121
- return true;
122
- } else if (!id.startsWith(".") && !import_node_path.default.isAbsolute(id)) {
123
- return true;
124
- }
125
- return false;
126
- }
127
- }
128
- }
129
- };
130
- }
131
- }
132
- const babelPlugins = workspace.includes("api") ? (0, import_babel_config.getApiSideBabelPlugins)({
133
- openTelemetry: (cedarConfig.experimental?.opentelemetry?.enabled ?? false) && (cedarConfig.experimental?.opentelemetry?.wrapApi ?? false),
134
- projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
135
- }) : null;
136
- const workspacePkgSourceMap = workspace.includes("api") ? Object.fromEntries(
137
- Object.entries((0, import_workspacePackageAliases.getWorkspacePackageAliases)(cedarPaths, cedarConfig)).map(
138
- ([name, sourceFile]) => [name, (0, import_vite2.normalizePath)(sourceFile)]
139
- )
140
- ) : {};
141
- const plugins = [
142
- // Suppress noisy warnings from third-party dependencies across all
143
- // environments by injecting onwarn into every environment's rollupOptions.
144
- {
145
- name: "cedar-suppress-third-party-warnings",
146
- configResolved(config) {
147
- function onwarn(warning, warn) {
148
- if (warning.code === "EVAL" && warning.id?.includes("@prisma/internals")) {
149
- return;
150
- }
151
- if (warning.code === "INVALID_ANNOTATION" && warning.id?.includes("graphql-scalars")) {
152
- return;
153
- }
154
- warn(warning);
155
- }
156
- for (const env of Object.values(config.environments ?? {})) {
157
- env.build.rollupOptions ??= {};
158
- const existingOnwarn = env.build.rollupOptions.onwarn;
159
- env.build.rollupOptions.onwarn = existingOnwarn ? (warning, warn) => {
160
- onwarn(warning, (w) => existingOnwarn(w, warn));
161
- } : onwarn;
162
- }
163
- }
164
- },
165
- // Resolve bare-specifier dynamic imports from node_modules as external
166
- // before Rollup attempts resolution, avoiding UNRESOLVED_IMPORT warnings
167
- // for optional peer dependencies (e.g. @simplewebauthn/server).
168
- {
169
- name: "cedar-optional-peer-deps",
170
- resolveDynamicImport(specifier, importer) {
171
- if (typeof specifier === "string" && !specifier.startsWith(".") && !specifier.startsWith("/") && importer?.includes("node_modules") && this.environment.config.consumer === "server") {
172
- return { id: specifier, external: true };
173
- }
174
- return null;
175
- }
176
- },
177
- {
178
- name: "cedar-build-app-cleanup",
179
- configResolved(config) {
180
- if (!workspace.includes("web") && config.environments.client) {
181
- delete config.environments.client;
182
- }
183
- if (!environments.ssr && config.environments.ssr) {
184
- delete config.environments.ssr;
185
- }
186
- }
187
- },
188
- {
189
- name: "cedar-build-app",
190
- buildApp: {
191
- order: "pre",
192
- async handler(builder2) {
193
- if (workspace.includes("web") && builder2.environments.client && !builder2.environments.client.isBuilt) {
194
- await builder2.build(builder2.environments.client);
195
- }
196
- if (workspace.includes("api") && builder2.environments.api && !builder2.environments.api.isBuilt) {
197
- await builder2.build(builder2.environments.api);
198
- }
199
- if (workspace.includes("api") && builder2.environments["ssr"] && !builder2.environments["ssr"].isBuilt) {
200
- await builder2.build(builder2.environments["ssr"]);
201
- }
202
- }
203
- }
204
- }
205
- ];
206
- if (ud) {
207
- plugins.push((0, import_vite.catchAll)());
208
- plugins.push({
209
- name: "cedar-ud-verify-routes",
210
- configResolved() {
211
- const entries = (0, import_store.getAllEntries)();
212
- if (entries.length === 0) {
213
- console.warn(
214
- "\n",
215
- " Warning: No Universal Deploy API routes were registered.\n",
216
- " The built server entry will be an empty router (404 for all\n",
217
- " requests). Check that you have API functions under\n",
218
- " `api/src/functions/` and that your vite config includes\n",
219
- " `cedarUniversalDeployPlugin()`.\n"
220
- );
221
- }
222
- }
223
- });
224
- plugins.push({
225
- name: "cedar-ud-write-package-json",
226
- applyToEnvironment(env) {
227
- return env.name === "ssr";
228
- },
229
- closeBundle() {
230
- const dir = import_node_path.default.join(cedarPaths.api.dist, "ud");
231
- import_node_fs.default.mkdirSync(dir, { recursive: true });
232
- import_node_fs.default.writeFileSync(
233
- import_node_path.default.join(dir, "package.json"),
234
- JSON.stringify({ type: "module" }, null, 2)
235
- );
236
- }
237
- });
238
- }
239
- if (workspace.includes("api")) {
240
- plugins.push({
241
- name: "cedar-api-src-redirect",
242
- enforce: "pre",
243
- resolveId(id, importer) {
244
- if (!importer?.startsWith(cedarPaths.api.src)) {
245
- return null;
246
- }
247
- if (id.startsWith("src/")) {
248
- return resolveWithExtensions(
249
- import_node_path.default.join(cedarPaths.api.src, id.slice(4))
250
- );
251
- }
252
- return null;
253
- }
254
- });
255
- }
256
- if (workspace.includes("api")) {
257
- plugins.push(
258
- (0, import_vite_plugin_cedar_context_wrapping.cedarContextWrappingPlugin)({ projectIsEsm: (0, import_project_config.projectSideIsEsm)("api") })
259
- );
260
- }
261
- if (babelPlugins) {
262
- plugins.push({
263
- name: "cedar-vite-api-babel-transform",
264
- enforce: "pre",
265
- async transform(code, id) {
266
- if (!/\.(js|ts|tsx|jsx)$/.test(id)) {
267
- return null;
268
- }
269
- if (id.includes("node_modules")) {
270
- return null;
271
- }
272
- if (!(0, import_vite2.normalizePath)(id).startsWith((0, import_vite2.normalizePath)(cedarPaths.api.base))) {
273
- return null;
274
- }
275
- const transformedCode = await (0, import_babel_config.transformWithBabel)(
276
- code,
277
- id,
278
- babelPlugins,
279
- true
280
- );
281
- if (transformedCode?.code) {
282
- return {
283
- code: transformedCode.code,
284
- map: transformedCode.map ?? null
285
- };
286
- }
287
- return null;
288
- }
289
- });
290
- }
291
- const builder = await (0, import_vite2.createBuilder)({
292
- configFile: cedarPaths.web.viteConfig,
293
- envFile: false,
294
- logLevel: verbose ? "info" : "warn",
295
- environments,
296
- resolve: {
297
- alias: workspacePkgSourceMap
298
- },
299
- plugins
300
- });
301
- return builder.buildApp();
302
- }
303
- // Annotate the CommonJS export names for ESM import in node:
304
- 0 && (module.exports = {
305
- buildCedarApp
306
- });
@@ -1 +0,0 @@
1
- export type * from "../buildFeServer.d.ts"
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var buildFeServer_exports = {};
20
- __export(buildFeServer_exports, {
21
- buildFeServer: () => buildFeServer
22
- });
23
- module.exports = __toCommonJS(buildFeServer_exports);
24
- var import_project_config = require("@cedarjs/project-config");
25
- var import_build = require("./build/build.js");
26
- var import_buildRouteHooks = require("./buildRouteHooks.js");
27
- var import_buildRouteManifest = require("./buildRouteManifest.js");
28
- var import_buildRscClientAndServer = require("./buildRscClientAndServer.js");
29
- var import_buildForStreamingServer = require("./streaming/buildForStreamingServer.js");
30
- var import_utils = require("./utils.js");
31
- const buildFeServer = async ({ verbose, webDir } = {}) => {
32
- (0, import_utils.ensureProcessDirWeb)(webDir);
33
- const rwPaths = (0, import_project_config.getPaths)();
34
- const rwConfig = (0, import_project_config.getConfig)();
35
- const viteConfigPath = rwPaths.web.viteConfig;
36
- const rscEnabled = rwConfig.experimental?.rsc?.enabled;
37
- const streamingSsrEnabled = rwConfig.experimental?.streamingSsr?.enabled;
38
- if (!viteConfigPath) {
39
- throw new Error(
40
- "Vite config not found. Please set up Vite before building."
41
- );
42
- }
43
- if (!rwPaths.web.entryServer || !rwPaths.web.entryClient) {
44
- throw new Error(
45
- "Vite entry points not found. Please check that your project has an entry.client.{jsx,tsx} and entry.server.{jsx,tsx} file in the web/src directory."
46
- );
47
- }
48
- if (rscEnabled) {
49
- await (0, import_buildRscClientAndServer.buildRscClientAndServer)({ verbose });
50
- } else {
51
- await (0, import_buildForStreamingServer.buildForStreamingServer)({ verbose });
52
- }
53
- if (streamingSsrEnabled && !rscEnabled) {
54
- console.log("Building client for streaming SSR...\n");
55
- await (0, import_build.buildWeb)({ verbose });
56
- }
57
- await (0, import_buildRouteHooks.buildRouteHooks)(verbose, rwPaths);
58
- await (0, import_buildRouteManifest.buildRouteManifest)();
59
- };
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- buildFeServer
63
- });
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var buildRouteHooks_exports = {};
30
- __export(buildRouteHooks_exports, {
31
- buildRouteHooks: () => buildRouteHooks
32
- });
33
- module.exports = __toCommonJS(buildRouteHooks_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_esbuild = require("esbuild");
36
- var import_babel_config = require("@cedarjs/babel-config");
37
- var import_files = require("@cedarjs/internal/dist/files.js");
38
- var import_project_config = require("@cedarjs/project-config");
39
- async function buildRouteHooks(verbose, rwPaths) {
40
- const allRouteHooks = (0, import_files.findRouteHooksSrc)();
41
- const runRwBabelTransformsPlugin = {
42
- name: "rw-esbuild-babel-transform",
43
- setup(build) {
44
- build.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
45
- const fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
46
- const transformedCode = await (0, import_babel_config.transformWithBabel)(
47
- fileContents,
48
- args.path,
49
- [...(0, import_babel_config.getRouteHookBabelPlugins)()]
50
- );
51
- if (transformedCode?.code) {
52
- return {
53
- contents: transformedCode.code,
54
- loader: "js"
55
- };
56
- }
57
- throw new Error(`Could not transform file: ${args.path}`);
58
- });
59
- }
60
- };
61
- await (0, import_esbuild.build)({
62
- absWorkingDir: (0, import_project_config.getPaths)().web.base,
63
- entryPoints: allRouteHooks,
64
- platform: "node",
65
- target: "node16",
66
- // @MARK Disable splitting and esm, because Redwood web modules don't support esm yet
67
- // outExtension: { '.js': '.mjs' },
68
- // format: 'esm',
69
- // splitting: true,
70
- bundle: true,
71
- plugins: [runRwBabelTransformsPlugin],
72
- packages: "external",
73
- logLevel: verbose ? "info" : "error",
74
- outdir: rwPaths.web.distRouteHooks
75
- });
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- buildRouteHooks
80
- });
@@ -1,92 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var buildRouteManifest_exports = {};
30
- __export(buildRouteManifest_exports, {
31
- buildRouteManifest: () => buildRouteManifest
32
- });
33
- module.exports = __toCommonJS(buildRouteManifest_exports);
34
- var import_promises = __toESM(require("node:fs/promises"), 1);
35
- var import_node_path = __toESM(require("node:path"), 1);
36
- var import_node_url = __toESM(require("node:url"), 1);
37
- var import_routes = require("@cedarjs/internal/dist/routes.js");
38
- var import_project_config = require("@cedarjs/project-config");
39
- async function buildRouteManifest() {
40
- const rwPaths = (0, import_project_config.getPaths)();
41
- const buildManifestUrl = import_node_url.default.pathToFileURL(
42
- import_node_path.default.join((0, import_project_config.getPaths)().web.distBrowser, "client-build-manifest.json")
43
- ).href;
44
- const clientBuildManifest = (await import(buildManifestUrl, { with: { type: "json" } })).default;
45
- const routesList = (0, import_routes.getProjectRoutes)();
46
- const routeManifest = routesList.reduce((acc, route) => {
47
- acc[route.pathDefinition] = {
48
- name: route.name,
49
- bundle: route.relativeFilePath ? (
50
- // @TODO(RSC_DC): this no longer resolves to anything i.e. its always null
51
- // Because the clientBuildManifest has no pages, because all pages are Server-components?
52
- // This may be a non-issue, because RSC pages don't need a client bundle per page (or atleast not the same bundle)
53
- clientBuildManifest[route.relativeFilePath]?.file ?? null
54
- ) : null,
55
- matchRegexString: route.matchRegexString,
56
- // NOTE this is the path definition, not the actual path
57
- // E.g. /blog/post/{id:Int}
58
- pathDefinition: route.pathDefinition,
59
- hasParams: route.hasParams,
60
- routeHooks: FIXME_constructRouteHookPath(route.routeHooks),
61
- redirect: route.redirect ? {
62
- to: route.redirect?.to,
63
- permanent: false
64
- } : null,
65
- relativeFilePath: route.relativeFilePath,
66
- isPrivate: route.isPrivate,
67
- unauthenticated: route.unauthenticated,
68
- roles: route.roles,
69
- pageIdentifier: route.pageIdentifier
70
- };
71
- return acc;
72
- }, {});
73
- console.log("routeManifest", JSON.stringify(routeManifest, null, 2));
74
- const webRouteManifest = rwPaths.web.routeManifest;
75
- await import_promises.default.mkdir(rwPaths.web.distSsr, { recursive: true });
76
- return import_promises.default.writeFile(webRouteManifest, JSON.stringify(routeManifest, null, 2));
77
- }
78
- const FIXME_constructRouteHookPath = (routeHookSrcPath) => {
79
- const rwPaths = (0, import_project_config.getPaths)();
80
- if (!routeHookSrcPath) {
81
- return null;
82
- }
83
- if ((0, import_project_config.getAppRouteHook)()) {
84
- return import_node_path.default.relative(rwPaths.web.src, routeHookSrcPath).replace(".ts", ".js");
85
- } else {
86
- return import_node_path.default.relative(import_node_path.default.join(rwPaths.web.src, "pages"), routeHookSrcPath).replace(".ts", ".js");
87
- }
88
- };
89
- // Annotate the CommonJS export names for ESM import in node:
90
- 0 && (module.exports = {
91
- buildRouteManifest
92
- });
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var buildRscClientAndServer_exports = {};
20
- __export(buildRscClientAndServer_exports, {
21
- buildRscClientAndServer: () => buildRscClientAndServer
22
- });
23
- module.exports = __toCommonJS(buildRscClientAndServer_exports);
24
- var import_rscBuildAnalyze = require("./rsc/rscBuildAnalyze.js");
25
- var import_rscBuildClient = require("./rsc/rscBuildClient.js");
26
- var import_rscBuildCopyCssAssets = require("./rsc/rscBuildCopyCssAssets.js");
27
- var import_rscBuildEntriesFile = require("./rsc/rscBuildEntriesFile.js");
28
- var import_rscBuildForServer = require("./rsc/rscBuildForServer.js");
29
- var import_rscBuildForSsr = require("./rsc/rscBuildForSsr.js");
30
- var import_rscBuildRwEnvVars = require("./rsc/rscBuildRwEnvVars.js");
31
- const buildRscClientAndServer = async ({
32
- verbose = false
33
- }) => {
34
- const { clientEntryFiles, serverEntryFiles } = await (0, import_rscBuildAnalyze.rscBuildAnalyze)();
35
- const clientBuildOutput = await (0, import_rscBuildClient.rscBuildClient)(clientEntryFiles);
36
- const ssrBuildOutput = await (0, import_rscBuildForSsr.rscBuildForSsr)({ clientEntryFiles, verbose });
37
- const serverBuildOutput = await (0, import_rscBuildForServer.rscBuildForServer)(
38
- clientEntryFiles,
39
- serverEntryFiles,
40
- {}
41
- );
42
- await (0, import_rscBuildCopyCssAssets.rscBuildCopyCssAssets)(serverBuildOutput);
43
- await (0, import_rscBuildEntriesFile.rscBuildEntriesMappings)(
44
- clientBuildOutput,
45
- ssrBuildOutput,
46
- serverBuildOutput,
47
- clientEntryFiles
48
- );
49
- await (0, import_rscBuildRwEnvVars.rscBuildRwEnvVars)();
50
- };
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- buildRscClientAndServer
54
- });