@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.
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 +0 -4
  3. package/dist/apiDevMiddleware.d.ts.map +1 -1
  4. package/dist/apiDevMiddleware.js +9 -105
  5. package/dist/buildApp.d.ts.map +1 -1
  6. package/dist/buildApp.js +18 -79
  7. package/dist/buildRouteHooks.d.ts.map +1 -1
  8. package/dist/buildRouteHooks.js +4 -36
  9. package/dist/bundled/react-server-dom-webpack.server.js +99 -192
  10. package/dist/cedar-unified-dev.d.ts +0 -18
  11. package/dist/cedar-unified-dev.d.ts.map +1 -1
  12. package/dist/cedar-unified-dev.js +5 -39
  13. package/dist/cjs/ClientRouter.d.ts +1 -0
  14. package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +37 -0
  15. package/dist/cjs/apiDevMiddleware.js +371 -0
  16. package/dist/cjs/build/build.d.ts +1 -0
  17. package/dist/cjs/build/build.js +58 -0
  18. package/dist/cjs/buildApp.js +306 -0
  19. package/dist/cjs/buildFeServer.d.ts +1 -0
  20. package/dist/cjs/buildFeServer.js +63 -0
  21. package/dist/cjs/buildRouteHooks.js +80 -0
  22. package/dist/cjs/buildRouteManifest.js +92 -0
  23. package/dist/cjs/buildRscClientAndServer.js +54 -0
  24. package/dist/cjs/cedar-unified-dev.js +310 -0
  25. package/dist/cjs/client.d.ts +1 -0
  26. package/dist/cjs/clientSsr.d.ts +1 -0
  27. package/dist/cjs/devFeServer.js +157 -0
  28. package/dist/cjs/index.d.ts +1 -0
  29. package/dist/cjs/index.js +141 -0
  30. package/dist/cjs/lib/StatusError.js +37 -0
  31. package/dist/cjs/lib/entries.js +52 -0
  32. package/dist/cjs/lib/getMergedConfig.js +185 -0
  33. package/dist/cjs/lib/onWarn.js +36 -0
  34. package/dist/cjs/lib/registerFwGlobalsAndShims.js +102 -0
  35. package/dist/cjs/lib/workspacePackageAliases.js +107 -0
  36. package/dist/cjs/middleware/index.js +22 -0
  37. package/dist/cjs/middleware/invokeMiddleware.js +52 -0
  38. package/dist/cjs/middleware/register.js +105 -0
  39. package/dist/cjs/middleware/types.js +16 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/cjs/plugins/vite-plugin-cedar-auto-import.js +107 -0
  42. package/dist/cjs/plugins/vite-plugin-cedar-cell.js +183 -0
  43. package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +341 -0
  44. package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +95 -0
  45. package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +107 -0
  46. package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +67 -0
  47. package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +118 -0
  48. package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +43 -0
  49. package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +61 -0
  50. package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +76 -0
  51. package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +126 -0
  52. package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +346 -0
  53. package/dist/cjs/plugins/vite-plugin-cedar-wait-for-api-server.js +134 -0
  54. package/dist/cjs/plugins/vite-plugin-cedarjs-job-path-injector.js +134 -0
  55. package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +106 -0
  56. package/dist/cjs/plugins/vite-plugin-jsx-loader.js +42 -0
  57. package/dist/cjs/plugins/vite-plugin-merged-config.js +39 -0
  58. package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +104 -0
  59. package/dist/cjs/plugins/vite-plugin-rsc-reload.js +75 -0
  60. package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +159 -0
  61. package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +125 -0
  62. package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +75 -0
  63. package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +228 -0
  64. package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +398 -0
  65. package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +46 -0
  66. package/dist/cjs/rsc/rscBuildAnalyze.js +126 -0
  67. package/dist/cjs/rsc/rscBuildClient.js +91 -0
  68. package/dist/cjs/rsc/rscBuildCopyCssAssets.js +56 -0
  69. package/dist/cjs/rsc/rscBuildEntriesFile.js +115 -0
  70. package/dist/cjs/rsc/rscBuildForServer.js +168 -0
  71. package/dist/cjs/rsc/rscBuildForSsr.js +173 -0
  72. package/dist/cjs/rsc/rscBuildRwEnvVars.js +56 -0
  73. package/dist/cjs/rsc/rscRenderer.js +165 -0
  74. package/dist/cjs/rsc/rscRequestHandler.js +162 -0
  75. package/dist/cjs/rsc/rscStudioHandlers.js +156 -0
  76. package/dist/cjs/runFeServer.js +165 -0
  77. package/dist/cjs/streaming/buildForStreamingServer.js +65 -0
  78. package/dist/cjs/streaming/collectCss.js +52 -0
  79. package/dist/cjs/streaming/createReactStreamingHandler.js +173 -0
  80. package/dist/cjs/streaming/streamHelpers.js +230 -0
  81. package/dist/cjs/streaming/transforms/bufferedTransform.js +61 -0
  82. package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +34 -0
  83. package/dist/cjs/streaming/transforms/encode-decode.js +36 -0
  84. package/dist/cjs/streaming/transforms/serverInjectionTransform.js +84 -0
  85. package/dist/cjs/streaming/triggerRouteHooks.js +96 -0
  86. package/dist/cjs/types.js +16 -0
  87. package/dist/cjs/utils.js +92 -0
  88. package/dist/devFeServer.js +8 -3
  89. package/dist/index.d.ts +4 -10
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +19 -45
  92. package/dist/lib/getMergedConfig.d.ts.map +1 -1
  93. package/dist/lib/getMergedConfig.js +0 -4
  94. package/dist/package.json +1 -0
  95. package/dist/plugins/vite-plugin-cedar-auto-import.d.ts +1 -1
  96. package/dist/plugins/vite-plugin-cedar-auto-import.d.ts.map +1 -1
  97. package/dist/plugins/vite-plugin-cedar-auto-import.js +1 -8
  98. package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
  99. package/dist/plugins/vite-plugin-cedar-cell.js +1 -2
  100. package/dist/plugins/{vite-plugin-handler-als-wrapping.d.ts → vite-plugin-cedar-context-wrapping.d.ts} +12 -12
  101. package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +1 -0
  102. package/dist/plugins/{vite-plugin-handler-als-wrapping.js → vite-plugin-cedar-context-wrapping.js} +16 -16
  103. package/dist/plugins/vite-plugin-cedar-import-dir.d.ts.map +1 -1
  104. package/dist/plugins/vite-plugin-cedar-import-dir.js +15 -33
  105. package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +3 -0
  106. package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +1 -0
  107. package/dist/plugins/vite-plugin-cedar-node-polyfills.js +19 -0
  108. package/dist/plugins/vite-plugin-cedar-universal-deploy.js +1 -1
  109. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map +1 -1
  110. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +0 -14
  111. package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +0 -3
  112. package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
  113. package/dist/plugins/vite-plugin-swap-apollo-provider.js +2 -2
  114. package/dist/rsc/rscBuildForSsr.d.ts.map +1 -1
  115. package/dist/rsc/rscBuildForSsr.js +5 -3
  116. package/dist/streaming/buildForStreamingServer.d.ts.map +1 -1
  117. package/dist/streaming/buildForStreamingServer.js +5 -3
  118. package/package.json +52 -42
  119. package/dist/lib/generateDiffSourceMap.d.ts +0 -18
  120. package/dist/lib/generateDiffSourceMap.d.ts.map +0 -1
  121. package/dist/lib/generateDiffSourceMap.js +0 -151
  122. package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +0 -3
  123. package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +0 -1
  124. package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +0 -43
  125. package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +0 -12
  126. package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +0 -1
  127. package/dist/plugins/vite-plugin-cedar-directory-named-import.js +0 -35
  128. package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +0 -29
  129. package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +0 -1
  130. package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +0 -76
  131. package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +0 -42
  132. package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +0 -1
  133. package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +0 -93
  134. package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts +0 -28
  135. package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts.map +0 -1
  136. package/dist/plugins/vite-plugin-cedar-log-formatter-dev.js +0 -67
  137. package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts +0 -28
  138. package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +0 -1
  139. package/dist/plugins/vite-plugin-cedar-mock-cell-data.js +0 -247
  140. package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +0 -39
  141. package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +0 -1
  142. package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +0 -200
  143. package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +0 -1
