@cedarjs/vite 7.1.0 → 7.1.1-next.469

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 (35) hide show
  1. package/dist/buildApp.d.ts.map +1 -1
  2. package/dist/buildApp.js +32 -11
  3. package/dist/buildRouteHooks.d.ts +7 -13
  4. package/dist/buildRouteHooks.d.ts.map +1 -1
  5. package/dist/buildRouteHooks.js +5 -10
  6. package/dist/bundled/react-server-dom-webpack.server.js +2263 -29124
  7. package/dist/devFeServer.js +3 -3
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +4 -0
  11. package/dist/jobsDevMiddleware.d.ts.map +1 -1
  12. package/dist/jobsDevMiddleware.js +29 -2
  13. package/dist/lib/sandboxChildren.d.ts +58 -0
  14. package/dist/lib/sandboxChildren.d.ts.map +1 -0
  15. package/dist/lib/sandboxChildren.js +157 -0
  16. package/dist/plugins/vite-plugin-cedar-cell.d.ts +2 -1
  17. package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
  18. package/dist/plugins/vite-plugin-cedar-cell.js +30 -11
  19. package/dist/plugins/vite-plugin-cedar-parsed-scalars.d.ts +20 -0
  20. package/dist/plugins/vite-plugin-cedar-parsed-scalars.d.ts.map +1 -0
  21. package/dist/plugins/vite-plugin-cedar-parsed-scalars.js +60 -0
  22. package/dist/plugins/vite-plugin-cedar-sandbox-children.d.ts +20 -0
  23. package/dist/plugins/vite-plugin-cedar-sandbox-children.d.ts.map +1 -0
  24. package/dist/plugins/vite-plugin-cedar-sandbox-children.js +58 -0
  25. package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts +2 -6
  26. package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -1
  27. package/dist/plugins/vite-plugin-handler-als-wrapping.js +4 -7
  28. package/dist/rsc/rscBuildClient.d.ts +1 -1
  29. package/dist/rsc/rscBuildForServer.d.ts +1 -1
  30. package/dist/rsc/rscBuildForSsr.d.ts +1 -1
  31. package/dist/runFeServer.js +3 -3
  32. package/dist/streaming/streamHelpers.d.ts +6 -1
  33. package/dist/streaming/streamHelpers.d.ts.map +1 -1
  34. package/dist/streaming/streamHelpers.js +1 -1
  35. package/package.json +46 -44
@@ -1 +1 @@
1
- {"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AAkEA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,iBAgc3B"}
1
+ {"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AAuEA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,iBAyd3B"}
package/dist/buildApp.js CHANGED
@@ -23,10 +23,14 @@ import { findApiFiles } from "@cedarjs/internal/dist/files.js";
23
23
  import {
24
24
  createPrismaClientFileMatcher,
25
25
  getConfig,
26
- getPaths,
27
- projectSideIsEsm
26
+ getPaths
28
27
  } from "@cedarjs/project-config";
29
28
  import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
29
+ import {
30
+ copySandboxChildrenIntoVercelFunctions,
31
+ findSandboxChildScripts,
32
+ SANDBOX_CHILDREN_DIR
33
+ } from "./lib/sandboxChildren.js";
30
34
  import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
31
35
  import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
32
36
  import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
@@ -35,6 +39,7 @@ import { cedarGraphqlOptionsExtractPlugin } from "./plugins/vite-plugin-cedar-gr
35
39
  import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
36
40
  import { cedarMockCellDataPlugin } from "./plugins/vite-plugin-cedar-mock-cell-data.js";
37
41
  import { cedarOtelWrappingPlugin } from "./plugins/vite-plugin-cedar-otel-wrapping.js";
42
+ import { cedarSandboxChildrenPlugin } from "./plugins/vite-plugin-cedar-sandbox-children.js";
38
43
  import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-path-injector.js";
39
44
  import { handlerAlsWrappingPlugin } from "./plugins/vite-plugin-handler-als-wrapping.js";
