@cedarjs/vite 5.0.0-canary.2468 → 5.0.0-canary.2470

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.
@@ -174,10 +174,9 @@ function cedarUniversalDeployPlugin(options = {}) {
174
174
  }
175
175
  };
176
176
  }
177
- async function bundleDistFile(distPath) {
177
+ async function bundleDistFile(distPath, options = {}) {
178
178
  const { build } = await import("esbuild");
179
- const result = await build({
180
- entryPoints: [distPath],
179
+ const buildOptions = {
181
180
  bundle: true,
182
181
  write: false,
183
182
  format: "esm",
@@ -200,7 +199,25 @@ async function bundleDistFile(distPath) {
200
199
  }
201
200
  ],
202
201
  logLevel: "silent"
203
- });
202
+ };
203
+ if (options.include && options.include.length > 0) {
204
+ const resolveDir = import_node_path.default.dirname(distPath);
205
+ const relativeDistPath = "./" + import_node_path.default.basename(distPath);
206
+ const exportList = options.include.join(", ");
207
+ buildOptions.stdin = {
208
+ // Use stdin to define a synthetic entry point that exports only the
209
+ // requested named exports
210
+ contents: `export { ${exportList} } from ${JSON.stringify(relativeDistPath)}`,
211
+ resolveDir,
212
+ loader: "js"
213
+ };
214
+ } else {
215
+ buildOptions.entryPoints = [distPath];
216
+ }
217
+ const result = await build(buildOptions);
218
+ if (!result.outputFiles || result.outputFiles.length === 0) {
219
+ throw new Error("esbuild bundle produced no output files");
220
+ }
204
221
  let text = result.outputFiles[0].text;
205
222
  const exportBlock = text.match(/\nexport\s*\{([^}]*)\};\s*$/);
206
223
  if (exportBlock) {
@@ -218,17 +235,15 @@ const __cedar_default = ${defaultBinding};`;
218
235
  return text;
219
236
  }
220
237
  async function generateGraphQLModule(distPath) {
221
- const bundledCode = await bundleDistFile(distPath);
222
- const cleanedCode = bundledCode.replace(
223
- /\n\s*(?:var|const)\s+\w+\s*=\s*createGraphQLHandler\s*\(.*\)\s*;?/,
224
- "\n"
225
- );
238
+ const bundledCode = await bundleDistFile(distPath, {
239
+ include: ["__cedar_graphqlOptions"]
240
+ });
226
241
  return `
227
242
  import { buildCedarContext, requestToLegacyEvent } from '@cedarjs/api/runtime';
228
243
  import { createGraphQLYoga } from '@cedarjs/graphql-server';
229
244
 
230
245
  // Inlined bundle of ${import_node_path.default.basename(distPath)} (node_modules kept external)
231
- ${cleanedCode}
246
+ ${bundledCode}
232
247
 
233
248
  let yogaInitPromise = null;
234
249
 
@@ -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,CAuHR"}
1
+ {"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"AAIA,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,CAuHR"}
@@ -141,10 +141,9 @@ function cedarUniversalDeployPlugin(options = {}) {
141
141
  }
142
142
  };
143
143
  }
144
- async function bundleDistFile(distPath) {
144
+ async function bundleDistFile(distPath, options = {}) {
145
145
  const { build } = await import("esbuild");
146
- const result = await build({
147
- entryPoints: [distPath],
146
+ const buildOptions = {
148
147
  bundle: true,
149
148
  write: false,
150
149
  format: "esm",
@@ -167,7 +166,25 @@ async function bundleDistFile(distPath) {
167
166
  }
168
167
  ],
169
168
  logLevel: "silent"
170
- });
169
+ };
170
+ if (options.include && options.include.length > 0) {
171
+ const resolveDir = path.dirname(distPath);
172
+ const relativeDistPath = "./" + path.basename(distPath);
173
+ const exportList = options.include.join(", ");
174
+ buildOptions.stdin = {
175
+ // Use stdin to define a synthetic entry point that exports only the
176
+ // requested named exports
177
+ contents: `export { ${exportList} } from ${JSON.stringify(relativeDistPath)}`,
178
+ resolveDir,
179
+ loader: "js"
180
+ };
181
+ } else {
182
+ buildOptions.entryPoints = [distPath];
183
+ }
184
+ const result = await build(buildOptions);
185
+ if (!result.outputFiles || result.outputFiles.length === 0) {
186
+ throw new Error("esbuild bundle produced no output files");
187
+ }
171
188
  let text = result.outputFiles[0].text;
172
189
  const exportBlock = text.match(/\nexport\s*\{([^}]*)\};\s*$/);
