@cedarjs/vite 1.0.0-canary.12558 → 1.0.0-canary.12560

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) {
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "1.0.0-canary.12558+2212ab860",
3
+ "version": "1.0.0-canary.12560+9bd622a6a",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,13 +60,13 @@
60
60
  "@babel/generator": "7.27.5",
61
61
  "@babel/parser": "7.27.5",
62
62
  "@babel/traverse": "7.27.4",
63
- "@cedarjs/auth": "1.0.0-canary.12558",
64
- "@cedarjs/babel-config": "1.0.0-canary.12558",
65
- "@cedarjs/cookie-jar": "1.0.0-canary.12558",
66
- "@cedarjs/internal": "1.0.0-canary.12558",
67
- "@cedarjs/project-config": "1.0.0-canary.12558",
68
- "@cedarjs/server-store": "1.0.0-canary.12558",
69
- "@cedarjs/web": "1.0.0-canary.12558",
63
+ "@cedarjs/auth": "1.0.0-canary.12560",
64
+ "@cedarjs/babel-config": "1.0.0-canary.12560",
65
+ "@cedarjs/cookie-jar": "1.0.0-canary.12560",
66
+ "@cedarjs/internal": "1.0.0-canary.12560",
67
+ "@cedarjs/project-config": "1.0.0-canary.12560",
68
+ "@cedarjs/server-store": "1.0.0-canary.12560",
69
+ "@cedarjs/web": "1.0.0-canary.12560",
70
70
  "@swc/core": "1.13.3",
71
71
  "@vitejs/plugin-react": "4.3.4",
72
72
  "@whatwg-node/fetch": "0.9.21",
@@ -110,5 +110,5 @@
110
110
  "typescript": "5.6.2",
111
111
  "vitest": "3.2.4"
112
112
  },
113
- "gitHead": "2212ab8607fadb7ed3122e3b05af3edaf6a7e066"
113
+ "gitHead": "9bd622a6a56ffe1cedf7b4dd4a30d4ee994d911e"
114
114
  }
@@ -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
- };