@cedarjs/vite 5.0.0-canary.2421 → 5.0.0-canary.2423

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,6 +1,5 @@
1
1
  export interface BuildUDApiServerOptions {
2
2
  verbose?: boolean;
3
- apiRootPath?: string;
4
3
  }
5
4
  /**
6
5
  * Builds the API server Universal Deploy server entry using Vite.
@@ -26,5 +25,5 @@ export interface BuildUDApiServerOptions {
26
25
  * simply means Vite produces a Node-compatible bundle rather than a browser
27
26
  * bundle.
28
27
  */
29
- export declare function buildUDApiServer({ verbose, apiRootPath, }?: BuildUDApiServerOptions): Promise<void>;
28
+ export declare function buildUDApiServer({ verbose, }?: BuildUDApiServerOptions): Promise<void>;
30
29
  //# sourceMappingURL=buildUDApiServer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildUDApiServer.d.ts","sourceRoot":"","sources":["../src/buildUDApiServer.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,OAAe,EACf,WAAW,GACZ,GAAE,uBAA4B,iBA2F9B"}
1
+ {"version":3,"file":"buildUDApiServer.d.ts","sourceRoot":"","sources":["../src/buildUDApiServer.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,OAAe,GAChB,GAAE,uBAA4B,iBA6E9B"}
@@ -2,79 +2,69 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { getPaths } from "@cedarjs/project-config";
4
4
  async function buildUDApiServer({
5
- verbose = false,
6
- apiRootPath
5
+ verbose = false
7
6
  } = {}) {
8
7
  const { build } = await import("vite");
9
8
  const { catchAll, devServer } = await import("@universal-deploy/vite");
10
9
  const { catchAllEntry, getAllEntries } = await import("@universal-deploy/store");
11
10
  const cedarPaths = getPaths();
12
11
  const outDir = path.join(cedarPaths.api.dist, "ud");
13
- if (apiRootPath !== void 0) {
14
- process.env.CEDAR_API_ROOT_PATH = apiRootPath;
15
- }
16
- try {
17
- await build({
18
- // Load the user's Vite config so all plugins (Cedar's UD plugin,
19
- // provider plugins, etc.) run during the build.
20
- configFile: cedarPaths.web.viteConfig,
21
- logLevel: verbose ? "info" : "warn",
22
- plugins: [
23
- // catchAll() generates the rou3-based route dispatcher
24
- // (virtual:ud:catch-all). devServer() provides Vite dev support for
25
- // cedar dev --ud.
26
- //
27
- // NOTE: We intentionally do NOT use universalDeploy() here — that
28
- // plugin auto-detects deployment targets and would embed the Node
29
- // HTTP server startup code into the output. Our plugin list is
30
- // adapter-free: the output is a pure Fetchable export, and cedar
31
- // serve wraps it in srvx at runtime.
32
- catchAll(),
33
- devServer(),
34
- // Warn if no Cedar API routes were registered — likely means the
35
- // user's vite config is missing cedarUniversalDeployPlugin or there
36
- // are no API functions to serve.
37
- {
38
- name: "cedar-ud-verify-routes",
39
- configResolved() {
40
- const entries = getAllEntries();
41
- if (entries.length === 0) {
42
- console.warn(
43
- "\n Warning: No Universal Deploy API routes were registered.",
44
- "\n The built server entry will be an empty router (404 for all",
45
- "\n requests). Check that you have API functions under",
46
- "\n `api/src/functions/` and that your vite config includes",
47
- "\n `cedarUniversalDeployPlugin()`.\n"
48
- );
49
- }
12
+ await build({
13
+ // Load the user's Vite config so all plugins (Cedar's UD plugin,
14
+ // provider plugins, etc.) run during the build.
15
+ configFile: cedarPaths.web.viteConfig,
16
+ logLevel: verbose ? "info" : "warn",
17
+ plugins: [
18
+ // catchAll() generates the rou3-based route dispatcher
19
+ // (virtual:ud:catch-all). devServer() provides Vite dev support for
20
+ // cedar dev --ud.
21
+ //
22
+ // NOTE: We intentionally do NOT use universalDeploy() here that
23
+ // plugin auto-detects deployment targets and would embed the Node
24
+ // HTTP server startup code into the output. Our plugin list is
25
+ // adapter-free: the output is a pure Fetchable export, and cedar
26
+ // serve wraps it in srvx at runtime.
27
+ catchAll(),
28
+ devServer(),
29
+ // Warn if no Cedar API routes were registered likely means the
30
+ // user's vite config is missing cedarUniversalDeployPlugin or there
31
+ // are no API functions to serve.
32
+ {
33
+ name: "cedar-ud-verify-routes",
34
+ configResolved() {
35
+ const entries = getAllEntries();
36
+ if (entries.length === 0) {
37
+ console.warn(
38
+ "\n Warning: No Universal Deploy API routes were registered.",
39
+ "\n The built server entry will be an empty router (404 for all",
40
+ "\n requests). Check that you have API functions under",
41
+ "\n `api/src/functions/` and that your vite config includes",
42
+ "\n `cedarUniversalDeployPlugin()`.\n"
43
+ );
50
44
  }
51
45
  }
52
- ],
53
- // Legacy ssr flag approach. The explicit rollupOptions.input prevents the
54
- // "index.html as SSR entry" error. Vite will also build a 'client'
55
- // environment from the user's config file (wasteful but harmless), and
56
- // the 'ssr' environment produces our canonical Fetchable artifact at
57
- // api/dist/ud/index.js.
58
- build: {
59
- ssr: true,
60
- outDir,
61
- rollupOptions: {
62
- input: catchAllEntry,
63
- output: {
64
- entryFileNames: "index.js"
65
- }
46
+ }
47
+ ],
48
+ // Legacy ssr flag approach. The explicit rollupOptions.input prevents the
49
+ // "index.html as SSR entry" error. Vite will also build a 'client'
50
+ // environment from the user's config file (wasteful but harmless), and
51
+ // the 'ssr' environment produces our canonical Fetchable artifact at
52
+ // api/dist/ud/index.js.
53
+ build: {
54
+ ssr: true,
55
+ outDir,
56
+ rollupOptions: {
57
+ input: catchAllEntry,
58
+ output: {
59
+ entryFileNames: "index.js"
66
60
  }
67
61
  }
68
- });
69
- fs.writeFileSync(
70
- path.join(outDir, "package.json"),
71
- JSON.stringify({ type: "module" }, null, 2)
72
- );
73
- } finally {
74
- if (apiRootPath !== void 0) {
75
- delete process.env.CEDAR_API_ROOT_PATH;
76
62
  }
77
- }
63
+ });
64
+ fs.writeFileSync(
65
+ path.join(outDir, "package.json"),
66
+ JSON.stringify({ type: "module" }, null, 2)
67
+ );
78
68
  }
79
69
  export {
80
70
  buildUDApiServer
@@ -35,79 +35,69 @@ var import_node_fs = __toESM(require("node:fs"), 1);
35
35
  var import_node_path = __toESM(require("node:path"), 1);
36
36
  var import_project_config = require("@cedarjs/project-config");
37
37
  async function buildUDApiServer({
38
- verbose = false,
39
- apiRootPath
38
+ verbose = false
40
39
  } = {}) {
41
40
  const { build } = await import("vite");
42
41
  const { catchAll, devServer } = await import("@universal-deploy/vite");
43
42
  const { catchAllEntry, getAllEntries } = await import("@universal-deploy/store");
44
43
  const cedarPaths = (0, import_project_config.getPaths)();
45
44
  const outDir = import_node_path.default.join(cedarPaths.api.dist, "ud");
46
- if (apiRootPath !== void 0) {
47
- process.env.CEDAR_API_ROOT_PATH = apiRootPath;
48
- }
49
- try {
50
- await build({
51
- // Load the user's Vite config so all plugins (Cedar's UD plugin,
52
- // provider plugins, etc.) run during the build.
53
- configFile: cedarPaths.web.viteConfig,
54
- logLevel: verbose ? "info" : "warn",
55
- plugins: [
56
- // catchAll() generates the rou3-based route dispatcher
57
- // (virtual:ud:catch-all). devServer() provides Vite dev support for
58
- // cedar dev --ud.
59
- //
60
- // NOTE: We intentionally do NOT use universalDeploy() here — that
61
- // plugin auto-detects deployment targets and would embed the Node
62
- // HTTP server startup code into the output. Our plugin list is
63
- // adapter-free: the output is a pure Fetchable export, and cedar
64
- // serve wraps it in srvx at runtime.
65
- catchAll(),
66
- devServer(),
67
- // Warn if no Cedar API routes were registered — likely means the
68
- // user's vite config is missing cedarUniversalDeployPlugin or there
69
- // are no API functions to serve.
70
- {
71
- name: "cedar-ud-verify-routes",
72
- configResolved() {
73
- const entries = getAllEntries();
74
- if (entries.length === 0) {
75
- console.warn(
76
- "\n Warning: No Universal Deploy API routes were registered.",
77
- "\n The built server entry will be an empty router (404 for all",
78
- "\n requests). Check that you have API functions under",
79
- "\n `api/src/functions/` and that your vite config includes",
80
- "\n `cedarUniversalDeployPlugin()`.\n"
81
- );
82
- }
45
+ await build({
46
+ // Load the user's Vite config so all plugins (Cedar's UD plugin,
47
+ // provider plugins, etc.) run during the build.
48
+ configFile: cedarPaths.web.viteConfig,
49
+ logLevel: verbose ? "info" : "warn",
50
+ plugins: [
51
+ // catchAll() generates the rou3-based route dispatcher
52
+ // (virtual:ud:catch-all). devServer() provides Vite dev support for
53
+ // cedar dev --ud.
54
+ //
55
+ // NOTE: We intentionally do NOT use universalDeploy() here that
56
+ // plugin auto-detects deployment targets and would embed the Node
57
+ // HTTP server startup code into the output. Our plugin list is
58
+ // adapter-free: the output is a pure Fetchable export, and cedar
59
+ // serve wraps it in srvx at runtime.
60
+ catchAll(),
61
+ devServer(),
62
+ // Warn if no Cedar API routes were registered likely means the
63
+ // user's vite config is missing cedarUniversalDeployPlugin or there
64
+ // are no API functions to serve.
65
+ {
66
+ name: "cedar-ud-verify-routes",
67
+ configResolved() {
68
+ const entries = getAllEntries();
69
+ if (entries.length === 0) {
70
+ console.warn(
71
+ "\n Warning: No Universal Deploy API routes were registered.",
72
+ "\n The built server entry will be an empty router (404 for all",
73
+ "\n requests). Check that you have API functions under",
74
+ "\n `api/src/functions/` and that your vite config includes",
75
+ "\n `cedarUniversalDeployPlugin()`.\n"
76
+ );
83
77
  }
84
78
  }
85
- ],
86
- // Legacy ssr flag approach. The explicit rollupOptions.input prevents the
87
- // "index.html as SSR entry" error. Vite will also build a 'client'
88
- // environment from the user's config file (wasteful but harmless), and
89
- // the 'ssr' environment produces our canonical Fetchable artifact at
90
- // api/dist/ud/index.js.
91
- build: {
92
- ssr: true,
93
- outDir,
94
- rollupOptions: {
95
- input: catchAllEntry,
96
- output: {
97
- entryFileNames: "index.js"
98
- }
79
+ }
80
+ ],
81
+ // Legacy ssr flag approach. The explicit rollupOptions.input prevents the
82
+ // "index.html as SSR entry" error. Vite will also build a 'client'
83
+ // environment from the user's config file (wasteful but harmless), and
84
+ // the 'ssr' environment produces our canonical Fetchable artifact at
85
+ // api/dist/ud/index.js.
86
+ build: {
87
+ ssr: true,
88
+ outDir,
89
+ rollupOptions: {
90
+ input: catchAllEntry,
91
+ output: {
92
+ entryFileNames: "index.js"
99
93
  }
100
94
  }
101
- });
102
- import_node_fs.default.writeFileSync(
103
- import_node_path.default.join(outDir, "package.json"),
104
- JSON.stringify({ type: "module" }, null, 2)
105
- );
106
- } finally {
107
- if (apiRootPath !== void 0) {
108
- delete process.env.CEDAR_API_ROOT_PATH;
109
95
  }
110
- }
96
+ });
97
+ import_node_fs.default.writeFileSync(
98
+ import_node_path.default.join(outDir, "package.json"),
99
+ JSON.stringify({ type: "module" }, null, 2)
100
+ );
111
101
  }
112
102
  // Annotate the CommonJS export names for ESM import in node:
113
103
  0 && (module.exports = {
@@ -130,7 +130,7 @@ function cedarUniversalDeployPlugin(options = {}) {
130
130
  }
131
131
  },
132
132
  buildStart() {
133
- if (this.environment?.name !== "ssr") {
133
+ if (this.environment.name !== "ssr") {
134
134
  return;
135
135
  }
136
136
  for (const route of routes) {
@@ -145,7 +145,8 @@ function cedarUniversalDeployPlugin(options = {}) {
145
145
  }
146
146
  },
147
147
  resolveId(id) {
148
- if (this.environment?.name !== "ssr") {
148
+ const viteEnv = this.environment;
149
+ if (viteEnv.config.consumer === "client" || viteEnv.name === "api") {
149
150
  return void 0;
150
151
  }
151
152
  if (id.startsWith(RESOLVED_CEDAR_FN_PREFIX)) {
@@ -157,7 +158,8 @@ function cedarUniversalDeployPlugin(options = {}) {
157
158
  return void 0;
158
159
  },
159
160
  async load(id) {
160
- if (this.environment?.name !== "ssr") {
161
+ const viteEnv = this.environment;
162
+ if (viteEnv.config.consumer === "client" || viteEnv.name === "api") {
161
163
  return void 0;
162
164
  }
163
165
  if (id.startsWith(RESOLVED_CEDAR_FN_PREFIX)) {
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAuJD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,iCAAsC,GAC9C,MAAM,CAgHR"}
1
+ {"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAuJD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,iCAAsC,GAC9C,MAAM,CA0HR"}
@@ -97,7 +97,7 @@ function cedarUniversalDeployPlugin(options = {}) {
97
97
  }
98
98
  },
99
99
  buildStart() {
100
- if (this.environment?.name !== "ssr") {
100
+ if (this.environment.name !== "ssr") {
101
101
  return;
102
102
  }
103
103
  for (const route of routes) {
@@ -112,7 +112,8 @@ function cedarUniversalDeployPlugin(options = {}) {
112
112
  }
113
113
  },
114
114
  resolveId(id) {
115
- if (this.environment?.name !== "ssr") {
115
+ const viteEnv = this.environment;
116
+ if (viteEnv.config.consumer === "client" || viteEnv.name === "api") {
116
117
  return void 0;
117
118
  }
118
119
  if (id.startsWith(RESOLVED_CEDAR_FN_PREFIX)) {
@@ -124,7 +125,8 @@ function cedarUniversalDeployPlugin(options = {}) {
124
125
  return void 0;
125
126
  },
126
127
  async load(id) {
127
- if (this.environment?.name !== "ssr") {
128
+ const viteEnv = this.environment;
129
+ if (viteEnv.config.consumer === "client" || viteEnv.name === "api") {
128
130
  return void 0;
129
131
  }
130
132
  if (id.startsWith(RESOLVED_CEDAR_FN_PREFIX)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "5.0.0-canary.2421",
3
+ "version": "5.0.0-canary.2423",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,17 +69,17 @@
69
69
  "@babel/generator": "7.29.1",
70
70
  "@babel/parser": "7.29.3",
71
71
  "@babel/traverse": "7.29.0",
72
- "@cedarjs/api": "5.0.0-canary.2421",
73
- "@cedarjs/auth": "5.0.0-canary.2421",
74
- "@cedarjs/babel-config": "5.0.0-canary.2421",
75
- "@cedarjs/context": "5.0.0-canary.2421",
76
- "@cedarjs/cookie-jar": "5.0.0-canary.2421",
77
- "@cedarjs/graphql-server": "5.0.0-canary.2421",
78
- "@cedarjs/internal": "5.0.0-canary.2421",
79
- "@cedarjs/project-config": "5.0.0-canary.2421",
80
- "@cedarjs/server-store": "5.0.0-canary.2421",
81
- "@cedarjs/testing": "5.0.0-canary.2421",
82
- "@cedarjs/web": "5.0.0-canary.2421",
72
+ "@cedarjs/api": "5.0.0-canary.2423",
73
+ "@cedarjs/auth": "5.0.0-canary.2423",
74
+ "@cedarjs/babel-config": "5.0.0-canary.2423",
75
+ "@cedarjs/context": "5.0.0-canary.2423",
76
+ "@cedarjs/cookie-jar": "5.0.0-canary.2423",
77
+ "@cedarjs/graphql-server": "5.0.0-canary.2423",
78
+ "@cedarjs/internal": "5.0.0-canary.2423",
79
+ "@cedarjs/project-config": "5.0.0-canary.2423",
80
+ "@cedarjs/server-store": "5.0.0-canary.2423",
81
+ "@cedarjs/testing": "5.0.0-canary.2423",
82
+ "@cedarjs/web": "5.0.0-canary.2423",
83
83
  "@fastify/url-data": "6.0.3",
84
84
  "@swc/core": "1.15.33",
85
85
  "@universal-deploy/store": "^0.2.1",