173
190
  if (exportBlock) {
@@ -185,17 +202,15 @@ const __cedar_default = ${defaultBinding};`;
185
202
  return text;
186
203
  }
187
204
  async function generateGraphQLModule(distPath) {
188
- const bundledCode = await bundleDistFile(distPath);
189
- const cleanedCode = bundledCode.replace(
190
- /\n\s*(?:var|const)\s+\w+\s*=\s*createGraphQLHandler\s*\(.*\)\s*;?/,
191
- "\n"
192
- );
205
+ const bundledCode = await bundleDistFile(distPath, {
206
+ include: ["__cedar_graphqlOptions"]
207
+ });
193
208
  return `
194
209
  import { buildCedarContext, requestToLegacyEvent } from '@cedarjs/api/runtime';
195
210
  import { createGraphQLYoga } from '@cedarjs/graphql-server';
196
211
 
197
212
  // Inlined bundle of ${path.basename(distPath)} (node_modules kept external)
198
- ${cleanedCode}
213
+ ${bundledCode}
199
214
 
200
215
  let yogaInitPromise = null;
201
216
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "5.0.0-canary.2468",
3
+ "version": "5.0.0-canary.2470",
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.2468",
73
- "@cedarjs/auth": "5.0.0-canary.2468",
74
- "@cedarjs/babel-config": "5.0.0-canary.2468",
75
- "@cedarjs/context": "5.0.0-canary.2468",
76
- "@cedarjs/cookie-jar": "5.0.0-canary.2468",
77
- "@cedarjs/graphql-server": "5.0.0-canary.2468",
78
- "@cedarjs/internal": "5.0.0-canary.2468",
79
- "@cedarjs/project-config": "5.0.0-canary.2468",
80
- "@cedarjs/server-store": "5.0.0-canary.2468",
81
- "@cedarjs/testing": "5.0.0-canary.2468",
82
- "@cedarjs/web": "5.0.0-canary.2468",
72
+ "@cedarjs/api": "5.0.0-canary.2470",
73
+ "@cedarjs/auth": "5.0.0-canary.2470",
74
+ "@cedarjs/babel-config": "5.0.0-canary.2470",
75
+ "@cedarjs/context": "5.0.0-canary.2470",
76
+ "@cedarjs/cookie-jar": "5.0.0-canary.2470",
77
+ "@cedarjs/graphql-server": "5.0.0-canary.2470",
78
+ "@cedarjs/internal": "5.0.0-canary.2470",
79
+ "@cedarjs/project-config": "5.0.0-canary.2470",
80
+ "@cedarjs/server-store": "5.0.0-canary.2470",
81
+ "@cedarjs/testing": "5.0.0-canary.2470",
82
+ "@cedarjs/web": "5.0.0-canary.2470",
83
83
  "@fastify/url-data": "6.0.3",
84
84
  "@swc/core": "1.15.33",
85
85
  "@universal-deploy/store": "^0.2.1",
@@ -122,7 +122,7 @@
122
122
  "@types/yargs-parser": "21.0.3",
123
123
  "concurrently": "9.2.1",
124
124
  "glob": "11.1.0",
125
- "memfs": "4.57.6",
125
+ "memfs": "4.57.7",
126
126
  "publint": "0.3.21",
127
127
  "rollup": "4.60.4",
128
128
  "tsx": "4.21.0",