@cedarjs/vite 3.1.1 → 3.1.2-next.126

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 (37) hide show
  1. package/dist/api/vite-plugin-cedar-vitest-api-preset.js +2 -2
  2. package/dist/bundled/react-server-dom-webpack.server.js +114 -62
  3. package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +2 -2
  4. package/dist/cjs/index.js +14 -10
  5. package/dist/cjs/lib/StatusError.js +1 -0
  6. package/dist/cjs/lib/getMergedConfig.js +1 -1
  7. package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +106 -0
  8. package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +6 -6
  9. package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +6 -6
  10. package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +1 -0
  11. package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +1 -0
  12. package/dist/cjs/rsc/rscBuildAnalyze.js +7 -1
  13. package/dist/cjs/rsc/rscBuildForServer.js +9 -2
  14. package/dist/devFeServer.js +0 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +9 -5
  18. package/dist/lib/StatusError.js +1 -0
  19. package/dist/lib/getMergedConfig.d.ts.map +1 -1
  20. package/dist/lib/getMergedConfig.js +1 -1
  21. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts +3 -0
  22. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map +1 -0
  23. package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +72 -0
  24. package/dist/plugins/vite-plugin-rsc-routes-auto-loader.js +3 -3
  25. package/dist/plugins/vite-plugin-rsc-routes-imports.js +3 -3
  26. package/dist/plugins/vite-plugin-rsc-transform-client.js +1 -0
  27. package/dist/plugins/vite-plugin-rsc-transform-server.js +1 -0
  28. package/dist/rsc/rscBuildAnalyze.d.ts.map +1 -1
  29. package/dist/rsc/rscBuildAnalyze.js +8 -2
  30. package/dist/rsc/rscBuildForServer.d.ts.map +1 -1
  31. package/dist/rsc/rscBuildForServer.js +10 -3
  32. package/dist/runFeServer.js +0 -0
  33. package/package.json +16 -16
  34. package/dist/cjs/plugins/vite-plugin-cedarjs-directory-named-import.js +0 -82
  35. package/dist/plugins/vite-plugin-cedarjs-directory-named-import.d.ts +0 -3
  36. package/dist/plugins/vite-plugin-cedarjs-directory-named-import.d.ts.map +0 -1
  37. package/dist/plugins/vite-plugin-cedarjs-directory-named-import.js +0 -48