40
45
  function resolveWithExtensions(id) {
@@ -57,6 +62,7 @@ async function buildCedarApp({
57
62
  const cedarPaths = getPaths();
58
63
  const cedarConfig = getConfig();
59
64
  const environments = {};
65
+ let sandboxChildren = {};
60
66
  if (workspace.includes("web")) {
61
67
  environments.client = {
62
68
  build: {
@@ -65,8 +71,6 @@ async function buildCedarApp({
65
71
  };
66
72
  }
67
73
  if (workspace.includes("api")) {
68
- const isEsm = projectSideIsEsm("api");
69
- const format = isEsm ? "es" : "cjs";
70
74
  const apiFiles = findApiFiles();
71
75
  const input = {};
72
76
  for (const f of apiFiles) {
@@ -82,7 +86,7 @@ async function buildCedarApp({
82
86
  rollupOptions: {
83
87
  input,
84
88
  output: {
85
- format,
89
+ format: "es",
86
90
  preserveModules: true,
87
91
  preserveModulesRoot: cedarPaths.api.src,
88
92
  entryFileNames: "[name].js",
@@ -100,15 +104,16 @@ async function buildCedarApp({
100
104
  }
101
105
  };
102
106
  if (ud) {
107
+ sandboxChildren = findSandboxChildScripts(cedarPaths.api.src);
103
108
  environments["ssr"] = {
104
109
  build: {
105
110
  ssr: true,
106
111
  outDir: path.join(cedarPaths.api.dist, "ud"),
107
112
  emptyOutDir: true,
108
113
  rollupOptions: {
109
- input: catchAllEntry,
114
+ input: { index: catchAllEntry, ...sandboxChildren },
110
115
  output: {
111
- entryFileNames: "index.js"
116
+ entryFileNames: "[name].js"
112
117
  },
113
118
  external: (id) => {
114
119
  if (id.startsWith("virtual:")) {
@@ -204,6 +209,12 @@ async function buildCedarApp({
204
209
  ];
205
210
  if (ud) {
206
211
  plugins.push(catchAll());
212
+ plugins.push(
213
+ cedarSandboxChildrenPlugin({
214
+ environment: "ssr",
215
+ children: sandboxChildren
216
+ })
217
+ );
207
218
  plugins.push({
208
219
  name: "cedar-ud-verify-routes",
209
220
  configResolved() {
@@ -261,9 +272,7 @@ async function buildCedarApp({
261
272
  plugins.push(cedarDirectoryNamedImportPlugin());
262
273
  plugins.push(cedarOtelWrappingPlugin());
263
274
  plugins.push(cedarjsJobPathInjectorPlugin());
264
- plugins.push(
265
- handlerAlsWrappingPlugin({ projectIsEsm: projectSideIsEsm("api") })
266
- );
275
+ plugins.push(handlerAlsWrappingPlugin());
267
276
  }
268
277
  plugins.push(cedarMockCellDataPlugin());
269
278
  if (workspace.includes("api")) {
@@ -346,7 +355,19 @@ async function buildCedarApp({
346
355
  },
347
356
  plugins
348
357
  });
349
- return builder.buildApp();
358
+ await builder.buildApp();
359
+ const vercelNode = builder.environments["vercel_node"];
360
+ if (ud && vercelNode && Object.keys(sandboxChildren).length > 0) {
361
+ const outDir = path.resolve(
362
+ vercelNode.config.root,
363
+ vercelNode.config.build.outDir
364
+ );
365
+ copySandboxChildrenIntoVercelFunctions({
366
+ appRoot: cedarPaths.base,
367
+ childrenDir: path.join(cedarPaths.api.dist, "ud", SANDBOX_CHILDREN_DIR),
368
+ functionsDir: path.join(outDir, "functions")
369
+ });
370
+ }
350
371
  }
351
372
  export {
352
373
  buildCedarApp
@@ -1,22 +1,16 @@
1
1
  import type { Paths } from '@cedarjs/project-config';
2
2
  /**
3
- * Route hooks are built as ES modules. Node reads a `.js` file as CommonJS
4
- * when the nearest package.json has no `"type": "module"`, so in a CommonJS
5
- * web side the output gets the `.mjs` extension instead.
6
- */
7
- export declare function getRouteHookDistExtension(): ".js" | ".mjs";
8
- /**
9
- * Returns the path, relative to `web/dist/ssr/routeHooks`, that the built
10
- * version of the given route hook source file is written to. The layout
11
- * mirrors `web/src`, so `web/src/pages/HomePage/HomePage.routeHooks.ts` ends
12
- * up at `pages/HomePage/HomePage.routeHooks.js` and `web/src/App.routeHooks.ts`
13
- * at `App.routeHooks.js` (`.mjs` in a CommonJS web side, see
14
- * getRouteHookDistExtension()).
3
+ * Returns the path, relative to `web/dist/ssr/routeHooks` and with a `.js`
4
+ * extension, that the built version of the given route hook source file is
5
+ * written to. The layout mirrors `web/src`, so
6
+ * `web/src/pages/HomePage/HomePage.routeHooks.ts` ends up at
7
+ * `pages/HomePage/HomePage.routeHooks.js` and `web/src/App.routeHooks.ts` at
8
+ * `App.routeHooks.js`.
15
9
  *
16
10
  * Used both by the build (to name the Rollup entries) and by the route
17
11
  * manifest (so the streaming handler can find the file at request time).
18
12
  */
19
- export declare function getRouteHookDistPath(routeHookSrcPath: string, webSrc?: string, extension?: string): string;
13
+ export declare function getRouteHookDistPath(routeHookSrcPath: string, webSrc?: string): string;
20
14
  /**
21
15
  * Bundles every `web/src/** /*.routeHooks.{js,ts,tsx,jsx}` file into
22
16
  * `web/dist/ssr/routeHooks` as a node ESM module, one output file per route
@@ -1 +1 @@
1
- {"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAiBpD;;;;GAIG;AACH,wBAAgB,yBAAyB,mBAExC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,MAAM,SAAqB,EAC3B,SAAS,SAA8B,UAGxC;AA6BD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBAyEf"}
1
+ {"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAiBpD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,MAAM,SAAqB,UAG5B;AA6BD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBAuEf"}
@@ -3,7 +3,7 @@ import { build as viteBuild } from "vite";
3
3
  import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
4
4
  import tsPathsMod from "vite-tsconfig-paths";
5
5
  import { findRouteHooksSrc } from "@cedarjs/internal/dist/files.js";
6
- import { getPaths, projectSideIsEsm } from "@cedarjs/project-config";
6
+ import { getPaths } from "@cedarjs/project-config";
7
7
  import { cedarApiImportGuardPlugin } from "./plugins/vite-plugin-cedar-api-import-guard.js";
8
8
  import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
9
9
  import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
@@ -13,11 +13,8 @@ const tsconfigPaths = (
13
13
  // interop
14
14
  tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
15
15
  );
16
- function getRouteHookDistExtension() {
17
- return projectSideIsEsm("web") ? ".js" : ".mjs";
18
- }
19
- function getRouteHookDistPath(routeHookSrcPath, webSrc = getPaths().web.src, extension = getRouteHookDistExtension()) {
20
- return getRouteHookEntryName(routeHookSrcPath, webSrc) + extension;
16
+ function getRouteHookDistPath(routeHookSrcPath, webSrc = getPaths().web.src) {
17
+ return getRouteHookEntryName(routeHookSrcPath, webSrc) + ".js";
21
18
  }
22
19
  function getRouteHookEntryName(routeHookSrcPath, webSrc) {
23
20
  return path.relative(webSrc, routeHookSrcPath).replace(/\.(js|ts|tsx|jsx)$/, "").split(path.sep).join("/");
@@ -38,7 +35,6 @@ async function buildRouteHooks(verbose, rwPaths) {
38
35
  for (const routeHook of allRouteHooks) {
39
36
  input[getRouteHookEntryName(routeHook, rwPaths.web.src)] = routeHook;
40
37
  }
41
- const extension = getRouteHookDistExtension();
42
38
  await viteBuild({
43
39
  // Route hooks run in node, so the project's web/vite.config, which is set
44
40
  // up for browser and SSR builds of React code, doesn't apply. Only the
@@ -81,9 +77,9 @@ async function buildRouteHooks(verbose, rwPaths) {
81
77
  input,
82
78
  output: {
83
79
  format: "es",
84
- entryFileNames: "[name]" + extension,
80
+ entryFileNames: "[name].js",
85
81
  // Modules shared between route hooks, like the api side's db.js
86
- chunkFileNames: "chunks/[name]-[hash]" + extension,
82
+ chunkFileNames: "chunks/[name]-[hash].js",
87
83
  exports: "named"
88
84
  }
89
85
  }
@@ -100,6 +96,5 @@ async function buildRouteHooks(verbose, rwPaths) {
100
96
  }
101
97
  export {
102
98
  buildRouteHooks,
103
- getRouteHookDistExtension,
104
99
  getRouteHookDistPath
105
100
  };