@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,56 +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 rscBuildCopyCssAssets_exports = {};
30
- __export(rscBuildCopyCssAssets_exports, {
31
- rscBuildCopyCssAssets: () => rscBuildCopyCssAssets
32
- });
33
- module.exports = __toCommonJS(rscBuildCopyCssAssets_exports);
34
- var import_promises = __toESM(require("fs/promises"), 1);
35
- var import_path = __toESM(require("path"), 1);
36
- var import_project_config = require("@cedarjs/project-config");
37
- function rscBuildCopyCssAssets(serverBuildOutput) {
38
- console.log("\n");
39
- console.log("5. rscBuildCopyCssAssets");
40
- console.log("========================\n");
41
- const rwPaths = (0, import_project_config.getPaths)();
42
- return Promise.all(
43
- serverBuildOutput.filter((item) => {
44
- return item.type === "asset" && item.fileName.endsWith(".css");
45
- }).map((cssAsset) => {
46
- return import_promises.default.copyFile(
47
- import_path.default.join(rwPaths.web.distRsc, cssAsset.fileName),
48
- import_path.default.join(rwPaths.web.distBrowser, cssAsset.fileName)
49
- );
50
- })
51
- );
52
- }
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- rscBuildCopyCssAssets
56
- });
@@ -1,115 +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 rscBuildEntriesFile_exports = {};
30
- __export(rscBuildEntriesFile_exports, {
31
- rscBuildEntriesMappings: () => rscBuildEntriesMappings
32
- });
33
- module.exports = __toCommonJS(rscBuildEntriesFile_exports);
34
- var import_promises = __toESM(require("fs/promises"), 1);
35
- var import_vite = require("vite");
36
- var import_project_config = require("@cedarjs/project-config");
37
- async function rscBuildEntriesMappings(clientBuildOutput, ssrBuildOutput, serverBuildOutput, clientEntryFiles) {
38
- console.log("\n");
39
- console.log("6. rscBuildEntriesMapping");
40
- console.log("=========================\n");
41
- const rwPaths = (0, import_project_config.getPaths)();
42
- const clientEntries = {};
43
- for (const item of clientBuildOutput) {
44
- const { name, fileName } = item;
45
- const entryFile = name && // TODO (RSC) Can't we just compare the names? `item.name === name`
46
- serverBuildOutput.find(
47
- (item2) => "moduleIds" in item2 && item2.moduleIds.includes(clientEntryFiles[name])
48
- )?.fileName;
49
- if (entryFile) {
50
- if (process.platform === "win32") {
51
- const entryFileSlash = entryFile.replaceAll("\\", "/");
52
- clientEntries[entryFileSlash] = fileName;
53
- } else {
54
- clientEntries[entryFile] = fileName;
55
- }
56
- }
57
- }
58
- console.log("clientEntries", clientEntries);
59
- const ssrEntries = {};
60
- for (const item of ssrBuildOutput) {
61
- const { name, fileName } = item;
62
- const entryFile = name && // TODO (RSC) Can't we just compare the names? `item.name === name`
63
- serverBuildOutput.find(
64
- (item2) => "moduleIds" in item2 && item2.moduleIds.includes(clientEntryFiles[name])
65
- )?.fileName;
66
- if (entryFile) {
67
- if (process.platform === "win32") {
68
- const entryFileSlash = entryFile.replaceAll("\\", "/");
69
- ssrEntries[entryFileSlash] = fileName;
70
- } else {
71
- ssrEntries[entryFile] = fileName;
72
- }
73
- }
74
- }
75
- console.log("ssrEntries", ssrEntries);
76
- await import_promises.default.appendFile(
77
- rwPaths.web.distRscEntries,
78
- `// client component mapping (dist/rsc -> dist/browser)
79
- export const clientEntries = ${JSON.stringify(clientEntries, void 0, 2)};
80
-
81
- `
82
- );
83
- await import_promises.default.appendFile(
84
- rwPaths.web.distRscEntries,
85
- `// client component mapping (dist/rsc -> dist/ssr)
86
- export const ssrEntries = ${JSON.stringify(ssrEntries, void 0, 2)};
87
-
88
- `
89
- );
90
- const serverEntries = {};
91
- const entries = {
92
- __cedarjs__ServerEntry: (0, import_project_config.getPaths)().web.entryServer || "",
93
- __cedarjs__Routes: (0, import_project_config.getPaths)().web.routes
94
- };
95
- for (const [name, sourceFile] of Object.entries(entries)) {
96
- const buildOutputItem = serverBuildOutput.find((item) => {
97
- return item.facadeModuleId === (0, import_vite.normalizePath)(sourceFile);
98
- });
99
- if (buildOutputItem) {
100
- serverEntries[name] = buildOutputItem.fileName;
101
- }
102
- }
103
- console.log("serverEntries", serverEntries);
104
- await import_promises.default.appendFile(
105
- rwPaths.web.distRscEntries,
106
- `// server component mapping (src -> dist/rsc)
107
- export const serverEntries = ${JSON.stringify(serverEntries, void 0, 2)};
108
-
109
- `
110
- );
111
- }
112
- // Annotate the CommonJS export names for ESM import in node:
113
- 0 && (module.exports = {
114
- rscBuildEntriesMappings
115
- });
@@ -1,168 +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 rscBuildForServer_exports = {};
20
- __export(rscBuildForServer_exports, {
21
- rscBuildForServer: () => rscBuildForServer
22
- });
23
- module.exports = __toCommonJS(rscBuildForServer_exports);
24
- var import_vite = require("vite");
25
- var import_project_config = require("@cedarjs/project-config");
26
- var import_entries = require("../lib/entries.js");
27
- var import_onWarn = require("../lib/onWarn.js");
28
- var import_vite_plugin_rsc_routes_imports = require("../plugins/vite-plugin-rsc-routes-imports.js");
29
- var import_vite_plugin_rsc_transform_client = require("../plugins/vite-plugin-rsc-transform-client.js");
30
- var import_vite_plugin_rsc_transform_server = require("../plugins/vite-plugin-rsc-transform-server.js");
31
- async function rscBuildForServer(clientEntryFiles, serverEntryFiles, customModules) {
32
- console.log("\n");
33
- console.log("4. rscBuildForServer");
34
- console.log("====================\n");
35
- const rwPaths = (0, import_project_config.getPaths)();
36
- const entryFiles = (0, import_entries.getEntries)();
37
- const entryFilesKeys = Object.keys(entryFiles);
38
- if (!rwPaths.web.entryServer) {
39
- throw new Error("Server Entry file not found");
40
- }
41
- const outDir = rwPaths.web.distRsc;
42
- const rscServerBuildOutput = await (0, import_vite.build)({
43
- envFile: false,
44
- define: {
45
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
46
- },
47
- ssr: {
48
- // Inline every file apart from node built-ins. We want vite/rollup to
49
- // inline dependencies in the server build. This gets round runtime
50
- // importing of "server-only" and other packages with poisoned imports.
51
- //
52
- // Files included in `noExternal` are files we want Vite to analyze
53
- // As of vite 5.2 `true` here means "all except node built-ins"
54
- noExternal: true,
55
- // TODO (RSC): Other frameworks build for RSC without `noExternal: true`.
56
- // What are we missing here? When/why is that a better choice? I know
57
- // we would have to explicitly add a bunch of packages to noExternal, if
58
- // we wanted to go that route.
59
- // noExternal: ['@tobbe.dev/rsc-test'],
60
- // Can't inline prisma client (db calls fail at runtime) or react-dom
61
- // (css pre-init failure)
62
- // Server store has to be externalized, because it's a singleton (shared between FW and App)
63
- external: [
64
- "@prisma/client",
65
- "@prisma/adapter-better-sqlite3",
66
- "@prisma/fetch-engine",
67
- "@prisma/internals",
68
- "better-sqlite3",
69
- "@cedarjs/auth-dbauth-api",
70
- "@cedarjs/cookie-jar",
71
- "@cedarjs/realtime",
72
- "@cedarjs/server-store",
73
- "@simplewebauthn/server",
74
- "graphql-scalars",
75
- "minimatch",
76
- "playwright",
77
- "react-dom"
78
- ],
79
- resolve: {
80
- // These conditions are used in the plugin pipeline, and only affect non-externalized
81
- // dependencies during the SSR build. Which because of `noExternal: true` means all
82
- // dependencies apart from node built-ins.
83
- // TODO (RSC): What's the difference between `conditions` and
84
- // `externalConditions`? When is one used over the other?
85
- //
86
- // In Vite 6, we must include `defaultServerConditions` alongside
87
- // `react-server` so that nested condition maps (e.g. the `node`
88
- // sub-condition inside `react-server-dom-webpack/server`'s exports)
89
- // can still be resolved. Without `node` (or another environment
90
- // condition), the commonjs resolver throws "No known conditions for
91
- // './server' specifier in 'react-server-dom-webpack' package".
92
- conditions: ["react-server", ...import_vite.defaultServerConditions],
93
- externalConditions: ["react-server", ...import_vite.defaultServerConditions]
94
- }
95
- },
96
- plugins: [
97
- // The rscTransformUseClientPlugin maps paths like
98
- // /Users/tobbe/.../rw-app/node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js
99
- // to
100
- // /Users/tobbe/.../rw-app/web/dist/ssr/assets/rsc0.js
101
- // That's why it needs the `clientEntryFiles` data
102
- // (It does other things as well, but that's why it needs clientEntryFiles)
103
- (0, import_vite_plugin_rsc_transform_client.rscTransformUseClientPlugin)(clientEntryFiles),
104
- (0, import_vite_plugin_rsc_transform_server.rscTransformUseServerPlugin)(outDir, serverEntryFiles),
105
- (0, import_vite_plugin_rsc_routes_imports.rscRoutesImports)()
106
- ],
107
- build: {
108
- // TODO (RSC): Remove `minify: false` when we don't need to debug as often
109
- minify: false,
110
- ssr: true,
111
- ssrEmitAssets: true,
112
- outDir,
113
- emptyOutDir: true,
114
- // Needed because `outDir` is not inside `root`
115
- manifest: "server-build-manifest.json",
116
- rollupOptions: {
117
- onwarn: import_onWarn.onWarn,
118
- external: ["@cedarjs/realtime"],
119
- input: {
120
- ...entryFiles,
121
- ...clientEntryFiles,
122
- ...serverEntryFiles,
123
- ...customModules,
124
- "entry.server": rwPaths.web.entryServer
125
- },
126
- output: {
127
- banner: (chunk) => {
128
- let code = "";
129
- const clientValues = Object.values(clientEntryFiles);
130
- if (chunk.moduleIds.some((id) => clientValues.includes(id))) {
131
- code += '"use client";';
132
- }
133
- const serverValues = Object.values(serverEntryFiles);
134
- if (chunk.moduleIds.some((id) => serverValues.includes(id))) {
135
- code += '"use server";';
136
- }
137
- return code;
138
- },
139
- entryFileNames: (chunkInfo) => {
140
- if (entryFilesKeys.includes(chunkInfo.name)) {
141
- return "assets/[name]-[hash].mjs";
142
- }
143
- if (chunkInfo.name === "entry.server" || customModules[chunkInfo.name]) {
144
- return "[name].mjs";
145
- }
146
- return "assets/[name].mjs";
147
- },
148
- chunkFileNames: `assets/[name]-[hash].mjs`,
149
- // This is not ideal. See
150
- // https://rollupjs.org/faqs/#why-do-additional-imports-turn-up-in-my-entry-chunks-when-code-splitting
151
- // But we need it to prevent `import 'client-only'` from being
152
- // hoisted into App.tsx
153
- // TODO (RSC): Fix when https://github.com/rollup/rollup/issues/5235
154
- // is resolved
155
- hoistTransitiveImports: false
156
- }
157
- }
158
- }
159
- });
160
- if (!("output" in rscServerBuildOutput)) {
161
- throw new Error("Unexpected rsc server build output");
162
- }
163
- return rscServerBuildOutput.output;
164
- }
165
- // Annotate the CommonJS export names for ESM import in node:
166
- 0 && (module.exports = {
167
- rscBuildForServer
168
- });
@@ -1,173 +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 rscBuildForSsr_exports = {};
30
- __export(rscBuildForSsr_exports, {
31
- rscBuildForSsr: () => rscBuildForSsr
32
- });
33
- module.exports = __toCommonJS(rscBuildForSsr_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_vite = require("vite");
36
- var import_vite_plugin_cjs_interop = require("vite-plugin-cjs-interop");
37
- var import_project_config = require("@cedarjs/project-config");
38
- var import_onWarn = require("../lib/onWarn.js");
39
- var import_vite_plugin_rsc_routes_auto_loader = require("../plugins/vite-plugin-rsc-routes-auto-loader.js");
40
- var import_vite_plugin_rsc_ssr_router_import = require("../plugins/vite-plugin-rsc-ssr-router-import.js");
41
- async function rscBuildForSsr({
42
- clientEntryFiles,
43
- verbose = false
44
- }) {
45
- console.log("\n");
46
- console.log("3. rscBuildForSsr");
47
- console.log("=================\n");
48
- const rwPaths = (0, import_project_config.getPaths)();
49
- if (!rwPaths.web.entryClient) {
50
- throw new Error("No client entry file found inside " + rwPaths.web.src);
51
- }
52
- if (!rwPaths.web.entryServer) {
53
- throw new Error("No server entry file found inside " + rwPaths.web.src);
54
- }
55
- const ssrBuildOutput = await (0, import_vite.build)({
56
- envFile: false,
57
- define: {
58
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
59
- },
60
- ssr: {
61
- // Inline every file apart from node built-ins. We want vite/rollup to
62
- // inline dependencies in the server build. This gets round runtime
63
- // importing of "server-only" and other packages with poisoned imports.
64
- //
65
- // Files included in `noExternal` are files we want Vite to analyze
66
- // As of vite 5.2 `true` here means "all except node built-ins"
67
- noExternal: true,
68
- external: [
69
- "@prisma/client",
70
- "@prisma/adapter-better-sqlite3",
71
- "@prisma/fetch-engine",
72
- "@prisma/internals",
73
- "better-sqlite3",
74
- "@cedarjs/auth-dbauth-api",
75
- "@cedarjs/cookie-jar",
76
- "@cedarjs/realtime",
77
- "@cedarjs/server-store",
78
- "@simplewebauthn/server",
79
- "graphql-scalars",
80
- "minimatch",
81
- "playwright"
82
- ]
83
- },
84
- plugins: [
85
- (0, import_vite_plugin_cjs_interop.cjsInterop)({
86
- dependencies: [
87
- // Skip ESM modules: rwjs/auth, rwjs/web, rwjs/auth-*-middleware, rwjs/router
88
- "@cedarjs/forms",
89
- "@cedarjs/prerender/*",
90
- "@cedarjs/auth-*-api",
91
- "@cedarjs/auth-!(dbauth)-web"
92
- ]
93
- }),
94
- (0, import_vite_plugin_rsc_routes_auto_loader.rscRoutesAutoLoader)(),
95
- (0, import_vite_plugin_rsc_ssr_router_import.rscSsrRouterImport)()
96
- ],
97
- build: {
98
- // TODO (RSC): Remove `minify: false` when we don't need to debug as often
99
- minify: false,
100
- outDir: rwPaths.web.distSsr,
101
- ssr: true,
102
- emptyOutDir: true,
103
- // Needed because `outDir` is not inside `root`
104
- rollupOptions: {
105
- onwarn: import_onWarn.onWarn,
106
- external: ["@cedarjs/realtime"],
107
- input: {
108
- // @MARK: temporary hack to find the entry client so we can get the
109
- // index.css bundle but we don't actually want this on an rsc page!
110
- // TODO (RSC): Look into if we can remove this (and perhaps instead
111
- // use entry.server)
112
- __cedarjs__client_entry: rwPaths.web.entryClient,
113
- "entry.server": rwPaths.web.entryServer,
114
- // we need this, so that the output contains rsc-specific bundles
115
- // for the client-only components. They get loaded once the page is
116
- // rendered
117
- ...clientEntryFiles,
118
- // These import redirections are so that we don't bundle multiple versions of react
119
- __cedarjs__react: "react",
120
- __cedarjs__location: "@cedarjs/router/location",
121
- __cedarjs__server_auth_provider: "@cedarjs/auth/ServerAuthProvider",
122
- __cedarjs__server_inject: "@cedarjs/web/serverInject",
123
- "__cedarjs__rsdw-client": "react-server-dom-webpack/client.edge",
124
- // TODO (RSC): add __cedarjs__ prefix to the entry below
125
- "rd-server": "react-dom/server.edge",
126
- // We need the document for React's fallback
127
- Document: rwPaths.web.document
128
- },
129
- preserveEntrySignatures: "exports-only",
130
- output: {
131
- // This is not ideal. See
132
- // https://rollupjs.org/faqs/#why-do-additional-imports-turn-up-in-my-entry-chunks-when-code-splitting
133
- // But we need it to prevent `import 'client-only'` from being
134
- // hoisted into App.tsx
135
- // TODO (RSC): Fix when https://github.com/rollup/rollup/issues/5235
136
- // is resolved
137
- hoistTransitiveImports: false,
138
- entryFileNames: (chunkInfo) => {
139
- if (chunkInfo.name === "rd-server" || chunkInfo.name === "__cedarjs__react" || chunkInfo.name === "__cedarjs__location" || chunkInfo.name === "__cedarjs__server_auth_provider" || chunkInfo.name === "__cedarjs__server_inject" || chunkInfo.name === "__cedarjs__rsdw-client" || chunkInfo.name === "entry.server" || chunkInfo.name === "Document") {
140
- return "[name].mjs";
141
- }
142
- return "assets/[name]-[hash].mjs";
143
- },
144
- chunkFileNames: `assets/[name]-[hash].mjs`
145
- }
146
- },
147
- manifest: "client-build-manifest-ssr.json"
148
- },
149
- esbuild: {
150
- logLevel: verbose ? "debug" : "silent",
151
- logOverride: {
152
- "unsupported-dynamic-import": "silent"
153
- }
154
- },
155
- logLevel: verbose ? "info" : "silent"
156
- });
157
- if (!("output" in ssrBuildOutput)) {
158
- throw new Error("Unexpected vite ssr build output");
159
- }
160
- const entryServerMjs = import_node_fs.default.readFileSync((0, import_project_config.getBuiltServerEntryFile)(), "utf-8");
161
- import_node_fs.default.writeFileSync(
162
- (0, import_project_config.getBuiltServerEntryFile)(),
163
- entryServerMjs.replace(
164
- /import (require\S+) from "graphql-scalars";/,
165
- 'import * as $1 from "graphql-scalars";'
166
- )
167
- );
168
- return ssrBuildOutput.output;
169
- }
170
- // Annotate the CommonJS export names for ESM import in node:
171
- 0 && (module.exports = {
172
- rscBuildForSsr
173
- });
@@ -1,56 +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 rscBuildRwEnvVars_exports = {};
30
- __export(rscBuildRwEnvVars_exports, {
31
- rscBuildRwEnvVars: () => rscBuildRwEnvVars
32
- });
33
- module.exports = __toCommonJS(rscBuildRwEnvVars_exports);
34
- var import_promises = __toESM(require("fs/promises"), 1);
35
- var import_project_config = require("@cedarjs/project-config");
36
- async function rscBuildRwEnvVars() {
37
- console.log("\n");
38
- console.log("7. rscBuildRwEnvVars");
39
- console.log("====================\n");
40
- const rwPaths = (0, import_project_config.getPaths)();
41
- await import_promises.default.appendFile(
42
- rwPaths.web.distRscEntries,
43
- `
44
-
45
- globalThis.RWJS_API_GRAPHQL_URL = RWJS_ENV.RWJS_API_GRAPHQL_URL
46
- globalThis.RWJS_API_URL = RWJS_ENV.RWJS_API_URL
47
- globalThis.__REDWOOD__APP_TITLE = RWJS_ENV.__REDWOOD__APP_TITLE
48
- globalThis.RWJS_EXP_STREAMING_SSR = RWJS_ENV.RWJS_EXP_STREAMING_SSR
49
- globalThis.RWJS_EXP_RSC = RWJS_ENV.RWJS_EXP_RSC
50
- `
51
- );
52
- }
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- rscBuildRwEnvVars
56
- });