@@ -0,0 +1,106 @@
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_cedarjs_resolve_cedar_style_imports_exports = {};
30
+ __export(vite_plugin_cedarjs_resolve_cedar_style_imports_exports, {
31
+ cedarjsResolveCedarStyleImportsPlugin: () => cedarjsResolveCedarStyleImportsPlugin
32
+ });
33
+ module.exports = __toCommonJS(vite_plugin_cedarjs_resolve_cedar_style_imports_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 resolveFromAbsolutePath(absolutePath) {
39
+ const ext = import_node_path.default.extname(absolutePath);
40
+ const pathToResolve = ext ? absolutePath.slice(0, -ext.length) : absolutePath;
41
+ const direct = (0, import_project_config.resolveFile)(pathToResolve);
42
+ if (direct) {
43
+ return direct;
44
+ }
45
+ const indexFile = (0, import_project_config.resolveFile)(import_node_path.default.join(pathToResolve, "index"));
46
+ if (indexFile) {
47
+ return indexFile;
48
+ }
49
+ const dirNamedFile = (0, import_project_config.resolveFile)(
50
+ import_node_path.default.join(pathToResolve, import_node_path.default.basename(pathToResolve))
51
+ );
52
+ if (dirNamedFile) {
53
+ return dirNamedFile;
54
+ }
55
+ return null;
56
+ }
57
+ function cedarjsResolveCedarStyleImportsPlugin() {
58
+ let cedarPaths;
59
+ try {
60
+ cedarPaths = (0, import_project_config.getPaths)();
61
+ } catch {
62
+ }
63
+ return {
64
+ name: "cedarjs-resolve-cedar-style-imports",
65
+ resolveId(id, importer) {
66
+ if (!importer || (0, import_vite.normalizePath)(importer).includes("/node_modules/")) {
67
+ return null;
68
+ }
69
+ if (cedarPaths && id.startsWith("src/")) {
70
+ const normalizedImporter = (0, import_vite.normalizePath)(importer);
71
+ const normalizedWebSrc = (0, import_vite.normalizePath)(cedarPaths.web.src);
72
+ const normalizedApiSrc = (0, import_vite.normalizePath)(cedarPaths.api.src);
73
+ let srcDir;
74
+ if (normalizedImporter.startsWith(normalizedWebSrc)) {
75
+ srcDir = cedarPaths.web.src;
76
+ } else if (normalizedImporter.startsWith(normalizedApiSrc)) {
77
+ srcDir = cedarPaths.api.src;
78
+ }
79
+ if (srcDir) {
80
+ const resolved = resolveFromAbsolutePath(
81
+ import_node_path.default.join(srcDir, id.slice("src/".length))
82
+ );
83
+ if (resolved) {
84
+ return (0, import_vite.normalizePath)(resolved);
85
+ }
86
+ }
87
+ }
88
+ const resolvedPath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
89
+ if (import_node_fs.default.existsSync(resolvedPath)) {
90
+ const stats = import_node_fs.default.statSync(resolvedPath);
91
+ if (stats.isFile()) {
92
+ return null;
93
+ }
94
+ }
95
+ const newPath = resolveFromAbsolutePath(resolvedPath);
96
+ if (!newPath) {
97
+ return null;
98
+ }
99
+ return (0, import_vite.normalizePath)(newPath);
100
+ }
101
+ };
102
+ }
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ cedarjsResolveCedarStyleImportsPlugin
106
+ });
@@ -31,7 +31,7 @@ __export(vite_plugin_rsc_routes_auto_loader_exports, {
31
31
  rscRoutesAutoLoader: () => rscRoutesAutoLoader
32
32
  });
33
33
  module.exports = __toCommonJS(vite_plugin_rsc_routes_auto_loader_exports);
34
- var import_path = __toESM(require("path"), 1);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
35
  var import_generator = __toESM(require("@babel/generator"), 1);
36
36
  var import_parser = require("@babel/parser");
37
37
  var import_traverse = __toESM(require("@babel/traverse"), 1);
@@ -41,10 +41,10 @@ var import_project_config = require("@cedarjs/project-config");
41
41
  const generate = import_generator.default.default;
42
42
  const traverse = import_traverse.default.default;