@@ -0,0 +1,95 @@
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 vite_plugin_cedar_context_wrapping_exports = {};
30
+ __export(vite_plugin_cedar_context_wrapping_exports, {
31
+ applyContextWrapping: () => applyContextWrapping,
32
+ cedarContextWrappingPlugin: () => cedarContextWrappingPlugin
33
+ });
34
+ module.exports = __toCommonJS(vite_plugin_cedar_context_wrapping_exports);
35
+ var import_node_path = __toESM(require("node:path"), 1);
36
+ var import_vite = require("vite");
37
+ var import_project_config = require("@cedarjs/project-config");
38
+ function cedarContextWrappingPlugin({
39
+ projectIsEsm = false
40
+ } = {}) {
41
+ return {
42
+ name: "cedar-context-wrapping",
43
+ transform(code, id) {
44
+ let paths;
45
+ try {
46
+ paths = (0, import_project_config.getPaths)();
47
+ } catch {
48
+ return null;
49
+ }
50
+ const functionsDir = (0, import_vite.normalizePath)(import_node_path.default.join(paths.api.src, "functions"));
51
+ if (!(0, import_vite.normalizePath)(id).startsWith(functionsDir + "/")) {
52
+ return null;
53
+ }
54
+ const wrapped = applyContextWrapping(code, { projectIsEsm });
55
+ return wrapped ? { code: wrapped, map: null } : null;
56
+ }
57
+ };
58
+ }
59
+ function applyContextWrapping(code, { projectIsEsm = false } = {}) {
60
+ const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
61
+ const handlerMatch = handlerRe.exec(code);
62
+ if (!handlerMatch) {
63
+ return null;
64
+ }
65
+ const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
66
+ const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
67
+ const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
68
+ const importStatement = `import { getAsyncStoreInstance as __rw_getAsyncStoreInstance } from '${storePath}'
69
+ `;
70
+ const handlerStart = handlerMatch.index;
71
+ const before = code.slice(0, handlerStart);
72
+ const after = code.slice(handlerStart);
73
+ const renamed = after.replace(handlerRe, "const __rw_handler =");
74
+ const wrappedHandler = `
75
+ export const handler = ${isAsync ? "async " : ""}(__rw_event, __rw__context) => {
76
+ // The store will be undefined if no context isolation has been performed yet
77
+ const __rw_contextStore = __rw_getAsyncStoreInstance().getStore()
78
+ if (__rw_contextStore === undefined) {
79
+ return __rw_getAsyncStoreInstance().run(
80
+ new Map(),
81
+ __rw_handler,
82
+ __rw_event,
83
+ __rw__context
84
+ )
85
+ }
86
+ return __rw_handler(__rw_event, __rw__context)
87
+ }
88
+ `;
89
+ return before + importStatement + renamed + wrappedHandler;
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ applyContextWrapping,
94
+ cedarContextWrappingPlugin
95
+ });
@@ -0,0 +1,107 @@
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 vite_plugin_cedar_entry_injection_exports = {};
30
+ __export(vite_plugin_cedar_entry_injection_exports, {
31
+ cedarEntryInjectionPlugin: () => cedarEntryInjectionPlugin
32
+ });
33
+ module.exports = __toCommonJS(vite_plugin_cedar_entry_injection_exports);
34
+ var import_node_fs = __toESM(require("node:fs"), 1);
35
+ var import_node_path = __toESM(require("node:path"), 1);
36
+ var import_vite = require("vite");
37
+ var import_project_config = require("@cedarjs/project-config");
38
+ function cedarEntryInjectionPlugin() {
39
+ const cedarPaths = (0, import_project_config.getPaths)();
40
+ const clientEntryPath = cedarPaths.web.entryClient;
41
+ if (!clientEntryPath) {
42
+ throw new Error(
43
+ "Vite client entry point not found. Please check that your project has an entry.client.{jsx,tsx} file in the web/src directory."
44
+ );
45
+ }
46
+ const relativeEntryPath = (0, import_vite.normalizePath)(
47
+ import_node_path.default.relative(cedarPaths.web.base, clientEntryPath)
48
+ );
49
+ return {
50
+ name: "cedar-entry-injection",
51
+ // Vite's dependency optimizer and dev server resolve the script tag
52
+ // src="/src/entry.client.{tsx,jsx}" as an absolute filesystem path
53
+ // (/src/entry.client.tsx) instead of relative to the Vite root.
54
+ // This hook maps it to the real file path so Vite can find it.
55
+ resolveId(id) {
56
+ if (id === "/" + relativeEntryPath) {
57
+ return clientEntryPath;
58
+ }
59
+ return null;
60
+ },
61
+ // ---------- Bundle injection ----------
62
+ // Used by Vite during dev, to inject the entrypoint.
63
+ transformIndexHtml: {
64
+ order: "pre",
65
+ handler: (html, ctx) => {
66
+ if (!ctx.filename || (0, import_vite.normalizePath)(ctx.filename) !== (0, import_vite.normalizePath)(cedarPaths.web.html)) {
67
+ return html;
68
+ }
69
+ if (import_node_fs.default.existsSync(clientEntryPath)) {
70
+ return html.replace(
71
+ "</head>",
72
+ // @NOTE the slash in front, for windows compatibility and for
73
+ // pages in subdirectories
74
+ `<script type="module" src="/${relativeEntryPath}"></script>
75
+ </head>`
76
+ );
77
+ } else {
78
+ return html;
79
+ }
80
+ }
81
+ },
82
+ // Used by rollup during build to inject the entrypoint
83
+ // but note index.html does not come through as an id during dev
84
+ transform: (code, id) => {
85
+ if (import_node_fs.default.existsSync(clientEntryPath) && (0, import_vite.normalizePath)(id) === (0, import_vite.normalizePath)(cedarPaths.web.html)) {
86
+ return {
87
+ code: code.replace(
88
+ "</head>",
89
+ `<script type="module" src="/${relativeEntryPath}"></script>
90
+ </head>`
91
+ ),
92
+ map: null
93
+ };
94
+ } else {
95
+ return {
96
+ code,
97
+ map: null
98
+ // Returning null here preserves the original sourcemap
99
+ };
100
+ }
101
+ }
102
+ };
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ cedarEntryInjectionPlugin
107
+ });
@@ -0,0 +1,67 @@
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 vite_plugin_cedar_html_env_exports = {};
20
+ __export(vite_plugin_cedar_html_env_exports, {
21
+ cedarHtmlEnvPlugin: () => cedarHtmlEnvPlugin
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_cedar_html_env_exports);
24
+ var import_project_config = require("@cedarjs/project-config");
25
+ function cedarHtmlEnvPlugin() {
26
+ return {
27
+ name: "cedar-html-env",
28
+ // Vite can support replacing environment variables in index.html but
29
+ // there are currently two issues with that:
30
+ // 1. It requires the environment variables to be exposed on
31
+ // `import.meta.env`, but we expose them on `process.env` in Redwood.
32
+ // 2. There's an open issue on Vite where it adds extra quotes around
33
+ // the replaced values, which breaks trying to use environment
34
+ // variables in src attributes for example.
35
+ // Until those issues are resolved, we'll do the replacement ourselves
36
+ // instead using transformIndexHtml. Doing it this was was also the
37
+ // recommended way until Vite added built-in support for it.
38
+ //
39
+ // Extra quotes issue: https://github.com/vitejs/vite/issues/13424
40
+ // transformIndexHtml being the recommended way:
41
+ // https://github.com/vitejs/vite/issues/3105#issuecomment-1059975023
42
+ transformIndexHtml: {
43
+ // Setting order: 'pre' so that it runs before the built-in
44
+ // html env replacement.
45
+ order: "pre",
46
+ handler: (html) => {
47
+ let newHtml = html;
48
+ (0, import_project_config.getConfig)().web.includeEnvironmentVariables.map((envName) => {
49
+ newHtml = newHtml.replaceAll(
50
+ `%${envName}%`,
51
+ process.env[envName] || ""
52
+ );
53
+ });
54
+ Object.entries(process.env).forEach(([envName, value]) => {
55
+ if (envName.startsWith("REDWOOD_ENV_")) {
56
+ newHtml = newHtml.replaceAll(`%${envName}%`, value || "");
57
+ }
58
+ });
59
+ return newHtml;
60
+ }
61
+ }
62
+ };
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ cedarHtmlEnvPlugin
67
+ });
@@ -0,0 +1,118 @@
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 vite_plugin_cedar_import_dir_exports = {};
30
+ __export(vite_plugin_cedar_import_dir_exports, {
31
+ cedarImportDirPlugin: () => cedarImportDirPlugin
32
+ });
33
+ module.exports = __toCommonJS(vite_plugin_cedar_import_dir_exports);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
+ var import_napi = require("@ast-grep/napi");
36
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
37
+ var import_project_config = require("@cedarjs/project-config");
38
+ function cedarImportDirPlugin() {
39
+ return {
40
+ name: "vite-plugin-cedar-import-dir",
41
+ enforce: "pre",
42
+ async transform(code, id) {
43
+ if (!code.includes("/**/")) {
44
+ return null;
45
+ }
46
+ const ext = import_node_path.default.extname(id);
47
+ const language = ext === ".ts" || ext === ".tsx" ? import_napi.Lang.TypeScript : import_napi.Lang.JavaScript;
48
+ let ast;
49
+ try {
50
+ ast = (0, import_napi.parse)(language, code);
51
+ } catch (error) {
52
+ console.warn("Failed to parse file:", id);
53
+ console.warn(error);
54
+ return null;
55
+ }
56
+ const root = ast.root();
57
+ let hasTransformations = false;
58
+ const edits = [];
59
+ const globImports = root.findAll({
60
+ rule: {
61
+ pattern: "import $DEFAULT_IMPORT from $SOURCE"
62
+ }
63
+ });
64
+ for (const importNode of globImports) {
65
+ const sourceNode = importNode.getMatch("SOURCE");
66
+ const defaultImportNode = importNode.getMatch("DEFAULT_IMPORT");
67
+ if (!sourceNode || !defaultImportNode) {
68
+ continue;
69
+ }
70
+ const sourceValue = sourceNode.text().slice(1, -1);
71
+ if (!sourceValue.includes("/**/")) {
72
+ continue;
73
+ }
74
+ hasTransformations = true;
75
+ const importName = defaultImportNode.text();
76
+ const importGlob = (0, import_project_config.importStatementPath)(sourceValue);
77
+ const cwd = importGlob.startsWith("src/") ? (0, import_project_config.getPaths)().api.base : import_node_path.default.dirname(id);
78
+ try {
79
+ const dirFiles = import_fast_glob.default.sync(importGlob, { cwd }).filter(
80
+ (n) => !n.includes(".test.") && !n.includes(".scenarios.") && !n.includes(".d.ts")
81
+ );
82
+ const staticGlob = importGlob.split("*")[0];
83
+ const filePathToVarName = (filePath) => {
84
+ return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
85
+ };
86
+ let replacement = `let ${importName} = {};
87
+ `;
88
+ for (const filePath of dirFiles) {
89
+ const { dir: fileDir, name: fileName } = import_node_path.default.parse(filePath);
90
+ const fileImportPath = fileDir + "/" + fileName;
91
+ const filePathVarName = filePathToVarName(filePath);
92
+ const namespaceImportName = `${importName}_${filePathVarName}`;
93
+ replacement += `import * as ${namespaceImportName} from '${fileImportPath}';
94
+ `;
95
+ replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
96
+ `;
97
+ }
98
+ edits.push(importNode.replace(replacement.trim()));
99
+ } catch (error) {
100
+ console.warn(`Failed to process glob import: ${sourceValue}`, error);
101
+ }
102
+ }
103
+ if (hasTransformations && edits.length > 0) {
104
+ const transformedCode = root.commitEdits(edits);
105
+ return {
106
+ code: transformedCode,
107
+ map: null
108
+ // For simplicity, not generating source maps
109
+ };
110
+ }
111
+ return null;
112
+ }
113
+ };
114
+ }
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ cedarImportDirPlugin
118
+ });
@@ -0,0 +1,43 @@
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 vite_plugin_cedar_node_polyfills_exports = {};
20
+ __export(vite_plugin_cedar_node_polyfills_exports, {
21
+ cedarNodePolyfills: () => cedarNodePolyfills
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_cedar_node_polyfills_exports);
24
+ var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
25
+ var import_project_config = require("@cedarjs/project-config");
26
+ function cedarNodePolyfills() {
27
+ if ((0, import_project_config.getConfig)().experimental?.rsc?.enabled) {
28
+ return void 0;
29
+ }
30
+ return {
31
+ ...(0, import_vite_plugin_node_polyfills.nodePolyfills)({
32
+ include: ["buffer"],
33
+ globals: {
34
+ Buffer: true
35
+ }
36
+ }),
37
+ apply: "serve"
38
+ };
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ cedarNodePolyfills
43
+ });
@@ -0,0 +1,61 @@
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 vite_plugin_cedar_remove_dev_fatal_error_page_exports = {};
20
+ __export(vite_plugin_cedar_remove_dev_fatal_error_page_exports, {
21
+ cedarRemoveDevFatalErrorPage: () => cedarRemoveDevFatalErrorPage
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_cedar_remove_dev_fatal_error_page_exports);
24
+ const DEV_FATAL_ERROR_PAGE_MODULE = "@cedarjs/web/dist/components/DevFatalErrorPage";
25
+ function escapeRegExp(s) {
26
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27
+ }
28
+ const ESCAPED_MODULE = escapeRegExp(DEV_FATAL_ERROR_PAGE_MODULE);
29
+ const IMPORT_PATTERN = new RegExp(
30
+ `import\\s*\\{[^}]*\\bDevFatalErrorPage\\b[^}]*\\}\\s*from\\s*['"]${ESCAPED_MODULE}['"]`
31
+ );
32
+ function cedarRemoveDevFatalErrorPage() {
33
+ let config;
34
+ return {
35
+ name: "cedar-remove-dev-fatal-error-page",
36
+ apply: "build",
37
+ configResolved(resolvedConfig) {
38
+ config = resolvedConfig;
39
+ },
40
+ transform(code) {
41
+ if (config.command === "build" && config.mode === "development") {
42
+ return null;
43
+ }
44
+ if (!code.includes(DEV_FATAL_ERROR_PAGE_MODULE)) {
45
+ return null;
46
+ }
47
+ const newCode = code.replace(
48
+ IMPORT_PATTERN,
49
+ "const DevFatalErrorPage = undefined"
50
+ );
51
+ if (newCode === code) {
52
+ return null;
53
+ }
54
+ return { code: newCode, map: null };
55
+ }
56
+ };
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ cedarRemoveDevFatalErrorPage
61
+ });
@@ -0,0 +1,76 @@
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 vite_plugin_cedar_remove_from_bundle_exports = {};
30
+ __export(vite_plugin_cedar_remove_from_bundle_exports, {
31
+ cedarRemoveFromBundle: () => cedarRemoveFromBundle,
32
+ excludeOnMatch: () => excludeOnMatch
33
+ });
34
+ module.exports = __toCommonJS(vite_plugin_cedar_remove_from_bundle_exports);
35
+ var import_node_fs = __toESM(require("node:fs"), 1);
36
+ var import_node_path = __toESM(require("node:path"), 1);
37
+ var import_project_config = require("@cedarjs/project-config");
38
+ function cedarRemoveFromBundle() {
39
+ const apiPackageJsonPath = import_node_path.default.join((0, import_project_config.getPaths)().api.base, "package.json");
40
+ const realtimeEnabled = import_node_fs.default.existsSync(apiPackageJsonPath) && import_node_fs.default.readFileSync(apiPackageJsonPath, "utf-8").includes("@cedarjs/realtime");
41
+ const modulesToExclude = [
42
+ {
43
+ id: /@cedarjs\/router\/dist\/splash-page/,
44
+ exportNames: ["SplashPage"]
45
+ }
46
+ ];
47
+ if (!realtimeEnabled) {
48
+ modulesToExclude.push({
49
+ id: /@cedarjs\/web\/dist\/apollo\/sseLink/
50
+ });
51
+ }
52
+ return {
53
+ name: "remove-from-bundle",
54
+ apply: "build",
55
+ load: (id) => {
56
+ return excludeOnMatch(modulesToExclude, id);
57
+ }
58
+ };
59
+ }
60
+ function generateModuleWithExports(exportNames) {
61
+ return {
62
+ code: `export default {}; ${exportNames.map((name) => `export const ${name} = undefined;`).join("\n")}`
63
+ };
64
+ }
65
+ function excludeOnMatch(modulesToExclude, id) {
66
+ const moduleToExclude = modulesToExclude.find((module2) => module2.id.test(id));
67
+ if (moduleToExclude) {
68
+ return generateModuleWithExports(moduleToExclude.exportNames || []);
69
+ }
70
+ return null;
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ cedarRemoveFromBundle,
75
+ excludeOnMatch
76
+ });