@cedarjs/vite 0.6.1-next.0 → 0.7.0

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.
@@ -1,14 +1,3 @@
1
- import * as babel from '@babel/core';
2
- import type { Flags } from '@cedarjs/babel-config';
3
- export declare const cleanWebBuild: () => void;
4
- export declare function prebuildWebFile(srcPath: string, flags?: Flags): Promise<babel.BabelFileResult | null>;
5
- export declare function transform(srcPath: string): Promise<string>;
6
- /**
7
- * Remove RedwoodJS "magic" from a user's code leaving JavaScript behind.
8
- *
9
- * Currently only used for debugging purposes
10
- */
11
- export declare const prebuildWebFiles: (srcFiles: string[], flags?: Flags) => Promise<(string | undefined)[]>;
12
1
  interface BuildOptions {
13
2
  verbose?: boolean;
14
3
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AAIpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAIlD,eAAO,MAAM,aAAa,YAIzB,CAAA;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,KAAU,yCAUvE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,mBAS9C;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAoB,MAAM,EAAE,UAAU,KAAK,oCAgCvE,CAAA;AAED,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,gBAAuB,YAAY,8GAoBvD,CAAA"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build/build.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,gBAAuB,YAAY,8GAoBvD,CAAA"}
@@ -1,57 +1,4 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import * as babel from "@babel/core";
4
- import fse from "fs-extra";
5
- import { transformWithEsbuild } from "vite";
6
- import { getWebSideDefaultBabelConfig } from "@cedarjs/babel-config";
7
1
  import { getPaths } from "@cedarjs/project-config";
8
- const cleanWebBuild = () => {
9
- const rwjsPaths = getPaths();
10
- fse.removeSync(rwjsPaths.web.dist);
11
- fse.removeSync(path.join(rwjsPaths.generated.prebuild, "web"));
12
- };
13
- async function prebuildWebFile(srcPath, flags = {}) {
14
- const code = await fs.promises.readFile(srcPath, "utf-8");
15
- const config = getWebSideDefaultBabelConfig(flags);
16
- const result = babel.transform(code, {
17
- ...config,
18
- cwd: getPaths().web.base,
19
- filename: srcPath
20
- });
21
- return result;
22
- }
23
- async function transform(srcPath) {
24
- const code = fs.readFileSync(srcPath, "utf-8");
25
- const loader = path.extname(srcPath).match(/^\.m?ts/) ? "tsx" : "jsx";
26
- const transformed = await transformWithEsbuild(code, srcPath, {
27
- loader
28
- });
29
- return transformed.code;
30
- }
31
- const prebuildWebFiles = async (srcFiles, flags) => {
32
- const rwjsPaths = getPaths();
33
- const processFile = async (srcPath) => {
34
- const relativePathFromSrc = path.relative(rwjsPaths.base, srcPath);
35
- const dstPath = path.join(rwjsPaths.generated.prebuild, relativePathFromSrc).replace(/\.(ts)$/, ".js");
36
- try {
37
- const result = await prebuildWebFile(srcPath, flags);
38
- if (!result?.code) {
39
- throw new Error("No code returned from prebuildWebFile");
40
- }
41
- await fs.promises.mkdir(path.dirname(dstPath), { recursive: true });
42
- await fs.promises.writeFile(dstPath, result.code);
43
- } catch {
44
- console.warn("Error:", srcPath, "could not prebuilt.");
45
- return void 0;
46
- }
47
- return dstPath;
48
- };
49
- const promises = [];
50
- for (const srcPath of srcFiles) {
51
- promises.push(processFile(srcPath));
52
- }
53
- return await Promise.all(promises);
54
- };
55
2
  const buildWeb = async ({ verbose }) => {
56
3
  const { build } = await import("vite");
57
4
  const viteConfig = getPaths().web.viteConfig;
@@ -70,9 +17,5 @@ const buildWeb = async ({ verbose }) => {
70
17
  });
71
18
  };
72
19
  export {
73
- buildWeb,
74
- cleanWebBuild,
75
- prebuildWebFile,
76
- prebuildWebFiles,
77
- transform
20
+ buildWeb
78
21
  };