43
43
  const getPathRelativeToSrc = (maybeAbsolutePath) => {
44
- if (!import_path.default.isAbsolute(maybeAbsolutePath)) {
44
+ if (!import_node_path.default.isAbsolute(maybeAbsolutePath)) {
45
45
  return maybeAbsolutePath;
46
46
  }
47
- return `./${import_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
47
+ return `./${import_node_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
48
48
  };
49
49
  const withRelativeImports = (page) => {
50
50
  return {
@@ -77,7 +77,7 @@ function rscRoutesAutoLoader() {
77
77
  if (pages.length === 0) {
78
78
  return null;
79
79
  }
80
- const ext = import_path.default.extname(id);
80
+ const ext = import_node_path.default.extname(id);
81
81
  const plugins = [];
82
82
  if (ext === ".jsx") {
83
83
  plugins.push("jsx");
@@ -98,9 +98,9 @@ function rscRoutesAutoLoader() {
98
98
  const userImportRelativePath = getPathRelativeToSrc(
99
99
  (0, import_project_config.importStatementPath)(importPath)
100
100
  );
101
- const defaultSpecifier = path2.node.specifiers.filter(
101
+ const defaultSpecifier = path2.node.specifiers.find(
102
102
  (specifier) => t.isImportDefaultSpecifier(specifier)
103
- )[0];
103
+ );
104
104
  if (userImportRelativePath && defaultSpecifier) {
105
105
  importedNames.add(defaultSpecifier.local.name);
106
106
  }
@@ -31,7 +31,7 @@ __export(vite_plugin_rsc_routes_imports_exports, {
31
31
  rscRoutesImports: () => rscRoutesImports
32
32
  });
33
33
  module.exports = __toCommonJS(vite_plugin_rsc_routes_imports_exports);
34
- var import_path = __toESM(require("path"), 1);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
35
  var import_generator = __toESM(require("@babel/generator"), 1);
36
36
  var import_parser = require("@babel/parser");
37
37
  var import_traverse = __toESM(require("@babel/traverse"), 1);
@@ -41,10 +41,10 @@ var import_project_config = require("@cedarjs/project-config");
41
41
  const { default: generate } = import_generator.default;
42
42
  const { default: traverse } = import_traverse.default;
43
43
  const getPathRelativeToSrc = (maybeAbsolutePath) => {
44
- if (!import_path.default.isAbsolute(maybeAbsolutePath)) {
44
+ if (!import_node_path.default.isAbsolute(maybeAbsolutePath)) {
45
45
  return maybeAbsolutePath;
46
46
  }
47
- return `./${import_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
47
+ return `./${import_node_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
48
48
  };
49
49
  const withRelativeImports = (page) => {
50
50
  return {
@@ -77,7 +77,7 @@ function rscRoutesImports() {
77
77
  if (pages.length === 0) {
78
78
  return null;
79
79
  }
80
- const ext = import_path.default.extname(id);
80
+ const ext = import_node_path.default.extname(id);
81
81
  const plugins = [];
82
82
  if (ext === ".jsx") {
83
83
  plugins.push("jsx");
@@ -96,9 +96,9 @@ function rscRoutesImports() {
96
96
  const userImportRelativePath = getPathRelativeToSrc(
97
97
  (0, import_project_config.importStatementPath)(path2.node.source?.value)
98
98
  );
99
- const defaultSpecifier = path2.node.specifiers.filter(
99
+ const defaultSpecifier = path2.node.specifiers.find(
100
100
  (specifier) => t.isImportDefaultSpecifier(specifier)
101
- )[0];
101
+ );
102
102
  if (userImportRelativePath && defaultSpecifier) {
103
103
  importedNames.add(defaultSpecifier.local.name);
104
104
  }
@@ -159,6 +159,7 @@ async function parseExportNamesIntoNames(code, body, names) {
159
159
  }
160
160
  }
161
161
  continue;
162
+ // For CJS support
162
163
  case "ExpressionStatement": {
163
164
  let assignmentExpression = null;
164
165
  if (node.expression.type === "AssignmentExpression") {
@@ -115,6 +115,7 @@ function transformServerModule(mod, url, code) {
115
115
  const localTypes = /* @__PURE__ */ new Map();
116
116
  for (const node of mod.body) {
117
117
  switch (node.type) {
118
+ // TODO (RSC): Add code comments with examples of each type of node
118
119
  case "ExportDeclaration":
119
120
  if (node.declaration.type === "FunctionDeclaration") {
120
121
  const name = node.declaration.identifier.value;
@@ -74,7 +74,13 @@ async function rscBuildAnalyze() {
74
74
  "react"
75
75
  ],
76
76
  resolve: {
77
- externalConditions: ["react-server"]
77
+ // In Vite 6, we must include `defaultServerConditions` alongside
78
+ // `react-server` so that nested condition maps (e.g. the `node`
79
+ // sub-condition inside `react-server-dom-webpack/server`'s exports)
80
+ // can still be resolved. Without `node` (or another environment
81
+ // condition), the resolver throws "No known conditions for
82
+ // './server' specifier in 'react-server-dom-webpack' package".
83
+ externalConditions: ["react-server", ...import_vite.defaultServerConditions]
78
84
  }
79
85
  },
80
86
  build: {
@@ -81,8 +81,15 @@ async function rscBuildForServer(clientEntryFiles, serverEntryFiles, customModul
81
81
  // dependencies apart from node built-ins.
82
82
  // TODO (RSC): What's the difference between `conditions` and
83
83
  // `externalConditions`? When is one used over the other?
84
- conditions: ["react-server"],
85
- externalConditions: ["react-server"]
84
+ //
85
+ // In Vite 6, we must include `defaultServerConditions` alongside
86
+ // `react-server` so that nested condition maps (e.g. the `node`
87
+ // sub-condition inside `react-server-dom-webpack/server`'s exports)
88
+ // can still be resolved. Without `node` (or another environment
89
+ // condition), the commonjs resolver throws "No known conditions for
90
+ // './server' specifier in 'react-server-dom-webpack' package".
91
+ conditions: ["react-server", ...import_vite.defaultServerConditions],
92
+ externalConditions: ["react-server", ...import_vite.defaultServerConditions]
86
93
  }
87
94
  },
88
95
  plugins: [
File without changes
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { cedarHtmlEnvPlugin } from './plugins/vite-plugin-cedar-html-env.js';
6
6
  export { cedarImportDirPlugin } from './plugins/vite-plugin-cedar-import-dir.js';
7
7
  export { cedarNodePolyfills } from './plugins/vite-plugin-cedar-node-polyfills.js';
8
8
  export { cedarRemoveFromBundle } from './plugins/vite-plugin-cedar-remove-from-bundle.js';
9
- export { cedarjsDirectoryNamedImportPlugin } from './plugins/vite-plugin-cedarjs-directory-named-import.js';
9
+ export { cedarjsResolveCedarStyleImportsPlugin } from './plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js';
10
10
  export { cedarjsJobPathInjectorPlugin } from './plugins/vite-plugin-cedarjs-job-path-injector.js';
11
11
  export { cedarTransformJsAsJsx } from './plugins/vite-plugin-jsx-loader.js';
12
12
  export { cedarMergedConfig } from './plugins/vite-plugin-merged-config.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAoBxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,yDAAyD,CAAA;AAC3G,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AAEvF,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAsClE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAqBxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,8DAA8D,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AAEvF,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAyClE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import { cedarHtmlEnvPlugin } from "./plugins/vite-plugin-cedar-html-env.js";
12
12
  import { cedarNodePolyfills } from "./plugins/vite-plugin-cedar-node-polyfills.js";
13
13
  import { cedarRemoveFromBundle } from "./plugins/vite-plugin-cedar-remove-from-bundle.js";
14
14
  import { cedarWaitForApiServer } from "./plugins/vite-plugin-cedar-wait-for-api-server.js";
15
+ import { cedarjsResolveCedarStyleImportsPlugin } from "./plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js";
15
16
  import { cedarTransformJsAsJsx } from "./plugins/vite-plugin-jsx-loader.js";
16
17
  import { cedarMergedConfig } from "./plugins/vite-plugin-merged-config.js";
17
18
  import { cedarSwapApolloProvider } from "./plugins/vite-plugin-swap-apollo-provider.js";
@@ -22,7 +23,7 @@ import { cedarHtmlEnvPlugin as cedarHtmlEnvPlugin2 } from "./plugins/vite-plugin
22
23
  import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
23
24
  import { cedarNodePolyfills as cedarNodePolyfills2 } from "./plugins/vite-plugin-cedar-node-polyfills.js";
24
25
  import { cedarRemoveFromBundle as cedarRemoveFromBundle2 } from "./plugins/vite-plugin-cedar-remove-from-bundle.js";
25
- import { cedarjsDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedarjs-directory-named-import.js";
26
+ import { cedarjsResolveCedarStyleImportsPlugin as cedarjsResolveCedarStyleImportsPlugin2 } from "./plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js";
26
27
  import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-path-injector.js";
27
28
  import { cedarTransformJsAsJsx as cedarTransformJsAsJsx2 } from "./plugins/vite-plugin-jsx-loader.js";
28
29
  import { cedarMergedConfig as cedarMergedConfig2 } from "./plugins/vite-plugin-merged-config.js";
@@ -30,7 +31,9 @@ import { cedarSwapApolloProvider as cedarSwapApolloProvider2 } from "./plugins/v
30
31
  function cedar({ mode } = {}) {
31
32
  const cedarConfig = getConfig();
32
33
  const rscEnabled = cedarConfig.experimental?.rsc?.enabled;
33
- const webSideDefaultBabelConfig = getWebSideDefaultBabelConfig();
34
+ const webSideDefaultBabelConfig = getWebSideDefaultBabelConfig({
35
+ forVite: true
36
+ });
34
37
  const babelConfig = {
35
38
  ...webSideDefaultBabelConfig,
36
39
  // For RSC we don't want to include the routes auto-loader plugin as we
@@ -50,6 +53,7 @@ function cedar({ mode } = {}) {
50
53
  cedarHtmlEnvPlugin(),
51
54
  cedarEntryInjectionPlugin(),
52
55
  cedarMergedConfig(),
56
+ cedarjsResolveCedarStyleImportsPlugin(),
53
57
  cedarSwapApolloProvider(),
54
58
  cedarCellTransform(),
55
59
  cedarTransformJsAsJsx(),
@@ -57,7 +61,7 @@ function cedar({ mode } = {}) {
57
61
  react({ babel: babelConfig })
58
62
  ];
59
63
  }
60
- var src_default = cedar;
64
+ var index_default = cedar;
61
65
  export {
62
66
  cedar,
63
67
  cedarAutoImportsPlugin,
@@ -70,7 +74,7 @@ export {
70
74
  cedarRemoveFromBundle2 as cedarRemoveFromBundle,
71
75
  cedarSwapApolloProvider2 as cedarSwapApolloProvider,
72
76
  cedarTransformJsAsJsx2 as cedarTransformJsAsJsx,
73
- cedarjsDirectoryNamedImportPlugin,
74
77
  cedarjsJobPathInjectorPlugin,
75
- src_default as default
78
+ cedarjsResolveCedarStyleImportsPlugin2 as cedarjsResolveCedarStyleImportsPlugin,
79
+ index_default as default
76
80
  };
@@ -3,6 +3,7 @@ class StatusError extends Error {
3
3
  super(message);
4
4
  this.statusCode = statusCode;
5
5
  }
6
+ statusCode;
6
7
  }
7
8
  const hasStatusCode = (x) => typeof x?.statusCode === "number";
8
9
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"getMergedConfig.d.ts","sourceRoot":"","sources":["../../src/lib/getMergedConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,IAC5D,YAAY,cAAc,EAAE,KAAK,SAAS,KAAG,cAAc,CAwGpE"}
1
+ {"version":3,"file":"getMergedConfig.d.ts","sourceRoot":"","sources":["../../src/lib/getMergedConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAO5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,IAC5D,YAAY,cAAc,EAAE,KAAK,SAAS,KAAG,cAAc,CA0GpE"}
@@ -9,7 +9,7 @@ function getMergedConfig(cedarConfig, cedarPaths) {
9
9
  return (userConfig, env) => {
10
10
  let apiHost = process.env.REDWOOD_API_HOST;
11
11
  apiHost ??= cedarConfig.api.host;
12
- apiHost ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "[::]";
12
+ apiHost ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "127.0.0.1";
13
13
  const streamingSsrEnabled = cedarConfig.experimental.streamingSsr?.enabled;
14
14
  const rscEnabled = cedarConfig.experimental.rsc?.enabled;
15
15
  let apiPort;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function cedarjsResolveCedarStyleImportsPlugin(): Plugin;
3
+ //# sourceMappingURL=vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAiClC,wBAAgB,qCAAqC,IAAI,MAAM,CAkE9D"}
@@ -0,0 +1,72 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { normalizePath } from "vite";
4
+ import { getPaths, resolveFile } from "@cedarjs/project-config";
5
+ function resolveFromAbsolutePath(absolutePath) {
6
+ const ext = path.extname(absolutePath);
7
+ const pathToResolve = ext ? absolutePath.slice(0, -ext.length) : absolutePath;
8
+ const direct = resolveFile(pathToResolve);
9
+ if (direct) {
10
+ return direct;
11
+ }
12
+ const indexFile = resolveFile(path.join(pathToResolve, "index"));
13
+ if (indexFile) {
14
+ return indexFile;
15
+ }
16
+ const dirNamedFile = resolveFile(
17
+ path.join(pathToResolve, path.basename(pathToResolve))
18
+ );
19
+ if (dirNamedFile) {
20
+ return dirNamedFile;
21
+ }
22
+ return null;
23
+ }
24
+ function cedarjsResolveCedarStyleImportsPlugin() {
25
+ let cedarPaths;
26
+ try {
27
+ cedarPaths = getPaths();
28
+ } catch {
29
+ }
30
+ return {
31
+ name: "cedarjs-resolve-cedar-style-imports",
32
+ resolveId(id, importer) {
33
+ if (!importer || normalizePath(importer).includes("/node_modules/")) {
34
+ return null;
35
+ }
36
+ if (cedarPaths && id.startsWith("src/")) {
37
+ const normalizedImporter = normalizePath(importer);
38
+ const normalizedWebSrc = normalizePath(cedarPaths.web.src);
39
+ const normalizedApiSrc = normalizePath(cedarPaths.api.src);
40
+ let srcDir;
41
+ if (normalizedImporter.startsWith(normalizedWebSrc)) {
42
+ srcDir = cedarPaths.web.src;
43
+ } else if (normalizedImporter.startsWith(normalizedApiSrc)) {
44
+ srcDir = cedarPaths.api.src;
45
+ }
46
+ if (srcDir) {
47
+ const resolved = resolveFromAbsolutePath(
48
+ path.join(srcDir, id.slice("src/".length))
49
+ );
50
+ if (resolved) {
51
+ return normalizePath(resolved);
52
+ }
53
+ }
54
+ }
55
+ const resolvedPath = path.resolve(path.dirname(importer), id);
56
+ if (fs.existsSync(resolvedPath)) {
57
+ const stats = fs.statSync(resolvedPath);
58
+ if (stats.isFile()) {
59
+ return null;
60
+ }
61
+ }
62
+ const newPath = resolveFromAbsolutePath(resolvedPath);
63
+ if (!newPath) {
64
+ return null;
65
+ }
66
+ return normalizePath(newPath);
67
+ }
68
+ };
69
+ }
70
+ export {
71
+ cedarjsResolveCedarStyleImportsPlugin
72
+ };
@@ -1,4 +1,4 @@
1
- import path from "path";
1
+ import path from "node:path";
2
2
  import babelGenerator from "@babel/generator";
3
3
  const generate = babelGenerator.default;
4
4
  import { parse as babelParse } from "@babel/parser";
@@ -70,9 +70,9 @@ function rscRoutesAutoLoader() {
70
70
  const userImportRelativePath = getPathRelativeToSrc(
71
71
  importStatementPath(importPath)
72
72
  );
73
- const defaultSpecifier = path2.node.specifiers.filter(
73
+ const defaultSpecifier = path2.node.specifiers.find(
74
74
  (specifier) => t.isImportDefaultSpecifier(specifier)
75
- )[0];
75
+ );
76
76
  if (userImportRelativePath && defaultSpecifier) {
77
77
  importedNames.add(defaultSpecifier.local.name);
78
78
  }
@@ -1,4 +1,4 @@
1
- import path from "path";
1
+ import path from "node:path";
2
2
  import babelGenerator from "@babel/generator";
3
3
  const { default: generate } = babelGenerator;
4
4
  import { parse as babelParse } from "@babel/parser";
@@ -68,9 +68,9 @@ function rscRoutesImports() {
68
68
  const userImportRelativePath = getPathRelativeToSrc(
69
69
  importStatementPath(path2.node.source?.value)
70
70
  );
71
- const defaultSpecifier = path2.node.specifiers.filter(
71
+ const defaultSpecifier = path2.node.specifiers.find(
72
72
  (specifier) => t.isImportDefaultSpecifier(specifier)
73
- )[0];
73
+ );
74
74
  if (userImportRelativePath && defaultSpecifier) {
75
75
  importedNames.add(defaultSpecifier.local.name);
76
76
  }
@@ -126,6 +126,7 @@ async function parseExportNamesIntoNames(code, body, names) {
126
126
  }
127
127
  }
128
128
  continue;
129
+ // For CJS support
129
130
  case "ExpressionStatement": {
130
131
  let assignmentExpression = null;
131
132
  if (node.expression.type === "AssignmentExpression") {
@@ -82,6 +82,7 @@ function transformServerModule(mod, url, code) {
82
82
  const localTypes = /* @__PURE__ */ new Map();
83
83
  for (const node of mod.body) {
84
84
  switch (node.type) {
85
+ // TODO (RSC): Add code comments with examples of each type of node
85
86
  case "ExportDeclaration":
86
87
  if (node.declaration.type === "FunctionDeclaration") {
87
88
  const name = node.declaration.identifier.value;
@@ -1 +1 @@
1
- {"version":3,"file":"rscBuildAnalyze.d.ts","sourceRoot":"","sources":["../../src/rsc/rscBuildAnalyze.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAsB,eAAe;;;;;;;GAkGpC"}
1
+ {"version":3,"file":"rscBuildAnalyze.d.ts","sourceRoot":"","sources":["../../src/rsc/rscBuildAnalyze.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAsB,eAAe;;;;;;;GAwGpC"}
@@ -1,4 +1,4 @@
1
- import { build as viteBuild } from "vite";
1
+ import { build as viteBuild, defaultServerConditions } from "vite";
2
2
  import { getPaths } from "@cedarjs/project-config";
3
3
  import { getEntries } from "../lib/entries.js";
4
4
  import { onWarn } from "../lib/onWarn.js";
@@ -51,7 +51,13 @@ async function rscBuildAnalyze() {
51
51
  "react"
52
52
  ],
53
53
  resolve: {
54
- externalConditions: ["react-server"]
54
+ // In Vite 6, we must include `defaultServerConditions` alongside
55
+ // `react-server` so that nested condition maps (e.g. the `node`
56
+ // sub-condition inside `react-server-dom-webpack/server`'s exports)
57
+ // can still be resolved. Without `node` (or another environment
58
+ // condition), the resolver throws "No known conditions for
59
+ // './server' specifier in 'react-server-dom-webpack' package".
60
+ externalConditions: ["react-server", ...defaultServerConditions]
55
61
  }
56
62
  },
57
63
  build: {
@@ -1 +1 @@
1
- {"version":3,"file":"rscBuildForServer.d.ts","sourceRoot":"","sources":["../../src/rsc/rscBuildForServer.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,+GA2ItC"}
1
+ {"version":3,"file":"rscBuildForServer.d.ts","sourceRoot":"","sources":["../../src/rsc/rscBuildForServer.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,+GAkJtC"}
@@ -1,4 +1,4 @@
1
- import { build as viteBuild } from "vite";
1
+ import { build as viteBuild, defaultServerConditions } from "vite";
2
2
  import { getPaths } from "@cedarjs/project-config";
3
3
  import { getEntries } from "../lib/entries.js";
4
4
  import { onWarn } from "../lib/onWarn.js";
@@ -58,8 +58,15 @@ async function rscBuildForServer(clientEntryFiles, serverEntryFiles, customModul
58
58
  // dependencies apart from node built-ins.
59
59
  // TODO (RSC): What's the difference between `conditions` and
60
60
  // `externalConditions`? When is one used over the other?
61
- conditions: ["react-server"],
62
- externalConditions: ["react-server"]
61
+ //
62
+ // In Vite 6, we must include `defaultServerConditions` alongside
63
+ // `react-server` so that nested condition maps (e.g. the `node`
64
+ // sub-condition inside `react-server-dom-webpack/server`'s exports)
65
+ // can still be resolved. Without `node` (or another environment
66
+ // condition), the commonjs resolver throws "No known conditions for
67
+ // './server' specifier in 'react-server-dom-webpack' package".
68
+ conditions: ["react-server", ...defaultServerConditions],
69
+ externalConditions: ["react-server", ...defaultServerConditions]
63
70
  }
64
71
  },
65
72
  plugins: [
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "3.1.1",
3
+ "version": "3.1.2-next.126+e7fa625a39",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,19 +60,19 @@
60
60
  "test:watch": "vitest watch"
61
61
  },
62
62
  "dependencies": {
63
- "@ast-grep/napi": "0.42.0",
63
+ "@ast-grep/napi": "0.42.1",
64
64
  "@babel/generator": "7.29.1",
65
65
  "@babel/parser": "7.29.2",
66
66
  "@babel/traverse": "7.29.0",
67
- "@cedarjs/auth": "3.1.1",
68
- "@cedarjs/babel-config": "3.1.1",
69
- "@cedarjs/cookie-jar": "3.1.1",
70
- "@cedarjs/internal": "3.1.1",
71
- "@cedarjs/project-config": "3.1.1",
72
- "@cedarjs/server-store": "3.1.1",
73
- "@cedarjs/testing": "3.1.1",
74
- "@cedarjs/web": "3.1.1",
75
- "@swc/core": "1.15.21",
67
+ "@cedarjs/auth": "3.1.2-next.126+e7fa625a39",
68
+ "@cedarjs/babel-config": "3.1.2-next.126+e7fa625a39",
69
+ "@cedarjs/cookie-jar": "3.1.2-next.126+e7fa625a39",
70
+ "@cedarjs/internal": "3.1.2-next.126+e7fa625a39",
71
+ "@cedarjs/project-config": "3.1.2-next.126+e7fa625a39",
72
+ "@cedarjs/server-store": "3.1.2-next.126+e7fa625a39",
73
+ "@cedarjs/testing": "3.1.2-next.126+e7fa625a39",
74
+ "@cedarjs/web": "3.1.2-next.126+e7fa625a39",
75
+ "@swc/core": "1.15.24",
76
76
  "@vitejs/plugin-react": "4.7.0",
77
77
  "@whatwg-node/fetch": "0.10.13",
78
78
  "@whatwg-node/server": "0.10.18",
@@ -85,13 +85,13 @@
85
85
  "express": "4.22.1",
86
86
  "find-my-way": "8.2.2",
87
87
  "http-proxy-middleware": "3.0.5",
88
- "isbot": "5.1.36",
88
+ "isbot": "5.1.37",
89
89
  "react": "18.3.1",
90
90
  "react-server-dom-webpack": "19.2.4",
91
91
  "rimraf": "6.1.3",
92
- "vite": "5.4.21",
92
+ "vite": "7.3.2",
93
93
  "vite-plugin-cjs-interop": "2.4.4",
94
- "vite-plugin-node-polyfills": "0.25.0",
94
+ "vite-plugin-node-polyfills": "0.26.0",
95
95
  "ws": "8.20.0",
96
96
  "yargs-parser": "21.1.1"
97
97
  },
@@ -107,7 +107,7 @@
107
107
  "glob": "11.1.0",
108
108
  "memfs": "4.57.1",
109
109
  "publint": "0.3.18",
110
- "rollup": "4.60.0",
110
+ "rollup": "4.60.1",
111
111
  "tsx": "4.21.0",
112
112
  "typescript": "5.9.3",
113
113
  "vitest": "3.2.4"
@@ -118,5 +118,5 @@
118
118
  "publishConfig": {
119
119
  "access": "public"
120
120
  },
121
- "gitHead": "daccdd356942396c8037bd53c8e945255e4c8fdb"
121
+ "gitHead": "e7fa625a39d829a9078bd5b8237e93ec1a8745be"
122
122
  }