@@ -28,67 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var build_exports = {};
30
30
  __export(build_exports, {
31
- buildWeb: () => buildWeb,
32
- cleanWebBuild: () => cleanWebBuild,
33
- prebuildWebFile: () => prebuildWebFile,
34
- prebuildWebFiles: () => prebuildWebFiles,
35
- transform: () => transform
31
+ buildWeb: () => buildWeb
36
32
  });
37
33
  module.exports = __toCommonJS(build_exports);
38
- var import_node_fs = __toESM(require("node:fs"), 1);
39
- var import_node_path = __toESM(require("node:path"), 1);
40
- var babel = __toESM(require("@babel/core"), 1);
41
- var import_fs_extra = __toESM(require("fs-extra"), 1);
42
- var import_vite = require("vite");
43
- var import_babel_config = require("@cedarjs/babel-config");
44
34
  var import_project_config = require("@cedarjs/project-config");
45
- const cleanWebBuild = () => {
46
- const rwjsPaths = (0, import_project_config.getPaths)();
47
- import_fs_extra.default.removeSync(rwjsPaths.web.dist);
48
- import_fs_extra.default.removeSync(import_node_path.default.join(rwjsPaths.generated.prebuild, "web"));
49
- };
50
- async function prebuildWebFile(srcPath, flags = {}) {
51
- const code = await import_node_fs.default.promises.readFile(srcPath, "utf-8");
52
- const config = (0, import_babel_config.getWebSideDefaultBabelConfig)(flags);
53
- const result = babel.transform(code, {
54
- ...config,
55
- cwd: (0, import_project_config.getPaths)().web.base,
56
- filename: srcPath
57
- });
58
- return result;
59
- }
60
- async function transform(srcPath) {
61
- const code = import_node_fs.default.readFileSync(srcPath, "utf-8");
62
- const loader = import_node_path.default.extname(srcPath).match(/^\.m?ts/) ? "tsx" : "jsx";
63
- const transformed = await (0, import_vite.transformWithEsbuild)(code, srcPath, {
64
- loader
65
- });
66
- return transformed.code;
67
- }
68
- const prebuildWebFiles = async (srcFiles, flags) => {
69
- const rwjsPaths = (0, import_project_config.getPaths)();
70
- const processFile = async (srcPath) => {
71
- const relativePathFromSrc = import_node_path.default.relative(rwjsPaths.base, srcPath);
72
- const dstPath = import_node_path.default.join(rwjsPaths.generated.prebuild, relativePathFromSrc).replace(/\.(ts)$/, ".js");
73
- try {
74
- const result = await prebuildWebFile(srcPath, flags);
75
- if (!result?.code) {
76
- throw new Error("No code returned from prebuildWebFile");
77
- }
78
- await import_node_fs.default.promises.mkdir(import_node_path.default.dirname(dstPath), { recursive: true });
79
- await import_node_fs.default.promises.writeFile(dstPath, result.code);
80
- } catch {
81
- console.warn("Error:", srcPath, "could not prebuilt.");
82
- return void 0;
83
- }
84
- return dstPath;
85
- };
86
- const promises = [];
87
- for (const srcPath of srcFiles) {
88
- promises.push(processFile(srcPath));
89
- }
90
- return await Promise.all(promises);
91
- };
92
35
  const buildWeb = async ({ verbose }) => {
93
36
  const { build } = await import("vite");
94
37
  const viteConfig = (0, import_project_config.getPaths)().web.viteConfig;
@@ -108,9 +51,5 @@ const buildWeb = async ({ verbose }) => {
108
51
  };
109
52
  // Annotate the CommonJS export names for ESM import in node:
110
53
  0 && (module.exports = {
111
- buildWeb,
112
- cleanWebBuild,
113
- prebuildWebFile,
114
- prebuildWebFiles,
115
- transform
54
+ buildWeb
116
55
  });
@@ -34,7 +34,6 @@ module.exports = __toCommonJS(getMergedConfig_exports);
34
34
  var import_node_path = __toESM(require("node:path"), 1);
35
35
  var import_vite = require("vite");
36
36
  var import_project_config = require("@cedarjs/project-config");
37
- var import_envVarDefinitions = require("./envVarDefinitions.js");
38
37
  function getMergedConfig(rwConfig, rwPaths) {
39
38
  return (userConfig, env) => {
40
39
  let apiHost = process.env.REDWOOD_API_HOST;
@@ -69,7 +68,7 @@ function getMergedConfig(rwConfig, rwPaths) {
69
68
  // },
70
69
  envPrefix: "REDWOOD_ENV_",
71
70
  publicDir: import_node_path.default.join(rwPaths.web.base, "public"),
72
- define: (0, import_envVarDefinitions.getEnvVarDefinitions)(),
71
+ define: (0, import_project_config.getEnvVarDefinitions)(),
73
72
  css: {
74
73
  // @NOTE config path is relative to where vite.config.js is if you use
75
74
  // a relative path
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,21 +15,12 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var registerFwGlobalsAndShims_exports = {};
30
20
  __export(registerFwGlobalsAndShims_exports, {
31
21
  registerFwGlobalsAndShims: () => registerFwGlobalsAndShims
32
22
  });
33
23
  module.exports = __toCommonJS(registerFwGlobalsAndShims_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
24
  var import_project_config = require("@cedarjs/project-config");
36
25
  const registerFwGlobalsAndShims = () => {
37
26
  registerFwGlobals();
@@ -39,13 +28,9 @@ const registerFwGlobalsAndShims = () => {
39
28
  };
40
29
  function registerFwGlobals() {
41
30
  const rwConfig = (0, import_project_config.getConfig)();
42
- const rwPaths = (0, import_project_config.getPaths)();
31
+ const envVars = (0, import_project_config.getEnvVarDefinitions)();
43
32
  globalThis.RWJS_ENV = {
44
- RWJS_API_GRAPHQL_URL: rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql",
45
- RWJS_API_URL: rwConfig.web.apiUrl,
46
- __REDWOOD__APP_TITLE: rwConfig.web.title || import_node_path.default.basename(rwPaths.base),
47
- RWJS_EXP_STREAMING_SSR: rwConfig.experimental.streamingSsr?.enabled,
48
- RWJS_EXP_RSC: rwConfig.experimental?.rsc?.enabled,
33
+ ...envVars.RWJS_ENV,
49
34
  RWJS_EXP_SSR_GRAPHQL_ENDPOINT: (() => {
50
35
  const apiPath = rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql";
51
36
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(apiPath)) {
@@ -83,10 +68,7 @@ function registerFwGlobals() {
83
68
  }
84
69
  })()
85
70
  };
86
- globalThis.RWJS_DEBUG_ENV = {
87
- RWJS_SRC_ROOT: rwPaths.web.src,
88
- REDWOOD_ENV_EDITOR: JSON.stringify(process.env.REDWOOD_ENV_EDITOR)
89
- };
71
+ globalThis.RWJS_DEBUG_ENV = envVars.RWJS_DEBUG_ENV;
90
72
  }
91
73
  function registerFwShims() {
92
74
  if (!(0, import_project_config.getConfig)().experimental?.rsc?.enabled) {
@@ -89,8 +89,7 @@ const addMiddlewareHandlers = (mwRegList = []) => {
89
89
  return mwRouter;
90
90
  };
91
91
  const createMiddlewareRouter = async (vite) => {
92
- const rwPaths = (0, import_project_config.getPaths)();
93
- const entryServerImport = vite ? await (0, import_utils.ssrLoadEntryServer)(vite) : await import((0, import_utils.makeFilePath)(rwPaths.web.distSsrEntryServer));
92
+ const entryServerImport = vite ? await (0, import_utils.ssrLoadEntryServer)(vite) : await import((0, import_utils.makeFilePath)((0, import_project_config.getBuiltServerEntryFile)()));
94
93
  const { registerMiddleware } = entryServerImport;
95
94
  if (!registerMiddleware) {
96
95
  return (0, import_find_my_way.default)();
@@ -153,12 +153,9 @@ async function rscBuildForSsr({
153
153
  if (!("output" in ssrBuildOutput)) {
154
154
  throw new Error("Unexpected vite ssr build output");
155
155
  }
156
- const entryServerMjs = import_node_fs.default.readFileSync(
157
- rwPaths.web.distSsrEntryServer,
158
- "utf-8"
159
- );
156
+ const entryServerMjs = import_node_fs.default.readFileSync((0, import_project_config.getBuiltServerEntryFile)(), "utf-8");
160
157
  import_node_fs.default.writeFileSync(
161
- rwPaths.web.distSsrEntryServer,
158
+ (0, import_project_config.getBuiltServerEntryFile)(),
162
159
  entryServerMjs.replace(
163
160
  /import (require\S+) from "graphql-scalars";/,
164
161
  'import * as $1 from "graphql-scalars";'
@@ -60,11 +60,11 @@ const createReactStreamingHandler = async ({
60
60
  const rscEnabled = rwConfig.experimental?.rsc?.enabled;
61
61
  if (isProd) {
62
62
  if (rscEnabled) {
63
- entryServerImport = await import((0, import_utils.makeFilePath)(rwPaths.web.distSsrEntryServer));
63
+ entryServerImport = await import((0, import_utils.makeFilePath)((0, import_project_config.getBuiltServerEntryFile)()));
64
64
  } else {
65
- entryServerImport = await import((0, import_utils.makeFilePath)(rwPaths.web.distSsrEntryServer));
65
+ entryServerImport = await import((0, import_utils.makeFilePath)((0, import_project_config.getBuiltServerEntryFile)()));
66
66
  }
67
- fallbackDocumentImport = await import((0, import_utils.makeFilePath)(rwPaths.web.distSsrDocument));
67
+ fallbackDocumentImport = await import((0, import_utils.makeFilePath)((0, import_project_config.getBuiltDocumentFile)()));
68
68
  }
69
69
  return async (req) => {
70
70
  let mwResponse = import_middleware.MiddlewareResponse.next();
@@ -1 +1 @@
1
- {"version":3,"file":"getMergedConfig.d.ts","sourceRoot":"","sources":["../../src/lib/getMergedConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAGjD,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAK5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,gBAC1C,UAAU,OAAO,SAAS,KAAG,UAAU,CAkI5D"}
1
+ {"version":3,"file":"getMergedConfig.d.ts","sourceRoot":"","sources":["../../src/lib/getMergedConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAGjD,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,gBAC1C,UAAU,OAAO,SAAS,KAAG,UAAU,CAkI5D"}
@@ -1,7 +1,10 @@
1
1
  import path from "node:path";
2
2
  import { mergeConfig } from "vite";
3
- import { getConfig, getPaths } from "@cedarjs/project-config";
4
- import { getEnvVarDefinitions } from "./envVarDefinitions.js";
3
+ import {
4
+ getConfig,
5
+ getEnvVarDefinitions,
6
+ getPaths
7
+ } from "@cedarjs/project-config";
5
8
  function getMergedConfig(rwConfig, rwPaths) {
6
9
  return (userConfig, env) => {
7
10
  let apiHost = process.env.REDWOOD_API_HOST;
@@ -1 +1 @@
1
- {"version":3,"file":"registerFwGlobalsAndShims.d.ts","sourceRoot":"","sources":["../../src/lib/registerFwGlobalsAndShims.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,YAGrC,CAAA"}
1
+ {"version":3,"file":"registerFwGlobalsAndShims.d.ts","sourceRoot":"","sources":["../../src/lib/registerFwGlobalsAndShims.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,YAGrC,CAAA"}
@@ -1,18 +1,13 @@
1
- import path from "node:path";
2
- import { getConfig, getPaths } from "@cedarjs/project-config";
1
+ import { getConfig, getEnvVarDefinitions } from "@cedarjs/project-config";
3
2
  const registerFwGlobalsAndShims = () => {
4
3
  registerFwGlobals();
5
4
  registerFwShims();
6
5
  };
7
6
  function registerFwGlobals() {
8
7
  const rwConfig = getConfig();
9
- const rwPaths = getPaths();
8
+ const envVars = getEnvVarDefinitions();
10
9
  globalThis.RWJS_ENV = {
11
- RWJS_API_GRAPHQL_URL: rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql",
12
- RWJS_API_URL: rwConfig.web.apiUrl,
13
- __REDWOOD__APP_TITLE: rwConfig.web.title || path.basename(rwPaths.base),
14
- RWJS_EXP_STREAMING_SSR: rwConfig.experimental.streamingSsr?.enabled,
15
- RWJS_EXP_RSC: rwConfig.experimental?.rsc?.enabled,
10
+ ...envVars.RWJS_ENV,
16
11
  RWJS_EXP_SSR_GRAPHQL_ENDPOINT: (() => {
17
12
  const apiPath = rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql";
18
13
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(apiPath)) {
@@ -50,10 +45,7 @@ function registerFwGlobals() {
50
45
  }
51
46
  })()
52
47
  };
53
- globalThis.RWJS_DEBUG_ENV = {
54
- RWJS_SRC_ROOT: rwPaths.web.src,
55
- REDWOOD_ENV_EDITOR: JSON.stringify(process.env.REDWOOD_ENV_EDITOR)
56
- };
48
+ globalThis.RWJS_DEBUG_ENV = envVars.RWJS_DEBUG_ENV;
57
49
  }
58
50
  function registerFwShims() {
59
51
  if (!getConfig().experimental?.rsc?.enabled) {
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/middleware/register.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAGzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EACV,UAAU,EAEV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAKhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;AAgB7C,eAAO,MAAM,oBAAoB,cAAe,aAAa,cAoB5D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,WAAY,UAAU,EAAE,WAEjC,iBAAiB,QACjB,kBAAkB,YACb,uBAAuB,gCAcpC,CAAA;AAED,eAAO,MAAM,qBAAqB,eAAe,aAAa,qCAc7D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,UAC1B,aAAa,KACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAe9B,CAAA"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/middleware/register.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAGzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EACV,UAAU,EAEV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAKhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;AAgB7C,eAAO,MAAM,oBAAoB,cAAe,aAAa,cAoB5D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,WAAY,UAAU,EAAE,WAEjC,iBAAiB,QACjB,kBAAkB,YACb,uBAAuB,gCAcpC,CAAA;AAED,eAAO,MAAM,qBAAqB,eAAe,aAAa,qCAc7D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,UAC1B,aAAa,KACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAa9B,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import fmw from "find-my-way";
2
- import { getPaths } from "@cedarjs/project-config";
2
+ import { getBuiltServerEntryFile } from "@cedarjs/project-config";
3
3
  import { MiddlewareResponse } from "@cedarjs/web/middleware";
4
4
  import { makeFilePath, ssrLoadEntryServer } from "../utils.js";
5
5
  const validateMw = (mw) => {
@@ -53,8 +53,7 @@ const addMiddlewareHandlers = (mwRegList = []) => {
53
53
  return mwRouter;
54
54
  };
55
55
  const createMiddlewareRouter = async (vite) => {
56
- const rwPaths = getPaths();
57
- const entryServerImport = vite ? await ssrLoadEntryServer(vite) : await import(makeFilePath(rwPaths.web.distSsrEntryServer));
56
+ const entryServerImport = vite ? await ssrLoadEntryServer(vite) : await import(makeFilePath(getBuiltServerEntryFile()));
58
57
  const { registerMiddleware } = entryServerImport;
59
58
  if (!registerMiddleware) {
60
59
  return fmw();
@@ -1 +1 @@
1
- {"version":3,"file":"rscBuildForSsr.d.ts","sourceRoot":"","sources":["../../src/rsc/rscBuildForSsr.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAsB,cAAc,CAAC,EACnC,gBAAgB,EAChB,OAAe,GAChB,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,+GA8IA"}
1
+ {"version":3,"file":"rscBuildForSsr.d.ts","sourceRoot":"","sources":["../../src/rsc/rscBuildForSsr.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAsB,cAAc,CAAC,EACnC,gBAAgB,EAChB,OAAe,GAChB,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,+GA2IA"}
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import { build as viteBuild } from "vite";
3
3
  import { cjsInterop } from "vite-plugin-cjs-interop";
4
- import { getPaths } from "@cedarjs/project-config";
4
+ import { getBuiltServerEntryFile, getPaths } from "@cedarjs/project-config";
5
5
  import { onWarn } from "../lib/onWarn.js";
6
6
  import { rscRoutesAutoLoader } from "../plugins/vite-plugin-rsc-routes-auto-loader.js";
7
7
  import { rscSsrRouterImport } from "../plugins/vite-plugin-rsc-ssr-router-import.js";
@@ -120,12 +120,9 @@ async function rscBuildForSsr({
120
120
  if (!("output" in ssrBuildOutput)) {
121
121
  throw new Error("Unexpected vite ssr build output");
122
122
  }
123
- const entryServerMjs = fs.readFileSync(
124
- rwPaths.web.distSsrEntryServer,
125
- "utf-8"
126
- );
123
+ const entryServerMjs = fs.readFileSync(getBuiltServerEntryFile(), "utf-8");
127
124
  fs.writeFileSync(
128
- rwPaths.web.distSsrEntryServer,
125
+ getBuiltServerEntryFile(),
129
126
  entryServerMjs.replace(
130
127
  /import (require\S+) from "graphql-scalars";/,
131
128
  'import * as $1 from "graphql-scalars";'
@@ -1 +1 @@
1
- {"version":3,"file":"createReactStreamingHandler.d.ts","sourceRoot":"","sources":["../../src/streaming/createReactStreamingHandler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAGrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAcvE,UAAU,kCAAkC;IAC1C,MAAM,EAAE,mBAAmB,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,GAAG,SAAS,KAAK,MAAM,EAAE,CAAA;IACzE,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;CACzD;AAOD,eAAO,MAAM,2BAA2B,0EAMnC,kCAAkC,kBACrB,aAAa,mBA6BV,OAAO,uBA8I3B,CAAA"}
1
+ {"version":3,"file":"createReactStreamingHandler.d.ts","sourceRoot":"","sources":["../../src/streaming/createReactStreamingHandler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAGrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAoBvE,UAAU,kCAAkC;IAC1C,MAAM,EAAE,mBAAmB,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,GAAG,SAAS,KAAK,MAAM,EAAE,CAAA;IACzE,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;CACzD;AAOD,eAAO,MAAM,2BAA2B,0EAMnC,kCAAkC,kBACrB,aAAa,mBAuBV,OAAO,uBA8I3B,CAAA"}
@@ -2,7 +2,13 @@ import path from "path";
2
2
  import { Response } from "@whatwg-node/fetch";
3
3
  import { createIsbotFromList, list as isbotList } from "isbot";
4
4
  import { middlewareDefaultAuthProviderState } from "@cedarjs/auth/dist/AuthProvider/AuthProviderState.js";
5
- import { getAppRouteHook, getConfig, getPaths } from "@cedarjs/project-config";
5
+ import {
6
+ getAppRouteHook,
7
+ getConfig,
8
+ getPaths,
9
+ getBuiltServerEntryFile,
10
+ getBuiltDocumentFile
11
+ } from "@cedarjs/project-config";
6
12
  import { matchPath } from "@cedarjs/router/util";
7
13
  import { MiddlewareResponse } from "@cedarjs/web/middleware";
8
14
  import { invoke } from "../middleware/invokeMiddleware.js";
@@ -27,11 +33,11 @@ const createReactStreamingHandler = async ({
27
33
  const rscEnabled = rwConfig.experimental?.rsc?.enabled;
28
34
  if (isProd) {
29
35
  if (rscEnabled) {
30
- entryServerImport = await import(makeFilePath(rwPaths.web.distSsrEntryServer));
36
+ entryServerImport = await import(makeFilePath(getBuiltServerEntryFile()));
31
37
  } else {
32
- entryServerImport = await import(makeFilePath(rwPaths.web.distSsrEntryServer));
38
+ entryServerImport = await import(makeFilePath(getBuiltServerEntryFile()));
33
39
  }
34
- fallbackDocumentImport = await import(makeFilePath(rwPaths.web.distSsrDocument));
40
+ fallbackDocumentImport = await import(makeFilePath(getBuiltDocumentFile()));
35
41
  }
36
42
  return async (req) => {
37
43
  let mwResponse = MiddlewareResponse.next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "0.6.1-next.0+2f33ffc44",
3
+ "version": "0.7.0",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -59,14 +59,14 @@
59
59
  "@babel/generator": "7.27.5",
60
60
  "@babel/parser": "7.27.5",
61
61
  "@babel/traverse": "7.27.4",
62
- "@cedarjs/auth": "0.6.1-next.0+2f33ffc44",
63
- "@cedarjs/babel-config": "0.6.1-next.0+2f33ffc44",
64
- "@cedarjs/cookie-jar": "0.6.1-next.0+2f33ffc44",
65
- "@cedarjs/internal": "0.6.1-next.0+2f33ffc44",
66
- "@cedarjs/project-config": "0.6.1-next.0+2f33ffc44",
67
- "@cedarjs/server-store": "0.6.1-next.0+2f33ffc44",
68
- "@cedarjs/web": "0.6.1-next.0+2f33ffc44",
69
- "@swc/core": "1.13.2",
62
+ "@cedarjs/auth": "0.7.0",
63
+ "@cedarjs/babel-config": "0.7.0",
64
+ "@cedarjs/cookie-jar": "0.7.0",
65
+ "@cedarjs/internal": "0.7.0",
66
+ "@cedarjs/project-config": "0.7.0",
67
+ "@cedarjs/server-store": "0.7.0",
68
+ "@cedarjs/web": "0.7.0",
69
+ "@swc/core": "1.13.3",
70
70
  "@vitejs/plugin-react": "4.3.4",
71
71
  "@whatwg-node/fetch": "0.9.21",
72
72
  "@whatwg-node/server": "0.9.65",
@@ -81,7 +81,7 @@
81
81
  "find-my-way": "8.2.2",
82
82
  "fs-extra": "11.2.0",
83
83
  "http-proxy-middleware": "3.0.5",
84
- "isbot": "5.1.28",
84
+ "isbot": "5.1.29",
85
85
  "react": "18.3.1",
86
86
  "react-server-dom-webpack": "19.0.0-rc-8269d55d-20240802",
87
87
  "rimraf": "6.0.1",
@@ -112,5 +112,5 @@
112
112
  "publishConfig": {
113
113
  "access": "public"
114
114
  },
115
- "gitHead": "2f33ffc44a616d71e3954228ea2f09e6d1b976f2"
115
+ "gitHead": "9e720ea4b6ca8306d466378104f532f818015531"
116
116
  }
@@ -1,87 +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 envVarDefinitions_exports = {};
30
- __export(envVarDefinitions_exports, {
31
- getEnvVarDefinitions: () => getEnvVarDefinitions
32
- });
33
- module.exports = __toCommonJS(envVarDefinitions_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_project_config = require("@cedarjs/project-config");
36
- function getEnvVarDefinitions() {
37
- const rwConfig = (0, import_project_config.getConfig)();
38
- const rwPaths = (0, import_project_config.getPaths)();
39
- return {
40
- RWJS_ENV: {
41
- RWJS_API_GRAPHQL_URL: rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql",
42
- RWJS_API_URL: rwConfig.web.apiUrl,
43
- __REDWOOD__APP_TITLE: rwConfig.web.title || import_node_path.default.basename(rwPaths.base),
44
- RWJS_EXP_STREAMING_SSR: rwConfig.experimental.streamingSsr?.enabled,
45
- RWJS_EXP_RSC: rwConfig.experimental?.rsc?.enabled
46
- },
47
- RWJS_DEBUG_ENV: {
48
- RWJS_SRC_ROOT: rwPaths.web.src,
49
- REDWOOD_ENV_EDITOR: JSON.stringify(process.env.REDWOOD_ENV_EDITOR)
50
- },
51
- // Vite can automatically expose environment variables, but we
52
- // disable that in `buildFeServer.ts` by setting `envFile: false`
53
- // because we want to use our own logic for loading .env,
54
- // .env.defaults, etc
55
- // The two object spreads below will expose all environment
56
- // variables listed in redwood.toml and all environment variables
57
- // prefixed with REDWOOD_ENV_
58
- ...Object.fromEntries(
59
- rwConfig.web.includeEnvironmentVariables.flatMap((envName) => [
60
- // TODO: Figure out if/why we need to disable eslint here, when we
61
- // didn't have to before, when this code was in index.ts
62
- // Re-enable if possible
63
- // eslint-disable-next-line
64
- [`import.meta.env.${envName}`, JSON.stringify(process.env[envName])],
65
- // TODO: Figure out if/why we need to disable eslint here, when we
66
- // didn't have to before, when this code was in index.ts
67
- // Re-enable if possible
68
- // eslint-disable-next-line
69
- [`process.env.${envName}`, JSON.stringify(process.env[envName])]
70
- ])
71
- ),
72
- ...Object.entries(process.env).reduce(
73
- (acc, [key, value]) => {
74
- if (key.startsWith("REDWOOD_ENV_")) {
75
- acc[`import.meta.env.${key}`] = JSON.stringify(value);
76
- acc[`process.env.${key}`] = JSON.stringify(value);
77
- }
78
- return acc;
79
- },
80
- {}
81
- )
82
- };
83
- }
84
- // Annotate the CommonJS export names for ESM import in node:
85
- 0 && (module.exports = {
86
- getEnvVarDefinitions
87
- });
@@ -1,14 +0,0 @@
1
- export declare function getEnvVarDefinitions(): {
2
- RWJS_ENV: {
3
- RWJS_API_GRAPHQL_URL: string;
4
- RWJS_API_URL: string;
5
- __REDWOOD__APP_TITLE: string;
6
- RWJS_EXP_STREAMING_SSR: boolean;
7
- RWJS_EXP_RSC: boolean;
8
- };
9
- RWJS_DEBUG_ENV: {
10
- RWJS_SRC_ROOT: string;
11
- REDWOOD_ENV_EDITOR: string;
12
- };
13
- };
14
- //# sourceMappingURL=envVarDefinitions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"envVarDefinitions.d.ts","sourceRoot":"","sources":["../../src/lib/envVarDefinitions.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB;;;;;;;;;;;;EAkDnC"}
@@ -1,53 +0,0 @@
1
- import path from "node:path";
2
- import { getConfig, getPaths } from "@cedarjs/project-config";
3
- function getEnvVarDefinitions() {
4
- const rwConfig = getConfig();
5
- const rwPaths = getPaths();
6
- return {
7
- RWJS_ENV: {
8
- RWJS_API_GRAPHQL_URL: rwConfig.web.apiGraphQLUrl ?? rwConfig.web.apiUrl + "/graphql",
9
- RWJS_API_URL: rwConfig.web.apiUrl,
10
- __REDWOOD__APP_TITLE: rwConfig.web.title || path.basename(rwPaths.base),
11
- RWJS_EXP_STREAMING_SSR: rwConfig.experimental.streamingSsr?.enabled,
12
- RWJS_EXP_RSC: rwConfig.experimental?.rsc?.enabled
13
- },
14
- RWJS_DEBUG_ENV: {
15
- RWJS_SRC_ROOT: rwPaths.web.src,
16
- REDWOOD_ENV_EDITOR: JSON.stringify(process.env.REDWOOD_ENV_EDITOR)
17
- },
18
- // Vite can automatically expose environment variables, but we
19
- // disable that in `buildFeServer.ts` by setting `envFile: false`
20
- // because we want to use our own logic for loading .env,
21
- // .env.defaults, etc
22
- // The two object spreads below will expose all environment
23
- // variables listed in redwood.toml and all environment variables
24
- // prefixed with REDWOOD_ENV_
25
- ...Object.fromEntries(
26
- rwConfig.web.includeEnvironmentVariables.flatMap((envName) => [
27
- // TODO: Figure out if/why we need to disable eslint here, when we
28
- // didn't have to before, when this code was in index.ts
29
- // Re-enable if possible
30
- // eslint-disable-next-line
31
- [`import.meta.env.${envName}`, JSON.stringify(process.env[envName])],
32
- // TODO: Figure out if/why we need to disable eslint here, when we
33
- // didn't have to before, when this code was in index.ts
34
- // Re-enable if possible
35
- // eslint-disable-next-line
36
- [`process.env.${envName}`, JSON.stringify(process.env[envName])]
37
- ])
38
- ),
39
- ...Object.entries(process.env).reduce(
40
- (acc, [key, value]) => {
41
- if (key.startsWith("REDWOOD_ENV_")) {
42
- acc[`import.meta.env.${key}`] = JSON.stringify(value);
43
- acc[`process.env.${key}`] = JSON.stringify(value);
44
- }
45
- return acc;
46
- },
47
- {}
48
- )
49
- };
50
- }
51
- export {
52
- getEnvVarDefinitions
53
- };